TFGrid#

class pynlo.utility.TFGrid(n, v_ref, dv, alias=1)[source]#

Bases: object

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

The frequency grid is shifted and scaled such that it is aligned with the origin and contains only positive frequencies. The values given to the initializers are only targets and may be adjusted slightly. If necessary, the reference frequency will be increased so that the grids can be formed without any negative frequencies.

Parameters:
nint

The number of grid points.

v_reffloat

The target central frequency of the grid.

dvfloat

The frequency step size. This is equal to the reciprocal of the total time window.

aliasint, optional

The number of harmonics supported by the real-valued time domain grid without aliasing. The default is 1, which only generates enough points for one alias-free Nyquist zone. A higher number may be useful when simulating nonlinear interactions.

Notes

For discrete Fourier transforms (DFT), the frequency step multiplied by the time step is always equal to the reciprocal of the total number of points:

dt*dv == 1/n

Each grid point represents the midpoint of a bin that extends 0.5 grid spacings in both directions.

Aligning the frequency grid to the origin facilitates calculations using real Fourier transforms, which have grids that start at zero frequency. The rtf_grids method and the rn_range and rn_slice attributes are useful when transitioning between the analytic representation of this class to the real-valued representation.

By definition of the DFT, the time and frequency grids must range symmetrically about the origin, with the time grid incrementing in unit steps and the frequency grid in steps of 1/n. The grids of the TFGrid class are scaled and shifted such that they represent absolute time or frequency values. The scaling is accomplished by setting the forward scale parameter of the Fourier transforms to dt. The v_ref and t_ref variables describe the amount that the TFGrid grids need to be shifted to come into alignment with the origins of the grids implicitly defined by the DFT.

Methods#

FromFreqRange(n, v_min, v_max, **kwargs)

Initialize a set of time and frequency grids given the total number of grid points and a target minimum and maximum frequency.

rtf_grids([alias, fast_n, update])

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

copy()

Copy the time and frequency grids.

Attributes#

n

The number of grid points of the analytic representation.

rn

The number of grid points of the real-valued time domain representation.

rn_range

The minimum and maximum indices of the origin-contiguous frequency grid, associated with the real-valued time domain representation, that correspond to the first and last points of the analytic frequency grid.

rn_slice

A slice object that indexes the origin-contiguous frequency grid, associated with the real-valued time domain representation, onto the analytic frequency grid.

v_grid

The frequency grid of the analytic representation, with units of Hz.

v_ref

The grid reference frequency of the analytic representation, with units of Hz.

dv

The frequency grid step size of the analytic representation, with units of Hz.

v_window

The span of the frequency grid in the analytic representation, with units of Hz.

t_grid

The time grid of the analytic representation, with units of s.

t_ref

The grid reference time of the analytic representation, with units of s.

dt

The time grid step size of the analytic representation, with units of s.

t_window

The span of the time grid in the analytic representation, with units of s.

rv_grid

The origin-contiguous frequency grid of the real-valued time domain representation, with units of Hz.

rv_ref

The grid reference frequency of the real-valued time domain representation, with units of Hz.

rdv

The frequency grid step size of the real-valued time domain representation, with units of Hz.

rv_window

The span of the frequency grid in the real-valued time domain representation, with units of Hz.

rt_grid

The time grid of the real-valued time domain representation, with units of s.

rt_ref

The grid reference time of the real-valued time domain representation, with units of s.

rdt

The time grid step size of the real-valued time domain representation, with units of s.

rt_window

The span of the time grid in the real-valued time domain representation, with units of s.