Python package to read .sm4 files
Project description
sm4file
sm4file is Python library for reading RHK .sm4 files.
Installing
Installation via pip:
pip install sm4file
Example Usage
from sm4file import Sm4
sm4 = Sm4("path/to/sm4-file")
This return a list of all acquired measurement channels. Metadata can be accessed as properties on a channel. For example to print the bias voltage for all channels:
for channel in sm4:
print(channel.bias)
The measurement's numerical data is stored in the data
property on each
channel. For images this is a two dimensional numpy array. For lines / spectra
it is a (n, m) where n is the number of acquired data points and m is the
number of spectra + 1.
The array's first column contains the x-values and all subsequent ones the
corresponding y-values.
Plot images from all channels
import matplotlib.pyplot as plt
for channel in sm4:
plt.imshow(channel.data)
plt.title(f"{channel.label} - {channel.scan_direction}")
plt.show()
Plot all spectra, e.g. IV
for channel in sm4:
for i in range(1, len(channel.data[0])):
plt.plot(channel.data[:, 0], channel.data[:, i], label=f"{i}")
plt.title(channel.label)
plt.legend()
plt.show()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file sm4file-0.1.0.tar.gz
.
File metadata
- Download URL: sm4file-0.1.0.tar.gz
- Upload date:
- Size: 13.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e774b7589684c8a9f28f1fde150ef43fea6b694eabd5f9d348e541025efd82c |
|
MD5 | 9a9c66f3a516f58be1301902bb6c27ce |
|
BLAKE2b-256 | a1785bfee384be588ee58d661c7a07b6ac5ffa6123e5d1b34534f83810416a46 |
File details
Details for the file sm4file-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: sm4file-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.12.5 Darwin/23.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e44f4dba36bc51ee2d3366484c1f2b26e3a056da14f38717cef22b015da51fbc |
|
MD5 | f27563fda884d20e38e75d9f3b9eed9c |
|
BLAKE2b-256 | 05f164fede2b50ed3f1b68abf81b3b9d5f0a48f04769f1928f43858a7f56e7bf |