toolbox_scs.detectors.dssc
¶
DSSC-detector class module
The dssc detector class. It represents a namespace for frequent evaluation while implicitly applying/requiring certain structure/naming conventions to its objects.
- comments:
contributions should comply with pep8 code structure guidelines.
Plot routines don’t fit into objects since they are rather fluent. They have been outsourced to dssc_plot.py. They can now be accessed as toolbox_scs member functions.
Module Contents¶
Classes¶
- class toolbox_scs.detectors.dssc.DSSCBinner(proposal_nr, run_nr, binners={}, xgm_name='SCS_SA3', tim_names=['MCP1apd', 'MCP2apd', 'MCP3apd'], dssc_coords_stride=2)[source]¶
-
- add_binner(name, binner)[source]¶
Add additional binner to internal dictionary
- Parameters:
name (str) – name of binner to be created
binner (xarray.DataArray) – An array that represents a map how the respective coordinate should be binned.
- Raises:
ToolBoxValueError – Exception: Raises exception in case the name does not correspond to a valid binner name. To be generalized.
- load_xgm()[source]¶
load xgm data and construct coordinate array according to corresponding dssc frame number.
- load_tim()[source]¶
load tim data and construct coordinate array according to corresponding dssc frame number.
- create_pulsemask(use_data='xgm', threshold=(0, np.inf))[source]¶
creates a mask for dssc frames according to measured xgm intensity. Once such a mask has been constructed, it will be used in the data reduction process to drop out-of-bounds pulses.
- get_info()[source]¶
Returns the expected shape of the binned dataset, in case binners have been defined.
- get_xgm_binned()[source]¶
Bin the xgm data according to the binners of the dssc data. The result can eventually be merged into the final dataset by the DSSCFormatter.
- Returns:
xgm_data – xarray dataset containing the binned xgm data
- Return type:
xarray.DataSet
- get_tim_binned()[source]¶
Bin the tim data according to the binners of the dssc data. The result can eventually be merged into the final dataset by the DSSCFormatter.
- Returns:
tim_data – xarray dataset containing the binned tim data
- Return type:
xarray.DataSet
- process_data(modules=[], filepath='./', chunksize=512, backend='loky', n_jobs=None, dark_image=None, xgm_normalization=False, normevery=1)[source]¶
Load and bin dssc data according to self.bins. No data is returned by this method. The condensed data is written to file by the worker processes directly.
- Parameters:
modules (list of ints) – a list containing the module numbers that should be processed. If empty, all modules are processed.
filepath (str) – the path where the files containing the reduced data should be stored.
chunksize (int) – The number of trains that should be read in one iterative step.
backend (str) – joblib multiprocessing backend to be used. At the moment it can be any of joblibs standard backends: ‘loky’ (default), ‘multiprocessing’, ‘threading’. Anything else than the default is experimental and not appropriately implemented in the dbdet member function ‘bin_data’.
n_jobs (int) – inversely proportional of the number of cpu’s available for one job. Tasks within one job can grab a maximum of n_CPU_tot/n_jobs of cpu’s. Note that when using the default backend there is no need to adjust this parameter with the current implementation.
dark_image (xarray.DataArray) – DataArray with dimensions compatible with the loaded dssc data. If given, it will be subtracted from the dssc data before the binning. The dark image needs to be of dimension module, trainId, pulse, x and y.
xgm_normalization (boolean) – if true, the dssc data is normalized by the xgm data before the binning.
normevery (int) – integer indicating which out of normevery frame will be normalized.
- class toolbox_scs.detectors.dssc.DSSCFormatter(filepath)[source]¶
- combine_files(filenames=[])[source]¶
Read the files given in filenames, and store the data in the class variable ‘data’. If no filenames are given, it tries to read the files stored in the class-internal variable ‘_filenames’.
- Parameters:
filenames (list) – list of strings containing the names of the files to be combined.
- add_dataArray(groups=[])[source]¶
Reads addional xarray-data from the first file given in the list of filenames. This assumes that all the files in the folder contain the same additional data. To be generalized.
- Parameters:
groups (list) – list of strings with the names of the groups in the h5 file, containing additional xarray data.
- add_attributes(attributes={})[source]¶
Add additional information, such as run-type, as attributes to the formatted .h5 file.
- Parameters:
attributes (dictionary) – a dictionary, containing information or data of any kind, that will be added to the formatted .h5 file as attributes.
- save_formatted_data(filename)[source]¶
Create a .h5 file containing the main dataset in the group called ‘data’. Additional groups will be created for the content of the variable ‘data_array’. Metadata about the file is added in the form of attributes.
- Parameters:
filename (str) – the name of the file to be created