sdynpy.signal_processing.sdynpy_generator.sine_sweep

sine_sweep(dt, frequencies, sweep_rates, sweep_types, amplitudes=1, phases=0)[source]

Generates a sweeping sine wave with linear or logarithmic sweep rate

Parameters
  • dt (float) – The time step of the output signal

  • frequencies (iterable) – A list of frequency breakpoints for the sweep. Can be ascending or decending or both. Frequencies are specified in Hz, not rad/s.

  • sweep_rates (iterable) – A list of sweep rates between the breakpoints. This array should have one fewer element than the frequencies array. The ith element of this array specifies the sweep rate between frequencies[i] and frequencies[i+1]. For a linear sweep, the rate is in Hz/s. For a logarithmic sweep, the rate is in octave/s.

  • sweep_types (iterable or str) – The type of sweep to perform between each frequency breakpoint. Can be ‘lin’ or ‘log’. If a string is specified, it will be used for all breakpoints. Otherwise it should be an array containing strings with one fewer element than that of the frequencies array.

  • amplitudes (iterable or float, optional) – Amplitude of the sine wave at each of the frequency breakpoints. Can be specified as a single floating point value, or as an array with a value specified for each breakpoint. The default is 1.

  • phases (iterable or float, optional) – Phases of the sine wave at each of the frequency breakpoints. Can be specified as a single floating point value, or as an array with a value specified for each breakpoint. Be aware that modifying the phase between breakpoints will effectively change the frequency of the signal, because the phase will change over time. The default is 0.

Raises

ValueError – If the sweep rate and start and end frequency would result in a negative sweep time, for example if the start frequency is above the end frequency and a positive sweep rate is specified.

Returns

ordinate – A numpy array consisting of the generated sine sweep signal. The length of the signal will be determined by the frequency breakpoints and sweep rates.

Return type

np.ndarray