toolbox_scs.detectors.xgm

XGM related sub-routines

Copyright (2019) SCS Team.

(contributions preferrably comply with pep8 code structure guidelines.)

Module Contents

Functions

get_xgm(run[, mnemonics, merge_with, indices])

Load and/or computes XGM data. Sources can be loaded on the

calibrate_xgm(run, data[, xgm, plot])

Calculates the calibration factor F between the photon flux (slow signal)

toolbox_scs.detectors.xgm.get_xgm(run, mnemonics=None, merge_with=None, indices=slice(0, None))[source]

Load and/or computes XGM data. Sources can be loaded on the fly via the mnemonics argument, or processed from an existing dataset (merge_with). The bunch pattern table is used to assign the pulse id coordinates if the number of pulses has changed during the run.

Parameters
  • run (extra_data.DataCollection) – DataCollection containing the xgm data.

  • mnemonics (str or list of str) – mnemonics for XGM, e.g. “SCS_SA3” or [“XTD10_XGM”, “SCS_XGM”]. If None, defaults to “SCS_SA3” in case no merge_with dataset is provided.

  • merge_with (xarray Dataset) – If provided, the resulting Dataset will be merged with this one. The XGM variables of merge_with (if any) will also be computed and merged.

  • indices (slice, list, 1D array) – Pulse indices of the XGM array in case bunch pattern is missing.

Returns

merged with Dataset merge_with if provided.

Return type

xarray Dataset with pulse-resolved XGM variables aligned,

Example

>>> import toolbox_scs as tb
>>> run, ds = tb.load(2212, 213, 'SCS_SA3')
>>> ds['SCS_SA3']
toolbox_scs.detectors.xgm.calibrate_xgm(run, data, xgm='SCS', plot=False)[source]

Calculates the calibration factor F between the photon flux (slow signal) and the fast signal (pulse-resolved) of the sase 3 pulses. The calibrated fast signal is equal to the uncalibrated one multiplied by F.

Parameters
  • run (extra_data.DataCollection) – DataCollection containing the digitizer data.

  • data (xarray Dataset) – dataset containing the pulse-resolved sase 3 signal, e.g. ‘SCS_SA3’

  • xgm (str) – one in {‘XTD10’, ‘SCS’}

  • plot (bool) – If True, shows a plot of the photon flux, averaged fast signal and calibrated fast signal.

Returns

F – calibration factor F defined as: calibrated XGM [microJ] = F * fast XGM array (‘SCS_SA3’ or ‘XTD10_SA3’)

Return type

float

Example

>>> import toolbox_scs as tb
>>> import toolbox_scs.detectors as tbdet
>>> run, data = tb.load(900074, 69, ['SCS_XGM'])
>>> ds = tbdet.get_xgm(run, merge_with=data)
>>> F = tbdet.calibrate_xgm(run, ds, plot=True)
>>> # Add calibrated XGM to the dataset:
>>> ds['SCS_SA3_uJ'] = F * ds['SCS_SA3']