# SPDX-License-Identifier: BSD-3-Clause# Copyright (c) 2023 Scipp contributors (https://github.com/scipp)"""Beamline parameters and utilities for POWGEN."""importscippasscfrom...powder.typesimport(DetectorBankSizes,NeXusDetectorName,)DETECTOR_BANK_SIZES={"powgen_detector":{"bank":23,"column":154,"row":7}}
[docs]defmap_detector_to_spectrum(data:sc.Dataset,*,detector_info:sc.Dataset)->sc.Dataset:""" Transform 'detector' coords to 'spectrum'. Parameters ---------- data: Input data whose 'detector' coord is transformed. detector_info: Defines mapping from detector numbers to spectra. Returns ------- : `data` with 'detector' coord and dim replaced by 'spectrum'. """ifnotsc.identical(data.coords["detector"].to(dtype=detector_info.coords["detector"].dtype,copy=False),detector_info.coords["detector"],):raisesc.CoordError("The 'detector' coords of `data` and `detector_info` do not match.")out=data.copy(deep=False)delout.coords["detector"]# Add 1 because spectrum numbers in the data start at 1 but# detector_info contains spectrum indices which start at 0.out.coords["spectrum"]=detector_info.coords["spectrum"]+sc.index(1,dtype=detector_info.coords["spectrum"].dtype)returnout.rename_dims({"detector":"spectrum"})
[docs]defpowgen_detector_dimensions(detector_name:NeXusDetectorName,)->DetectorBankSizes:"""Dimensions used by POWGEN detectors."""returnDetectorBankSizes(DETECTOR_BANK_SIZES[detector_name])
providers=(powgen_detector_dimensions,)"""Sciline providers for POWGEN beamline processing."""