reader#
For usage, see Reader: Reading Data. For subclassing guidance, see Reader API.
- class pyleem.reader.Reader[source]#
Bases:
ABCAbstract 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.
- abstract property image#
Return image data as numpy array.
- class pyleem.reader.UViewReader(path, metadata=None)[source]#
Bases:
ReaderReader 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