Usage¶
After installation you can import spym simply with:
import spym
Now the spym
accessor will be available to xarray objects.
For example to apply the plane() function to an xarray DataArray:
dr = xarray.DataArray()
dr.spym.plane()
Examples¶
The spym package is best integrated with xarray objects. Here is a typical usage for scanning tunneling microscopy data loaded into an xarray Dataset:
# Import the package
import spym
# Load the file and show the content
f = spym.load("/path/to/a/supported/file")
f
# Select the channel of interest (e.g. Topography_Forward) and show its content
tf = f.Topography_Forward
tf
# Align the rows
tf.spym.align()
# Make plane on the image
tf.spym.plane()
# Fix the minimum to zero
tf.spym.fixzero()
# Plot the image
tf.spym.plot()
Many of the spym
functions are also applicable directly to numpy arrays:
from spym.level import align
aligned, background = align(my_array, baseline='median')
The documentation of each spym
method can be accessed with the ?
syntax:
dr.spym.plane?
See the API Reference section for a list of all the methods available.