playnano.io.formats.read_h5jpk module¶
Load JPK .h5-jpk high-speed AFM files as an AFMImageStack.
All frames are read from one HDF5 file. Channels with a length unit (for example
m) are converted to nm; see apply_z_unit_conversion().
- playnano.io.formats.read_h5jpk.apply_z_unit_conversion(images: ndarray, channel_group: Group, channel: str = 'height_trace') ndarray[source]¶
Convert a channel’s values to nm if it has a length unit.
- Parameters:
images (numpy.ndarray) – Channel values, already z-scaled.
channel_group (h5py.Group) – The channel’s group, whose attributes give the unit.
channel (str, optional) – Channel name, used only in log messages. Default is
"height_trace".
- Returns:
The values in nm if the unit is a length; unchanged if it is
"V","v"or"deg". If the unit is missing or not recognised, it is guessed from the range of the data, falling back to nm.- Return type:
- playnano.io.formats.read_h5jpk.load_h5jpk(file_path: Path | str, channel: str, flip_image: bool = True) AFMImageStack[source]¶
Load a JPK
.h5-jpkfile.Each frame is reshaped from the channel’s data, z-scaled and converted to nm (see
apply_z_unit_conversion()). Frame times come from the file’s start and end time records; if they are missing, they are worked out from the scan rate, allowing for interlaced (bidirectional) scanning.- Parameters:
file_path (str or pathlib.Path) – The
.h5-jpkfile.channel (str) – Channel to load, for example
"height_trace","measuredheight_trace","amplitude_retrace"or"phase_trace": the channel name in lower case,_, thentraceorretrace.flip_image (bool, optional) – Flip each frame vertically. Default is True.
- Returns:
The stack. Each
frame_metadataentry holdstimestamp(s from the first frame),frame_pixel_size_nm,line_rate,frame_duration_s,start_epoch_msandscan_direction.stack.acquisition["bidirectional"]records whether the scan was interlaced.- Return type:
- Raises:
ValueError – If the channel is not in the file.
Notes
Pixel size, interlacing and scan direction are set per measurement, so they are the same for every frame. Only the first measurement in the file is read; a warning is logged if there are more.