nifty.cl.library.nft module#

class Gridder(target, uv, eps=2e-10)[source]#

Bases: LinearOperator

Compute non-uniform 2D FFT with ducc.

Parameters:
  • target (Domain, tuple of domains or DomainTuple.) – Target domain, must be a single two-dimensional RGSpace.

  • uv (np.ndarray) – Coordinates of the data-points, shape (n, 2).

  • eps (float) – Requested precision, defaults to 2e-10.

Note

If this operator is called on inputs stored on device, it will copy them to host, perform the operations with the CPU and copy back.

__init__(target, uv, eps=2e-10)[source]#
apply(x, mode)[source]#

Applies the Operator to a given x, in a specified mode.

Parameters:
  • x (nifty.cl.field.Field) – The input Field, defined on the Operator’s domain or target, depending on mode.

  • mode (int) –

    • TIMES: normal application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty.cl.field.Field

class Nufft(target, pos, eps=2e-10)[source]#

Bases: LinearOperator

Compute non-uniform 1D, 2D and 3D FFTs.

Parameters:
  • target (Domain, tuple of domains or DomainTuple.) – Target domain, must be an RGSpace with one to three dimensions.

  • pos (np.ndarray) – Coordinates of the data-points, shape (n, ndim).

  • eps (float) – Requested precision, defaults to 2e-10.

Note

If this operator is called on inputs stored on device, it will copy them to host, perform the operations with the CPU and copy back.

__init__(target, pos, eps=2e-10)[source]#
apply(x, mode)[source]#

Applies the Operator to a given x, in a specified mode.

Parameters:
  • x (nifty.cl.field.Field) – The input Field, defined on the Operator’s domain or target, depending on mode.

  • mode (int) –

    • TIMES: normal application

    • ADJOINT_TIMES: adjoint application

    • INVERSE_TIMES: inverse application

    • ADJOINT_INVERSE_TIMES or INVERSE_ADJOINT_TIMES: adjoint inverse application

Returns:

The processed Field defined on the Operator’s target or domain, depending on mode.

Return type:

nifty.cl.field.Field

ShiftedPositionFFT(grid_domain, eps, pre_domain=None, shift_directions=None)[source]#

Type 2 NUFFT operator for shifted grid-like positions.

Constructs a NUFFT operator that emulates an FFT on a regular grid, while allowing evaluation at positions offset from the standard sampling points. This enables perturbations of sampling coordinates, which can be interpreted as small displacements in either domain of a Fourier transform pair, depending on context.

The resulting domain of this operator is a MultiDomain with two subspaces:
  • “grid”: grid_domain

  • “delta_coord”: (grid_domain, UnstructuredDomain(ndim)) where ndim is the number of dimensions of grid_domain

or if pre_domain is set:
  • “grid”: (pre_domain, grid_domain)

  • “delta_coord”: (pre_domain, grid_domain, UnstructuredDomain(ndim))

The target of the operator is (hgrid_domain,) or if pre_domain is set (pre_domain, hgrid_domain), where hgrid_domain = grid_domain.get_default_codomain()

“delta_coord” specifies the relative shift of the sampling positions with respect to the regular FFT grid, expressed in units of Nyquist-scaled frequency spacing.

A value of 0 means the Fourier sampling is performed exactly at the standard FFT grid points. A value of 1 shifts the sampling position by one full grid step in frequency space, effectively aligning with the next neighboring FFT frequency point. Fractional values enable interpolation between FFT frequencies.

Parameters:
  • grid_domain (RGSpace or DomainTuple) – The input domain of the signal.

  • eps (float) – Precision parameter for the NUFFT computation. Smaller values lead to higher accuracy but slower performance.

  • pre_domain (Arbitrary 1d space, optional) – If pre_domain is not None, it will be prepended to grid_domain. All transformations are performed for each element in pre_domain. Default is None.

  • shift_directions (int, set of ints or None) – Collection of integers representing the directions in which a shift shall be modeled. Default is None.

class VariablePositionNufft(grid_domain, npoints, epsilon, pre_domain=None)[source]#

Bases: Operator

Type 2 NUFFT operator for variable non-uniform positions.

This operator performs a type 2 Non-Uniform Fast Fourier Transform (NUFFT, uniform to non-uniform) for a signal sampled on a regular grid and evaluated at arbitrary spatial positions.

The resulting domain of this operator is a MultiDomain with two subspaces:
  • “grid”: grid_domain

  • “coord”: (UnstructuredDomain(npoints), UnstructuredDomain(ndim)) where ndim is the number of dimensions of grid_domain

or if pre_domain is set:
  • “grid”: (pre_domain, grid_domain)

  • “coord”: (UnstructuredDomain(npoints), UnstructuredDomain(ndim))

The target of this operator is a DomainTuple: (UnstructuredDomain(npoints),) or (pre_domain, UnstructuredDomain(npoints)) if pre_domain is not None.

Parameters:
  • grid_domain (DomainTuple or RGSpace) – The regular grid domain over which the input signal is defined.

  • npoints (int) – Number of non-uniform evaluation points.

  • epsilon (float) – Precision parameter for the NUFFT computation. Smaller values lead to higher accuracy but slower performance.

  • pre_domain (Arbitrary 1d space, optional) – If pre_domain is not None, it will be prepended to grid_domain. All transformations are performed for each element in pre_domain. Default is None.

__init__(grid_domain, npoints, epsilon, pre_domain=None)[source]#
apply(x)[source]#

Applies the operator to a Field, MultiField or Linearization.

Parameters:

x (nifty.cl.field.Field, nifty.cl.multi_field.MultiField,) – or nifty.cl.linearization.Linearization Input on which the operator shall act. Needs to be defined on domain. If x`is a :class:`nifty.cl.linearization.Linearization, apply returns a new nifty.cl.linearization.Linearization contining the result of the operator application as well as its Jacobian, evaluated at x.