dedalus.core.transforms ======================= .. py:module:: dedalus.core.transforms .. autoapi-nested-parse:: Spectral transform classes. Module Contents --------------- .. py:class:: BallRadialTransform(grid_shape, coeff_size, axis, ell_maps, regindex, regtotal, k, alpha, dtype=np.complex128, dealias_before_converting=None) Abstract base class for all transforms. .. py:method:: backward(cdata, gdata, axis) .. py:method:: backward_reduced(cdata, gdata) .. py:method:: forward(gdata, cdata, axis) .. py:method:: forward_reduced(gdata, cdata) .. py:attribute:: N3c .. py:attribute:: N3g .. py:attribute:: alpha .. py:attribute:: dealias_before_converting :value: None .. py:attribute:: ell_maps .. py:attribute:: intertwiner .. py:attribute:: k .. py:attribute:: regindex .. py:attribute:: regtotal .. py:class:: ComplexFFT(grid_size, coeff_size) Abstract base class for complex-to-complex FFTs. .. py:method:: resize_coeffs(data_in, data_out, axis, rescale) Resize and rescale coefficients in standard FFT format by intermediate padding/truncation. .. py:class:: ComplexFourierMMT(grid_size, coeff_size) Complex-to-complex Fourier MMT. .. py:method:: backward_matrix() Build backward transform matrix. .. py:method:: forward_matrix() Build forward transform matrix. .. py:class:: ComplexFourierTransform(grid_size, coeff_size) Abstract base class for complex-to-complex Fourier transforms. :Parameters: * **grid_size** (*int*) -- Grid size (N) along transform dimension. * **coeff_size** (*int*) -- Coefficient size (M) along transform dimension. .. rubric:: Notes Let KN = (N - 1) // 2 be the maximum fully resolved (non-Nyquist) mode on the grid. Let KM = (M - 1) // 2 be the maximum retained mode in coeff space. Then K = min(KN, KM) is the maximum wavenumber used in the transforms. A unit-amplitude normalization is used. Forward transform: if abs(k) <= K: F(k) = (1/N) \sum_{x=0}^{N-1} f(x) \exp(-2 \pi i k x / N) else: F(k) = 0 Backward transform: f(x) = \sum_{k=-K}^{K} F(k) \exp(2 \pi i k x / N) Coefficient ordering: If M is odd, the ordering is [0, 1, 2, ..., KM, KM+1, -KM, -KM+1, ..., -1], where the Nyquist mode k = KM + 1 is zeroed in both directions. If M is even, the ordering is [0, 1, 2, ..., KM, -KM, -KM+1, ..., -1]. .. py:attribute:: KM .. py:attribute:: KN .. py:attribute:: Kmax .. py:attribute:: M .. py:attribute:: N .. py:property:: wavenumbers One-dimensional global wavenumber array. .. py:class:: CosineMMT(grid_size, coeff_size) Cosine MMT. .. py:method:: backward_matrix() Build backward transform matrix. .. py:method:: forward_matrix() Build forward transform matrix. .. py:class:: CosineTransform(grid_size, coeff_size) Abstract base class for cosine transforms. :Parameters: * **grid_size** (*int*) -- Grid size (N) along transform dimension. * **coeff_size** (*int*) -- Coefficient size (M) along transform dimension. .. rubric:: Notes Let KN = (N - 1) be the maximum (Nyquist) mode on the grid. Let KM = (M - 1) be the maximum retained mode in coeff space. Then K = min(KN, KM) is the maximum wavenumber used in the transforms. A unit-amplitude normalization is used. Forward transform: if k == 0: a(k) = (1/N) \sum_{x=0}^{N-1} f(x) elif k <= K: a(k) = (2/N) \sum_{x=0}^{N-1} f(x) \cos(\pi k x / N) else: a(k) = 0 Backward transform: f(x) = \sum_{k=0}^{K} a(k) \cos(\pi k x / N) Coefficient ordering: The cosine coefficients are ordered simply as [a(0), a(1), a(2), ..., a(KM)] .. py:attribute:: KM .. py:attribute:: KN .. py:attribute:: Kmax .. py:attribute:: M .. py:attribute:: N .. py:property:: wavenumbers One-dimensional global wavenumber array. .. py:class:: DiskRadialTransform(grid_shape, basis_shape, axis, m_maps, s, k, alpha, dtype=np.complex128, dealias_before_converting=None) .. todo:: - Remove dependence on grid_shape? .. py:method:: backward_reduced(cdata, gdata) .. py:method:: forward_reduced(gdata, cdata) .. py:attribute:: Nmax .. py:attribute:: Nphi .. py:attribute:: alpha .. py:attribute:: dealias_before_converting :value: None .. py:attribute:: k .. py:attribute:: m_maps .. py:attribute:: s .. py:class:: FFTPACKRealFFT(grid_size, coeff_size) Real-to-real FFT using scipy.fftpack. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:class:: FFTWBase(*args, rigor=None, **kw) Abstract base class for FFTW transforms. .. py:attribute:: rigor :value: None .. py:class:: FFTWComplexFFT(*args, rigor=None, **kw) Complex-to-complex FFT using FFTW. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:class:: FFTWDCT(*args, rigor=None, **kw) Fast cosine transform using FFTW. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:class:: FFTWFastChebyshevTransform(grid_size, coeff_size, a, b, a0, b0, **kw) Fast ultraspherical transform using scipy.fft and spectral conversion. .. py:class:: FFTWHalfComplexFFT(*args, rigor=None, **kw) Real-to-real FFT using FFTW half-complex DFT. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:method:: repack(cdata, temp, axis) Repack into complex coefficients and rescale for unit-amplitude normalization. .. py:method:: unpack_rescale(temp, cdata, axis, rescale) Unpack halfcomplex coefficients and rescale for unit-amplitude normalization. .. py:class:: FFTWRealFFT(*args, rigor=None, **kw) Real-to-real FFT using FFTW. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:class:: FastChebyshevTransform(grid_size, coeff_size, a, b, a0, b0, **kw) Abstract base class for fast Chebyshev transforms including ultraspherical conversion. Subclasses should inherit from this class, then a FastCosineTransform subclass. .. py:attribute:: KM_orig .. py:attribute:: Kmax_orig .. py:attribute:: M_orig .. py:class:: FastCosineTransform(*args, **kw) Abstract base class for fast cosine transforms. .. py:method:: resize_rescale_backward(data_in, data_out, axis, Kmax) Resize by padding/trunction and rescale to unit amplitude. .. py:method:: resize_rescale_forward(data_in, data_out, axis, Kmax) Resize by padding/trunction and rescale to unit amplitude. .. py:attribute:: backward_rescale_pos :value: 0.5 .. py:attribute:: backward_rescale_zero :value: 1 .. py:attribute:: forward_rescale_pos .. py:attribute:: forward_rescale_zero .. py:class:: JacobiMMT(grid_size, coeff_size, a, b, a0, b0, dealias_before_converting=None) Jacobi polynomial MMTs. .. py:method:: backward_matrix() Build backward transform matrix. .. py:method:: forward_matrix() Build forward transform matrix. .. py:class:: JacobiTransform(grid_size, coeff_size, a, b, a0, b0, dealias_before_converting=None) Abstract base class for Jacobi polynomial transforms. :Parameters: * **grid_size** (*int*) -- Grid size (N) along transform dimension. * **coeff_size** (*int*) -- Coefficient size (M) along transform dimension. * **a** (*int*) -- Jacobi "a" parameter for polynomials. * **b** (*int*) -- Jacobi "b" parameters for polynomials. * **a0** (*int*) -- Jacobi "a" parameter for the quadrature grid. * **b0** (*int*) -- Jacobi "b" parameter for the quadrature grid. .. rubric:: Notes TODO: We need to define the normalization we use here. .. py:attribute:: M .. py:attribute:: N .. py:attribute:: a .. py:attribute:: a0 .. py:attribute:: b .. py:attribute:: b0 .. py:attribute:: dealias_before_converting :value: None .. py:class:: NonSeparableTransform(grid_shape, coeff_size, axis, dtype) Abstract base class for all transforms. .. py:method:: backward(cdata, gdata, axis) .. py:method:: forward(gdata, cdata, axis) .. py:attribute:: N2c .. py:attribute:: N2g .. py:class:: PolynomialTransform(grid_size, coeff_size) Abstract base class for all transforms. .. py:method:: backward(cdata, gdata, axis) .. py:method:: forward(gdata, cdata, axis) .. py:method:: resize_reduced(data_in, data_out) :staticmethod: Resize data by padding/truncation. .. py:class:: RealFFT(grid_size, coeff_size) Abstract base class for real-to-real FFTs using real-to-complex algorithms. .. py:method:: repack_rescale(cdata, temp, axis, rescale) Repack into complex coefficients and rescale for unit-amplitude normalization. .. py:method:: unpack_rescale(temp, cdata, axis, rescale) Unpack complex coefficients and rescale for unit-amplitude normalization. .. py:class:: RealFourierMMT(grid_size, coeff_size) Real-to-real Fourier MMT. .. py:method:: backward_matrix() Build backward transform matrix. .. py:method:: forward_matrix() Build forward transform matrix. .. py:class:: RealFourierTransform(grid_size, coeff_size) Abstract base class for real-to-real Fourier transforms. :Parameters: * **grid_size** (*int*) -- Grid size (N) along transform dimension. * **coeff_size** (*int*) -- Coefficient size (M) along transform dimension. .. rubric:: Notes Let KN = (N - 1) // 2 be the maximum fully resolved (non-Nyquist) mode on the grid. Let KM = (M - 1) // 2 be the maximum retained mode in coeff space. Then K = min(KN, KM) is the maximum wavenumber used in the transforms. A unit-amplitude normalization is used. Forward transform: if k == 0: a(k) = (1/N) \sum_{x=0}^{N-1} f(x) b(k) = 0 elif k <= K: a(k) = (2/N) \sum_{x=0}^{N-1} f(x) \cos(-2 \pi k x / N) b(k) = -(2/N) \sum_{x=0}^{N-1} f(x) \sin(-2 \pi k x / N) else: a(k) = 0 b(k) = 0 Backward transform: f(x) = \sum_{k=0}^{K} a(k) \cos(2 \pi k x / N) - b(k) \sin(2 \pi k x / N) Coefficient ordering: The cosine and minus-sine coefficients are interleaved as [a(0), b(0), a(1), b(1), a(2), b(2), ..., a(KM), b(KM)] where the k = 0 minus-sine mode is zeroed in both directions. .. py:attribute:: KM .. py:attribute:: KN .. py:attribute:: Kmax .. py:attribute:: M .. py:attribute:: N .. py:property:: wavenumbers One-dimensional global wavenumber array. .. py:class:: SWSHColatitudeTransform(Ntheta, Lmax, m_maps, s) Abstract base class for all transforms. .. py:method:: backward_reduced(cdata, gdata) .. py:method:: forward_reduced(gdata, cdata) .. py:attribute:: Lmax .. py:attribute:: Ntheta .. py:attribute:: m_maps .. py:attribute:: s .. py:class:: ScipyComplexFFT(grid_size, coeff_size) Complex-to-complex FFT using scipy.fft. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:class:: ScipyDCT(*args, **kw) Fast cosine transform using scipy.fft. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:class:: ScipyFastChebyshevTransform(grid_size, coeff_size, a, b, a0, b0, **kw) Fast ultraspherical transform using scipy.fft and spectral conversion. .. py:class:: ScipyRealFFT(grid_size, coeff_size) Real-to-real FFT using scipy.fft. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:class:: SeparableMatrixTransform Abstract base class for separable matrix-multiplication transforms. .. py:method:: backward(cdata, gdata, axis) Apply backward transform along specified axis. .. py:method:: backward_matrix() :abstractmethod: Build backward transform matrix. .. py:method:: forward(gdata, cdata, axis) Apply forward transform along specified axis. .. py:method:: forward_matrix() :abstractmethod: Build forward transform matrix. .. py:class:: SeparableTransform Abstract base class for transforms that only apply to one dimension, independent of all others. .. py:method:: backward(cdata, gdata, axis) :abstractmethod: Apply backward transform along specified axis. .. py:method:: forward(gdata, cdata, axis) :abstractmethod: Apply forward transform along specified axis. .. py:class:: Transform Abstract base class for all transforms. .. py:function:: backward_DFT(cdata, gdata, axis) .. py:function:: backward_disk(cdata, gdata, axis, k, s, local_m) Apply bakward radial transform to data with fixed s and varying m. .. py:function:: forward_DFT(gdata, cdata, axis) .. py:function:: forward_disk(gdata, cdata, axis, k0, k, s, local_m) Apply forward radial transform to data with fixed s and varying m. .. py:function:: reduce_array(data, axis) Return reduced 3D view of array collapsed above and below specified axis. .. py:function:: reduced_view_3(data, axis) .. py:function:: reduced_view_4(data, axis) .. py:function:: reduced_view_5(data, axis) .. py:function:: register_transform(basis, name) Decorator to add transform to basis class dictionary. .. py:data:: GET_DEALIAS_BEFORE_CONVERTING .. py:data:: GET_FFTW_RIGOR .. py:data:: logger