From 9622a0d671a3ac1bb915b26f04a7ff552cff6730 Mon Sep 17 00:00:00 2001 From: Alex Buts Date: Thu, 10 Apr 2014 18:23:32 +0100 Subject: [PATCH] refs #9135 Modified ISIS reduction to load monitors separately except special cases (MARI). new parameter in reduction is responsible for this. --- .../instrument/LET_Parameters_dr2to9.xml | 9 ++++++++ Code/Mantid/instrument/MAPS_Parameters.xml | 8 +++++++ Code/Mantid/instrument/MARI_Parameters.xml | 9 ++++++++ Code/Mantid/instrument/MERLIN_Parameters.xml | 10 +++++++++ .../MERLIN_Parameters_after2014_4.xml | 8 +++++++ .../scripts/Inelastic/CommonFunctions.py | 12 ++++++---- .../Inelastic/DirectEnergyConversion.py | 22 +++++++++++++++++-- Code/Mantid/scripts/Inelastic/dgreduce.py | 4 ++-- .../test/DirectEnergyConversionTest.py | 11 ++++++++++ 9 files changed, 85 insertions(+), 8 deletions(-) diff --git a/Code/Mantid/instrument/LET_Parameters_dr2to9.xml b/Code/Mantid/instrument/LET_Parameters_dr2to9.xml index e85b1cf88762..fa496a1221fc 100644 --- a/Code/Mantid/instrument/LET_Parameters_dr2to9.xml +++ b/Code/Mantid/instrument/LET_Parameters_dr2to9.xml @@ -106,6 +106,15 @@ + + + + + + + + diff --git a/Code/Mantid/instrument/MARI_Parameters.xml b/Code/Mantid/instrument/MARI_Parameters.xml index 7d7f491cf134..4a8404e9d0a6 100644 --- a/Code/Mantid/instrument/MARI_Parameters.xml +++ b/Code/Mantid/instrument/MARI_Parameters.xml @@ -64,6 +64,15 @@ + + + + + diff --git a/Code/Mantid/instrument/MERLIN_Parameters.xml b/Code/Mantid/instrument/MERLIN_Parameters.xml index 378bacdd1b7d..a88527127451 100644 --- a/Code/Mantid/instrument/MERLIN_Parameters.xml +++ b/Code/Mantid/instrument/MERLIN_Parameters.xml @@ -65,6 +65,16 @@ + + + + + + diff --git a/Code/Mantid/instrument/MERLIN_Parameters_after2014_4.xml b/Code/Mantid/instrument/MERLIN_Parameters_after2014_4.xml index 96f6548b2861..8536409cf83a 100644 --- a/Code/Mantid/instrument/MERLIN_Parameters_after2014_4.xml +++ b/Code/Mantid/instrument/MERLIN_Parameters_after2014_4.xml @@ -87,6 +87,14 @@ + + + + diff --git a/Code/Mantid/scripts/Inelastic/CommonFunctions.py b/Code/Mantid/scripts/Inelastic/CommonFunctions.py index 05171956a3e3..bf0bda852312 100644 --- a/Code/Mantid/scripts/Inelastic/CommonFunctions.py +++ b/Code/Mantid/scripts/Inelastic/CommonFunctions.py @@ -70,7 +70,7 @@ def mark_as_loaded(filename): logger.notice("Marking %s as loaded." % filename) _loaded_data.append(data_name) -def load_runs(inst_name, runs, sum=True, calibration=None): +def load_runs(inst_name, runs, sum=True, calibration=None,load_with_workspace=False): """ Loads a list of files, summing if the required. """ @@ -96,9 +96,9 @@ def load_runs(inst_name, runs, sum=True, calibration=None): return loaded else: # Try a single run - return load_run(inst_name, runs, calibration) + return load_run(inst_name, runs, calibration,False,load_with_workspace) -def load_run(inst_name, run_number, calibration=None, force=False): +def load_run(inst_name, run_number, calibration=None, force=False, load_with_workspace=False): """Loads run into the given workspace. If force is true then the file is loaded regardless of whether @@ -134,7 +134,11 @@ def load_run(inst_name, run_number, calibration=None, force=False): ext = os.path.splitext(filename)[1].lower(); wrong_monitors_name = False; if ext.endswith("raw"): - args['LoadMonitors']='Include' + if load_with_workspace: + args['LoadMonitors']='Include' + else: + args['LoadMonitors']='Separate' + elif ext.endswith('nxs'): args['LoadMonitors'] = '1' diff --git a/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py b/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py index 7757ca7d83c8..5e8b691eddc9 100644 --- a/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py +++ b/Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py @@ -830,8 +830,8 @@ def load_data(self, runs,new_ws_name=None,keep_previous_ws=False): # this can be a workspace too calibration = self.det_cal_file; - - result_ws = common.load_runs(self.instr_name, runs, calibration=calibration, sum=True) + monitors_inWS=self.load_monitors_with_workspace + result_ws = common.load_runs(self.instr_name, runs, calibration=calibration, sum=True,load_with_workspace=monitors_inWS) mon_WsName = result_ws.getName()+'_monitors' if mon_WsName in mtd: @@ -918,6 +918,24 @@ def __init__(self, instr_name=None): #---------------------------------------------------------------------------------- # Complex setters/getters #---------------------------------------------------------------------------------- + @property + def load_monitors_with_workspace(self): + if hasattr(self,'_load_monitors_with_workspace'): + return self._load_monitors_with_workspace; + else: + return False; + @load_monitors_with_workspace.setter + def load_monitors_with_workspace(self,val): + try: + if val>0: + do_load=True; + else: + do_load=False; + except ValueError: + do_load=False; + + setattr(self,'_load_monitors_with_workspace',do_load); + @property def ei_mon_spectra(self): diff --git a/Code/Mantid/scripts/Inelastic/dgreduce.py b/Code/Mantid/scripts/Inelastic/dgreduce.py index 92c289aa2faf..e6db76acce9d 100644 --- a/Code/Mantid/scripts/Inelastic/dgreduce.py +++ b/Code/Mantid/scripts/Inelastic/dgreduce.py @@ -705,7 +705,7 @@ def sum_files(inst_name, accumulator, files): for filename in files: print 'Summing run ',filename,' to workspace ',accumulator - temp = common.load_run(inst_name,filename, force=False) + temp = common.load_run(inst_name,filename, force=False,load_with_workspace=Reducer.load_monitors_with_workspace) if accum_name in mtd: # add current workspace to the existing one if not isinstance(accumulator,api.Workspace): @@ -718,7 +718,7 @@ def sum_files(inst_name, accumulator, files): return accumulator else: - temp = common.load_run(inst_name,files, force=False) + temp = common.load_run(inst_name,files, force=False,load_with_workspace=Reducer.load_monitors_with_workspace) accumulator=RenameWorkspace(InputWorkspace=temp,OutputWorkspace=accum_name) return accumulator; diff --git a/Code/Mantid/scripts/test/DirectEnergyConversionTest.py b/Code/Mantid/scripts/test/DirectEnergyConversionTest.py index 765ad7c6c3e8..90a68bff2992 100644 --- a/Code/Mantid/scripts/test/DirectEnergyConversionTest.py +++ b/Code/Mantid/scripts/test/DirectEnergyConversionTest.py @@ -360,6 +360,17 @@ def test_set_get_ei_monitor(self): self.assertEqual(41474,tReducer.ei_mon_spectra[0]) self.assertEqual(41475,tReducer.ei_mon_spectra[1]) + def test_load_monitors_with_workspacer(self): + tReducer =self.reducer; + + self.assertFalse(tReducer.load_monitors_with_workspace) + + tReducer.load_monitors_with_workspace=True; + self.assertTrue(tReducer.load_monitors_with_workspace) + tReducer.load_monitors_with_workspace=0; + self.assertFalse(tReducer.load_monitors_with_workspace) + tReducer.load_monitors_with_workspace=10; + self.assertTrue(tReducer.load_monitors_with_workspace) #def test_diag_call(self): # tReducer = self.reducer