SciFiReaders.readers.microscopy.spm.stm.nanonis_base.Grid

SciFiReaders.readers.microscopy.spm.stm.nanonis_base.Grid#

class SciFiReaders.readers.microscopy.spm.stm.nanonis_base.Grid(fname, header_override=None, data_format=None)[source]#

Bases: NanonisFile

Nanonis grid file class.

Contains data loading method specific to Nanonis grid file. Nanonis 3ds files contain a header terminated by ‘

HEADER_END:

line, after which big endian encoded binary data starts. A grid is always recorded in an ‘up’ direction, and data is recorded sequentially starting from the first pixel. The number of bytes corresponding to a single pixel will depend on the experiment parameters. In general the size of one pixel will be a sum of

  • # fixed parameters

  • # experimental parameters

  • # sweep signal points (typically bias).

Hence if there are 2 fixed parameters, 8 experimental parameters, and a 512 point bias sweep, a pixel will account 4 x (522) = 2088 bytes of data. The class intuits this from header info and extracts the data for you and cuts it up into each channel, though normally this should be just the current.

Currently cannot accept grids that are incomplete.

fnamestr

Filename for grid file.

header_overridedict, optional

A dict of key:value to override any corresponding key:value should they be wrong or missing in your header. Keys in header_override must match keys in Grid.header_raw.

headerdict

Parsed 3ds header. Relevant fields are converted to float, otherwise most are string values.

signalsdict

Dict keys correspond to channel name, with values being the corresponding data array.

UnhandledFileError

If fname does not have a ‘.3ds’ extension.

Methods

read_raw_header

Return header as a raw string.

set_data_format

start_byte

Find first byte after end tag signalling end of header info.

read_raw_header(byte_offset)#

Return header as a raw string.

Everything before the end tag is considered to be part of the header. the parsing will be done later by subclass methods.

Parameters:

byte_offset (int) – Size of header in bytes. Read up to this point in file.

Returns:

Contents of filename up to byte_offset as a decoded binary string.

Return type:

str

start_byte()#

Find first byte after end tag signalling end of header info.

Caveat, I believe this is the first byte after the end of the line that the end tag is found on, not strictly the first byte directly after the end tag is found. For example in Scan __init__, byte_offset is incremented by 4 to account for a ‘start’ byte that is not actual data.

Returns:

Size of header in bytes.

Return type:

int