afmformats.meta

Functions

afmformats.meta.parse_time(time_str: str)[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

digraph inheritance59f436c358 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "MetaDataMissingError" [URL="#afmformats.meta.MetaDataMissingError",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Raised when meta data is missing"]; }
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

digraph inheritancefb0122210b { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "LazyMetaValue" [URL="#afmformats.meta.LazyMetaValue",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="A metadata value that is evaluated lazily in :class:`MetaData`"]; }
class afmformats.meta.MetaData(*args, **kwargs)[source]

Management of meta data variables

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

Inheritance

digraph inheritanceaafae26581 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "MetaData" [URL="#afmformats.meta.MetaData",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Management of meta data variables"]; }
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 0x74128d6ade40>],
                 'imaging mode': ['Imaging modality',
                                  '',
                                  <function vd_str_in.<locals>.str_in at 0x74128d6adf80>],
                 '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 0x74128d6ae200>],
             'point count': ['Size of the dataset in points',
                             '',
                             <function fint at 0x74128d6ae200>],
             '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 0x74128d6ae200>],
             '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 0x74128d6ae200>],
          'grid index y': ['Vertical grid position index',
                           '',
                           <function fint at 0x74128d6ae200>],
          'grid shape x': ['Horizontal grid shape',
                           'px',
                           <function fint at 0x74128d6ae200>],
          'grid shape y': ['Vertical grid shape',
                           'px',
                           <function fint at 0x74128d6ae200>],
          '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 0x74128d6ae200>],
 'feedback mode': ['Feedback mode',
                   '',
                   <function vd_str_in.<locals>.str_in at 0x74128d6ade40>],
 '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 0x74128d6ae200>],
 'grid index y': ['Vertical grid position index',
                  '',
                  <function fint at 0x74128d6ae200>],
 'grid shape x': ['Horizontal grid shape',
                  'px',
                  <function fint at 0x74128d6ae200>],
 'grid shape y': ['Vertical grid shape',
                  'px',
                  <function fint at 0x74128d6ae200>],
 '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 0x74128d6adf80>],
 'instrument': ['Instrument', '', <class 'str'>],
 'path': ['Path', '', <class 'pathlib.Path'>],
 'point count': ['Size of the dataset in points',
                 '',
                 <function fint at 0x74128d6ae200>],
 '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 0x74128d6ae200>],
 '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']