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
_try_access_metadata(s, name, index)¶
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).
- 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.
Imports a jpk processed curve and returns two lists containing the height and the vertical response force as measured by the AFM device.
- 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.
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.
- 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
h5storagefor more information.
- verbose (bool) – If
True, we will print the jpk files that are being imported
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.
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.
- fob (file) – File object opened in read-mode
- section_list (list) – List of sections, in which a new section will be added to