daxs.measurements: Measurements#
The module provides classes to deal with different types of measurements.
- class daxs.measurements.Measurement(sources: Source | list[Source])[source]#
Bases:
objectBase class for measurements.
- __init__(sources: Source | list[Source])[source]#
Initialize the measurement.
- Parameters:
sources – Sources of scans.
- property x: ndarray[tuple[int, ...], dtype[float64]]#
- property signal: ndarray[tuple[int, ...], dtype[float64]]#
- property monitor: ndarray[tuple[int, ...], dtype[float64]]#
- abstract plot(axes: Any | None = None, **kwargs: Any) Any[source]#
Plot the measurement signal.
- Parameters:
axes – Matplotlib axes where to plot the signal.
**kwargs – Additional arguments passed to the plot function.
- Returns:
The matplotlib axes where the signal was plotted.
- abstract save(filename: str, delimiter: str = ',') None[source]#
Save the current measurement data to a file.
- Parameters:
filename – Name of the output file.
delimiter – Column delimiter in the output file.
- add_source(source: Source) None[source]#
Add a new source to the measurement.
- Parameters:
source – Source to be added.
- remove_source(index: int) None[source]#
Remove a source from the measurement.
- Parameters:
index – Index of the source to be removed.
- add_scans(scans: Scan | list[Scan]) None[source]#
Add scans to the measurement.
- Parameters:
scans – Scans to be added.
- remove_scans(indices: int | list[int], filename: str | None = None) None[source]#
Remove scans from the measurement.
- Parameters:
indices – Indices of the scans to be removed.
filename – Name of the file from which the scans where read.
- find_outliers(method: str = 'hampel', **kwargs: Any)[source]#
Find outliers in the data.
Note
See the docstring of
scans.Scan.find_outliers()for details.
- remove_outliers(method: str = 'hampel', **kwargs: Any)[source]#
Remove outliers from the signal.
Note
See the docstring of
scans.Scan.remove_outliers()for details.
- dead_time_correction(tau: Iterable[float], detection_time: float | ndarray[tuple[int, ...], dtype[float64]] | None = None)[source]#
Perform a dead time correction using a non-paralyzable model.
- Parameters:
tau – Dead time value(s).
detection_time – Detection time value(s).
Note
See the docstring of
scans.Scan.dead_time_correction()for details.
- concentration_correction(indices: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None, data_mappings: dict[str, str] | None = None, scans: Scan | list[Scan] | Scans | None = None) None[source]#
Apply the concentration correction using data from the specified scans.
- Parameters:
indices – Indices of the scans used for concentration correction.
data_mappings – Data mappings for the concentration correction scans.
scans – Scans used for concentration corrections.
- Raises:
ValueError – If neither indices nor scans are specified.
- class daxs.measurements.Measurement1D(sources: Source | list[Source])[source]#
Bases:
MeasurementBase class for 1D measurements.
- property x#
- process(aggregation: str = 'fraction of sums', normalization: str | None = None)[source]#
Process the scans data.
- Parameters:
aggregation – Method to use for aggregating data.
normalization – Method to use for normalizing the signal.
Note
The processing includes aggregating the data of the selected scans and normalizing the signal.
- aggregate(mode: str = 'fraction of sums')[source]#
Aggregate the scans signal using the selected mode.
- Parameters:
mode –
Defines how the signal is aggregated.
”fraction of sums”: fraction of the signals sum and monitors sum
”mean of fractions”, mean of the signal and monitor fractions
- Raises:
ValueError – If the aggregation mode is unknown.
Note
When present, the aggregated monitor is always a mean of the monitors from the individual scans.
- normalize(mode: str = 'area') None[source]#
Normalize the signal.
- Parameters:
mode –
Defines how the signal is normalized.
”area”: Normalize using the absolute signal area calculated using the trapezoidal rule.
”maximum”: Normalize using the absolute maximum intensity of the signal.
- Raises:
ValueError – If the normalization mode is unknown.
Note
This will overwrite the original signal with the normalized one.
- plot(axes: Axes | None = None, **kwargs: Any) Axes[source]#
Plot the measurement signal.
- Parameters:
axes – Matplotlib axes where to plot the signal.
**kwargs – Additional arguments passed to the plot function.
- Returns:
The matplotlib axes where the signal was plotted.
- Raises:
ValueError – If the signal is not defined.
- save(filename: str, delimiter: str = ',') None[source]#
Save the current measurement data to a file.
- Parameters:
filename – Name of the output file.
delimiter – Column delimiter in the output file.
- Raises:
ValueError – If the signal is not defined.
- __init__(sources: Source | list[Source])#
Initialize the measurement.
- Parameters:
sources – Sources of scans.
- add_scans(scans: Scan | list[Scan]) None#
Add scans to the measurement.
- Parameters:
scans – Scans to be added.
- add_source(source: Source) None#
Add a new source to the measurement.
- Parameters:
source – Source to be added.
- concentration_correction(indices: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None, data_mappings: dict[str, str] | None = None, scans: Scan | list[Scan] | Scans | None = None) None#
Apply the concentration correction using data from the specified scans.
- Parameters:
indices – Indices of the scans used for concentration correction.
data_mappings – Data mappings for the concentration correction scans.
scans – Scans used for concentration corrections.
- Raises:
ValueError – If neither indices nor scans are specified.
- dead_time_correction(tau: Iterable[float], detection_time: float | ndarray[tuple[int, ...], dtype[float64]] | None = None)#
Perform a dead time correction using a non-paralyzable model.
- Parameters:
tau – Dead time value(s).
detection_time – Detection time value(s).
Note
See the docstring of
scans.Scan.dead_time_correction()for details.
- find_outliers(method: str = 'hampel', **kwargs: Any)#
Find outliers in the data.
Note
See the docstring of
scans.Scan.find_outliers()for details.
- property monitor: ndarray[tuple[int, ...], dtype[float64]]#
- remove_outliers(method: str = 'hampel', **kwargs: Any)#
Remove outliers from the signal.
Note
See the docstring of
scans.Scan.remove_outliers()for details.
- remove_scans(indices: int | list[int], filename: str | None = None) None#
Remove scans from the measurement.
- Parameters:
indices – Indices of the scans to be removed.
filename – Name of the file from which the scans where read.
- remove_source(index: int) None#
Remove a source from the measurement.
- Parameters:
index – Index of the source to be removed.
- reset(scans: float = True)#
Reset the measurement.
- property signal: ndarray[tuple[int, ...], dtype[float64]]#
- class daxs.measurements.Xas(sources: Source | list[Source])[source]#
Bases:
Measurement1DClass to represent a X-ray absorption measurement.
- __init__(sources: Source | list[Source])#
Initialize the measurement.
- Parameters:
sources – Sources of scans.
- add_scans(scans: Scan | list[Scan]) None#
Add scans to the measurement.
- Parameters:
scans – Scans to be added.
- add_source(source: Source) None#
Add a new source to the measurement.
- Parameters:
source – Source to be added.
- aggregate(mode: str = 'fraction of sums')#
Aggregate the scans signal using the selected mode.
- Parameters:
mode –
Defines how the signal is aggregated.
”fraction of sums”: fraction of the signals sum and monitors sum
”mean of fractions”, mean of the signal and monitor fractions
- Raises:
ValueError – If the aggregation mode is unknown.
Note
When present, the aggregated monitor is always a mean of the monitors from the individual scans.
- concentration_correction(indices: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None, data_mappings: dict[str, str] | None = None, scans: Scan | list[Scan] | Scans | None = None) None#
Apply the concentration correction using data from the specified scans.
- Parameters:
indices – Indices of the scans used for concentration correction.
data_mappings – Data mappings for the concentration correction scans.
scans – Scans used for concentration corrections.
- Raises:
ValueError – If neither indices nor scans are specified.
- dead_time_correction(tau: Iterable[float], detection_time: float | ndarray[tuple[int, ...], dtype[float64]] | None = None)#
Perform a dead time correction using a non-paralyzable model.
- Parameters:
tau – Dead time value(s).
detection_time – Detection time value(s).
Note
See the docstring of
scans.Scan.dead_time_correction()for details.
- find_outliers(method: str = 'hampel', **kwargs: Any)#
Find outliers in the data.
Note
See the docstring of
scans.Scan.find_outliers()for details.
- property monitor: ndarray[tuple[int, ...], dtype[float64]]#
- normalize(mode: str = 'area') None#
Normalize the signal.
- Parameters:
mode –
Defines how the signal is normalized.
”area”: Normalize using the absolute signal area calculated using the trapezoidal rule.
”maximum”: Normalize using the absolute maximum intensity of the signal.
- Raises:
ValueError – If the normalization mode is unknown.
Note
This will overwrite the original signal with the normalized one.
- plot(axes: Axes | None = None, **kwargs: Any) Axes#
Plot the measurement signal.
- Parameters:
axes – Matplotlib axes where to plot the signal.
**kwargs – Additional arguments passed to the plot function.
- Returns:
The matplotlib axes where the signal was plotted.
- Raises:
ValueError – If the signal is not defined.
- process(aggregation: str = 'fraction of sums', normalization: str | None = None)#
Process the scans data.
- Parameters:
aggregation – Method to use for aggregating data.
normalization – Method to use for normalizing the signal.
Note
The processing includes aggregating the data of the selected scans and normalizing the signal.
- remove_outliers(method: str = 'hampel', **kwargs: Any)#
Remove outliers from the signal.
Note
See the docstring of
scans.Scan.remove_outliers()for details.
- remove_scans(indices: int | list[int], filename: str | None = None) None#
Remove scans from the measurement.
- Parameters:
indices – Indices of the scans to be removed.
filename – Name of the file from which the scans where read.
- remove_source(index: int) None#
Remove a source from the measurement.
- Parameters:
index – Index of the source to be removed.
- reset(scans: float = True)#
Reset the measurement.
- save(filename: str, delimiter: str = ',') None#
Save the current measurement data to a file.
- Parameters:
filename – Name of the output file.
delimiter – Column delimiter in the output file.
- Raises:
ValueError – If the signal is not defined.
- property signal: ndarray[tuple[int, ...], dtype[float64]]#
- property x#
- class daxs.measurements.Xes(sources: Source | list[Source])[source]#
Bases:
Measurement1DClass to represent a X-ray emission measurement.
- __init__(sources: Source | list[Source])#
Initialize the measurement.
- Parameters:
sources – Sources of scans.
- add_scans(scans: Scan | list[Scan]) None#
Add scans to the measurement.
- Parameters:
scans – Scans to be added.
- add_source(source: Source) None#
Add a new source to the measurement.
- Parameters:
source – Source to be added.
- aggregate(mode: str = 'fraction of sums')#
Aggregate the scans signal using the selected mode.
- Parameters:
mode –
Defines how the signal is aggregated.
”fraction of sums”: fraction of the signals sum and monitors sum
”mean of fractions”, mean of the signal and monitor fractions
- Raises:
ValueError – If the aggregation mode is unknown.
Note
When present, the aggregated monitor is always a mean of the monitors from the individual scans.
- concentration_correction(indices: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None, data_mappings: dict[str, str] | None = None, scans: Scan | list[Scan] | Scans | None = None) None#
Apply the concentration correction using data from the specified scans.
- Parameters:
indices – Indices of the scans used for concentration correction.
data_mappings – Data mappings for the concentration correction scans.
scans – Scans used for concentration corrections.
- Raises:
ValueError – If neither indices nor scans are specified.
- dead_time_correction(tau: Iterable[float], detection_time: float | ndarray[tuple[int, ...], dtype[float64]] | None = None)#
Perform a dead time correction using a non-paralyzable model.
- Parameters:
tau – Dead time value(s).
detection_time – Detection time value(s).
Note
See the docstring of
scans.Scan.dead_time_correction()for details.
- find_outliers(method: str = 'hampel', **kwargs: Any)#
Find outliers in the data.
Note
See the docstring of
scans.Scan.find_outliers()for details.
- property monitor: ndarray[tuple[int, ...], dtype[float64]]#
- normalize(mode: str = 'area') None#
Normalize the signal.
- Parameters:
mode –
Defines how the signal is normalized.
”area”: Normalize using the absolute signal area calculated using the trapezoidal rule.
”maximum”: Normalize using the absolute maximum intensity of the signal.
- Raises:
ValueError – If the normalization mode is unknown.
Note
This will overwrite the original signal with the normalized one.
- plot(axes: Axes | None = None, **kwargs: Any) Axes#
Plot the measurement signal.
- Parameters:
axes – Matplotlib axes where to plot the signal.
**kwargs – Additional arguments passed to the plot function.
- Returns:
The matplotlib axes where the signal was plotted.
- Raises:
ValueError – If the signal is not defined.
- process(aggregation: str = 'fraction of sums', normalization: str | None = None)#
Process the scans data.
- Parameters:
aggregation – Method to use for aggregating data.
normalization – Method to use for normalizing the signal.
Note
The processing includes aggregating the data of the selected scans and normalizing the signal.
- remove_outliers(method: str = 'hampel', **kwargs: Any)#
Remove outliers from the signal.
Note
See the docstring of
scans.Scan.remove_outliers()for details.
- remove_scans(indices: int | list[int], filename: str | None = None) None#
Remove scans from the measurement.
- Parameters:
indices – Indices of the scans to be removed.
filename – Name of the file from which the scans where read.
- remove_source(index: int) None#
Remove a source from the measurement.
- Parameters:
index – Index of the source to be removed.
- reset(scans: float = True)#
Reset the measurement.
- save(filename: str, delimiter: str = ',') None#
Save the current measurement data to a file.
- Parameters:
filename – Name of the output file.
delimiter – Column delimiter in the output file.
- Raises:
ValueError – If the signal is not defined.
- property signal: ndarray[tuple[int, ...], dtype[float64]]#
- property x#
- class daxs.measurements.Measurement2D(sources: Source | list[Source])[source]#
Bases:
MeasurementBase class for 2D measurements.
- __init__(sources: Source | list[Source])[source]#
Initialize the measurement.
- Parameters:
sources – Sources of scans.
- property y#
- property shape: tuple[int, int]#
Shape of the current plane.
- property interpolator#
The interpolator of the current plane.
- concentration_correction(indices: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None, data_mappings: dict[str, str] | None = None, scans: Scan | list[Scan] | Scans | None = None) None[source]#
Apply the concentration correction using data from the specified scans.
- Parameters:
indices – Indices of the scans used for concentration correction.
data_mappings – Data mappings for the concentration correction scans.
scans – Scans used for concentration corrections.
- Raises:
ValueError – If neither indices nor scans are specified.
- interpolate(xi: ndarray[tuple[int, ...], dtype[float64]], yi: ndarray[tuple[int, ...], dtype[float64]], /)[source]#
Interpolate the plane using the new axes.
A regular grid defined by the new axes is used to interpolate the signal. The current x, y, and shape are also updated with the new values.
- Parameters:
xi – The new X-axis.
yi – The new Y-axis.
- cut(mode: str = 'CEE', energies: list[float] | None = None, widths: float | list[float] | None = None, nbins: int | list[int] | None | list[None] = None)[source]#
Calculate the cuts specified by the mode and energies.
- Parameters:
mode –
Defines the way to cut the plane:
”CEE” - constant emission energy
”CIE” - constant incident energy
”CET” - constant energy transfer
energies – List of energy values at which to extract cuts. Units should match the data axes.
widths – Widths of the energy window for each cut, centered at the specified energy. If None, if defaults to the approximate distance between the points along the relevant axis. Units should match the data axes.
nbins – Number of bins used to histogram the cut data. Using too many bins may result in empty bins with NaN values.
- Returns:
Dictionary with the cuts. Each entry has the form “{mode}@{energy}”: (centers, signal, mask), where centers are the centers of the bins, signal is the signal of the cut, and mask is a boolean array indicating which data points were included in the cut.
- Raises:
ValueError – If the energies parameter is not defined or if the mode is unknown.
- plot(axes: ndarray[tuple[int, ...], dtype[Any]] | None = None, **kwargs: Any) ndarray[tuple[int, ...], dtype[Any]][source]#
Plot the measurement signal.
- Parameters:
axes – Matplotlib axes where to plot the signal.
**kwargs – Additional arguments passed to the plot function.
- Returns:
The matplotlib axes where the signal was plotted.
- Raises:
ValueError – If the signal is not defined or if the axes are not provided or have an incorrect number of elements.
- save(filename: str, delimiter: str = ',') None[source]#
Save the current measurement data to a file.
- Parameters:
filename – Name of the output file.
delimiter – Column delimiter in the output file.
- Raises:
ValueError – If the signal is not defined.
- add_scans(scans: Scan | list[Scan]) None#
Add scans to the measurement.
- Parameters:
scans – Scans to be added.
- add_source(source: Source) None#
Add a new source to the measurement.
- Parameters:
source – Source to be added.
- dead_time_correction(tau: Iterable[float], detection_time: float | ndarray[tuple[int, ...], dtype[float64]] | None = None)#
Perform a dead time correction using a non-paralyzable model.
- Parameters:
tau – Dead time value(s).
detection_time – Detection time value(s).
Note
See the docstring of
scans.Scan.dead_time_correction()for details.
- find_outliers(method: str = 'hampel', **kwargs: Any)#
Find outliers in the data.
Note
See the docstring of
scans.Scan.find_outliers()for details.
- property monitor: ndarray[tuple[int, ...], dtype[float64]]#
- abstract process(*args: Any, **kwargs: Any) None#
Process the scans data.
- remove_outliers(method: str = 'hampel', **kwargs: Any)#
Remove outliers from the signal.
Note
See the docstring of
scans.Scan.remove_outliers()for details.
- remove_scans(indices: int | list[int], filename: str | None = None) None#
Remove scans from the measurement.
- Parameters:
indices – Indices of the scans to be removed.
filename – Name of the file from which the scans where read.
- remove_source(index: int) None#
Remove a source from the measurement.
- Parameters:
index – Index of the source to be removed.
- property signal: ndarray[tuple[int, ...], dtype[float64]]#
- property x: ndarray[tuple[int, ...], dtype[float64]]#
- class daxs.measurements.Rixs(sources: Source | list[Source])[source]#
Bases:
Measurement2DClass to represent a resonant inelastic X-ray scattering measurement.
- __init__(sources: Source | list[Source])#
Initialize the measurement.
- Parameters:
sources – Sources of scans.
- property acquisition_mode#
Determine the acquisition mode of the RIXS plane.
- Returns:
String indicating the acquisition mode (“absorption” or “emission”).
Note
There are two ways to measure a RIXS plane:
1. Step through a range of emission energies and scan the incoming (monochromator) energy for each step.
2. Step through incoming (monochromator) energy and scan the emission energy.
- add_scans(scans: Scan | list[Scan]) None#
Add scans to the measurement.
- Parameters:
scans – Scans to be added.
- add_source(source: Source) None#
Add a new source to the measurement.
- Parameters:
source – Source to be added.
- concentration_correction(indices: int | list[int] | ndarray[tuple[int, ...], dtype[int64]] | None = None, data_mappings: dict[str, str] | None = None, scans: Scan | list[Scan] | Scans | None = None) None#
Apply the concentration correction using data from the specified scans.
- Parameters:
indices – Indices of the scans used for concentration correction.
data_mappings – Data mappings for the concentration correction scans.
scans – Scans used for concentration corrections.
- Raises:
ValueError – If neither indices nor scans are specified.
- cut(mode: str = 'CEE', energies: list[float] | None = None, widths: float | list[float] | None = None, nbins: int | list[int] | None | list[None] = None)#
Calculate the cuts specified by the mode and energies.
- Parameters:
mode –
Defines the way to cut the plane:
”CEE” - constant emission energy
”CIE” - constant incident energy
”CET” - constant energy transfer
energies – List of energy values at which to extract cuts. Units should match the data axes.
widths – Widths of the energy window for each cut, centered at the specified energy. If None, if defaults to the approximate distance between the points along the relevant axis. Units should match the data axes.
nbins – Number of bins used to histogram the cut data. Using too many bins may result in empty bins with NaN values.
- Returns:
Dictionary with the cuts. Each entry has the form “{mode}@{energy}”: (centers, signal, mask), where centers are the centers of the bins, signal is the signal of the cut, and mask is a boolean array indicating which data points were included in the cut.
- Raises:
ValueError – If the energies parameter is not defined or if the mode is unknown.
- dead_time_correction(tau: Iterable[float], detection_time: float | ndarray[tuple[int, ...], dtype[float64]] | None = None)#
Perform a dead time correction using a non-paralyzable model.
- Parameters:
tau – Dead time value(s).
detection_time – Detection time value(s).
Note
See the docstring of
scans.Scan.dead_time_correction()for details.
- find_outliers(method: str = 'hampel', **kwargs: Any)#
Find outliers in the data.
Note
See the docstring of
scans.Scan.find_outliers()for details.
- interpolate(xi: ndarray[tuple[int, ...], dtype[float64]], yi: ndarray[tuple[int, ...], dtype[float64]], /)#
Interpolate the plane using the new axes.
A regular grid defined by the new axes is used to interpolate the signal. The current x, y, and shape are also updated with the new values.
- Parameters:
xi – The new X-axis.
yi – The new Y-axis.
- property interpolator#
The interpolator of the current plane.
- property monitor: ndarray[tuple[int, ...], dtype[float64]]#
- plot(axes: ndarray[tuple[int, ...], dtype[Any]] | None = None, **kwargs: Any) ndarray[tuple[int, ...], dtype[Any]]#
Plot the measurement signal.
- Parameters:
axes – Matplotlib axes where to plot the signal.
**kwargs – Additional arguments passed to the plot function.
- Returns:
The matplotlib axes where the signal was plotted.
- Raises:
ValueError – If the signal is not defined or if the axes are not provided or have an incorrect number of elements.
- remove_outliers(method: str = 'hampel', **kwargs: Any)#
Remove outliers from the signal.
Note
See the docstring of
scans.Scan.remove_outliers()for details.
- remove_scans(indices: int | list[int], filename: str | None = None) None#
Remove scans from the measurement.
- Parameters:
indices – Indices of the scans to be removed.
filename – Name of the file from which the scans where read.
- remove_source(index: int) None#
Remove a source from the measurement.
- Parameters:
index – Index of the source to be removed.
- reset(scans: float = True)#
Reset the measurement.
- save(filename: str, delimiter: str = ',') None#
Save the current measurement data to a file.
- Parameters:
filename – Name of the output file.
delimiter – Column delimiter in the output file.
- Raises:
ValueError – If the signal is not defined.
- property shape: tuple[int, int]#
Shape of the current plane.
- property signal: ndarray[tuple[int, ...], dtype[float64]]#
- property x: ndarray[tuple[int, ...], dtype[float64]]#
- property y#