Skip to content

Commit

Permalink
Refs #9736 Use FindDetectorsOutsideLimits instead.
Browse files Browse the repository at this point in the history
Also do a little light refactoring while we're here.
  • Loading branch information
Samuel Jackson committed Jun 26, 2014
1 parent 23aa885 commit 38e6e15
Showing 1 changed file with 11 additions and 16 deletions.
27 changes: 11 additions & 16 deletions Code/Mantid/scripts/Inelastic/inelastic_indirect_reduction_steps.py
Expand Up @@ -376,7 +376,6 @@ def execute(self, reducer, file_ws):
ntu = NormaliseToUnityStep()
ntu.set_factor(self._intensity_scale)
ntu.set_peak_range(peakMin, peakMax)
ntu.set_number_of_histograms(cal_ws.getNumberHistograms())
ntu.execute(reducer, cwsn)

RenameWorkspace(InputWorkspace=cwsn,OutputWorkspace= outWS_n)
Expand Down Expand Up @@ -798,32 +797,28 @@ class NormaliseToUnityStep(ReductionStep):
_factor = None
_peak_min = None
_peak_max = None
_no_hist = 1.0

def execute(self, reducer, ws):
Integration(InputWorkspace=ws,OutputWorkspace=ws,RangeLower=self._peak_min, RangeUpper= self._peak_max)

tempSum = SumSpectra(InputWorkspace=ws, OutputWorkspace='__tempSum')
num_zero_spectra = tempSum.getRun().getLogData('NumZeroSpectra').value
sum = tempSum.readY(0)[0]
number_historgrams = mtd[ws].getNumberHistograms()
Integration(InputWorkspace=ws, OutputWorkspace=ws, RangeLower=self._peak_min, RangeUpper= self._peak_max)
ws_mask, num_zero_spectra = FindDetectorsOutsideLimits(InputWorkspace=ws, OutputWorkspace='__temp_ws_mask')
DeleteWorkspace(ws_mask)

tempSum = SumSpectra(InputWorkspace=ws, OutputWorkspace='__temp_sum')
total = tempSum.readY(0)[0]
DeleteWorkspace(tempSum)

factor = 1.0
if self._factor:
factor = self._factor
else:
factor = 1 / ( sum / (self._no_hist - num_zero_spectra) )
Scale(InputWorkspace=ws,OutputWorkspace=ws,Factor=factor,Operation='Multiply')
if self._factor is None:
self._factor = 1 / ( total / (number_historgrams - num_zero_spectra) )

Scale(InputWorkspace=ws, OutputWorkspace=ws, Factor=self._factor, Operation='Multiply')

def set_factor(self, factor):
self._factor = factor

def set_peak_range(self, pmin, pmax):
self._peak_min = pmin
self._peak_max = pmax

def set_number_of_histograms(self, num):
self._no_hist = num

class DetailedBalance(ReductionStep):
"""
Expand Down

0 comments on commit 38e6e15

Please sign in to comment.