Advanced Usage

Grouping AFM data

AFM data can be organized in an afmformats.AFMGroup which comes with a few user-convenient functionalities:

In [1]: import afmformats

In [2]: group = afmformats.AFMGroup("data/force-map2x2-example.jpk-force-map")

# group contains all curves in the data file
In [3]: print(group)
AFMGroup: 'data/force-map2x2-example.jpk-force-map'
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[0]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[1]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[2]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[3]

# you may add other data files to groups
In [4]: group += afmformats.load_data("data/force-save-example.jpk-force")

In [5]: print(group)
AFMGroup: 'None'
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[0]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[1]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[2]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[3]
- AFMForceDistance 'data/force-save-example.jpk-force'[0]

# You can also extract a subgroup that matches a certin path
In [6]: subgroup = group.subgroup_with_path("data/force-map2x2-example.jpk-force-map")

In [7]: print(subgroup)
AFMGroup: 'data/force-map2x2-example.jpk-force-map'
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[0]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[1]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[2]
- AFMForceDistance 'data/force-map2x2-example.jpk-force-map'[3]