Skip to content

Commit

Permalink
Re #6516 Make sure output data is saved properly
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed May 7, 2013
1 parent 318e527 commit e0335ed
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ def _py_exec(self):
alg.setProperty("ReductionProperties", property_manager_name)
alg.execute()
if alg.existsProperty("OutputMessage"):
output_msg += alg.getProperty("OutputMessage").value
output_msg += alg.getProperty("OutputMessage").value+'\n'

# Compute I(qx,qy)
iqxy_output = None
Expand All @@ -249,16 +249,28 @@ def _py_exec(self):
alg.setProperty("ReductionProperties", property_manager_name)
alg.execute()
if alg.existsProperty("OutputMessage"):
output_msg += alg.getProperty("OutputMessage").value
output_msg += alg.getProperty("OutputMessage").value+'\n'

# Verify output directory and save data
if "OutputDirectory" in property_list:
output_dir = property_manager.getProperty("OutputDirectory").value
#if len(output_dir)==0:
# output_dir = os.path.dirname(filename)
if os.path.isdir(output_dir):
output_msg += self._save_output(iq_output, iqxy_output,
output_dir, property_manager)
# Check whether we were in frame-skipping mode
if iq_output is not None \
and not AnalysisDataService.doesExist(iq_output):
for i in [1, 2]:
iq_frame = iq_output.replace('_Iq', '_frame%s_Iq' % i)
iqxy_frame = None
if iqxy_output is not None:
iqxy_frame = iqxy_output.replace('_Iqxy', '_frame%s_Iqxy' % i)
if AnalysisDataService.doesExist(iq_frame):
output_msg += self._save_output(iq_frame, iqxy_frame,
output_dir, property_manager)
else:
output_msg += self._save_output(iq_output, iqxy_output,
output_dir, property_manager)
Logger.get("SANSReduction").notice("Output saved in %s" % output_dir)
elif len(output_dir)>0:
msg = "Output directory doesn't exist: %s\n" % output_dir
Expand Down Expand Up @@ -415,7 +427,14 @@ def _save_output(self, iq_output, iqxy_output, output_dir, property_manager):
alg.setProperty("Filename", filename)
alg.setProperty("InputWorkspace", iqxy_output)
alg.execute()
#api.SaveNISTDAT(InputWorkspace=iqxy_output, Filename=filename)

filename = os.path.join(output_dir, iqxy_output+'.nxs')
alg = AlgorithmManager.create("SaveNexus")
alg.initialize()
alg.setChild(True)
alg.setProperty("Filename", filename)
alg.setProperty("InputWorkspace", iqxy_output)
alg.execute()
output_msg += "I(Qx,Qy) saved in %s\n" % (filename)
else:
Logger.get("SANSReduction").error("No I(Qx,Qy) output found")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from scripter import BaseScriptElement
from mantid.api import AnalysisDataService

# Check whether we are running in MantidPlot
IS_IN_MANTIDPLOT = False
Expand All @@ -24,8 +25,17 @@ def update(self):
from reduction_workflow.command_interface import ReductionSingleton
self.log_text = ReductionSingleton().log_text
try:
if hasattr(ReductionSingleton(), "output_workspaces"):
if hasattr(ReductionSingleton(), "output_workspaces") \
and len(ReductionSingleton().output_workspaces)>0:
for item in ReductionSingleton().output_workspaces:
mantidplot.plotSpectrum(item, 0, True)
else:
iq_plots = []
for item in ReductionSingleton()._data_files.keys():
for ws in AnalysisDataService.Instance().getObjectNames():
if ws.startswith(item) and ws.endswith('_Iq'):
iq_plots.append(ws)
if len(iq_plots)>0:
mantidplot.plotSpectrum(iq_plots, 0, True)
except:
raise RuntimeError, "Could not plot resulting output\n %s" % sys.exc_value

0 comments on commit e0335ed

Please sign in to comment.