nifty7.domains.rg_space module#

class RGSpace(shape, distances=None, harmonic=False, _realdistances=None)[source]#

Bases: StructuredDomain

Represents a regular Cartesian grid.

Parameters:
  • shape (int or tuple of int) – Number of grid points or numbers of gridpoints along each axis.

  • distances (None or float or tuple of float, optional) –

    Distance between two grid points along each axis.

    By default (distances=None):
    • If harmonic==True, all distances will be set to 1

    • If harmonic==False, the distance along each axis will be set to the inverse of the number of points along that axis.

  • harmonic (bool, optional) – Whether the space represents a grid in position or harmonic space. Default: False.

Notes

Topologically, a n-dimensional RGSpace is a n-Torus, i.e. it has periodic boundary conditions.

__repr__()[source]#

Return repr(self).

check_codomain(codomain)[source]#

Raises TypeError if codomain is not a matching partner domain for self.

property distances#

Distance between grid points along each axis. The n-th entry of the tuple is the distance between neighboring grid points along the n-th dimension.

Type:

tuple of float

get_conv_kernel_from_func(func)[source]#

Creates a convolution kernel defined by a function.

Assumes the function to be radially symmetric, e.g. only dependant on distance.

Parameters:

func (function) – This function needs to take exactly one argument, which is distance from center (in the same units as the RGSpace distances), and return the kernel amplitude at that distance.

get_default_codomain()[source]#

Returns a RGSpace object representing the (position or harmonic) partner domain of self, depending on self.harmonic.

Returns:

The partner domain

Return type:

RGSpace

get_fft_smoothing_kernel_function(sigma)[source]#

Helper for Gaussian smoothing.

This method, which is only implemented for harmonic domains, helps to smoothe fields that are defined on a domain that has this domain as its harmonic partner. The returned function does a pointwise evaluation of a zero-centered Gaussian on the field values, which corresponds to a convolution with a Gaussian kernel with sigma standard deviation in position space.

Parameters:

sigma (float) – A real number representing a physical scale on which the smoothing takes place. Mathematically sigma is the standard deviation of a convolution with a normalized, zero-centered Gaussian that takes place in position space.

Returns:

A smoothing operation that multiplies values with a Gaussian kernel.

Return type:

function (array-like -> array-like)

get_k_length_array()[source]#

k vector lengths, if applicable.

Returns the length of the k vector for every pixel. This method is only implemented for harmonic domains.

Returns:

An array containing the k vector lengths

Return type:

Field

get_unique_k_lengths()[source]#

Sorted unique k-vector lengths, if applicable.

Returns an array of floats containing the unique k vector lengths for this domain. This method is only implemented for harmonic domains.

property harmonic#

True iff this domain is a harmonic domain.

Type:

bool

property scalar_dvol#

uniform pixel volume, if applicable

Returns the volume factors of this domain as a floating point scalar, if the volume factors are all identical, otherwise returns None.

Type:

float or None

property shape#

number of pixels along each axis

The shape of the array-like object required to store information defined on the domain.

Type:

tuple of int

property size#

total number of pixels.

Equivalent to the products over all entries in the domain’s shape.

Type:

int