DEMutilities.afmtools. import_afm_data

Module containing methods to import afm data files into easily accessible data types, compatible with Mpacts, and the Mpacts post-processing strategy.

In order to be able to use this module import it like this:

import DEMutilities.afmtools.import_afm_data
#or assign it to a shorter name
import DEMutilities.afmtools.import_afm_data as imp
DEMutilities.afmtools.import_afm_data._try_access_metadata(s, name, index)
DEMutilities.afmtools.import_afm_data.convert_fd_jpk_h5(jpkfname, h5name, mode='a')

Convert a processed jpk-formatted force-distance profile from an AFM measurement to an Hdf5 database file, in which all data are saved, including the different data arrays (force, deflection, voltage,...) and all the metadata in the jpk file, which is saved as attributes. Seperate sections in the jpk file are saved as root-level seperate sections in the hdf5 file (e.g. for an approach an a retract curve).

Parameters:
  • jpkfname (str) – Name of the processed jpk-formatted filename (typically a txt file)
  • h5name (str) – Name of the Hdf5 database file. If it does not exists, it will be newly created
  • mode (str) – Open mode of the Hdf5 database. Default = ‘a’, so data will be appended.
DEMutilities.afmtools.import_afm_data.import_fd_jpk_curve(filename, correct_retract_curve=True)

Imports a jpk processed curve and returns two lists containing the height and the vertical response force as measured by the AFM device.

Parameters:
  • filename (str) – filename of the jpk-formatted file to be read
  • correct_retract_curve (bool) – If True, the last 5.0% of values will be used to ‘correct’ the force profile for drift, ensuring that the force is zero at start and finish.
DEMutilities.afmtools.import_afm_data.import_fd_path_h5(path, h5name, pattern='*.txt', openmode='wa', verbose=True, **kwargs)

Import a complete path containing jpk-processed afm data files and imports them into an Hdf5 file with given name.The file structure of the path is converved in the section lay-out of the Hdf5 file.

Parameters:
  • path (str) – Absolute path, or path relative to the current directory, from which we will import files
  • h5name (str) – Name of the hdf5 file. If it does not exists, it will be automatically created
  • pattern (str) – Pattern to match when looking for jpk data files. Default = ‘*.txt’. If your directory contains other txt files that are not jpk data files, please adjust the pattern so it will match the proper files
  • openmmode (str) – Open mode of the hdf5 file. See h5storage for more information.
  • verbose (bool) – If True, we will print the jpk files that are being imported
DEMutilities.afmtools.import_afm_data.import_jpk_processed_curve(filename)

Reads a jpk processed curve (typically txt file) and returns a list of valid data sections which it contains. Each entry in this list is a section, which is a dictionary that contains the different data arrays, accessible by their names, and - usually - a ‘metadata’ dictionary, which contains all configuration information that was stored in the jpk processed curve for that data sections.

Parameters:filename (str) – Filename of jpk processed curve.
DEMutilities.afmtools.import_afm_data.parse_jpk_section(fob, section_list)

Method to continue reading a jpk data section from a file object and append it to a given list of sections. We continue reading the given file until the end of a valid data section is reached, at which point we return. If we have found no valid end, we stop reading after 100 million lines, and throw an error.

Parameters:
  • fob (file) – File object opened in read-mode
  • section_list (list) – List of sections, in which a new section will be added to