User API¶
Qpformat supports several file formats
(qpformat.file_formats.formats
), which are
divided into qpformat.file_formats.SingleData
(the experimental data file format contains only one phase image)
and qpformat.file_formats.SeriesData
(the experimental
data file format supports multiple phase images).
From these base classes, all data file formats are derived. The idea
is that experimental data is not loaded into memory until the
get_qpimage method is called which returns a
qpimage.QPImage
object.
Basic Usage¶
The file format type is determined automatically by qpformat.
If the file format is implemented in qpformat, experimental
data can be loaded with the qpformat.load_data()
method.
# Obtain a qpformat.file_formats.SingleData object
# (the data is not loaded into memory, only the meta data is read)
ds = qpformat.load_data(path="/path/to/SID PHA_xxx.tif")
# Get the quantitative phase data (a qpimage.QPImage is returned)
qpi = ds.get_qpimage()
SingleData¶
-
class
qpformat.file_formats.
SeriesData
(path, meta_data={}, holo_kw={}, as_type='float32')[source]¶ -
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
-
set_bg
(dataset)[source]¶ Set background data
Parameters: dataset (DataSet, qpimage.QPImage, or int) – If the len(dataset)
matcheslen(self)
, then background correction is performed element-wise. Otherwise,len(dataset)
must be one and is used for all data ofself
.See also
get_qpimage()
- obtain the background corrected QPImage
-
SeriesData¶
-
class
qpformat.file_formats.
SeriesData
(path, meta_data={}, holo_kw={}, as_type='float32')[source] -
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 format)
-
set_bg
(dataset)[source] Set background data
Parameters: dataset (DataSet, qpimage.QPImage, or int) – If the len(dataset)
matcheslen(self)
, then background correction is performed element-wise. Otherwise,len(dataset)
must be one and is used for all data ofself
.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.
-
Constants¶
-
qpformat.file_formats.
formats
= [<class 'qpformat.file_formats.SeriesFolder'>, <class 'qpformat.file_formats.single_hdf5_qpimage.SingleHdf5Qpimage'>, <class 'qpformat.file_formats.single_tif_phasics.SingleTifPhasics'>, <class 'qpformat.file_formats.single_tif_holo.SingleTifHolo'>, <class 'qpformat.file_formats.single_npy_numpy.SingleNpyNumpy'>, <class 'qpformat.file_formats.series_hdf5_hyperspy.SeriesHdf5HyperSpy'>, <class 'qpformat.file_formats.series_hdf5_qpimage.SeriesHdf5Qpimage'>, <class 'qpformat.file_formats.series_zip_tif_phasics.SeriesZipTifPhasics'>, <class 'qpformat.file_formats.series_zip_tif_holo.SeriesZipTifHolo'>]¶ list() -> new empty list list(iterable) -> new list initialized from iterable’s items