def PyExec(self): # Get peaks in dSpacing from file, and check we have what we need, before doing anything expectedPeaksD = EnggUtils.readInExpectedPeaks(self.getPropertyValue("ExpectedPeaksFromFile"), self.getProperty('ExpectedPeaks').value) if len(expectedPeaksD) < 1: raise ValueError("Cannot run this algorithm without any input expected peaks") inWS = self.getProperty('Workspace').value WSIndices = EnggUtils.getWsIndicesFromInProperties(inWS, self.getProperty('Bank').value, self.getProperty(self.INDICES_PROP_NAME).value) vanWS = self.getProperty("VanadiumWorkspace").value vanIntegWS = self.getProperty('VanIntegrationWorkspace').value vanCurvesWS = self.getProperty('VanCurvesWorkspace').value # These corrections rely on ToF<->Dspacing conversions, so ideally they'd be done after the # calibration step, which creates a cycle / chicken-and-egg issue. EnggUtils.applyVanadiumCorrections(self, inWS, WSIndices, vanWS, vanIntegWS, vanCurvesWS) rebinnedWS = self._prepareWsForFitting(inWS) posTbl = self._calculateCalibPositionsTbl(rebinnedWS, WSIndices, expectedPeaksD) # Produce 2 results: 'output table' and 'apply calibration' + (optional) calibration file self.setProperty("OutDetPosTable", posTbl) self._applyCalibrationTable(inWS, posTbl) self._outputDetPosFile(self.getPropertyValue('OutDetPosFilename'), posTbl)
def PyExec(self): # Get the run workspace wks = self.getProperty('InputWorkspace').value # Get spectra indices either from bank or direct list of indices, checking for errors bank = self.getProperty('Bank').value spectra = self.getProperty(self.INDICES_PROP_NAME).value indices = EnggUtils.getWsIndicesFromInProperties(wks, bank, spectra) detPos = self.getProperty("DetectorPositions").value nreports = 5 if detPos: nreports += 1 prog = Progress(self, start=0, end=1, nreports=nreports) # Leave only the data for the bank/spectra list requested prog.report('Selecting spectra from input workspace') wks = EnggUtils.cropData(self, wks, indices) prog.report('Masking some bins if requested') self._mask_bins(wks, self.getProperty('MaskBinsXMins').value, self.getProperty('MaskBinsXMaxs').value) prog.report('Preparing input workspace with vanadium corrections') # Leave data for the same bank in the vanadium workspace too vanWS = self.getProperty('VanadiumWorkspace').value vanIntegWS = self.getProperty('VanIntegrationWorkspace').value vanCurvesWS = self.getProperty('VanCurvesWorkspace').value EnggUtils.applyVanadiumCorrections(self, wks, indices, vanWS, vanIntegWS, vanCurvesWS) # Apply calibration if detPos: self._applyCalibration(wks, detPos) # Convert to dSpacing wks = EnggUtils.convertToDSpacing(self, wks) prog.report('Summing spectra') # Sum the values across spectra wks = EnggUtils.sumSpectra(self, wks) prog.report('Preparing output workspace') # Convert back to time of flight wks = EnggUtils.convertToToF(self, wks) prog.report('Normalizing input workspace if needed') if self.getProperty('NormaliseByCurrent').value: self._normalize_by_current(wks) # OpenGenie displays distributions instead of pure counts (this is done implicitly when # converting units), so I guess that's what users will expect self._convertToDistr(wks) self.setProperty("OutputWorkspace", wks)
def PyExec(self): # Get the run workspace wks = self.getProperty('InputWorkspace').value # Get spectra indices either from bank or direct list of indices, checking for errors bank = self.getProperty('Bank').value spectra = self.getProperty(self.INDICES_PROP_NAME).value indices = EnggUtils.getWsIndicesFromInProperties(wks, bank, spectra) # Leave the data for the bank we are interested in only wks = EnggUtils.cropData(self, wks, indices) prog = Progress(self, start=0, end=1, nreports=3) prog.report('Preparing input workspace') # Leave data for the same bank in the vanadium workspace too vanWS = self.getProperty('VanadiumWorkspace').value vanIntegWS = self.getProperty('VanIntegrationWorkspace').value vanCurvesWS = self.getProperty('VanCurvesWorkspace').value EnggUtils.applyVanadiumCorrections(self, wks, indices, vanWS, vanIntegWS, vanCurvesWS) # Apply calibration detPos = self.getProperty("DetectorPositions").value if detPos: self._applyCalibration(wks, detPos) # Convert to dSpacing wks = EnggUtils.convertToDSpacing(self, wks) prog.report('Summing spectra') # Sum the values wks = EnggUtils.sumSpectra(self, wks) prog.report('Preparing output workspace') # Convert back to time of flight wks = EnggUtils.convertToToF(self, wks) # OpenGenie displays distributions instead of pure counts (this is done implicitly when # converting units), so I guess that's what users will expect self._convertToDistr(wks) self.setProperty("OutputWorkspace", wks)
def PyExec(self): # Get peaks in dSpacing from file, and check we have what we need, before doing anything expectedPeaksD = EnggUtils.read_in_expected_peaks( self.getPropertyValue("ExpectedPeaksFromFile"), self.getProperty('ExpectedPeaks').value) if len(expectedPeaksD) < 1: raise ValueError( "Cannot run this algorithm without any input expected peaks") in_wks = self.getProperty('Workspace').value wks_indices = EnggUtils.getWsIndicesFromInProperties( in_wks, self.getProperty('Bank').value, self.getProperty(self.INDICES_PROP_NAME).value) van_wks = self.getProperty("VanadiumWorkspace").value van_integ_wks = self.getProperty('VanIntegrationWorkspace').value van_curves_wks = self.getProperty('VanCurvesWorkspace').value # These corrections rely on ToF<->Dspacing conversions, so ideally they'd be done after the # calibration step, which creates a cycle / chicken-and-egg issue. EnggUtils.applyVanadiumCorrections(self, in_wks, wks_indices, van_wks, van_integ_wks, van_curves_wks) rebinned_ws = self._prepare_ws_for_fitting( in_wks, self.getProperty('RebinBinWidth').value) pos_tbl, peaks_tbl = self._calculate_calib_positions_tbl( rebinned_ws, wks_indices, expectedPeaksD) # Produce 2 results: 'output table' and 'apply calibration' + (optional) calibration file self.setProperty("OutDetPosTable", pos_tbl) self.setProperty("FittedPeaks", peaks_tbl) self._apply_calibration_table(in_wks, pos_tbl) self._output_det_pos_file(self.getPropertyValue('OutDetPosFilename'), pos_tbl)