Signals¶
Generators of standard test signals for modeling, identification, and verification of control systems in TensorAeroSpace.
TensorAeroSpace provides 17 types of signals for comprehensive system testing and analysis:
- Basic signals: Step, Ramp, Pulse, Constant
- Periodic signals: Sinusoid, Square wave, Triangular wave, Sawtooth
- Complex signals: Chirp, Doublet, Multi-step, Exponential, Gaussian pulse, Multisine, Damped sinusoid
- Random signals: Full random signal
Quick Start¶
from tensoraerospace.utils import generate_time_period
from tensoraerospace.signals.standard import unit_step, sinusoid, chirp, doublet
from tensoraerospace.signals.random import full_random_signal
import numpy as np
# Time axis 0..20 s (default step)
tp = generate_time_period(tn=20)
# Step of 5° at t = 10 s
u_step = unit_step(degree=5, tp=tp, time_step=10, output_rad=False)
# Sine wave with amplitude 10 units, frequency 0.01 Hz
u_sin = sinusoid(tp=tp, amplitude=10, frequency=0.01)
# Chirp signal for frequency response analysis
u_chirp = chirp(tp, f0=0.1, f1=2.0, amplitude=2.0, method='linear')
# Doublet for aerospace maneuvers
u_doublet = doublet(tp, amplitude=np.deg2rad(5), time_start=5.0, width=1.0)
# Random signal with random frequency and amplitude
u_rand = full_random_signal(0, 0.01, 20, (-0.5, 0.5), (-0.5, 0.5))
Units
For functions that support it, the output_rad=False parameter returns angles in degrees. Set it to True to get radians.
Basic Signals¶
Step Signal¶
A classic step input for exciting transient processes and analyzing system response.
unit_step(tp, degree, time_step=10.0, dt=0.01, output_rad=False)
¶
Generate unit step signal for control system testing.
Creates a step function that transitions from 0 to a specified amplitude at a given time. Commonly used for analyzing system transient response and step response characteristics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
degree
|
float
|
Step amplitude (deflection angle in degrees if output_rad=False, or will be converted to radians if output_rad=True). |
required |
time_step
|
float
|
Time at which the step occurs, in seconds. Defaults to 10.0. |
10.0
|
dt
|
float
|
Discretization time step, in seconds. Defaults to 0.01. (Note: This parameter is not currently used in the function). |
0.01
|
output_rad
|
bool
|
If True, converts degree to radians. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Step signal array of the same shape as tp, with values of 0 before |
ndarray
|
time_step and the specified amplitude after time_step. |
Examples:
Ramp Signal¶
Linear increasing signal for testing tracking capability of control systems.
ramp(tp, slope=1.0, time_start=0.0)
¶
Generate ramp (linearly increasing) signal.
Creates a ramp signal for testing the tracking capability of control systems to linearly varying reference trajectories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
slope
|
float
|
Rate of increase (units per second). Defaults to 1.0. |
1.0
|
time_start
|
float
|
Time at which the ramp begins, in seconds. Before this time, the signal is zero. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Ramp signal array that increases linearly with the specified slope |
ndarray
|
after time_start, and is zero before time_start. |
Examples:
Pulse Signal¶
Rectangular pulse for analyzing impulse response and transient behavior.
pulse(tp, amplitude=1.0, time_start=0.0, width=1.0)
¶
Generate rectangular pulse signal.
Creates a pulse signal for analyzing impulse response and transient behavior of control systems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
amplitude
|
float
|
Pulse amplitude (height). Defaults to 1.0. |
1.0
|
time_start
|
float
|
Time at which pulse begins, in seconds. Defaults to 0.0. |
0.0
|
width
|
float
|
Duration of the pulse, in seconds. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Pulse signal array with value 'amplitude' from time_start to |
ndarray
|
(time_start + width), and zero elsewhere. |
Examples:
Constant Signal¶
Constant reference signal for setpoint tracking and steady-state analysis.
constant_line(tp, value_state=2)
¶
Generate constant reference signal.
Creates a constant-valued signal useful for setpoint tracking tests and steady-state analysis of control systems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
value_state
|
float
|
Constant value to maintain throughout the signal. Defaults to 2. |
2
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of constant values with the same shape as tp, where all |
ndarray
|
elements equal value_state. |
Examples:
Periodic Signals¶
Sinusoidal Signal¶
Used for frequency analysis and testing linear subsystems.
sinusoid(tp, frequency, amplitude)
¶
Generate sinusoidal signal for frequency analysis.
Creates a standard sinusoidal signal used for frequency response analysis and harmonic testing of control systems.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
frequency
|
float
|
Signal frequency in Hz (cycles per unit time). |
required |
amplitude
|
float
|
Signal peak amplitude. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Sinusoidal signal array of the same shape as tp, following |
ndarray
|
amplitude * sin(2pifrequency*tp). |
Examples:
Sinusoid with Vertical Shift¶
Sinusoidal signal with DC offset for testing systems with non-zero operating points.
sinusoid_vertical_shift(tp, frequency, amplitude, vertical_shift=0.0)
¶
Generate sinusoidal signal with DC offset.
Creates a sinusoidal signal with a vertical offset, useful for testing systems with non-zero operating points or bias conditions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
frequency
|
float
|
Oscillation frequency in Hz. |
required |
amplitude
|
float
|
Peak amplitude of oscillation. |
required |
vertical_shift
|
float
|
DC offset (vertical shift) of the signal. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Sinusoidal signal array oscillating between |
ndarray
|
(vertical_shift - amplitude) and (vertical_shift + amplitude). |
Examples:
Square Wave¶
Periodic square wave for switching control and relay-based systems.
square_wave(tp, frequency=1.0, amplitude=1.0, duty_cycle=0.5)
¶
Generate square wave signal.
Creates a periodic square wave useful for switching control systems, relay-based control, and testing system response to periodic ON/OFF inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
frequency
|
float
|
Oscillation frequency in Hz. Defaults to 1.0. |
1.0
|
amplitude
|
float
|
Signal amplitude (high level). Low level is always 0. Defaults to 1.0. |
1.0
|
duty_cycle
|
float
|
Fraction of each period where signal is high (0 to 1). For example, 0.5 means signal is high for 50% of each period. Defaults to 0.5. |
0.5
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Square wave signal array alternating between 0 and amplitude at the |
ndarray
|
specified frequency and duty cycle. |
Examples:
Triangular Wave¶
Smooth periodic signal with symmetric rise and fall times.
triangular_wave(tp, frequency=1.0, amplitude=1.0)
¶
Generate triangular wave signal.
Creates a periodic triangular wave with symmetric rise and fall times. Useful for smooth periodic reference signals in control system testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
frequency
|
float
|
Oscillation frequency in Hz. Defaults to 1.0. |
1.0
|
amplitude
|
float
|
Peak amplitude. Signal ranges from -amplitude to +amplitude. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Triangular wave signal array with values varying linearly between |
ndarray
|
-amplitude and +amplitude with equal rise and fall times. |
Examples:
Sawtooth Wave¶
Periodic sawtooth signal with linear increase from negative to positive amplitude.
sawtooth(tp, frequency=1.0, amplitude=1.0)
¶
Generate sawtooth wave signal.
Creates a periodic sawtooth wave with linear increase from negative to positive amplitude. Useful for sweep generators and linear ramp testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
frequency
|
float
|
Oscillation frequency in Hz. Defaults to 1.0. |
1.0
|
amplitude
|
float
|
Peak amplitude. Signal ranges from -amplitude to +amplitude. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Sawtooth wave signal array with values linearly increasing from |
ndarray
|
-amplitude to +amplitude within each period. |
Examples:
Complex Signals¶
Chirp Signal¶
Swept-frequency signal for system identification and frequency response analysis.
chirp(tp, f0=0.1, f1=1.0, amplitude=1.0, method='linear')
¶
Generate chirp signal with frequency sweep.
Creates a swept-frequency sinusoid (chirp) for system identification and frequency response analysis. The instantaneous frequency increases from f0 to f1 over the duration of the signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
f0
|
float
|
Starting frequency in Hz. Defaults to 0.1. |
0.1
|
f1
|
float
|
Ending frequency in Hz. Defaults to 1.0. |
1.0
|
amplitude
|
float
|
Signal amplitude (peak value). Defaults to 1.0. |
1.0
|
method
|
str
|
Frequency sweep method. Options are: - 'linear': Linear frequency increase (constant rate) - 'exponential': Exponential frequency increase (logarithmic) Defaults to 'linear'. |
'linear'
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Chirp signal array with frequency varying from f0 to f1. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If method is not 'linear' or 'exponential'. |
Examples:
Doublet¶
Aerospace maneuver signal consisting of positive and negative pulses for stability analysis.
doublet(tp, amplitude=1.0, time_start=0.0, width=1.0)
¶
Generate doublet signal for stability analysis.
Creates a doublet signal consisting of a positive pulse followed immediately by a negative pulse of equal magnitude and duration. Commonly used in aerospace for stability and control analysis, particularly for aircraft handling qualities testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
amplitude
|
float
|
Amplitude of both positive and negative pulses. Defaults to 1.0. |
1.0
|
time_start
|
float
|
Time at which the doublet begins, in seconds. Defaults to 0.0. |
0.0
|
width
|
float
|
Duration of each pulse (positive and negative), in seconds. Total doublet duration is 2*width. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Doublet signal array with a positive pulse from time_start to |
ndarray
|
(time_start + width), followed by a negative pulse from |
ndarray
|
(time_start + width) to (time_start + 2*width), and zero elsewhere. |
Examples:
Multi-Step Signal¶
Sequence of step changes for testing tracking performance with multiple setpoints.
multi_step(tp, step_times, step_values)
¶
Generate multi-step signal with multiple setpoint changes.
Creates a signal with multiple step changes at specified times, useful for testing tracking performance and setpoint response of control systems. Each step adds cumulatively to create a staircase pattern.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
step_times
|
list
|
List of times (in seconds) when each step occurs. Must have the same length as step_values. |
required |
step_values
|
list
|
List of step magnitudes. Each value is added to the cumulative signal at the corresponding step_time. Must have the same length as step_times. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Multi-step signal array where the signal value at any time is the |
ndarray
|
cumulative sum of all step_values that have occurred up to that time. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If step_times and step_values have different lengths. |
Examples:
Exponential Signal¶
Smooth exponential approach to final value, modeling first-order system response.
exponential(tp, amplitude=1.0, time_constant=1.0, time_start=0.0)
¶
Generate exponential approach signal.
Creates a signal that exponentially approaches a final value, modeling first-order system response or smooth transitions in control systems. The signal follows the form: amplitude * (1 - e^(-t/τ)).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
amplitude
|
float
|
Final asymptotic value that the signal approaches. Defaults to 1.0. |
1.0
|
time_constant
|
float
|
Time constant τ (tau) in seconds. The signal reaches approximately 63.2% of the final value after one time constant. Defaults to 1.0. |
1.0
|
time_start
|
float
|
Time at which the exponential rise begins, in seconds. Signal is zero before this time. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Exponential signal array that rises from 0 to approach amplitude |
ndarray
|
with the specified time constant, starting at time_start. |
Examples:
Gaussian Pulse¶
Bell-shaped pulse for smooth disturbances and band-limited excitations.
gaussian_pulse(tp, amplitude=1.0, center=0.0, width=1.0)
¶
Generate Gaussian-shaped pulse signal.
Creates a smooth, bell-shaped pulse based on the Gaussian (normal) distribution. Useful for modeling smooth disturbances and analyzing system response to band-limited excitations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
amplitude
|
float
|
Peak amplitude of the pulse at its center. Defaults to 1.0. |
1.0
|
center
|
float
|
Time at which the pulse reaches its peak, in seconds. Defaults to 0.0. |
0.0
|
width
|
float
|
Standard deviation (σ) of the Gaussian distribution, in seconds. Controls the pulse width; larger values create wider pulses. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Gaussian pulse signal array with peak at 'center' and shape |
ndarray
|
determined by 'width' (standard deviation). |
Examples:
Multisine Signal¶
Sum of multiple sinusoids for multi-frequency system excitation and MIMO analysis.
multisine(tp, frequencies, amplitudes, phases=None)
¶
Generate multi-sine signal for multi-frequency excitation.
Creates a signal that is the sum of multiple sinusoids with different frequencies, amplitudes, and phases. Particularly useful for system identification, frequency response testing, and MIMO system analysis where simultaneous excitation at multiple frequencies is desired.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
frequencies
|
list
|
List of frequencies in Hz for each sinusoidal component. Must have the same length as amplitudes. |
required |
amplitudes
|
list
|
List of amplitudes for each sinusoidal component. Must have the same length as frequencies. |
required |
phases
|
Optional[list]
|
List of phase shifts in radians for each component. If None, all phases are set to 0. If provided, must have the same length as frequencies. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Multi-sine signal array that is the sum of all sinusoidal |
ndarray
|
components with specified parameters. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If frequencies and amplitudes have different lengths, or if phases (when provided) has different length than frequencies. |
Examples:
Damped Sinusoid¶
Exponentially decaying oscillation, characteristic of underdamped systems.
damped_sinusoid(tp, frequency=1.0, amplitude=1.0, damping=0.1, time_start=0.0)
¶
Generate damped (decaying) sinusoidal signal.
Creates an exponentially decaying sinusoidal signal, characteristic of underdamped second-order systems. Useful for modeling oscillatory responses with energy dissipation, such as mechanical vibrations or RLC circuit responses.
The signal follows: amplitude * exp(-ζt) * sin(2πft) where ζ is the damping coefficient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tp
|
ndarray
|
Time array in seconds. |
required |
frequency
|
float
|
Oscillation frequency in Hz. Defaults to 1.0. |
1.0
|
amplitude
|
float
|
Initial amplitude at time_start (before damping). Defaults to 1.0. |
1.0
|
damping
|
float
|
Damping coefficient (ζ, zeta) that controls the rate of exponential decay. Larger values cause faster decay. Defaults to 0.1. |
0.1
|
time_start
|
float
|
Time at which oscillations begin, in seconds. Signal is zero before this time. Defaults to 0.0. |
0.0
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Damped sinusoidal signal array that oscillates at the specified |
ndarray
|
frequency while exponentially decaying in amplitude. |
Examples:
Random Signals¶
Random Signal by Frequency and Amplitude¶
Generates a random test input with configurable frequency and amplitude ranges for modeling disturbances.
full_random_signal(t0, dt, tn, sd, sv)
¶
Random signal with variable frequency and amplitude.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t0
|
float
|
Initial time. |
required |
dt
|
float
|
Discretization step. |
required |
tn
|
float
|
Signal duration. |
required |
sd
|
tuple
|
Signal duration constraints (min, max). |
required |
sv
|
tuple
|
Signal value constraints (min, max). |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Array with random signal by frequency and amplitude. |
Notes¶
- Use
tensoraerospace.utils.generate_time_periodto build the time axis. - All functions return an array of signal values that aligns with the
tptime axis. - For aerospace applications, doublet signals are particularly useful for flight control testing.
- Chirp signals are ideal for system identification and frequency response analysis.
- Combine multiple signals to create complex test scenarios.
- Chirp
f0parameter:f0must be positive; aValueErroris raised otherwise. - Chirp exponential mode with
f0 == f1: Whenf0equalsf1in exponential mode, the function returns a constant-frequency sinusoid instead of raising an error.
















