Experiment¶
The experimental data is stored in an Experiment class. Underneath we use Scipp and Plopp to handle and plot the data. We here show how to load an example data set, rebin it and plot it in various ways.
In [1]:
Copied!
import pooch
import easydynamics as edyn
%matplotlib widget
import pooch
import easydynamics as edyn
%matplotlib widget
In [2]:
Copied!
# Load and plot example vanadium data
# Load the vanadium data
vanadium_experiment = edyn.Experiment('Vanadium')
file_path = pooch.retrieve(
url='https://github.com/easyscience/dynamics-lib/raw/refs/heads/master/docs/docs/tutorials/data/vanadium_data_example.h5',
known_hash='16cc1b327c303feeb88fb9dda5390dc4880b62396b1793f98c6fef0b27c7b873',
)
vanadium_experiment.load_hdf5(filename=file_path)
vanadium_experiment.plot_data()
# Load and plot example vanadium data
# Load the vanadium data
vanadium_experiment = edyn.Experiment('Vanadium')
file_path = pooch.retrieve(
url='https://github.com/easyscience/dynamics-lib/raw/refs/heads/master/docs/docs/tutorials/data/vanadium_data_example.h5',
known_hash='16cc1b327c303feeb88fb9dda5390dc4880b62396b1793f98c6fef0b27c7b873',
)
vanadium_experiment.load_hdf5(filename=file_path)
vanadium_experiment.plot_data()
Out[2]:
In [3]:
Copied!
# Rebin the data and plot again
vanadium_experiment.rebin({'Q': 5, 'energy': 50})
vanadium_experiment.plot_data()
# Rebin the data and plot again
vanadium_experiment.rebin({'Q': 5, 'energy': 50})
vanadium_experiment.plot_data()
Out[3]:
In [4]:
Copied!
# Plot using the plopp slicer with extra arguments
vanadium_experiment.plot_data(slicer=True, keep='energy', vmin=0, vmax=2.0)
# Plot using the plopp slicer with extra arguments
vanadium_experiment.plot_data(slicer=True, keep='energy', vmin=0, vmax=2.0)
Out[4]:
Comparing Q slices¶
To compare spectra at different Q, use superplot=True. It works like the slicer, but the save tool on the right keeps the current line on the figure, so you can keep one or more Q values in different colours while sliding on to others. Setting normalize=True divides each spectrum by its sum over energy, which makes the line shapes easy to compare. It only affects the plot, not the data.
In [5]:
Copied!
# Compare normalized spectra at different Q
vanadium_experiment.plot_data(superplot=True, normalize=True)
# Compare normalized spectra at different Q
vanadium_experiment.plot_data(superplot=True, normalize=True)
Out[5]: