daxs.measurements: Measurements#

The module provides classes to deal with different types of measurements.

exception daxs.measurements.ConcentrationCorrectionError(message: str)[source]#

Bases: Exception

__init__(message: str)[source]#
args#
with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

class daxs.measurements.Corrector[source]#

Bases: ABC

Base class for measurement correctors.

abstract apply(scans: Scans) None[source]#

Apply the correction to the scans.

class daxs.measurements.SimpleConcentrationCorrector(scans: Scan | Scans)[source]#

Bases: Corrector

Class to perform simple, length-based, concentration corrections.

__init__(scans: Scan | Scans)[source]#
Parameters:

scans – Scans used for concentration correction.

apply(scans: Scans) None[source]#

Apply the correction to the scans.

class daxs.measurements.DataDrivenConcentrationCorrector(scans: Scan | Scans, paths: dict[str, str])[source]#

Bases: Corrector

Class to perform concentration corrections using data from specified paths.

__init__(scans: Scan | Scans, paths: dict[str, str])[source]#
Parameters:
  • scans – Scans used for concentration correction.

  • paths – Paths to the concentration correction data. It assumes they are the same for specified scans.

property conc_corr_points: ndarray[Any, dtype[float64]]#

Array of points used to determine the concentration correction indices.

Returns:

Array of points used for concentration correction.

Return type:

npt.NDArray[np.float64]

Raises:

ValueError – If the concentration correction counters don’t have the same length.

find_conc_corr_indices(scan: Scan) list[int][source]#

Determine the indices of the concentration correction data for each point in the scan.

Parameters:

scan – Scan for which the concentration correction data indices are to be found.

Returns:

Indices of the concentration correction data for the points in the scan.

Return type:

list[int]

create_conc_corr_scan(indices: list[int]) Scan[source]#

Create a scan with the concentration correction data at the specified indices.

Parameters:

indices – Indices of the concentration correction data to be used.

Returns:

Scan with the concentration correction data at the specified indices.

Return type:

Scan

apply(scans: Scans) None[source]#

Apply the concentration correction using data from the specified paths.

Parameters:

scans – Scans to be corrected.

class daxs.measurements.DeadTimeCorrector[source]#

Bases: Corrector

Class to perform dead time corrections.

abstract apply(scans: Scans) None#

Apply the correction to the scans.

class daxs.measurements.Measurement(sources: Source | list[Source])[source]#

Bases: object

Base class for measurements.

__init__(sources: Source | list[Source])[source]#
Parameters:

sources – Sources of scans.

property scans: Scans#

The scans of the measurement.

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.

reset(scans: float = True)[source]#

Reset the measurement.

get_scans(indices: int | list[int], filename: str | None = None) list[Scan][source]#
concentration_correction(indices: int | list[int] | npt.NDArray[np.int64] | None = None, scans: Scan | list[Scan] | Scans | None = None, paths: dict[str, str] | None = None) None[source]#

Apply the concentration correction using data from the specified scans.

Parameters:
  • indices – Indices of the scans used for concentration correction.

  • scans – Scans used for concentration corrections.

  • paths – Paths used to locate the required concentration correction data.

class daxs.measurements.Measurement1D(sources: Source | list[Source])[source]#

Bases: Measurement

Base class for 1D measurements.

property x#
property signal#
property monitor#
find_outliers(method: str = 'hampel', **kwargs: Any)[source]#

Find outliers in the data.

See the docstring of scans.Scan.find_outliers().

remove_outliers(method: str = 'hampel', **kwargs: Any)[source]#

Remove outliers from the signal.

See the docstring of scans.Scan.remove_outliers().

process(aggregation: str = 'fraction of sums', normalization: str | None = None)[source]#

Process the scans data.

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.

When present, the aggregated monitor is always a sum of the monitors from the individual scans.

Parameters:

mode (str) –

Defines how the signal is aggregated.

  • ”sum” : Sum of the signals from all scans.

  • ”fraction of sums” : Fraction of the signals sum and monitors sum.

  • ”sum of fractions” : Sum of the signal and monitor fractions.

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.

Notes

This will overwrite the original signal with the normalized one.

dead_time_correction(tau: Iterable[float], detection_time: float | npt.NDArray[np.float64] | None = None)[source]#

Perform a dead time correction using a non-paralyzable model.

See the docstring of scans.Scan.dead_time_correction().

save(filename: str, delimiter: str = ',')[source]#

Save the current x and signal to file.

Parameters:
  • filename – Name of the output file.

  • delimiter – Column delimiter in the output file.

__init__(sources: Source | list[Source])#
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] | npt.NDArray[np.int64] | None = None, scans: Scan | list[Scan] | Scans | None = None, paths: dict[str, str] | None = None) None#

Apply the concentration correction using data from the specified scans.

Parameters:
  • indices – Indices of the scans used for concentration correction.

  • scans – Scans used for concentration corrections.

  • paths – Paths used to locate the required concentration correction data.

get_scans(indices: int | list[int], filename: str | None = None) list[Scan]#
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 scans: Scans#

The scans of the measurement.

class daxs.measurements.Xas(sources: Source | list[Source])[source]#

Bases: Measurement1D

Class to represent a X-ray absorption measurement.

__init__(sources: Source | list[Source])#
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.

When present, the aggregated monitor is always a sum of the monitors from the individual scans.

Parameters:

mode (str) –

Defines how the signal is aggregated.

  • ”sum” : Sum of the signals from all scans.

  • ”fraction of sums” : Fraction of the signals sum and monitors sum.

  • ”sum of fractions” : Sum of the signal and monitor fractions.

concentration_correction(indices: int | list[int] | npt.NDArray[np.int64] | None = None, scans: Scan | list[Scan] | Scans | None = None, paths: dict[str, str] | None = None) None#

Apply the concentration correction using data from the specified scans.

Parameters:
  • indices – Indices of the scans used for concentration correction.

  • scans – Scans used for concentration corrections.

  • paths – Paths used to locate the required concentration correction data.

dead_time_correction(tau: Iterable[float], detection_time: float | npt.NDArray[np.float64] | None = None)#

Perform a dead time correction using a non-paralyzable model.

See the docstring of scans.Scan.dead_time_correction().

find_outliers(method: str = 'hampel', **kwargs: Any)#

Find outliers in the data.

See the docstring of scans.Scan.find_outliers().

get_scans(indices: int | list[int], filename: str | None = None) list[Scan]#
property monitor#
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.

Notes

This will overwrite the original signal with the normalized one.

process(aggregation: str = 'fraction of sums', normalization: str | None = None)#

Process the scans data.

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.

See the docstring of scans.Scan.remove_outliers().

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 = ',')#

Save the current x and signal to file.

Parameters:
  • filename – Name of the output file.

  • delimiter – Column delimiter in the output file.

property scans: Scans#

The scans of the measurement.

property signal#
property x#
class daxs.measurements.Xes(sources: Source | list[Source])[source]#

Bases: Measurement1D

Class to represent a X-ray emission measurement.

__init__(sources: Source | list[Source])#
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.

When present, the aggregated monitor is always a sum of the monitors from the individual scans.

Parameters:

mode (str) –

Defines how the signal is aggregated.

  • ”sum” : Sum of the signals from all scans.

  • ”fraction of sums” : Fraction of the signals sum and monitors sum.

  • ”sum of fractions” : Sum of the signal and monitor fractions.

concentration_correction(indices: int | list[int] | npt.NDArray[np.int64] | None = None, scans: Scan | list[Scan] | Scans | None = None, paths: dict[str, str] | None = None) None#

Apply the concentration correction using data from the specified scans.

Parameters:
  • indices – Indices of the scans used for concentration correction.

  • scans – Scans used for concentration corrections.

  • paths – Paths used to locate the required concentration correction data.

dead_time_correction(tau: Iterable[float], detection_time: float | npt.NDArray[np.float64] | None = None)#

Perform a dead time correction using a non-paralyzable model.

See the docstring of scans.Scan.dead_time_correction().

find_outliers(method: str = 'hampel', **kwargs: Any)#

Find outliers in the data.

See the docstring of scans.Scan.find_outliers().

get_scans(indices: int | list[int], filename: str | None = None) list[Scan]#
property monitor#
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.

Notes

This will overwrite the original signal with the normalized one.

process(aggregation: str = 'fraction of sums', normalization: str | None = None)#

Process the scans data.

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.

See the docstring of scans.Scan.remove_outliers().

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 = ',')#

Save the current x and signal to file.

Parameters:
  • filename – Name of the output file.

  • delimiter – Column delimiter in the output file.

property scans: Scans#

The scans of the measurement.

property signal#
property x#
class daxs.measurements.Measurement2D(sources: Source | list[Source])[source]#

Bases: Measurement

Base class for 2D measurements.

__init__(sources: Source | list[Source])#
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] | npt.NDArray[np.int64] | None = None, scans: Scan | list[Scan] | Scans | None = None, paths: dict[str, str] | None = None) None#

Apply the concentration correction using data from the specified scans.

Parameters:
  • indices – Indices of the scans used for concentration correction.

  • scans – Scans used for concentration corrections.

  • paths – Paths used to locate the required concentration correction data.

get_scans(indices: int | list[int], filename: str | None = None) list[Scan]#
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 scans: Scans#

The scans of the measurement.

class daxs.measurements.Rixs(sources: Source | list[Source])[source]#

Bases: Measurement2D

Class to represent a resonant inelastic X-ray scattering measurement.

__init__(sources: Source | list[Source])[source]#
Parameters:

sources – Sources of scans.

property x#
property y#
property signal#
property interpolator#

The interpolator of the current plane.

property acquisition_mode#

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.

reset(scans: float = True)[source]#

Reset the measurement.

find_outliers(method: str = 'hampel', **kwargs: Any)[source]#

Find outliers in the data.

See the docstring of scans.Scan.find_outliers().

remove_outliers(method: str = 'hampel', **kwargs: Any)[source]#

Remove outliers from the signal.

See the docstring of scans.Scan.remove_outliers().

concentration_correction(indices: int | list[int] | None | npt.NDArray[np.int64] = None, scans: Scan | list[Scan] | Scans | None = None, paths: dict[str, str] | None = None) None[source]#

Apply the concentration correction using data from the specified scans.

Parameters:
  • indices – Indices of the scans used for concentration correction.

  • scans – Scans used for concentration corrections.

  • paths – Paths used to locate the required concentration correction data.

process()[source]#

Read and store the scans data.

interpolate(xi: ndarray[Any, dtype[float64]], yi: ndarray[Any, dtype[float64]], /)[source]#

Interpolate the plane using the new axes.

Parameters:
  • xi – The new X-axis.

  • yi – The new Y-axis.

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.

cut(mode: str = 'CEE', energies: list[float] | None = None, npoints: int = 1024)[source]#

Calculate the cuts specified by the mode and energies.

Parameters:
  • mode (str) –

    Defines the way to cut the plane:

    • ”CEE” - constant emission energy

    • ”CIE” - constant incident energy

    • ”CET” - constant energy transfer

  • energies (list(float)) – Energies of the cuts.

  • npoints (int) – Number of points for the cuts.

get_scans(indices: int | list[int], filename: str | None = None) list[Scan]#
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 scans: Scans#

The scans of the measurement.