Skip to content

Commit

Permalink
Fix algorithm returns in ported reducers. Refs #7469
Browse files Browse the repository at this point in the history
  • Loading branch information
martyngigg committed Jul 23, 2013
1 parent 570ec2f commit 033d971
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
16 changes: 8 additions & 8 deletions Code/Mantid/scripts/reduction/instruments/sans/hfir_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from sans_reduction_steps import BaseBeamFinder

# Mantid imports
from mantidsimple import *
from mantid.simpleapi import *

class LoadRun(ReductionStep):
"""
Expand Down Expand Up @@ -130,15 +130,15 @@ def _load_data_file(file_name, wks_name):
else:
[beam_x, beam_y] = reducer.get_beam_center()

l = HFIRLoad(filepath, wks_name,
wksp, msg = HFIRLoad(Filename=filepath, OutputWorkspace=wks_name,
BeamCenterX = beam_x,
BeamCenterY = beam_y,
SampleDetectorDistance = self._sample_det_dist,
SampleDetectorDistanceOffset = self._sample_det_offset,
Wavelength = self._wavelength,
WavelengthSpread = self._wavelength_spread,
ReductionProperties=reducer.get_reduction_table_name())
return l.getPropertyValue("OutputMessage")
return msg

# Check whether we have a list of files that need merging
# Make sure we process a list of files written as a string
Expand Down Expand Up @@ -166,11 +166,11 @@ def _load_data_file(file_name, wks_name):
timer += mtd[workspace].getRun().getProperty("timer").value

# Update the timer and monitor
mantid[workspace].getRun().addProperty_dbl("monitor", monitor, True)
mantid[workspace].getRun().addProperty_dbl("timer", timer, True)
mtd[workspace].mutableRun().addProperty("monitor", monitor, True)
mtd[workspace].mutableRun().addProperty("timer", timer, True)

if mtd.workspaceExists('__tmp_wksp'):
mtd.deleteWorkspace('__tmp_wksp')
if mtd.doesExist('__tmp_wksp'):
DeleteWorkspace('__tmp_wksp')
else:
output_str += "Loaded %s\n" % data_file
output_str += _load_data_file(data_file, workspace)
Expand All @@ -181,7 +181,7 @@ def _load_data_file(file_name, wks_name):
beam_center_y = mtd[workspace].getRun().getProperty("beam_center_y").value
if type(reducer._beam_finder) is BaseBeamFinder:
reducer.set_beam_finder(BaseBeamFinder(beam_center_x, beam_center_y))
mantid.sendLogMessage("No beam finding method: setting to default [%-6.1f, %-6.1f]" % (beam_center_x, beam_center_y))
logger.notice("No beam finding method: setting to default [%-6.1f, %-6.1f]" % (beam_center_x, beam_center_y))

n_files = 1
if type(data_file)==list:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def execute(self, reducer, workspace=None):
WavelengthSpread=reducer._data_loader._wavelength_spread,
BeamCenterMethod=find_beam,
BeamCenterX=beam_ctr_x,
BeamCenterY=beam_ctr_y,
BeamCenterY=beam_ctr_y,
ReductionProperties=reducer.get_reduction_table_name())

class BaseBeamFinder(ReductionStep):
Expand Down Expand Up @@ -79,15 +79,15 @@ def _find_beam(self, direct_beam, reducer, workspace=None):
if self._beam_center_x is not None and self._beam_center_y is not None:
return "Using Beam Center at: %g %g" % (self._beam_center_x, self._beam_center_y)

c=SANSBeamFinder(Filename=self._datafile,
UseDirectBeamMethod=direct_beam,
BeamRadius=self._beam_radius,
PersistentCorrection=self._persistent,
ReductionProperties=reducer.get_reduction_table_name())
beam_x,beam_y,msg = SANSBeamFinder(Filename=self._datafile,
UseDirectBeamMethod=direct_beam,
BeamRadius=self._beam_radius,
PersistentCorrection=self._persistent,
ReductionProperties=reducer.get_reduction_table_name())

self._beam_center_x = c.getProperty("FoundBeamCenterX").value
self._beam_center_y = c.getProperty("FoundBeamCenterY").value
return c.getPropertyValue("OutputMessage")
self._beam_center_x = beam_x
self._beam_center_y = beam_y
return msg

class ScatteringBeamCenter(BaseBeamFinder):
"""
Expand Down Expand Up @@ -355,13 +355,11 @@ def _load_monitors(self, reducer, workspace):

# Use the transmission workspaces to find the list of monitor pixels
# since the beam center may be at a different location
det_finder = FindDetectorsInShape(Workspace=sample_ws, ShapeXML=cylXML)
det_list = det_finder.getPropertyValue("DetectorList")

first_det_str = det_list.split(',')[0]
if len(first_det_str.strip())==0:
det_list = FindDetectorsInShape(Workspace=sample_ws, ShapeXML=cylXML)

if len(det_list) == 0:
raise RuntimeError, "Could not find detector pixels near the beam center: check that the beam center is placed at (0,0)."
first_det = int(first_det_str)
first_det = det_list[0]

#TODO: check that both workspaces have the same masked spectra

Expand Down Expand Up @@ -497,7 +495,7 @@ def execute(self, reducer, workspace):
else:
logger.notice("Normalization step did not get a valid normalization option: skipping")
return "Normalization step did not get a valid normalization option: skipping"

def clean(self):
DeleteWorkspace(Workspace=norm_ws)

Expand Down Expand Up @@ -694,7 +692,7 @@ def execute(self, reducer, workspace):
ReductionProperties=reducer.get_reduction_table_name(),
OutputSensitivityWorkspace=self._efficiency_ws
)
return outputs[2] # message
return outputs[-1] # message is last output

class Mask(ReductionStep):
"""
Expand Down

0 comments on commit 033d971

Please sign in to comment.