Skip to content

Commit

Permalink
Refs #4531. Third histogram (spectra) created for Tosca Runs via CTE.
Browse files Browse the repository at this point in the history
"Summary" property with value "Average" added to TOSCA parameter file.
Values of Average and Sum add respective histograms to the resultant
workspace of any run loaded through the CTE interface.
  • Loading branch information
PeterParker committed Jan 22, 2012
1 parent 6ea40c2 commit 9d477c4
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Code/Mantid/instrument/TOSCA_Parameters.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<parameter name="refl-graphite" type="string">
<value val="002" />
</parameter>

<!-- This parameter will be taken as a default value for the rebinning of
the data in DeltaE. The existence of the parameter will make rebinning
the default, as opposed to not rebinning.
Expand Down Expand Up @@ -49,6 +49,10 @@
<parameter name="Workflow.Masking" type="string">
<value val="IdentifyNoisyDetectors" />
</parameter>
<!-- Available options are "average", "sum", or "none". -->
<parameter name="Workflow.Summary" type="string">
<value val="Average" />
</parameter>

</component-link>

Expand Down
7 changes: 6 additions & 1 deletion Code/Mantid/scripts/Inelastic/inelastic_indirect_reducer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ def _setup_steps(self):
self.append_step(steps.FoldData())
else:
return


# "Summary" adds another histogram onto the end of the resultant workspaces.
# "none", "sum" or "average" are currently supported.
step = steps.Summary(MultipleFrames=self._multiple_frames)
self.append_step(step)

# The "SaveItem" step saves the files in the requested formats.
if (len(self._save_formats) > 0):
step = steps.SaveItem()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,58 @@ def _ws_in_range(self, ranges, xval):
if ( xval >= range[0] and xval <= range[1] ): result += 1
return result

class Summary(ReductionStep):
"""
Adds an extra histogram to the workspace(s) that result from the reduction.
The options are:
* "Sum" - the sum of all the other histograms in the workspace.
* "Average" - the average of all the other histograms in the workspace.
* "None" - no extra histogram is added.
"""

_multiple_frames = False

def __init__(self, MultipleFrames=False):
super(Summary, self).__init__()
self._multiple_frames = MultipleFrames

def execute(self, reducer, file_ws):
try:
summary = mtd[file_ws].getInstrument().getStringParameter('Workflow.Summary')[0]
except IndexError:
return

if ((summary != "Sum") and (summary != "Average")):
return

if ( self._multiple_frames ):
try:
workspaceNames = mtd[file_ws].getNames()
except AttributeError:
workspaceNames = [file_ws]
else:
workspaceNames = [file_ws]

for wsName in workspaceNames:
try:
ws = mtd[wsName]
except:
continue
nSpec = ws.getNumberHistograms()
if (nSpec == 0):
continue
tempName = wsName + '_temp_sum'
SumSpectra(InputWorkspace=wsName, OutputWorkspace=tempName)

if (summary == 'average'):
tempWs = mtd[tempName]
tempWs /= nSpec
# Note: Detector info of the output becomes spurious as there will be a third entry for a detector
# that does not exist.
ConjoinWorkspaces(wsName, tempName, False)


class ConvertToEnergy(ReductionStep):
"""
"""
Expand Down

0 comments on commit 9d477c4

Please sign in to comment.