anu_ctlab_io
python I/O for the ANU CTLab array storage format(s).
Submodules
Package Contents
- class anu_ctlab_io.Dataset(data, *, dimension_names, voxel_unit, voxel_size, datatype, history=None)
Bases:
AbstractDatasetA
Dataset, containing the data and metadata read from one of the ANU CTLab file formats.Datasets are the primary interface to theanu_ctlab_iopackage, and should generally be constructed by users via theDataset.from_pathclassmethod. Note that the relevant extra (netcdforzarr) must be installed.The initializer of this class should only be used when manually constructing a
Dataset, which is not the primary usage of this library.- Parameters:
data (dask.array.Array)
dimension_names (tuple[str, Ellipsis])
voxel_unit (anu_ctlab_io._voxel_properties.VoxelUnit)
voxel_size (tuple[numpy.float32, numpy.float32, numpy.float32])
datatype (anu_ctlab_io._datatype.DataType)
history (dict[str, Any] | None)
- classmethod from_path(path, *, filetype='auto', parse_history=True, **kwargs)
Creates a
Datasetfrom the data at the givenpath.The data at
pathmust be in one of the ANU mass data storage formats, and the optional extras required for the specific file format must be installed.- Parameters:
path (pathlib.Path | str) – The
pathto read data from.filetype (str)
parse_history (bool)
kwargs (Any)
- Return type:
- property voxel_size: tuple[numpy.float32, numpy.float32, numpy.float32]
The voxel size of the data.
- Return type:
tuple[numpy.float32, numpy.float32, numpy.float32]
- property voxel_unit: anu_ctlab_io._voxel_properties.VoxelUnit
The unit the data’s voxel size is in.
- Return type:
anu_ctlab_io._voxel_properties.VoxelUnit
- property dimension_names: tuple[str, Ellipsis]
The names of the data’s dimensions. Usually
("z", "y", "x").- Return type:
tuple[str, Ellipsis]
- property history: dict[Any, Any] | str
The history metadata associated with the
Dataset.If parsing is enabled this will be a nested dict, otherwise it will be a dictionary without any guaranteed structure.
- Return type:
dict[Any, Any] | str
- property mask_value: anu_ctlab_io._datatype.StorageDType | None
The mask value being used by the data.
- Return type:
anu_ctlab_io._datatype.StorageDType | None
- property data: dask.array.Array
The data contained within the
Dataset.This is a Dask Array.
- Return type:
dask.array.Array
- class anu_ctlab_io.DataType(*args, **kwds)
Bases:
enum.EnumAn
Enumrepresenting the datatypes produced by MANGO.This is used when parsing metadata to construct a
Dataset, and generally should not need to be constructed by a user (use theDataset.from_pathclassmethod instead).When needed,
DataTypes should be constructed via either theinfer_from_pathor thefrom_basenameclassmethods.- PROJU16 = 'proju16'
- PROJF32 = 'projf32'
- TOMO_FLOAT = 'tomo_float'
- TOMO = 'tomo'
- FLOAT16 = 'float16'
- FLOAT64 = 'float64'
- SEGMENTED = 'segmented'
- DISTANCE_MAP = 'distance_map'
- LABELS = 'labels'
- RGBA8 = 'rgba8'
- property dtype: numpy.typing.DTypeLike
The numpy
dtypeappropriate for storing data of theDataType.Because of a historical decision in MANGO, the datatype listed in ANU CTLab NetCDFs is not guaranteed to have the correct signed/unsigned type – for some MANGO datatypes, data recorded in the NetCDF as an integer type is really an unsigned integer stored in an integer. The
dtypeis the real datatype of the data, regardless of whether a loaded NetCDF exhibits this behaviour (trust this value, not the NetCDF header).- Return type:
numpy.typing.DTypeLike
- property mask_value: StorageDType | None
The mask value of the
DataType.This value is corrected for signedness if required (see
dtype).- Return type:
StorageDType | None
- type anu_ctlab_io.StorageDType = np.uint8 | np.uint16 | np.uint32 | np.uint64 | np.float16 | np.float32 | np.float64