evoxels.voxelgrid

Classes

Grid(shape, origin, spacing, convention)

Handles most basic properties

VoxelGrid(grid, lib)

Abstract backend adapter: handles array conversion and padding.

VoxelGridJax(grid[, precision])

VoxelGridTorch(grid[, precision, device])

class evoxels.voxelgrid.Grid(shape: Tuple[int, int, int], origin: Tuple[float, float, float], spacing: Tuple[float, float, float], convention: str)

Handles most basic properties

__init__(shape: Tuple[int, int, int], origin: Tuple[float, float, float], spacing: Tuple[float, float, float], convention: str) None
convention: str
origin: Tuple[float, float, float]
shape: Tuple[int, int, int]
spacing: Tuple[float, float, float]
class evoxels.voxelgrid.VoxelGrid(grid: Grid, lib)

Abstract backend adapter: handles array conversion and padding.

__init__(grid: Grid, lib)
average(field)

Return the spatial average of field.

axes() Tuple[Any, ...]

Returns the 1D coordinate arrays along each axis.

concatenate(fieldlist, dim)

Concatenate fields in fieldlist.

expand_dim(field, dim)

Add a singleton dimension to field.

export_scalar_field_to_numpy(field)

Export backend field back to NumPy.

fft_axes() Tuple[Any, ...]
fft_k_squared()
fft_mesh() Tuple[Any, ...]
fftn(field, shape)

Compute the n-dimensional discrete Fourier transform.

init_scalar_field(array)

Convert and pad a NumPy array for simulation.

meshgrid() Tuple[Any, ...]

Returns full 3D mesh grids for each axis.

pad_periodic(field)

Pad a field with periodic boundary conditions.

pad_zeros(field)

Pad a field with zeros.

real_of_ifftn(field, shape)

Return the real part of the inverse FFT.

rfft_axes() Tuple[Any, ...]
rfft_k_squared()
rfft_k_squared_nonperiodic()
set(field, index, value)

Set field[index] to value and return field.

squeeze(field, dim)

Remove dim from field.

to_backend(field)

Convert a NumPy array to the backend representation.

to_numpy(field)

Convert a backend array to numpy.ndarray.

class evoxels.voxelgrid.VoxelGridJax(grid: Grid, precision='float32')
__init__(grid: Grid, precision='float32')

Create a JAX backed grid.

Parameters:
  • grid – Grid description.

  • precision – Floating point precision for arrays.

arange(start, stop)
argmax(field, dim=None, keepdim=False)
concatenate(fieldlist, dim)

Concatenate fields in fieldlist.

cumsum(field, dim=None)
expand_dim(field, dim)

Add a singleton dimension to field.

fftn(field, shape)

Compute the n-dimensional discrete Fourier transform.

irfftn(field, shape)
mean(field, dim=None, keepdim=False)
pad_periodic(field)

Pad a field with periodic boundary conditions.

pad_zeros(field)

Pad a field with zeros.

real_of_ifftn(field, shape)

Return the real part of the inverse FFT.

rfftn(field, shape)
set(field, index, value)

Set field[index] to value and return field.

sort(field, dim=0, descending=False)
squeeze(field, dim)

Remove dim from field.

sum(field, dim=None, keepdim=False)
take_along_dim(field, idx, dim=0)
to_backend(np_arr)

Convert a NumPy array to the backend representation.

to_numpy(field)

Convert a backend array to numpy.ndarray.

class evoxels.voxelgrid.VoxelGridTorch(grid: Grid, precision='float32', device: str = 'cuda')
__init__(grid: Grid, precision='float32', device: str = 'cuda')

Create a torch backed grid.

Parameters:
  • grid – Grid description.

  • precision – Floating point precision.

  • device – Torch device string.

arange(start, stop)
argmax(field, dim=None, keepdim=False)
concatenate(fieldlist, dim)

Concatenate fields in fieldlist.

cumsum(field, dim=None)
expand_dim(field, dim)

Add a singleton dimension to field.

fftn(field, shape)

Compute the n-dimensional discrete Fourier transform.

irfftn(field, shape)
mean(field, dim=None, keepdim=False)
pad_periodic(field)

Pad a field with periodic boundary conditions.

pad_zeros(field)

Pad a field with zeros.

real_of_ifftn(field, shape)

Return the real part of the inverse FFT.

rfftn(field, shape)
set(field, index, value)

Set field[index] to value and return field.

sort(field, dim=0, descending=False)
squeeze(field, dim)

Remove dim from field.

sum(field, dim=None, keepdim=False)
take_along_dim(field, idx, dim=0)
to_backend(np_arr)

Convert a NumPy array to the backend representation.

to_numpy(field)

Convert a backend array to numpy.ndarray.