Skip to content

Module: micpy.geo

The micpy.geo modules provides methods to read and write geometry files.

GeometryFileError

Bases: Exception

Base exception for geometry file errors.

GeometryFileNotFoundError

Bases: GeometryFileError

Raised when a geometry file is not found.

MultipleGeometryFilesError

Bases: GeometryFileError

Raised when multiple potential geometry files are found.

Type

Bases: Enum

Data type of geometry file.

build(filename, shape, spacing)

Create a basic geometry.

Parameters:

Name Type Description Default
filename str

Filename of a binary file.

required
shape tuple

Shape of the geometry (z, y, x).

required
spacing tuple

Spacing of the geometry (dz, dy, dx) in μm.

required

find(filename)

Find the geometry file for a given binary file.

This method assumes that (a) both files share a common basename and (b) the file extension of the geometry file starts with either .geoF or _geoF.

Parameters:

Name Type Description Default
filename str

Filename of a binary file.

required

Returns:

Type Description
Path

Path to the geometry file.

read(filename, type=Type.EXTENDED, compressed=True)

Read a geometry file.

Parameters:

Name Type Description Default
filename str

Filename of a geometry file.

required
type Type

Data type to be read. Defaults to Type.EXTENDED.

EXTENDED
compressed bool

True if file is compressed, False otherwise. Defaults to True.

True

Returns:

Type Description
dict

Dictionary representation of the geometry file.

read_ndarray(filename, type=Type.EXTENDED, compressed=True)

Read a geometry file.

Parameters:

Name Type Description Default
filename str

Filename of a geometry file.

required
type Type

Data type to be read. Defaults to Type.EXTENDED.

EXTENDED
compressed bool

True if file is compressed, False otherwise. Defaults to True.

True

Returns:

Type Description
ndarray

NumPy array representation of the geometry file.

write(filename, data, type=Type.EXTENDED, compressed=True)

Write a geometry file.

Parameters:

Name Type Description Default
filename str

Filename of a geometry file.

required
data dict

Dictionary representation of a geometry file.

required
type Type

Data type to be written. Defaults to Type.EXTENDED.

EXTENDED
compressed bool

True if file should be compressed, False otherwise. Defaults to True.

True

write_ndarray(filename, data, compressed=True)

Write a geometry file.

Parameters:

Name Type Description Default
filename str

Filename of a geometry file.

required
data ndarray

NumPy array representation of a geometry file.

required
compressed bool

True if file should be compressed, False otherwise. Defaults to True.

True