Cartesian¶
Convolutions¶
Differentiation¶
- shift.cart.dfdk(k, fk)[source]¶
Differentiation in Fourier space. This can be used for all functions.
- Parameters:
k (array) – Fourier scales.
fk (complex array) – Fourier mode amplitudes.
- Returns:
dfk – Differential of the fourier modes.
- Return type:
complex array
- shift.cart.dfdk2(k1, fk, k2=None)[source]¶
Second order differentiation in Fourier space. This can be used for all functions.
- Parameters:
k1 (array) – Fourier scales.
fk (complex array) – Fourier mode amplitudes.
k2 (array) – Fourier scales from a different axis, if you wish to different first by one axis and then a second.
- Returns:
dfk2 – Differential of the fourier modes.
- Return type:
Cartesian grids¶
- shift.cart.grid1D(boxsize, ngrid, origin=0.0)[source]¶
Returns the x coordinates of a cartesian grid.
- shift.cart.grid2D(boxsize, ngrid, origin=0.0)[source]¶
Returns the x, y coordinates of a cartesian grid.
- Parameters:
boxsize (float) – Box size or list of length along each axis.
ngrid (int) – Grid division along one axis or a list of the grid divisions along each axis.
origin (float, optional) – Origin of the grid. If all axes begin at the same origin this can be a scalar, if you instead wish to specify different origins for each axis this should be added as a list.
- Returns:
x2D (array) – X coordinates on a 2D cartesian grid.
y2D (array) – Y coordinates on a 2D cartesian grid.
- shift.cart.grid3D(boxsize, ngrid, origin=0.0)[source]¶
Returns the x, y, z coordinates of a cartesian grid.
- Parameters:
boxsize (float) – Box size or list of length along each axis.
ngrid (int) – Grid division along one axis or a list of the grid divisions along each axis.
origin (float, optional) – Origin of the grid. If all axes begin at the same origin this can be a scalar, if you instead wish to specify different origins for each axis this should be added as a list.
- Returns:
x3D (array) – X coordinates on a 3D cartesian grid.
y3D (array) – Y coordinates on a 3D cartesian grid.
z3D (array) – Z coordinates on a 3D cartesian grid.
FFT¶
Fourier grids¶
- shift.cart.kgrid1D(boxsize, ngrid)[source]¶
Returns the fourier modes for the Fourier transform of a cartesian grid.
- shift.cart.kgrid2D(boxsize, ngrid)[source]¶
Returns the fourier modes for the Fourier transform of a cartesian grid.
Forward/Backward Transforms¶
DCT¶
Fourier grids¶
- shift.cart.kgrid1D_dct(boxsize, ngrid)[source]¶
Returns the fourier modes for the Discrete Cosine transform on a cartesian grid.
- shift.cart.kgrid2D_dct(boxsize, ngrid)[source]¶
Returns the fourier modes for the Discrete Cosine transform on a 2D cartesian grid.
Forward/Backward Transforms¶
DST¶
Fourier grids¶
- shift.cart.kgrid1D_dst(boxsize, ngrid)[source]¶
Returns the fourier modes for the Discrete Sine Transform of a cartesian grid.
- shift.cart.kgrid2D_dst(boxsize, ngrid)[source]¶
Returns the fourier modes for the Discrete Sine transform on a 2D cartesian grid.
Forward/Backward Transforms¶
Multiply¶
- shift.cart.mult_fk_2D(fgrid, boxsize, k, fk)[source]¶
Multiply 2D grid in Fourier space by k dependent function.
- Parameters:
fgrid (2darray) – 2D grid data.
boxsize (float) – Size of the box the grid is defined on.
k (array) – K values for k-dependent function f(k).
fk (array) – Function values at k.
- shift.cart.mult_fk_3D(fgrid, boxsize, k, fk)[source]¶
Multiply 3D grid in Fourier space by k dependent function.
- Parameters:
fgrid (ndarray) – 3D grid data.
boxsize (float) – Size of the box the grid is defined on.
k (array) – K values for k-dependent function f(k).
fk (array) – Function values at k.
Power Spectrum¶
- shift.cart.get_pofk_2D(dgrid, boxsize, ngrid, kmin=None, kmax=None)[source]¶
Returns the power spectrum of a 2D data set.
- Parameters:
dgrid (2darray) – Density contrast.
boxsize (float or list) – Box size or a list of the dimensions of each axis.
ngrid (int or list) – Grid division along one axis or a list for each axis.
kmin (float, optional) – Minimum Fourier mode, default = Minimum k mode of the grid.
kmax (float, optional) – Maximum Fourier mode, default = Maximum k mode of the grid.
- Returns:
k (array) – k modes for the measured power spectrum.
keff (array) – Effective k modes for the measured power spectrum.
pk (array) – Measure power spectrum.
- shift.cart.get_pofk_3D(dgrid, boxsize, ngrid, kmin=None, kmax=None)[source]¶
Returns the power spectrum of a 3D data set.
- Parameters:
dgrid (3darray) – Density contrast.
boxsize (float or list) – Box size or a list of the dimensions of each axis.
ngrid (int or list) – Grid division along one axis or a list for each axis.
kmin (float, optional) – Minimum Fourier mode, default = Minimum k mode of the grid.
kmax (float, optional) – Maximum Fourier mode, default = Maximum k mode of the grid.
- Returns:
k (array) – k modes for the measured power spectrum.
keff (array) – Effective k modes for the measured power spectrum.
pk (array) – Measure power spectrum.
Utility Functions¶
- shift.cart.fftshift(freq)[source]¶
Centers FFT frequencies so that 0 is in the center.
- Parameters:
freq (array) – Reorders any FFT frequency-like array to have the 0th element in the center.
- shift.cart.ifftshift(freq)[source]¶
Uncenters FFT frequencies so that 0 is no longer in the center.
- Parameters:
freq (array) – Reorders any FFT frequency-like array to have the 0th element back to the normal convention and not in the center.