diff --git a/Code/Mantid/scripts/Interface/reduction_application.py b/Code/Mantid/scripts/Interface/reduction_application.py index cd5ec325522ebabe62e078793eabdf4a082f7d58..f7f0b0766c508dd034d11527e77a899d90158b20 100644 --- a/Code/Mantid/scripts/Interface/reduction_application.py +++ b/Code/Mantid/scripts/Interface/reduction_application.py @@ -376,18 +376,6 @@ class ReductionGUI(QtGui.QMainWindow, ui.ui_reduction_main.Ui_SANSReduction): Create an object capable of using the information in the interface and turn it into a reduction process. """ - - from mantid import mtd - #remove all previous workspaces - list_mt = mtd.getObjectNames() - for _mt in list_mt: - if _mt.find('_scaled') != -1: - mtd.remove(_mt) - if _mt.find('reflectivity') != -1: - mtd.remove(_mt) - - from mantidsimple import mtd - self.reduce_button.setEnabled(False) self.export_button.setEnabled(False) self.save_button.setEnabled(False) diff --git a/Code/Mantid/scripts/Interface/reduction_gui/instruments/reflectometer_l_interface_dev.py b/Code/Mantid/scripts/Interface/reduction_gui/instruments/reflectometer_l_interface_dev.py index 8072a3063a27f6e29065dd73ea1ca3600e225139..335d07da8d51fea554c77a45160af2dc791ccdaf 100644 --- a/Code/Mantid/scripts/Interface/reduction_gui/instruments/reflectometer_l_interface_dev.py +++ b/Code/Mantid/scripts/Interface/reduction_gui/instruments/reflectometer_l_interface_dev.py @@ -1,6 +1,7 @@ from interface import InstrumentInterface from reduction_gui.widgets.reflectometer.refl_reduction import DataReflWidget +from reduction_gui.reduction.reflectometer.refl_reduction import REFLReductionScripter try: from reduction_gui.widgets.reflectometer.stitcher import StitcherWidget HAS_STITCHER = True @@ -18,6 +19,9 @@ class REFLInterface(InstrumentInterface): self.ERROR_REPORT_NAME = "refl_error_report.xml" self.LAST_REDUCTION_NAME = ".mantid_last_refl_reduction.xml" + # Scripter object to interface with Mantid + self.scripter = REFLReductionScripter(name=name) + # data REF_L tab self.attach(DataReflWidget(settings = self._settings, name=name)) if HAS_STITCHER: diff --git a/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_reduction.py b/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_reduction.py new file mode 100644 index 0000000000000000000000000000000000000000..8338fca03d21bac47eeff437669d2fc1e60aa560 --- /dev/null +++ b/Code/Mantid/scripts/Interface/reduction_gui/reduction/reflectometer/refl_reduction.py @@ -0,0 +1,53 @@ +""" + This class holds all the necessary information to create a reduction script. +""" +import time +import os +from reduction_gui.reduction.scripter import BaseReductionScripter + +class REFLReductionScripter(BaseReductionScripter): + """ + Reduction scripter for REFL + """ + + def __init__(self, name="REFL"): + super(REFLReductionScripter, self).__init__(name=name) + + def to_script(self, file_name=None): + """ + Spits out the text of a reduction script with the current state. + @param file_name: name of the file to write the script to + """ + """ + Spits out the text of a reduction script with the current state. + @param file_name: name of the file to write the script to + """ + script = "# %s reduction script\n" % self.instrument_name + 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 *\n\n" + script += "\n" + script += "#remove all previous workspaces\n" + script += "list_mt = mtd.getWorkspaceNames()\n" + script += "for _mt in list_mt:\n" + script += " if _mt.find('_scaled') != -1:\n" + script += " mtd.remove(_mt)\n" + script += " if _mt.find('reflectivity') != -1:\n" + script += " mtd.remove(_mt)\n" + script += "\n" + + for item in self._observers: + if item.state() is not None: + script += str(item.state()) + + if file_name is not None: + f = open(file_name, 'w') + f.write(script) + f.close() + + return script + + + \ No newline at end of file