TFGrid.rtf_grids#

TFGrid.rtf_grids(alias=1, fast_n=True, update=False)[source]#

Complementary time and frequency domain grids for the representation of analytic functions with real-valued amplitudes.

The alias parameter determines the number of harmonics the time grid supports without aliasing. In order to maintain efficient DFT behavior, the number of points can be extended further based on the output of scipy.fft.next_fast_len for aliases greater than or equal to 1. An alias of 0 returns the set of time and frequency grids consistent with a real-valued function defined over the original, analytic t_grid.

The resulting frequency grid contains the origin and positive frequencies and is suitable for use with real DFTs (see fft.rfft and fft.irfft).

Parameters:
aliasfloat, optional

The harmonic support of the generated grids (the number of alias-free Nyquist zones). The default is 1, the fundamental harmonic.

fast_nbool, optional

A flag that determines whether the length of the new array is extended up to the next fast fft length. The default is to extend. This parameter has no effect when the alias is 0.

updatebool, optional

A flag that determines whether to update the real-valued time and frequency domain grids of the parent object with the output of this method. The default is to return the calculated grids without updating the associated values stored in the class. This parameter is only valid when alias is greater than or equal to 1.

Returns:
nint

The number of grid points.

v_gridarray of float

The origin-contiguous frequency grid.

v_reffloat

The grid reference frequency.

dvfloat

The frequency grid step size.

v_windowfloat

The span of the frequency grid.

t_gridarray of float

The time grid.

t_reffloat

The grid reference time.

dtfloat

The time grid step size.

t_windowfloat

The span of the time grid.

Notes

To avoid dealing with case-specific amplitude scale factors when transforming between analytic and real-valued representations the frequency grid for complex-valued functions must not contain the origin and there must be enough points in the real-valued representation to avoid aliasing the Nyquist frequency of the analytic representation. The initializer of the TFGrid class enforces the first condition, the frequency grid starts at minimum one step size away from the origin, and this method enforces the second by making the minimum number of points odd if the real grid only extends to the first harmonic.

The transformation between representations is performed as in the following example, with tf an instance of the TFGrid class, rtf the output of this method, a_v the spectrum of a complex-valued envelope defined over v_grid, ra_v the spectrum of the real-valued function defined over rtf.v_grid, and ra_t the real-valued function defined over rtf.t_grid. The 1/2**0.5 scale factor between a_v and ra_v preserves the integrated squared magnitude in the time domain:

rtf = tf.rtf_grids()
ra_v = np.zeros_like(rtf.v_grid, dtype=complex)
ra_v[tf.rn_slice] = 2**-0.5 * a_v
ra_t = fft.irfft(ra_v, fsc=rtf.dt, n=rtf.n)
np.sum(ra_t**2 * rtf.dt) == np.sum(np.abs(a_v)**2 * tf.dv)