afmformats.meta
¶
Functions¶
parse_time()
: Convert a time string to “HH:MM:SS.S”
Classes¶
MetaDataMissingError
: Raised when meta data is missingLazyMetaValue
: A metadata value that is evaluated lazily inMetaData
MetaData
: Management of meta data variables
- class afmformats.meta.LazyMetaValue(func, *args, **kwargs)[source]¶
A metadata value that is evaluated lazily in
MetaData
Example usage:
meta = afmformats.meta.MetaData meta["z range"] = afmformats.meta.LazyMetaValue( np.ptp, np.arange(10))
- Parameters
func (callable) – Function to call to get the metadata value
args – arguments to
func
kwargs – Keyword arguments to
func
Inheritance
- class afmformats.meta.MetaData(*args, **kwargs)[source]¶
Management of meta data variables
Valid key names are defined in
afmformats.meta.KEYS_VALID
.Inheritance
- as_dict()[source]¶
Convert to real dictionary
This is needed e.g. for self.items such that json.dump works in combination with LazyMetaValue (which is not JSON serializable)
- copy()[source]¶
Create a copy of the metadata
- Returns
mdc – Copy of the MetaData class (LazyMetaValue not copied)
- Return type
- get_summary()[source]¶
Convenience function returning the meta data summary
Returns a dict of dicts with keys matching the DEF_* dicts. Unset values are returned as np.nan.
Variables¶
- afmformats.meta.META_FIELDS¶
Compendium of all allowed meta data keys, sorted by topic, and including units and validation methods
{'acquisition': {'feedback mode': ['Feedback mode', '', <function vd_str_in.<locals>.str_in at 0x7f040541ca60>], 'imaging mode': ['Imaging modality', '', <function vd_str_in.<locals>.str_in at 0x7f0405438040>], 'rate approach': ['Sampling rate (approach)', 'Hz', <class 'float'>], 'rate retract': ['Sampling rate (retract)', 'Hz', <class 'float'>], 'sensitivity': ['Sensitivity', 'm/V', <class 'float'>], 'setpoint': ['Active feedback loop setpoint', 'N', <class 'float'>], 'spring constant': ['Cantilever spring constant', 'N/m', <class 'float'>]}, 'dataset': {'duration': ['Duration', 's', <class 'float'>], 'enum': ['Dataset index within the experiment', '', <function fint at 0x7f040541cd30>], 'point count': ['Size of the dataset in points', '', <function fint at 0x7f040541cd30>], 'speed approach': ['Piezo speed (approach)', 'm/s', <class 'float'>], 'speed retract': ['Piezo speed (retract)', 'm/s', <class 'float'>], 'z range': ['Axial piezo range', 'm', <class 'float'>]}, 'qmap': {'grid center x': ['Horizontal center of grid', 'm', <class 'float'>], 'grid center y': ['Vertical center of grid', 'm', <class 'float'>], 'grid index x': ['Horizontal grid position index', '', <function fint at 0x7f040541cd30>], 'grid index y': ['Vertical grid position index', '', <function fint at 0x7f040541cd30>], 'grid shape x': ['Horizontal grid shape', 'px', <function fint at 0x7f040541cd30>], 'grid shape y': ['Vertical grid shape', 'px', <function fint at 0x7f040541cd30>], 'grid size x': ['Horizontal grid image size', 'm', <class 'float'>], 'grid size y': ['Vertical grid image size', 'm', <class 'float'>], 'position x': ['Horizontal position', 'm', <class 'float'>], 'position y': ['Vertical position', 'm', <class 'float'>]}, 'setup': {'instrument': ['Instrument', '', <class 'str'>], 'software': ['Acquisition software', '', <class 'str'>], 'software version': ['Acquisition software version', '', <class 'str'>]}, 'storage': {'curve id': ['Curve identifier', '', <class 'str'>], 'date': ['Recording date', '', <class 'str'>], 'format': ['File format', '', <class 'str'>], 'path': ['Path', '', <class 'pathlib.Path'>], 'session id': ['Dataset identifier', '', <class 'str'>], 'time': ['Recording time', '', <class 'str'>]}}
- afmformats.meta.DEF_ALL¶
A dictionary for all metadata definitions
{'curve id': ['Curve identifier', '', <class 'str'>], 'date': ['Recording date', '', <class 'str'>], 'duration': ['Duration', 's', <class 'float'>], 'enum': ['Dataset index within the experiment', '', <function fint at 0x7f040541cd30>], 'feedback mode': ['Feedback mode', '', <function vd_str_in.<locals>.str_in at 0x7f040541ca60>], 'format': ['File format', '', <class 'str'>], 'grid center x': ['Horizontal center of grid', 'm', <class 'float'>], 'grid center y': ['Vertical center of grid', 'm', <class 'float'>], 'grid index x': ['Horizontal grid position index', '', <function fint at 0x7f040541cd30>], 'grid index y': ['Vertical grid position index', '', <function fint at 0x7f040541cd30>], 'grid shape x': ['Horizontal grid shape', 'px', <function fint at 0x7f040541cd30>], 'grid shape y': ['Vertical grid shape', 'px', <function fint at 0x7f040541cd30>], 'grid size x': ['Horizontal grid image size', 'm', <class 'float'>], 'grid size y': ['Vertical grid image size', 'm', <class 'float'>], 'imaging mode': ['Imaging modality', '', <function vd_str_in.<locals>.str_in at 0x7f0405438040>], 'instrument': ['Instrument', '', <class 'str'>], 'path': ['Path', '', <class 'pathlib.Path'>], 'point count': ['Size of the dataset in points', '', <function fint at 0x7f040541cd30>], 'position x': ['Horizontal position', 'm', <class 'float'>], 'position y': ['Vertical position', 'm', <class 'float'>], 'rate approach': ['Sampling rate (approach)', 'Hz', <class 'float'>], 'rate retract': ['Sampling rate (retract)', 'Hz', <class 'float'>], 'sensitivity': ['Sensitivity', 'm/V', <class 'float'>], 'session id': ['Dataset identifier', '', <class 'str'>], 'setpoint': ['Active feedback loop setpoint', 'N', <class 'float'>], 'software': ['Acquisition software', '', <class 'str'>], 'software version': ['Acquisition software version', '', <class 'str'>], 'speed approach': ['Piezo speed (approach)', 'm/s', <class 'float'>], 'speed retract': ['Piezo speed (retract)', 'm/s', <class 'float'>], 'spring constant': ['Cantilever spring constant', 'N/m', <class 'float'>], 'time': ['Recording time', '', <class 'str'>], 'z range': ['Axial piezo range', 'm', <class 'float'>]}
- afmformats.meta.KEYS_VALID¶
List of all valid meta data keys
['curve id', 'date', 'duration', 'enum', 'feedback mode', 'format', 'grid center x', 'grid center y', 'grid index x', 'grid index y', 'grid shape x', 'grid shape y', 'grid size x', 'grid size y', 'imaging mode', 'instrument', 'path', 'point count', 'position x', 'position y', 'rate approach', 'rate retract', 'sensitivity', 'session id', 'setpoint', 'software', 'software version', 'speed approach', 'speed retract', 'spring constant', 'time', 'z range']