Quickstart#
A short tour of polartools: load a scan, look at it, fit a peak.
In a hurry, and the data is a directory of *_master.hdf files? Run
scan-viewer in it and everything below is a few clicks instead — see
Scan viewers.
Load a SPEC scan into a DataFrame#
from polartools.load_data import load_table
table = load_table(scan_id=10, source="my_spec_file.dat", folder="/data/2024-1")
table.head()
load_table is the universal entry point — pass it a SPEC file, an HDF5 file,
a CSV folder, a databroker catalog, or a tiled catalog and it returns a pandas
DataFrame with the scan’s data columns.
Plot it#
import matplotlib.pyplot as plt
ax = table.plot(x="Energy", y="IfluorM/I0", marker=".")
ax.set_xlabel("Energy (eV)")
ax.set_ylabel("normalized fluorescence")
Process an XMCD scan#
from polartools.absorption import process_xmcd
xmcd = process_xmcd(
scan_plus=10, # +H scan
scan_minus=11, # -H scan
source="my_spec_file.dat",
folder="/data/2024-1",
monitor="I0",
detector="IfluorM",
transmission=False,
)
xmcd.plot(x="energy", y="xmcd")
Fit a Bragg peak#
from polartools.diffraction import fit_peak
result = fit_peak(
scan_id=42,
source="my_spec_file.dat",
folder="/data/2024-1",
x="th",
y="apd",
monitor="I0",
model="PseudoVoigt",
)
print(result.fit_report())
result.plot()
Where to next#
Load data — every supported source backend, with examples
XAS / XMCD — normalization, dichroism, edge-step
Diffraction — peak fitting, peak series, HKL conversions
Scan viewers —
scan-viewerand the spectrum and image windowsFlyscan dichroism — CR/CL difference maps, in the GUI and scripted
API reference — full function-by-function reference