Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sm4file-0.1.0.tar.gz (13.7 kB view hashes)

Uploaded Source

Built Distribution

sm4file-0.1.0-py3-none-any.whl (14.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page