Transforms

torusgrid.extend(grid: T, factors: Sequence[int]) T

Extend the grid periodically over all axes.

Parameters
  • grid – any grid

  • factors – (factor0, factor1, …) are the integer factors by which each axis is extended

torusgrid.transpose(grid: T, axes: Sequence[int]) T

Transpose the axes of a grid.

Parameters
  • grid – any grid

  • axes – a list of integers specifying a permutation of x’s axes

Example:

If x is a 2D Grid, transpose(x, [1,0]) will flip the X and Y axes

torusgrid.concat(*grids: T, axis: int) T

Concatenate grids along an axis.

Parameters

grids – a series of grid objects of the same type

Axis axis

concatenation axis

torusgrid.concat(*grids: T, axis: int) T

Concatenate grids along an axis.

Parameters

grids – a series of grid objects of the same type

Axis axis

concatenation axis

torusgrid.const_like(grid: T, fill: Optional[FloatLike | ComplexLike] = None) T

Return a new grid with constant value.

Parameters
  • grid – any grid

  • fill – The constant fill value. If not specified, the mean of the grid’s data will be used instead

torusgrid.resample(grid: T, shape: Tuple[int, ...], *, order: int, mode: Literal['constant', 'edge', 'symmetric', 'reflect', 'wrap'] = 'reflect', cval: int = 0, clip: bool = True, preserve_range: bool = False, anti_aliasing: bool = False) T

Change the shape and interpolate data

Parameters
  • grid – any grid

  • shape – new shape

  • anti_aliasing (order, mode, cval, clip, preserve_range,) – see skimage.resize

torusgrid.change_precision(grid: T, precision: Union[FloatingPointPrecision, Literal['SINGLE', 'DOUBLE', 'LONGDOUBLE', 'single', 'double', 'longdouble']]) T

Change the precision

Parameters
  • grid – any grid

  • precision – the new precision

torusgrid.crop(grid: T, axis: int, a: int, b: int) T

Crop input grid along the given axis

Parameters:

a: start index (inclusive) b: end index (exclusive)

torusgrid.blend(field1: T, field2: T, *, axis: int, a: Union[floating, float64, float] = 0.25, b: Union[floating, float64, float] = 0.75, interface_width: Union[floating, float64, float]) T

Blend two fields along an axis.

Parameters
  • field2 (field1,) – fields to be blended together

  • axis – axis along which to blend the fields

  • b (a,) – relative locations of the two interfaces, must satisfy \(0 < a < b < 1\)

Interface_width

interface width, used in the interpolation function \(tanh\)