daxs.scans: Scans#

The module provides classes for the representation of scans in measurements.

class daxs.scans.Scan(x: npt.NDArray[np.float64] | None = None, signal: npt.NDArray[np.float64] | None = None, *, data: dict[Any, Any] | None = None)[source]#

Bases: object

__init__(x: npt.NDArray[np.float64] | None = None, signal: npt.NDArray[np.float64] | None = None, *, data: dict[Any, Any] | None = None) None[source]#

Define the base representation of scans in measurements.

An scan can be initialized in two ways:

  1. Direct initialization - by passing the x and signal directly to the constructor, with optional additional data.

  2. Lazy initialization - by creating an empty scan and then setting values through properties, either all at once via the data property or individually x, signal, monitor, etc.

Parameters:
  • x – X-axis values (1D array).

  • signal – Signal values (1D or 2D array). For a 2D array, the components must be stored as rows. A 1D array will be converted to a 2D array.

  • data – Storage for the raw scan data and metadata.

property x#
property y#
property signal#
property monitor#
property indices#
property data#
property label: str#
reset() None[source]#

Reset the scan data to the original values stored internally.

reindex()[source]#

Reindex the scan data.

read_data_at_paths(data_paths: str | list[str]) npt.NDArray[np.float64][source]#

Read and store the data from the file.

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

Find outliers in the signal.

See the docstring in the daxs.filters.

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

Remove outliers from the signal.

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

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.

Parameters:
  • tau – The detector dead time in seconds.

  • detection_time – The time spent on a point of the scan in seconds.

interpolate(a: ndarray[Any, dtype[float64]])[source]#

Interpolate the signal and possibly the monitor data to the new X-axis values.

Parameters:

a – Array used to interpolate the signal and monitor.

divide_by_scalars(signal: int | float, monitor: int | float | None = None) Scan[source]#

Divide the scan by scalar values.

divide_by_scan(other: Scan) Scan[source]#

Divide the scan by another scan.

plot(ax: matplotlib.axes.Axes, shift: float = 0.0)[source]#

Plot the scan data and outliers if available.

Parameters:
  • ax – The axes to plot the scan data on.

  • shift – Shift the signal by the given value.

class daxs.scans.Scans(scans: Scan | list[Scan] | None = None)[source]#

Bases: object

A collection of scans.

__init__(scans: Scan | list[Scan] | None = None) None[source]#

Initialize the collection of scans.

check_sizes() None[source]#

Sanity check for the number of points in the scans.

get_common_axis(label: str = 'x', mode: str = 'intersection') ndarray[Any, dtype[float64]][source]#

Return the common axis for the scans.

reset() None[source]#

Reset the scans to their original values.

extend(scans: Scans) None[source]#

Extend the collection of scans.

remove(item: Scan) None[source]#

Remove the scan at the given index.

append(item: Scan) None[source]#

Append a scan to the collection.