Skip to content

Commit

Permalink
callfull-then-cal system test revamped for vanadium, re #12426
Browse files Browse the repository at this point in the history
  • Loading branch information
FedeMPouzols committed Jul 14, 2015
1 parent 2cc1814 commit 1c413bb
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ def PyExec(self):
import EnggUtils

focussed_ws = self._focusRun(self.getProperty('InputWorkspace').value,
self.getProperty("VanadiumWorkspace").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)
self.getProperty('ExpectedPeaks').value)

if len(expectedPeaksD) < 1:
raise ValueError("Cannot run this algorithm without any input expected peaks")
Expand Down Expand Up @@ -102,7 +102,7 @@ def _fitParams(self, focusedWS, expectedPeaksD):

return difc, zero

def _focusRun(self, ws, bank, indices, vanWS):
def _focusRun(self, ws, vanWS, bank, indices):
"""
Focuses the input workspace by running EnggFocus as a child algorithm, which will produce a
single spectrum workspace.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def PyInit(self):
self.declareProperty("Bank", '', StringListValidator(EnggUtils.ENGINX_BANKS),
direction=Direction.Input,
doc = "Which bank to calibrate: It can be specified as 1 or 2, or "
"equivalently,North or South. See also " + self.INDICES_PROP_NAME + " "
"equivalently, North or South. See also " + self.INDICES_PROP_NAME + " "
"for a more flexible alternative to select specific detectors")

self.declareProperty(self.INDICES_PROP_NAME, '', direction=Direction.Input,
Expand Down Expand Up @@ -66,12 +66,12 @@ def PyExec(self):

inWS = self.getProperty('Workspace').value
WSIndices = EnggUtils.getWsIndicesFromInProperties(inWS, self.getProperty('Bank').value,
self.getProperty(self.INDICES_PROP_NAME).value)
self.getProperty(self.INDICES_PROP_NAME).value)

vanWS = self.getProperty("VanadiumWorkspace").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.
EnginXUtils.applyVanadiumCorrection(self, ws, vanWS)
EnggUtils.applyVanadiumCorrection(self, inWS, vanWS)

rebinnedWS = self._prepareWsForFitting(inWS)
posTbl = self._calculateCalibPositionsTbl(rebinnedWS, WSIndices, expectedPeaksD)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,34 @@ def PyExec(self):
# Get the run workspace
ws = self.getProperty('InputWorkspace').value

indices = EnggUtils.getWsIndicesFromInProperties(ws, self.getProperty('Bank').value,
self.getProperty(self.INDICES_PROP_NAME).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(ws, bank, spectra)

# Leave the data for the bank we are interested in only
ws = EnginXUtils.cropData(self, ws, indices)
ws = EnggUtils.cropData(self, ws, indices)

# Apply calibration
detPos = self.getProperty("DetectorPositions").value
if detPos:
self._applyCalibration(ws, detPos)

# Leave data for the same bank in the vanadium workspace too
vanWS = self.getProperty("VanadiumWorkspace").value
vanWS = EnggUtils.cropData(self, vanWS, indices)

# These corrections rely on ToF<->Dspacing conversions, so they're done after the calibration step
EnginXUtils.applyVanadiumCorrection(self, ws, vanWS)
EnggUtils.applyVanadiumCorrection(self, ws, vanWS)

# Convert to dSpacing
ws = EnginXUtils.convertToDSpacing(self, ws)
ws = EnggUtils.convertToDSpacing(self, ws)

# Sum the values
ws = EnginXUtils.sumSpectra(self, ws)
ws = EnggUtils.sumSpectra(self, ws)

# Convert back to time of flight
ws = EnginXUtils.convertToTOF(self, ws)
ws = EnggUtils.convertToToF(self, ws)

# OpenGenie displays distributions instead of pure counts (this is done implicitly when
# converting units), so I guess that's what users will expect
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def _approxRelErrorLessThan(self, val, ref, epsilon):
@returns if val differs from ref by less than epsilon
"""
if 0 == ref:
return False
return (abs((ref-val)/ref) < epsilon)

def _check_outputs_ok(self, tblName, numPeaks, cell00, cell01, cell10, cell14):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def test_runs_ok(self):
"""

out_name = 'out'
out = EnggFocus(InputWorkspace=self.__class__._data_ws, Bank='1', OutputWorkspace=out_name)
out = EnggFocus(InputWorkspace=self.__class__._data_ws, VanadiumWorkspace=self.__class__._data_ws, Bank='1', OutputWorkspace=out_name)

self._check_output_ok(ws=out, ws_name=out_name, y_dim_max=1, yvalues=self._expected_yvals_bank1)

Expand Down

0 comments on commit 1c413bb

Please sign in to comment.