Quickstart#

This guide will get you started with daxs in just a few minutes.

Create a Source of Scans#

from daxs.sources import Hdf5Source

# Define the mapping of data fields in the HDF5 file.
data_mappings = {
    "x": ".1/measurement/hdh_energy",
    "signal": ".1/measurement/det_dtc",
    "monitor": ".1/measurement/I02",
}

# Define which scans to load.
selection = "1-3"

# Create the source of scans.
source = Hdf5Source("sample_0001.h5", selection, data_mappings)

# List available scans.
print(f"Available scans: {source.scans}")

Create a Measurement#

from daxs import Xas

# Create a measurement from scan source.
measurement = Xas(source)

# Access individual scans.
for scan in measurement.scans:
    print(f"Scan index: {scan.index}, X-axis: {scan.x}")

Process the Data#

# Remove signal outliers using the Hampel filter method.
measurement.remove_outliers(method="hampel")

# Aggregate scans using fraction of the sum of signals over the sum of monitors.
# Normalize the aggregated signal by the area under the curve.
measurement.process(aggregation="fraction of sums", normalization="area")

Visualise the Results#

import matplotlib.pyplot as plt

fig, ax = plt.subplots()

# Plot on the provided axes.
measurement.plot(ax=ax)

# Customize the plot as needed.
ax.set_title("Sample")
plt.show()