Process functions¶
Process functions for raw data from position sensitive detectors.
-
process_functions.
alignGroups
(data, position=None)¶ Align the peaks along the z-axis of the detectors.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
. First axis is assumed to be q-values. - position (int (optional)) – Position of the center along the ‘channels’ axis. (default, None, is determined automatically)
Returns: - data (
sample.Sample
) – Instance ofsample.Sample
for which the data maxima were aligned along the z direction. - center (int) – The center determined by the algorithm, which can then be used to convert the time-of-flight to energies as it defines the elastic peak.
- data (
-
process_functions.
alignTo
(data, refPos, peaks=None)¶ Align data peaks to zero energy transfer.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
. - refPos (int) – Reference index on energy/channels axis.
- peaks (np.ndarray (optional)) – Array of peak positions for each momentum transfer q value. (default, None - will be determined automatically)
- data (
-
process_functions.
alignToZero
(data, peaks=None)¶ Align data peaks to the zero of energy transfers.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
. - peaks (np.ndarray (optional)) – Array of peak positions for each momentum transfer q value. (default, None - will be determined automatically)
- data (
-
process_functions.
avgAlongObservable
(data)¶ Average a single dataset along with monitor over the observable.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
. - peaks (np.ndarray (optional)) – Array of peak positions for each momentum transfer q value. (default, None - will be determined automatically)
- data (
-
process_functions.
convertChannelsToEnergy
(data, type, refDist=33.388, tElastic=None)¶ Convert the ‘channels’ axis to ‘energies’
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
. - type ({'qens', 'fws', 'bats'}) – Type of dataset that is being processed.
- refDist (float (optional)) – Reference distance from the pulse chopper used in BATS mode to the sample.
- tElastic (int (optional)) – Reference value of time-of-flight for the elastic signal.
- data (
-
process_functions.
detGrouping
(data, detGroup=None)¶ The function performs a sum along detector tubes using the provided range to be kept.
It makes use of the :arg detGroup: argument.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
- detGroup (int, list, file path) –
If the argument is a scalar, it sums over all values that are in the range [center of the tube - detGroup : center of the tube + detGroup].
If the argument is a list of integers, then each element of the list is assumed to correspond to a range for each corresponding detector in ascending order.
If the argument is a mantid-related xml file (a python string), the xml_detector_grouping module is then used to parse the xml file and the provided values are used to define the range.
- data (
-
process_functions.
findPeaks
(data, peakFindingMask=None)¶ Find the peak for each momentum transfer in data.
The function always return a single peak for each momentum transfer value. Hence, it should be called twice for mirrored data, once for each wing, before unmirroring.
The data are expected to have the momentum transfer q-values in the first dimension, the channels in the second dimension and, for 3D arrays, the momentum transfer in vertical position qz in the third dimension.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
- peakFindingMask (np.ndarray (optional)) – A mask to exclude some points from peak search. (default None, use a small window centered on the ‘channel’ axis)
- data (
-
process_functions.
findPeaksFWS
(data)¶ Find peaks in FWS data.
For arrays with more than one dimension, the function assumes that the first axis is the momentum tansfer q values (‘q’) and the second the recorded channels (‘channels’).
Parameters: data ( sample.Sample
) – Instance ofsample.Sample
-
process_functions.
mergeDataset
(dataList, observable='time')¶ Produce a single dataset from multiple FWS data.
In the case of different sampling for the energy transfers used in FWS data, the function interpolates the smallest arrays to produce a unique numpy array of FWS data.
Parameters: - data (list of
sample.Sample
) – list of instances ofsample.Sample
. - observable ({'time', 'temperature', 'pressure'} (optional)) – The name of the observable used for series of data. (default, ‘time’)
- data (list of
-
process_functions.
normalizeToMonitor
(data, peaks=None, monPeaks=None, fws=False)¶ Normalize the data by divinding by the monitor.
If peaks an monPeaks are not None, the data are aligned to monitor peaks for each momenum transfer prior to normalization. For FWS data, only the values at peak positions are used.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
- peaks (np.ndarray) – The position of the peak(s) for each momentum transfer. Requires ‘monPeaks’ as well.
- monPeaks (np.ndarray) – The position of the peak(s) in monitor. Requires ‘peaks’ as well.
- fws (bool) – Whether data are FWS or not.
- data (
-
process_functions.
sumAlongObservable
(data)¶ Sum a single dataset along with monitor over the observable.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
. - peaks (np.ndarray (optional)) – Array of peak positions for each momentum transfer q value. (default, None - will be determined automatically)
- data (
-
process_functions.
unmirror
(data, refPeaks=None)¶ Unmirror data using the elastic peak as a reference.
Parameters: - data (
sample.Sample
) – Instance ofsample.Sample
. - refPeaks (np.ndarray (optional)) – Reference peak positions for the elastic signal. Should have one entry for each momentum transfer q-values in the first dimension and two entries in the second dimension for the peak in the left and right wing, respectively. (default None, will be determined automatically)
- data (