toolbox_scs.detectors.viking
¶
Module Contents¶
Classes¶
The Viking analysis (spectrometer used in combination with Andor Newton |
- class toolbox_scs.detectors.viking.Viking(proposalNB)[source]¶
The Viking analysis (spectrometer used in combination with Andor Newton camera)
The objects of this class contain the meta-information about the settings of the spectrometer, not the actual data, except possibly a dark image for background subtraction.
The actual data is loaded into xarray`s via the method `from_run(), and stays there.
- PROPOSAL¶
the number of the proposal
- Type
int
- X_RANGE¶
the slice to take in the non-dispersive direction, in pixels. Defaults to the entire width.
- Type
slice
- Y_RANGE¶
the slice to take in the energy dispersive direction
- Type
slice
- USE_DARK¶
whether to do dark subtraction. Is initially False, magically switches to True if a dark has been loaded, but may be reset.
- Type
bool
- ENERGY_CALIB¶
The 2nd degree polynomial coefficients for calibration from pixel to energy. Defaults to [0, 1, 0] (no calibration applied).
- Type
1D array (len=3)
- BL_POLY_DEG¶
the dgree of the polynomial used for baseline subtraction. Defaults to 1.
- Type
int
- BL_SIGNAL_RANGE¶
the dispersive-axis range, defined by an interval [min, max], to avoid when fitting a polynomial for baseline subtraction. Multiple ranges can be provided in the form [[min1, max1], [min2, max2], …].
- Type
list
- FIELDS¶
the fields to be loaded from the data. Add additional fields if so desired.
- Type
list of str
Example
proposal = 2953 v = Viking(proposal) v.X_RANGE = slice(0, 1900) v.Y_RANGE = slice(38, 80) v.ENERGY_CALIB = [1.47802667e-06, 2.30600328e-02, 5.15884589e+02] v.BL_SIGNAL_RANGE = [500, 545]
- from_run(runNB, add_attrs=True)[source]¶
load a run
Load the run runNB. A thin wrapper around toolbox_scs.load.
- Parameters
runNB (int) – the run number
add_attrs (bool) – if True, adds the camera parameters as attributes to the dataset (see get_camera_params())
Output –
------ –
ds (xarray Dataset) – the dataset containing the camera images
Example
data = v.from_run(145) # load run 145
data1 = v.from_run(145) # load run 145 data2 = v.from_run(155) # load run 155 data = xarray.concat([data1, data2], ‘trainId’) # combine both
- integrate(data)[source]¶
This function calculates the mean over the non-dispersive dimension to create a spectrum. If the camera parameters are known, the spectrum is multiplied by the number of photoelectrons per ADC count. A new variable “spectrum” is added to the data.
- get_camera_gain(run)[source]¶
Get the preamp gain of the camera in the Viking spectrometer for a specified run.
- Parameters
run (extra_data DataCollection) – information on the run
Output –
------ –
gain (int) –
- e_per_counts(run, gain=None)[source]¶
Conversion factor from camera digital counts to photoelectrons per count. The values can be found in the camera datasheet (Andor Newton) but they have been slightly corrected for High Sensitivity mode after analysis of runs 1204, 1207 and 1208, proposal 2937.
- Parameters
run (extra_data DataCollection) – information on the run
gain (int) – the camera preamp gain
Output –
------ –
ret (float) – photoelectrons per count
- removePolyBaseline(data)[source]¶
Removes a polynomial baseline to a spectrum, assuming a fixed position for the signal.
- Parameters
data (xarray Dataset) – The Viking data containing the variable “spectrum”
Output –
------ –
data – the original dataset with the added variable “spectrum_nobl” containing the baseline subtracted spectra.
- xas(data, data_ref, thickness=1, plot=False, plot_errors=True, xas_ylim=(-1, 3))[source]¶
Given two independent datasets (one with sample and one reference), this calculates the average XAS spectrum (absorption coefficient), associated standard deviation and standard error. The absorption coefficient is defined as -log(It/I0)/thickness.
- Parameters
data (xarray Dataset) – the dataset containing the spectra with sample
data_ref (xarray Dataset) – the dataset containing the spectra without sample
thickness (float) – the thickness used for the calculation of the absorption coefficient
plot (bool) – If True, plot the resulting average spectra.
plot_errors (bool) – If True, adds the 95% confidence interval on the spectra.
xas_ylim (tuple or list of float) – the y limits for the XAS plot.
Output –
------ –
xas (xarray Dataset) – the dataset containing the computed XAS quantities: I0, It, absorptionCoef and their associated errors.
- calibrate(runList, plot=True)[source]¶
This routine determines the calibration coefficients to translate the camera pixels into energy in eV. The Viking spectrometer is calibrated using the beamline monochromator: runs with various monochromatized photon energy are recorded and their peak position on the detector are determined by Gaussian fitting. The energy vs. position data is then fitted to a second degree polynomial.
- Parameters
runList (list of int) – the list of runs containing the monochromatized spectra
plot (bool) – if True, the spectra, their Gaussian fits and the calibration curve are plotted.
Output –
------ –
energy_calib (np.array) – the calibration coefficients (2nd degree polynomial)