diff --git a/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py b/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py index fc10388b98f9228f0916b9aa3d6221b82b1504e6..f147489744ffa47ced4f1c881929b0f4f73c80ea 100644 --- a/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/MatchPeaks.py @@ -228,7 +228,8 @@ class MatchPeaks(PythonAlgorithm): return - def _get_peak_position(self, input_ws): + @staticmethod + def _get_peak_position(input_ws): """ Gives bin of the peak of each spectrum in the input_ws @param input_ws :: input workspace @@ -245,25 +246,25 @@ class MatchPeaks(PythonAlgorithm): logger.error('Workspace not defined') # Mid bin number - mid_bin = int(mtd[self._input_ws].blocksize() / 2) + mid_bin = int(input_ws.blocksize() / 2) # Initialisation - peak_bin = np.ones(mtd[self._input_ws].getNumberHistograms()) * mid_bin + peak_bin = np.ones(input_ws.getNumberHistograms()) * mid_bin # Bin range: difference between mid bin and peak bin should be in this range tolerance = int(mid_bin / 2) - x_values = mtd[self._input_ws].readX(0) + x_values = input_ws.readX(0) - for i in range(mtd[self._input_ws].getNumberHistograms()): + for i in range(input_ws.getNumberHistograms()): fit = fit_table.row(i) # Bin number, where Y has its maximum - y_values = mtd[self._input_ws].readY(i) + y_values = input_ws.readY(i) max_pos = np.argmax(y_values) peak_plus_error = abs(fit["PeakCentreError"]) + abs(fit["PeakCentre"]) if peak_plus_error > x_values[0] and peak_plus_error < x_values[-1]: - peak_plus_error_bin = mtd[self._input_ws].yIndexOfX(peak_plus_error) + peak_plus_error_bin = input_ws.yIndexOfX(peak_plus_error) if abs(peak_plus_error_bin - mid_bin) < tolerance and fit["FitStatus"] == 'success': # fit succeeded, and fitted peak is within acceptance range, take it - peak_bin[i] = mtd[self._input_ws].yIndexOfX(fit["PeakCentre"]) + peak_bin[i] = input_ws.yIndexOfX(fit["PeakCentre"]) logger.debug('Fit successfull, peak inside tolerance') elif abs(max_pos - mid_bin) < tolerance: # fit not reliable, take the maximum if within acceptance diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py index 7530f8f48eb1451db3def6e998d1b1dad09c046f..82e3898ab5b0f7abf7a70248a17ff5205195d828 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py @@ -69,7 +69,6 @@ class IndirectILLEnergyTransfer(PythonAlgorithm): _fit_option = None _group_by = None _pulse_chopper = None - _group_detectors = None def category(self): return "Workflow\\MIDAS;Workflow\\Inelastic;Inelastic\\Indirect;Inelastic\\Reduction;ILL\\Indirect" @@ -171,6 +170,9 @@ class IndirectILLEnergyTransfer(PythonAlgorithm): 'in order to get absorption corrections right, \n' 'however the default value is True for backwards compatibility.') + self.declareProperty(name='DiscardSingleDetectors', defaultValue=False, + doc='Whether to discard the spectra of single detectors.') + def validateInputs(self): issues = dict() @@ -235,11 +237,11 @@ class IndirectILLEnergyTransfer(PythonAlgorithm): if self._use_map_file: if self._map_file == '': # path name for default map file - if self._instrument.hasParameter('Workflow.GroupingFile'): - grouping_filename = self._instrument.getStringParameter('Workflow.GroupingFile')[0] - self._map_file = os.path.join(config['groupingFiles.directory'], grouping_filename) + if self.getProperty('DiscardSingleDetectors').value: + grouping_filename = self._instrument.getStringParameter('Workflow.GroupingFile.PSDOnly')[0] else: - raise RuntimeError("Failed to find default detector grouping file. Please specify manually.") + grouping_filename = self._instrument.getStringParameter('Workflow.GroupingFile')[0] + self._map_file = os.path.join(config['groupingFiles.directory'], grouping_filename) self.log().information('Set detector map file : {0}'.format(self._map_file)) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py index 102f1069bca5415c7f5693d1b0c8cff76b6a82ce..565d37b113262a6c7ad54e3a500070050239ee06 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py @@ -37,6 +37,7 @@ class IndirectILLReductionFWS(PythonAlgorithm): _back_calib_option = None _common_args = {} _all_runs = None + _discard_sds = None def category(self): return "Workflow\\MIDAS;Workflow\\Inelastic;Inelastic\\Indirect;Inelastic\\Reduction;ILL\\Indirect" @@ -134,6 +135,9 @@ class IndirectILLReductionFWS(PythonAlgorithm): validator=StringListValidator(['SpectrumNumber', '2Theta', 'Q', 'Q2']), doc='The spectrum axis conversion target.') + self.declareProperty(name='DiscardSingleDetectors', defaultValue=False, + doc='Whether to discard the spectra of single detectors.') + def validateInputs(self): issues = dict() @@ -158,6 +162,7 @@ class IndirectILLReductionFWS(PythonAlgorithm): self._calib_option = self.getPropertyValue('CalibrationOption') self._back_calib_option = self.getPropertyValue('CalibrationBackgroundOption') self._spectrum_axis = self.getPropertyValue('SpectrumAxis') + self._discard_sds = self.getProperty('DiscardSingleDetectors').value # arguments to pass to IndirectILLEnergyTransfer self._common_args['MapFile'] = self.getPropertyValue('MapFile') @@ -165,6 +170,7 @@ class IndirectILLReductionFWS(PythonAlgorithm): self._common_args['Reflection'] = self.getPropertyValue('Reflection') self._common_args['ManualPSDIntegrationRange'] = self.getProperty('ManualPSDIntegrationRange').value self._common_args['SpectrumAxis'] = self._spectrum_axis + self._common_args['DiscardSingleDetectors'] = self._discard_sds self._red_ws = self.getPropertyValue('OutputWorkspace') diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py index bb84514045026e6ac3dde8e2ae26a460635cdae3..55d68c6cb4d6077480d6e47658af3d83130d3e98 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py @@ -34,6 +34,7 @@ class IndirectILLReductionQENS(PythonAlgorithm): _peak_range = [] _runs = None _spectrum_axis = None + _discard_sds = None def category(self): return "Workflow\\MIDAS;Workflow\\Inelastic;Inelastic\\Indirect;Inelastic\\Reduction;ILL\\Indirect" @@ -138,6 +139,9 @@ class IndirectILLReductionQENS(PythonAlgorithm): validator=StringListValidator(['SpectrumNumber', '2Theta', 'Q', 'Q2']), doc='The spectrum axis conversion target.') + self.declareProperty(name='DiscardSingleDetectors', defaultValue=False, + doc='Whether to discard the spectra of single detectors.') + def validateInputs(self): issues = dict() @@ -174,7 +178,7 @@ class IndirectILLReductionQENS(PythonAlgorithm): self._back_calib_scaling = self.getProperty('CalibrationBackgroundScalingFactor').value self._peak_range = self.getProperty('CalibrationPeakRange').value self._spectrum_axis = self.getPropertyValue('SpectrumAxis') - + self._discard_sds = self.getProperty('DiscardSingleDetectors').value self._red_ws = self.getPropertyValue('OutputWorkspace') suffix = '' @@ -196,6 +200,7 @@ class IndirectILLReductionQENS(PythonAlgorithm): self._common_args['ManualPSDIntegrationRange'] = self.getProperty('ManualPSDIntegrationRange').value self._common_args['CropDeadMonitorChannels'] = self.getProperty('CropDeadMonitorChannels').value self._common_args['SpectrumAxis'] = self._spectrum_axis + self._common_args['DiscardSingleDetectors'] = self._discard_sds if self._sum_all_runs is True: self.log().notice('All the sample runs will be summed') diff --git a/instrument/Grouping/IN16B_Grouping_PSD_Only.xml b/instrument/Grouping/IN16B_Grouping_PSD_Only.xml new file mode 100644 index 0000000000000000000000000000000000000000..357d94021c962baef4d94f97fcebaee8b6e9734c --- /dev/null +++ b/instrument/Grouping/IN16B_Grouping_PSD_Only.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="utf-8"?> +<detector-grouping instrument="IN16B"> + <group name="psd1"> <detids val="1-128"/> </group> + <group name="psd2"> <detids val="129-256"/> </group> + <group name="psd3"> <detids val="257-384"/> </group> + <group name="psd4"> <detids val="385-512"/> </group> + <group name="psd5"> <detids val="513-640"/> </group> + <group name="psd6"> <detids val="641-768"/> </group> + <group name="psd7"> <detids val="769-896"/> </group> + <group name="psd8"> <detids val="897-1024"/> </group> + <group name="psd9"> <detids val="1025-1152"/> </group> + <group name="psd10"> <detids val="1153-1280"/> </group> + <group name="psd11"> <detids val="1281-1408"/> </group> + <group name="psd12"> <detids val="1409-1536"/> </group> + <group name="psd13"> <detids val="1537-1664"/> </group> + <group name="psd14"> <detids val="1665-1792"/> </group> + <group name="psd15"> <detids val="1793-1920"/> </group> + <group name="psd16"> <detids val="1921-2048"/> </group> +</detector-grouping> diff --git a/instrument/IN16B_Parameters.xml b/instrument/IN16B_Parameters.xml index a17469199c8d746d97cef6bb8b1521e926092fbd..5ed22689a08f5e7045bac0ec3f18eb59b567870f 100644 --- a/instrument/IN16B_Parameters.xml +++ b/instrument/IN16B_Parameters.xml @@ -48,6 +48,9 @@ <parameter name="Workflow.GroupingFile" type="string"> <value val="IN16B_Grouping.xml" /> </parameter> +<parameter name="Workflow.GroupingFile.PSDOnly" type="string"> + <value val="IN16B_Grouping_PSD_Only.xml" /> +</parameter> <parameter name="EquatorialGroupingFile" type="string"> <value val="IN16B_Grouping_Equatorial.xml" /> </parameter>