reader#

For usage, see Reader: Reading Data. For subclassing guidance, see Reader API.

class pyleem.reader.Reader[source]#

Bases: ABC

Abstract base class for LEEM data readers.

The reader should implement the get_image and get_metadata methods. The property metadata and image are default and extract values at runtime.

The reader does not necessarily need to parse a physical file path.’ However, the comparison operator __lt__ is required to be implemented so that the reader is sortable.

property metadata#

Return metadata as dictionary in (value, unit) format.

The method forces the child class to possess the _metadata attribute.

update_metadata(metadata)[source]#

Update the metadata.

abstract property image#

Return image data as numpy array.

plot_image(ax=None, **kwargs)[source]#

Plot the raw image data.

Parameters:

ax (matplotlib.axes.Axes) – Matplotlib axes object.

class pyleem.reader.UViewReader(path, metadata=None)[source]#

Bases: Reader

Reader for UView LEEM raw .dat files.

UView .dat files contain a single image with combined file and image headers in a metadata block.

Additional metadata data can be added.

Parameters:

path (str or Path) – Path to .dat file.

read_metabytes(metasize)[source]#

Read metadata bytes from file.

Parameters:

metasize (int) – Number of bytes to read.

Returns:

Raw metadata bytes.

Return type:

bytes

property image#

Read the image data from file.

Images are stored at the end of the file as 16-bit unsigned integers (little-endian) with shape (height, width).

Returns:

Image array.

Return type:

ndarray

pyleem.reader.get_time_intervals(readers)[source]#

Get the time intervals from the readers.

pyleem.reader.read_files(paths, reader_cls=UViewReader, metadata_list=None)[source]#

Read a list of files and add time intervals metadata.

Additional metadata can be added to the readers with the metadata_list parameter.

TimeInterval metadata, however, is added directly.