iris.AbstractRawDataset¶
-
class
iris.
AbstractRawDataset
(source=None, metadata=None)¶ Abstract base class for ultrafast electron diffraction data set. AbstractRawDataset allows for enforced metadata types and values, as well as a standard interface. For example, AbstractRawDataset implements the context manager interface.
Minimally, the following method must be implemented in subclasses:
- raw_data
It is suggested to also implement the following magic method:
- __init__
- __exit__
Optionally, the
display_name
class attribute can be specified.For better results or performance during reduction, the following methods can be specialized:
- reduced
A list of concrete implementations of AbstractRawDatasets is available in the
implementations
class attribute. Subclasses are automatically added.The call signature must remain the same for all overwritten methods.
Parameters: Raises: TypeError : if an item from the metadata has an unexpected type.
-
__init__
(source=None, metadata=None)¶ Parameters: Raises: TypeError : if an item from the metadata has an unexpected type.
Methods
__init__
([source, metadata])param source: Data source, for example a directory or external file. iterscan
(scan, **kwargs)Generator function of diffraction patterns as part of a scan, in time-delay order. raw_data
(timedelay[, scan])Returns an array of the image at a timedelay and scan. reduced
([exclude_scans, align, normalize, …])Generator of reduced dataset. update_metadata
(metadata)Update metadata from a dictionary. -
__exit__
(*exc)¶ Raise any exception triggered within the runtime context.
-
__init__
(source=None, metadata=None) Parameters: Raises: TypeError : if an item from the metadata has an unexpected type.
-
__repr__
()¶ Return repr(self).
-
iterscan
(scan, **kwargs)¶ Generator function of diffraction patterns as part of a scan, in time-delay order.
Parameters: - scan (int) – Scan from which to yield the data.
- kwargs – Keyword-arguments are passed to
raw_data
method.
Yields: data (~numpy.ndarray, ndim 2)
See also
itertime()
- generator of diffraction patterns for a single time-delay, in scan order
-
itertime
(timedelay, exclude_scans=None, **kwargs)¶ Generator function of diffraction patterns of the same time-delay, in scan order.
Parameters: - timedelay (float) –
- from which to yield the data. (Scan) –
- exclude_scans : iterable or None, optional
- These scans will be skipped.
- kwargs
- Keyword-arguments are passed to
raw_data
method.
Yields: data (~numpy.ndarray, ndim 2) See also
iterscan()
- generator of diffraction patterns for a single scan, in time-delay order
-
metadata
¶ Experimental parameters and dataset metadata as a dictionary.
-
raw_data
(timedelay, scan=1, **kwargs)¶ Returns an array of the image at a timedelay and scan.
Parameters: Returns: arr
Return type: ~numpy.ndarray, ndim 2
Raises: - ValueError : if
timedelay
orscan
are invalid / out of bounds. - IOError : Filename is not associated with an image/does not exist.
- ValueError : if
-
reduced
(exclude_scans=None, align=True, normalize=True, mask=None, processes=1, dtype=<class 'float'>)¶ Generator of reduced dataset. The reduced diffraction patterns are generated in order of time-delay.
This particular implementation normalizes diffracted intensity of pictures acquired at the same time-delay while rejecting masked pixels.
Parameters: - exclude_scans (iterable or None, optional) – These scans will be skipped when reducing the dataset.
- align (bool, optional) – If True (default), raw diffraction patterns will be aligned using the masked normalized cross-correlation approach. See skued.align for more information.
- normalize (bool, optional) – If True (default), equivalent diffraction pictures (e.g. same time-delay, different scans) are normalized to the same diffracted intensity.
- mask (array-like of bool or None, optional) – If not None, pixels where
mask = True
are ignored for certain operations (e.g. alignment). - processes (int or None, optional) – Number of Processes to spawn for processing.
- dtype (numpy.dtype or None, optional) – Reduced patterns will be cast to
dtype
.
Yields: pattern (~numpy.ndarray, ndim 2)
-
update_metadata
(metadata)¶ Update metadata from a dictionary. Only appropriate keys are used; irrelevant keys are ignored.
Parameters: metadata (dictionary) – See AbstractRawDataset.valid_metadata
for valid keys.