Skip to content

Commit

Permalink
Re #6516 ghost conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
mdoucet committed May 7, 2013
2 parents 3d7fadf + cc0e2b8 commit fdf4bf1
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def _load_data(filename, output_ws):
monitor = 0.0
timer = 0.0
for i in range(len(data_file)):
output_str += "Loaded %s\n" % data_file[i]
if i==0:
output_str += _load_data(data_file[i], workspace)
else:
Expand Down Expand Up @@ -250,7 +249,7 @@ def PyExec(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 @@ -265,7 +264,7 @@ def PyExec(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:
Expand Down
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
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def to_script(self, file_name=None):
"""
script = "# %s reduction script\n" % self.instrument_name
script += "# Script automatically generated on %s\n\n" % time.ctime(time.time())

for item in self._observers:
if item.state() is not None:
script += str(item.state())
Expand Down Expand Up @@ -528,4 +528,4 @@ def _write_submission_script(self, file_path):
fd = open(file_path, 'w')
fd.write(content)
fd.close()


This file was deleted.

5 changes: 0 additions & 5 deletions Code/Mantid/scripts/Interface/templates/scripter_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ def to_script(self, file_name=None):
script = "# Reduction script\n"
script += "# Script automatically generated on %s\n\n" % time.ctime(time.time())

script += "from MantidFramework import *\n"
script += "mtd.initialise(False)\n"
script += "from mantidsimple import *"
script += "\n"

# The following code translates each panel/tab into python script
for item in self._observers:
if item.state() is not None:
Expand Down

0 comments on commit fdf4bf1

Please sign in to comment.