Map3D#

class cbclib.Map3D(val, x, y, z, num_threads=1)[source]#

A container for 3D spatial data. Stores data array defined on a 3D regular grid. Provides methods to perform the 3D fast Fourier transform and bilinear interpolation.

Parameters
  • val (ndarray) – 3D data array.

  • x (ndarray) – x coordinates.

  • y (ndarray) – y coordinates.

  • z (ndarray) – z coordinates.

  • num_threads (int) – Number of threads used in the calculations.

clip(vmin, vmax)[source]#

Clip the 3D data in a range of values [vmin, vmax].

Parameters
  • vmin (float) – Lower bound.

  • vmax (float) – Upper bound.

Return type

~M

Returns

A new 3D data object.

fft()[source]#

Perform 3D Fourier transform. FFTW C library is used to compute the transform.

Return type

~M

Returns

A 3Ddata object with the Fourier image data.

See also

cbclib.bin.FFTW : Python wrapper of FFTW library.

gaussian_blur(sigma)[source]#

Apply Gaussian blur to the 3D data.

Parameters

sigma (Union[float, Tuple[float, float, float]]) – width of the gaussian blur.

Return type

~M

Returns

A new 3D data container with blurred out data.

get_coordinates(index)[source]#

Transform a set of data indices to a set of coordinates.

Parameters

index (ndarray) – An array of indices.

Return type

ndarray

Returns

An array of coordinates.

classmethod import_hdf(path, key)[source]#

Initialize a 3D data container with data saved in a HDF5 file path at a key key inside the file.

Parameters
  • path (str) – Path to the HDF5 file.

  • key (str) – The group identifier in the HDF5 file.

Return type

Map3D

Returns

A new 3D data container.

interpolate(coordinates)[source]#

Interpolate the 3D grid at a given array of coordinates coordinates.

Parameters

coordinates (ndarray) – An array of coordinates.

Return type

ndarray

Returns

Array of interpolated values.

is_compatible(map_3d)[source]#

Check if 3D data object has a compatible set of coordinates.

Parameters

map_3d (~M) – 3D data object.

Return type

bool

Returns

True if the 3D data object map_3d has a compatible set of coordinates.

replace(**kwargs)[source]#

Return a new Map3D object with a set of attributes replaced.

Parameters

kwargs (Any) – A set of attributes and the values to to replace.

Return type

~M

Returns

A new Map3D object with the updated attributes.

to_dict()[source]#

Export the Map3D object to a dict.

Return type

Dict[str, Any]

Returns

A dictionary of Map3D object’s attributes.