Code reference

module-level

qpformat.load_data(path, fmt=None, bg_data=None, bg_fmt=None, meta_data={}, holo_kw={}, as_type='float32')[source]

Load experimental data

Parameters:
  • path (str) – Path to experimental data file or folder
  • fmt (str) – The file format to use (see file_formats.formats). If set to None, the file format is be guessed.
  • bg_data (str) – Path to background data file or qpimage.QPImage
  • bg_fmt (str) – The file format to use (see file_formats.formats) for the background. If set to None, the file format is be guessed.
  • meta_data (dict) – Meta data (see qpimage.meta.DATA_KEYS)
  • as_type (str) – Defines the data type that the input data is casted to. The default is “float32” which saves memory. If high numerical accuracy is required (does not apply for a simple 2D phase analysis), set this to double precision (“float64”).
Returns:

dataobj – Object that gives lazy access to the experimental data.

Return type:

SeriesData or SingleData

file format base classes

SeriesData

class qpformat.file_formats.SeriesData(path, meta_data={}, holo_kw={}, as_type='float32')[source]

Series data file format base class

Parameters:
  • path (str or pathlib.Path) – Path to the experimental data file.
  • meta_data (dict) – Dictionary containing meta data. see qpimage.META_KEYS.
  • as_type (str) – Defines the data type that the input data is casted to. The default is “float32” which saves memory. If high numerical accuracy is required (does not apply for a simple 2D phase analysis), set this to double precision (“float64”).
background_identifier = None

Unique string that identifies the background data that was set using set_bg.

identifier

Return a unique identifier for the given data set

get_identifier(idx)[source]

Return an identifier for the data at index idx

get_name(idx)[source]

Return name of data at index idx

get_qpimage(idx)[source]

Return background-corrected QPImage of data at index idx

get_qpimage_raw(idx)[source]

Return QPImage without background correction

get_time(idx)[source]

Return time of data at index idx

saveh5(h5file)[source]

Save the data set as an hdf5 file (qpimage.QPSeries format)

set_bg(dataset)[source]

Set background data

Parameters:dataset (DataSet, qpimage.QPImage, or int) – If the len(dataset) matches len(self), then background correction is performed element-wise. Otherwise, len(dataset) must be one and is used for all data of self.

See also

get_qpimage()
obtain the background corrected QPImage
static verify(path)[source]

Verify that path has this file format

Returns True if the file format matches. The implementation of this method should be fast and memory efficient, because e.g. the “GroupFolder” file format depends on it.

SingleData

class qpformat.file_formats.SingleData(path, meta_data={}, holo_kw={}, as_type='float32')[source]

Single data file format base class

Parameters:
  • path (str or pathlib.Path) – Path to the experimental data file.
  • meta_data (dict) – Dictionary containing meta data. see qpimage.META_KEYS.
  • as_type (str) – Defines the data type that the input data is casted to. The default is “float32” which saves memory. If high numerical accuracy is required (does not apply for a simple 2D phase analysis), set this to double precision (“float64”).
get_identifier(idx=0)[source]

Return an identifier for the data at index idx

get_name(idx=0)[source]

Return name of data at index idx

get_qpimage(idx=0)[source]

Return background-corrected QPImage of data at index idx

get_qpimage_raw(idx=0)[source]

QPImage without background correction

get_time(idx=0)[source]

Time of QPImage

identifier

Return a unique identifier for the given data set

saveh5(h5file)

Save the data set as an hdf5 file (qpimage.QPSeries format)

set_bg(dataset)

Set background data

Parameters:dataset (DataSet, qpimage.QPImage, or int) – If the len(dataset) matches len(self), then background correction is performed element-wise. Otherwise, len(dataset) must be one and is used for all data of self.

See also

get_qpimage()
obtain the background corrected QPImage
static verify(path)

Verify that path has this file format

Returns True if the file format matches. The implementation of this method should be fast and memory efficient, because e.g. the “GroupFolder” file format depends on it.

file format readers

All file formats inherit from qpformat.file_formats.SeriesData (and/or qpformat.file_formats.SingleData).

SeriesFolder

class qpformat.file_formats.SeriesFolder(*args, **kwargs)[source]

Folder-based wrapper file format

is_series = True
storage_type

The storage type depends on the wrapped file format

files

List of files (only supported file formats)

SeriesHdf5HyperSpy

class qpformat.file_formats.SeriesHdf5HyperSpy(path, meta_data={}, holo_kw={}, as_type='float32')[source]

HyperSpy hologram series (HDF5 format)

HyperSpy has its own implementation to read this file format.

is_series = True
storage_type = 'hologram'

SeriesHdf5Qpimage

class qpformat.file_formats.SeriesHdf5Qpimage(*args, **kwargs)[source]

Qpimage series (HDF5 format)

is_series = True
storage_type = 'phase,amplitude'

SeriesZipTifHolo

class qpformat.file_formats.SeriesZipTifHolo(*args, **kwargs)[source]

Off-axis hologram series (zipped TIFF files)

The data are stored as multiple TIFF files (qpformat.file_formats.SingleTifHolo) in a zip file.

is_series = True
storage_type = 'hologram'
files

List of hologram data file names in the input zip file

SeriesZipTifPhasics

class qpformat.file_formats.SeriesZipTifPhasics(*args, **kwargs)[source]

Phasics series data (zipped “SID PHA*.tif” files)

The data are stored as multiple TIFF files (qpformat.file_formats.SingleTifPhasics) in a zip file.

is_series = True
storage_type = 'phase,intensity'
files

List of Phasics tif file names in the input zip file

SingleHdf5Qpimage

class qpformat.file_formats.SingleHdf5Qpimage(path, meta_data={}, holo_kw={}, as_type='float32')[source]

Qpimage single (HDF5 format)

See the documentation of qpimage for more information.

is_series = False
storage_type = 'phase,amplitude'

SingleNpyNumpy

class qpformat.file_formats.SingleNpyNumpy(path, meta_data={}, holo_kw={}, as_type='float32')[source]

Numpy complex field or phase data (numpy binary format)

The experimental data given in path consist of a single 2D ndarray (no pickled objects). The ndarray is either complex-valued (scattered field) or real-valued (phase).

is_series = False
storage_type

Depending on input data type, the storage type is either “field” (complex) or “phase” (real).

SingleTifHolo

class qpformat.file_formats.SingleTifHolo(path, meta_data={}, holo_kw={}, as_type='float32')[source]

Off-axis hologram image (TIFF format)

is_series = False
storage_type = 'hologram'

SingleTifPhasics

class qpformat.file_formats.SingleTifPhasics(path, meta_data={}, *args, **kwargs)[source]

Phasics image (“SID PHA*.tif”)

Notes

  • Only the processed phase data files are supported, i.e. TIFF file names starting with “SID PHA” exported by the commercial Phasics software.
  • If the “wavelength” key in meta_data is not set (units: [m]), then the wavelength is extracted from the xml data stored in tag “61238” of the tif file.
is_series = False
storage_type = 'phase,intensity'

exceptions

exception qpformat.file_formats.MultipleFormatsNotSupportedError[source]

Used when a folder contains series file formats

(see GitHub issue #1)

exception qpformat.file_formats.UnknownFileFormatError[source]

Used when a file format could not be detected