Density#

The density module provides an abstract representation of N-dimensional densities, facilitating operations and manipulations of multi-dimensional data.

Constructor#

Density

Abstract representation of N-dimensional densities.

Attributes and underlying data#

Density.data

Returns the value of Density.data.

Density.origin

Returns the value of the instance's Density.origin attribute.

Density.sampling_rate

Returns the value of the instance's Density.sampling_rate attribute.

Density.metadata

Returns the instance's Density.metadata attribute.

Density.shape

Returns the dimensions of Density.data.

Density.empty

Returns a copy of the class instance with all elements in Density.data set to zero.

Serialization#

Density.to_file(filename[, gzip])

Writes class instance to disk.

Density.from_file(filename[, subset, use_memmap])

Reads a file into a Density instance.

Density.from_structure(filename_or_structure)

Reads in an atomic structure and converts it into a Density instance.

Conversion#

Density.copy()

Create a copy of the class instance.

Density.to_numpy()

Converts Density.data to an in-memory numpy.ndarray.

Density.to_memmap()

Converts Density.data to a numpy.memmap.

Subsetting#

Density.pad(new_shape[, center, padding_value])

Density.pad() extends the internal Density.data array of the current Density instance to new_shape and adapts Density.origin accordingly.

Density.trim_box(cutoff[, margin])

Computes a rectangle with sufficient dimension that encloses all values of the internal data array larger than the specified cutoff, expanded by the specified margin.

Density.centered([cutoff])

Shifts the data center of mass to the center of the data array using linear interpolation.

Density.adjust_box(box[, pad_kwargs])

Adjusts Density.data and Density.origin according to the provided box.

Density.minimum_enclosing_box(cutoff[, ...])

Compute the enclosing box that holds all possible rotations of the internal data array.

Computations#

Density.rigid_transform(rotation_matrix[, ...])

Performs a rigid transform of the class instance.

Density.to_pointcloud([threshold])

Returns data indices that are larger than the given threshold.

Density.resample(new_sampling_rate[, ...])

Resamples Density.data to new_sampling_rate.

Density.density_boundary(weight[, ...])

Computes the density boundary of the class instance.

Density.surface_coordinates(density_boundaries)

Calculates the surface coordinates of the class instance using different boundary and surface detection methods.

Density.normal_vectors(coordinates)

Calculates the normal vectors for the given coordinates on the densities of the class instance.

Density.core_mask()

Calculates a weighted core mask by performing iterative binary erosion on Density.data.

Density.center_of_mass(arr[, cutoff])

Computes the center of mass of a numpy ndarray instance using all available elements.

Density.match_densities(target, template[, ...])

Aligns two Density instances target and template and returns the aligned template.

Density.match_structure_to_density(target, ...)

Aligns a tme.structure.Structure template to Density target and returns an aligned tme.structure.Structure instance.

Density.fourier_shell_correlation(density1, ...)

Computes the Fourier Shell Correlation (FSC) between two instances of Density.