FourierIndexer#

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

3D data object designed to perform Fourier auto-indexing. Projects measured intensities to the reciprocal space and provides several tools to works with a 3D data in the reciprocal space. The container uses the FFTW C library to perform the 3-dimensional Fourier transform.

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)#

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()#

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.

filter_direction(axis, rng, sigma)[source]#

Mask out a specific direction in 3D data. Useful for correcting artifacts in a Fourier image caused by the detector gaps.

Parameters
  • axis (Sequence[float]) – Direction of the masking line.

  • rng (float) – Width of the masking line.

  • sigma (float) – Smoothness of the masking line.

Return type

FourierIndexer

Returns

New FourierIndexer object with the masked out 3D data.

find_peaks(val, dmin=0.0, dmax=inf)[source]#

Find a set of basis vectors, that correspond to the peaks in the 3D data, that lie above the threshold val.

Parameters
  • val (float) – Threshold value.

  • dmin (float) – Minimum peak distance. All the peaks below the bound are discarded.

  • dmin – Maximum peak distance. All the peaks above the bound are discarded.

Return type

ndarray

Returns

A set of peaks in the 3D data in order of distance.

fitness(x, center, sigma, cutoff)[source]#

Criterion function for Fourier autoindexing based on maximising the intersection between the experimental mapping and a grid of guassian peaks defined by a set of basis vectors x and lying in the sphere of radius cutoff.

Parameters
  • x (ndarray) – Flattened matrix of basis vectors.

  • center (ndarray) – Center of the modelled grid.

  • sigma (float) – A width of diffraction orders.

  • cutoff (float) – Distance cutoff for a modelled grid.

Return type

Tuple[float, ndarray]

Returns

The intersection criterion and the gradient.

gaussian_blur(sigma)#

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)#

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)#

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)#

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)#

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.

reduce_peaks(center, peaks, sigma, cutoff=None)[source]#

Reduce a set of peaks peaks to three basis vectors, that maximise the intersection between the experimental mapping and a grid of peaks formed by the basis. The grid of peaks is confined in a sphere of radius cutoff.

Parameters
  • center (ndarray) – Center of the grid.

  • peaks (ndarray) – Set of peaks.

  • sigma (float) – Width of a peak in the grid.

  • cutoff (Optional[float]) – A distance to the furthest peak in the grid. Defined by the distance to the furthest peak in peaks if None.

Returns:

Return type

Basis

replace(**kwargs)#

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()#

Export the Map3D object to a dict.

Return type

Dict[str, Any]

Returns

A dictionary of Map3D object’s attributes.

white_tophat(structure)[source]#

Perform 3-dimensional white tophat filtering.

Parameters

structure (ndarray) – Structuring element used for the filter.

Return type

Map3D

Returns

New 3D data container with the filtered data.