afmformats.meta

Functions

afmformats.meta.parse_time(value)[source]

Convert a time string to “HH:MM:SS.S”

  • leading zeros are added where necessary

  • trailing zeros after “.” are stripped

  • trailing “.” is stripped

e.g.

  • “6:15:22 PM” -> “18:15:22”

  • “6:15:22.00 AM” -> “06:15:22”

  • “6:02:22.010 AM” -> “06:02:22.01”

Classes

class afmformats.meta.MetaDataMissingError[source]

Raised when meta data is missing

Inheritance

Inheritance diagram of MetaDataMissingError
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

Inheritance diagram of LazyMetaValue
class afmformats.meta.MetaData(*args, **kwargs)[source]

Management of meta data variables

Valid key names are defined in afmformats.meta.KEYS_VALID.

Inheritance

Inheritance diagram of MetaData
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

MetaData

get(key, default=None)[source]

Return the value for key if key is in the dictionary, else default.

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.

items() a set-like object providing a view on D's items[source]
update([E, ]**F) None.  Update D from dict/iterable E and F.[source]

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values[source]

Variables

afmformats.meta.IMAGING_MODALITIES

supported imaging modalities

['creep-compliance', 'force-distance', 'stress-relaxation']
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 0x7f64e53d1a60>],
                 'imaging mode': ['Imaging modality',
                                  '',
                                  <function vd_str_in.<locals>.str_in at 0x7f64e53d1f70>],
                 'sensitivity': ['Sensitivity', 'm/V', <class 'float'>],
                 'spring constant': ['Cantilever spring constant',
                                     'N/m',
                                     <class 'float'>]},
 'dataset': {'duration': ['Duration', 's', <class 'float'>],
             'duration approach': ['Duration of approach segment',
                                   's',
                                   <class 'float'>],
             'duration retract': ['Duration of retract segment',
                                  's',
                                  <class 'float'>],
             'enum': ['Dataset index within the experiment',
                      '',
                      <function fint at 0x7f64e53d1ee0>],
             'point count': ['Size of the dataset in points',
                             '',
                             <function fint at 0x7f64e53d1ee0>],
             'rate approach': ['Sampling rate of approach segment',
                               'Hz',
                               <class 'float'>],
             'rate retract': ['Sampling rate of retract segment',
                              'Hz',
                              <class 'float'>],
             'segment count': ['Number of segments',
                               '',
                               <function fint at 0x7f64e53d1ee0>],
             'setpoint': ['Target indentation force', 'N', <class 'float'>],
             'speed approach': ['Piezo speed of approach segment',
                                'm/s',
                                <class 'float'>],
             'speed retract': ['Piezo speed of retract segment',
                               'm/s',
                               <class 'float'>],
             'z range': ['Axial piezo range', 'm', <class 'float'>]},
 'dataset-mod creep-compliance': {'duration intermediate': ['Duration of '
                                                            'intermediate '
                                                            'segment',
                                                            's',
                                                            <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 0x7f64e53d1ee0>],
          'grid index y': ['Vertical grid position index',
                           '',
                           <function fint at 0x7f64e53d1ee0>],
          'grid shape x': ['Horizontal grid shape',
                           'px',
                           <function fint at 0x7f64e53d1ee0>],
          'grid shape y': ['Vertical grid shape',
                           'px',
                           <function fint at 0x7f64e53d1ee0>],
          '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'>],
 'duration approach': ['Duration of approach segment', 's', <class 'float'>],
 'duration intermediate': ['Duration of intermediate segment',
                           's',
                           <class 'float'>],
 'duration retract': ['Duration of retract segment', 's', <class 'float'>],
 'enum': ['Dataset index within the experiment',
          '',
          <function fint at 0x7f64e53d1ee0>],
 'feedback mode': ['Feedback mode',
                   '',
                   <function vd_str_in.<locals>.str_in at 0x7f64e53d1a60>],
 '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 0x7f64e53d1ee0>],
 'grid index y': ['Vertical grid position index',
                  '',
                  <function fint at 0x7f64e53d1ee0>],
 'grid shape x': ['Horizontal grid shape',
                  'px',
                  <function fint at 0x7f64e53d1ee0>],
 'grid shape y': ['Vertical grid shape',
                  'px',
                  <function fint at 0x7f64e53d1ee0>],
 '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 0x7f64e53d1f70>],
 'instrument': ['Instrument', '', <class 'str'>],
 'path': ['Path', '', <class 'pathlib.Path'>],
 'point count': ['Size of the dataset in points',
                 '',
                 <function fint at 0x7f64e53d1ee0>],
 'position x': ['Horizontal position', 'm', <class 'float'>],
 'position y': ['Vertical position', 'm', <class 'float'>],
 'rate approach': ['Sampling rate of approach segment', 'Hz', <class 'float'>],
 'rate retract': ['Sampling rate of retract segment', 'Hz', <class 'float'>],
 'segment count': ['Number of segments', '', <function fint at 0x7f64e53d1ee0>],
 'sensitivity': ['Sensitivity', 'm/V', <class 'float'>],
 'session id': ['Dataset identifier', '', <class 'str'>],
 'setpoint': ['Target indentation force', 'N', <class 'float'>],
 'software': ['Acquisition software', '', <class 'str'>],
 'software version': ['Acquisition software version', '', <class 'str'>],
 'speed approach': ['Piezo speed of approach segment', 'm/s', <class 'float'>],
 'speed retract': ['Piezo speed of retract segment', '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',
 'duration approach',
 'duration intermediate',
 'duration retract',
 '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',
 'segment count',
 'sensitivity',
 'session id',
 'setpoint',
 'software',
 'software version',
 'speed approach',
 'speed retract',
 'spring constant',
 'time',
 'z range']