experiment
Modules:
| Name | Description |
|---|---|
experiment |
|
Classes:
| Name | Description |
|---|---|
Experiment |
Holds data from an experiment as a sc.DataArray along with metadata. |
Classes
Experiment(display_name='MyExperiment', unique_name=None, data=None)
Holds data from an experiment as a sc.DataArray along with metadata.
This is a minimal implementation that will be extended in the future.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str | None
|
Display name of the experiment. |
'MyExperiment'
|
unique_name
|
str | None
|
Unique name of the experiment. If None, a unique name will be generated. None. |
None
|
data
|
sc.DataArray | str | None
|
Dataset associated with the experiment. Can be a sc.DataArray or a filename string to load from. If None, no data is loaded. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data is not a sc.DataArray, a string, or None. |
Methods:
| Name | Description |
|---|---|
to_dict |
Convert an EasyScience object into a full dictionary using |
from_dict |
Re-create an EasyScience object from a full encoded |
__dir__ |
This creates auto-completion and helps out in iPython |
get_masked_energy |
Get the energy values from the dataset, removing points where the y values or variances are |
load_hdf5 |
Load data from an HDF5 file. |
save_hdf5 |
Save the dataset to HDF5. |
remove_data |
Remove the dataset from the experiment. |
rebin |
Rebin the dataset along specified dimensions. |
plot_data |
Plot the dataset using plopp: https://scipp.github.io/plopp/. |
__repr__ |
Return a string representation of the Experiment object. |
__copy__ |
Return a copy of the object. |
Attributes:
| Name | Type | Description |
|---|---|---|
unique_name |
str
|
Get the unique name of the object. |
display_name |
str
|
Get a pretty display name. |
name |
str
|
Get the name of the model. |
data |
sc.DataArray | None
|
Get the dataset associated with this experiment. |
binned_data |
sc.DataArray | None
|
Get the binned dataset associated with this experiment. |
Q |
sc.Variable | None
|
Get the Q values from the dataset. |
energy |
sc.Variable | None
|
Get the energy values from the dataset. |
Attributes
unique_name
property
writable
Get the unique name of the object.
display_name
property
writable
Get a pretty display name.
:return: The pretty display name.
name
property
writable
Get the name of the model.
Returns:
| Type | Description |
|---|---|
str
|
The name of the model. |
data
property
writable
Get the dataset associated with this experiment.
Returns:
| Type | Description |
|---|---|
sc.DataArray | None
|
The dataset associated with this experiment, or None if no data is loaded. |
binned_data
property
writable
Get the binned dataset associated with this experiment.
Returns:
| Type | Description |
|---|---|
sc.DataArray | None
|
The binned dataset associated with this experiment, or None if no data is loaded. |
Q
property
writable
Get the Q values from the dataset.
Returns:
| Type | Description |
|---|---|
sc.Variable | None
|
The Q values from the dataset, or None if no data is loaded. |
energy
property
writable
Get the energy values from the dataset.
Returns:
| Type | Description |
|---|---|
sc.Variable | None
|
The energy values from the dataset, or None if no data is loaded. |
Functions
to_dict(skip=None)
Convert an EasyScience object into a full dictionary using
SerializerBases generic convert_to_dict method.
:param skip: List of field names as strings to skip when forming the dictionary :return: encoded object containing all information to reform an EasyScience object.
from_dict(obj_dict)
classmethod
Re-create an EasyScience object from a full encoded dictionary.
:param obj_dict: dictionary containing the serialized contents (from SerializerDict) of an EasyScience object
:return: Reformed EasyScience object
__dir__()
This creates auto-completion and helps out in iPython notebooks.
:return: list of function and parameter names for auto- completion
get_masked_energy(Q_index)
Get the energy values from the dataset, removing points where the y values or variances are NaN or Inf for the given Q index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int
|
The Q index to get the masked energy values for. |
required |
Raises:
| Type | Description |
|---|---|
IndexError
|
If Q_index is not a valid index for the Q values. |
Returns:
| Type | Description |
|---|---|
sc.Variable | None
|
The masked energy values from the dataset, or None if no data is loaded. |
load_hdf5(filename, display_name=None)
Load data from an HDF5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the HDF5 file. |
required |
display_name
|
str | None
|
Optional display name for the experiment. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If filename is not a string or if display_name is not a string or None or if the loaded data is not a sc.DataArray. |
save_hdf5(filename=None)
Save the dataset to HDF5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | None
|
Path to the output HDF5 file. If None, the file will be named after the unique_name of the experiment with a .h5 extension. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If filename is not a string or None. |
ValueError
|
If there is no data to save. |
remove_data()
Remove the dataset from the experiment.
rebin(dimensions)
Rebin the dataset along specified dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimensions
|
dict[str, int | sc.Variable]
|
A dictionary mapping dimension names to number of bins (int) or bin edges (sc.Variable). |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If dimensions is not a dictionary or if keys/values are of incorrect types. |
ValueError
|
If there is no data to rebin. |
KeyError
|
If a specified dimension is not in the dataset. |
plot_data(slicer=False, transpose_axes=False, **kwargs)
Plot the dataset using plopp: https://scipp.github.io/plopp/.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
bool
|
If True, use plopp's slicer instead of plot. |
False
|
transpose_axes
|
bool
|
If True, transpose the data to have dimensions in the order (energy, Q) before plotting, so that energy is on the x-axis. This only applies when slicer=False. |
False
|
**kwargs
|
dict
|
Additional keyword arguments to pass to plopp. |
{}
|
Returns:
| Type | Description |
|---|---|
InteractiveFigure
|
A plot of the data and model. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no data to plot. |
RuntimeError
|
If not in a Jupyter notebook environment. |
TypeError
|
If slicer or transpose_axes are not True or False. |
__repr__()
Return a string representation of the Experiment object.
Returns:
| Type | Description |
|---|---|
str
|
A string representation of the Experiment object. |
__copy__()
Modules
experiment
Classes:
| Name | Description |
|---|---|
Experiment |
Holds data from an experiment as a sc.DataArray along with metadata. |
Classes
Experiment(display_name='MyExperiment', unique_name=None, data=None)
Holds data from an experiment as a sc.DataArray along with metadata.
This is a minimal implementation that will be extended in the future.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
display_name
|
str | None
|
Display name of the experiment. |
'MyExperiment'
|
unique_name
|
str | None
|
Unique name of the experiment. If None, a unique name will be generated. None. |
None
|
data
|
sc.DataArray | str | None
|
Dataset associated with the experiment. Can be a sc.DataArray or a filename string to load from. If None, no data is loaded. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If data is not a sc.DataArray, a string, or None. |
Methods:
| Name | Description |
|---|---|
get_masked_energy |
Get the energy values from the dataset, removing points where the y values or variances are |
load_hdf5 |
Load data from an HDF5 file. |
save_hdf5 |
Save the dataset to HDF5. |
remove_data |
Remove the dataset from the experiment. |
rebin |
Rebin the dataset along specified dimensions. |
plot_data |
Plot the dataset using plopp: https://scipp.github.io/plopp/. |
__repr__ |
Return a string representation of the Experiment object. |
__copy__ |
Return a copy of the object. |
to_dict |
Convert an EasyScience object into a full dictionary using |
from_dict |
Re-create an EasyScience object from a full encoded |
__dir__ |
This creates auto-completion and helps out in iPython |
Attributes:
| Name | Type | Description |
|---|---|---|
data |
sc.DataArray | None
|
Get the dataset associated with this experiment. |
binned_data |
sc.DataArray | None
|
Get the binned dataset associated with this experiment. |
Q |
sc.Variable | None
|
Get the Q values from the dataset. |
energy |
sc.Variable | None
|
Get the energy values from the dataset. |
unique_name |
str
|
Get the unique name of the object. |
display_name |
str
|
Get a pretty display name. |
name |
str
|
Get the name of the model. |
Attributes
data
property
writable
Get the dataset associated with this experiment.
Returns:
| Type | Description |
|---|---|
sc.DataArray | None
|
The dataset associated with this experiment, or None if no data is loaded. |
binned_data
property
writable
Get the binned dataset associated with this experiment.
Returns:
| Type | Description |
|---|---|
sc.DataArray | None
|
The binned dataset associated with this experiment, or None if no data is loaded. |
Q
property
writable
Get the Q values from the dataset.
Returns:
| Type | Description |
|---|---|
sc.Variable | None
|
The Q values from the dataset, or None if no data is loaded. |
energy
property
writable
Get the energy values from the dataset.
Returns:
| Type | Description |
|---|---|
sc.Variable | None
|
The energy values from the dataset, or None if no data is loaded. |
unique_name
property
writable
Get the unique name of the object.
display_name
property
writable
Get a pretty display name.
:return: The pretty display name.
name
property
writable
Get the name of the model.
Returns:
| Type | Description |
|---|---|
str
|
The name of the model. |
Functions
get_masked_energy(Q_index)
Get the energy values from the dataset, removing points where the y values or variances are NaN or Inf for the given Q index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
Q_index
|
int
|
The Q index to get the masked energy values for. |
required |
Raises:
| Type | Description |
|---|---|
IndexError
|
If Q_index is not a valid index for the Q values. |
Returns:
| Type | Description |
|---|---|
sc.Variable | None
|
The masked energy values from the dataset, or None if no data is loaded. |
load_hdf5(filename, display_name=None)
Load data from an HDF5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the HDF5 file. |
required |
display_name
|
str | None
|
Optional display name for the experiment. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If filename is not a string or if display_name is not a string or None or if the loaded data is not a sc.DataArray. |
save_hdf5(filename=None)
Save the dataset to HDF5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str | None
|
Path to the output HDF5 file. If None, the file will be named after the unique_name of the experiment with a .h5 extension. |
None
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If filename is not a string or None. |
ValueError
|
If there is no data to save. |
remove_data()
Remove the dataset from the experiment.
rebin(dimensions)
Rebin the dataset along specified dimensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimensions
|
dict[str, int | sc.Variable]
|
A dictionary mapping dimension names to number of bins (int) or bin edges (sc.Variable). |
required |
Raises:
| Type | Description |
|---|---|
TypeError
|
If dimensions is not a dictionary or if keys/values are of incorrect types. |
ValueError
|
If there is no data to rebin. |
KeyError
|
If a specified dimension is not in the dataset. |
plot_data(slicer=False, transpose_axes=False, **kwargs)
Plot the dataset using plopp: https://scipp.github.io/plopp/.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
slicer
|
bool
|
If True, use plopp's slicer instead of plot. |
False
|
transpose_axes
|
bool
|
If True, transpose the data to have dimensions in the order (energy, Q) before plotting, so that energy is on the x-axis. This only applies when slicer=False. |
False
|
**kwargs
|
dict
|
Additional keyword arguments to pass to plopp. |
{}
|
Returns:
| Type | Description |
|---|---|
InteractiveFigure
|
A plot of the data and model. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If there is no data to plot. |
RuntimeError
|
If not in a Jupyter notebook environment. |
TypeError
|
If slicer or transpose_axes are not True or False. |
__repr__()
Return a string representation of the Experiment object.
Returns:
| Type | Description |
|---|---|
str
|
A string representation of the Experiment object. |
__copy__()
to_dict(skip=None)
Convert an EasyScience object into a full dictionary using
SerializerBases generic convert_to_dict method.
:param skip: List of field names as strings to skip when forming the dictionary :return: encoded object containing all information to reform an EasyScience object.
from_dict(obj_dict)
classmethod
Re-create an EasyScience object from a full encoded dictionary.
:param obj_dict: dictionary containing the serialized contents (from SerializerDict) of an EasyScience object
:return: Reformed EasyScience object
__dir__()
This creates auto-completion and helps out in iPython notebooks.
:return: list of function and parameter names for auto- completion