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.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(k[, d])D[k] if k in D, else d.  d defaults to None.[source]
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.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 0x7f5d4b859400>],
                 'imaging mode': ['Imaging modality',
                                  '',
                                  <function vd_str_in.<locals>.str_in at 0x7f5d4b8596a8>],
                 '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 0x7f5d4b859840>],
             'point count': ['Size of the dataset in points',
                             '',
                             <function fint at 0x7f5d4b859840>],
             '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 0x7f5d4b859840>],
          'grid index y': ['Vertical grid position index',
                           '',
                           <function fint at 0x7f5d4b859840>],
          'grid shape x': ['Horizontal grid shape',
                           'px',
                           <function fint at 0x7f5d4b859840>],
          'grid shape y': ['Vertical grid shape',
                           'px',
                           <function fint at 0x7f5d4b859840>],
          '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 0x7f5d4b859840>],
 'feedback mode': ['Feedback mode',
                   '',
                   <function vd_str_in.<locals>.str_in at 0x7f5d4b859400>],
 '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 0x7f5d4b859840>],
 'grid index y': ['Vertical grid position index',
                  '',
                  <function fint at 0x7f5d4b859840>],
 'grid shape x': ['Horizontal grid shape',
                  'px',
                  <function fint at 0x7f5d4b859840>],
 'grid shape y': ['Vertical grid shape',
                  'px',
                  <function fint at 0x7f5d4b859840>],
 '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 0x7f5d4b8596a8>],
 'instrument': ['Instrument', '', <class 'str'>],
 'path': ['Path', '', <class 'pathlib.Path'>],
 'point count': ['Size of the dataset in points',
                 '',
                 <function fint at 0x7f5d4b859840>],
 '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']