GWY Modules
For decoding and loading .gwy AFM file format into Python Numpy arrays.
gwy_get_channels(gwy_file_structure)
Extract a list of channels and their corresponding dictionary key ids from the .gwy
file dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gwy_file_structure
|
dict
|
Dictionary of the nested object / component structure of a |
required |
Returns:
Type | Description |
---|---|
dict
|
Dictionary where the keys are the channel names and the values are the dictionary key ids. |
Examples:
Using a loaded dictionary generated from a .gwy
file:
LoadScans._gwy_get_channels(gwy_file_structure=loaded_gwy_file_dictionary)
Source code in AFMReader/gwy.py
gwy_read_component(open_file, initial_byte_pos, data_dict)
Parse and extract data from a .gwy
file object, starting at the current open file read position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
open_file
|
BinaryIO
|
An open file object. |
required |
initial_byte_pos
|
int
|
Initial position, as byte. |
required |
data_dict
|
dict
|
Dictionary of |
required |
Returns:
Type | Description |
---|---|
int
|
Size of the component in bytes. |
Source code in AFMReader/gwy.py
gwy_read_object(open_file, data_dict)
Parse and extract data from a .gwy
file object, starting at the current open file read position.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
open_file
|
BinaryIO
|
An open file object. |
required |
data_dict
|
dict
|
Dictionary of |
required |
Source code in AFMReader/gwy.py
load_gwy(file_path, channel)
Extract image and pixel to nm scaling from the .gwy file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
Path or str
|
Path to the .gwy file. |
required |
channel
|
str
|
Channel name to extract from the .gwy file. |
required |
Returns:
Type | Description |
---|---|
tuple(ndarray, float)
|
A tuple containing the image and its pixel to nanometre scaling value. |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If the file is not found. |
ValueError
|
If the channel is not found in the .gwy file. |
Examples:
Load the image and pixel to nanometre scaling factor, available channels are 'Height', 'ZSensor' and 'Height Sensor'.
>>> from AFMReader.gwy import load_gwy
>>> image, pixel_to_nm = load_gwy(file_path="path/to/file.gwy", channel="Height")
```
Source code in AFMReader/gwy.py
read_gwy_component_dtype(open_file)
Read the data type of a .gwy
file component.
Possible data types are as follows:
- 'b': boolean
- 'c': character
- 'i': 32-bit integer
- 'q': 64-bit integer
- 'd': double
- 's': string
- 'o':
.gwy
format object
Capitalised versions of some of these data types represent arrays of values of that data type. Arrays are stored as an unsigned 32 bit integer, describing the size of the array, followed by the unseparated array values:
- 'C': array of characters
- 'I': array of 32-bit integers
- 'Q': array of 64-bit integers
- 'D': array of doubles
- 'S': array of strings
- 'O': array of objects.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
open_file
|
BinaryIO
|
An open file object. |
required |
Returns:
Type | Description |
---|---|
str
|
Python string (one character long) of the data type of the component's value. |