def PyExec(self): import EnggUtils # Get peaks in dSpacing from file 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") # Get expected peaks in TOF for the detector inWS = self.getProperty("InputWorkspace").value dimType = inWS.getXDimension().getName() if self.EXPECTED_DIM_TYPE != dimType: raise ValueError("This algorithm expects a workspace with %s X dimension, but " "the X dimension of the input workspace is: '%s'" % (self.EXPECTED_DIM_TYPE, dimType)) wsIndex = self.getProperty("WorkspaceIndex").value # FindPeaks will return a list of peaks sorted by the centre found. Sort the peaks as well, # so we can match them with fitted centres later. expectedPeaksToF = sorted(self._expectedPeaksInTOF(expectedPeaksD, inWS, wsIndex)) foundPeaks = self._peaksFromFindPeaks(inWS, expectedPeaksToF, wsIndex) if foundPeaks.rowCount() < len(expectedPeaksToF): txt = "Peaks effectively found: " + str(foundPeaks)[1:-1] self.log().warning("Some peaks from the list of expected peaks were not found by the algorithm " "FindPeaks which this algorithm uses to check that the data has the the " "expected peaks. " + txt) peaksTableName = self.getPropertyValue("OutFittedPeaksTable") difc, zero = self._fitAllPeaks(inWS, wsIndex, (foundPeaks, expectedPeaksD), peaksTableName) self._produceOutputs(difc, zero)
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): import EnggUtils focussed_ws = self._focusRun(self.getProperty('InputWorkspace').value, self.getProperty("VanadiumWorkspace").value, self.getProperty('Bank').value, self.getProperty(self.INDICES_PROP_NAME).value) # Get peaks in dSpacing from file 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") difc, zero = self._fitParams(focussed_ws, expectedPeaksD) self._produceOutputs(difc, zero)
def PyExec(self): import EnggUtils # Get peaks in dSpacing from file expectedPeaksD = EnggUtils.readInExpectedPeaks(self.getPropertyValue("ExpectedPeaksFromFile"), self.getProperty('ExpectedPeaks').value) prog = Progress(self, start=0, end=1, nreports=2) prog.report('Focusing the input workspace') focussed_ws = self._focusRun(self.getProperty('InputWorkspace').value, self.getProperty("VanadiumWorkspace").value, self.getProperty('Bank').value, self.getProperty(self.INDICES_PROP_NAME).value) if len(expectedPeaksD) < 1: raise ValueError("Cannot run this algorithm without any input expected peaks") prog.report('Fitting parameters for the focused run') difc, zero = self._fitParams(focussed_ws, expectedPeaksD) self._produceOutputs(difc, zero)