Skip to content

Commit

Permalink
refs #9135 Modified ISIS reduction to load monitors separately
Browse files Browse the repository at this point in the history
except special cases (MARI). new parameter in reduction is responsible for this.
  • Loading branch information
abuts committed Apr 10, 2014
1 parent e2ef4a5 commit 9622a0d
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 8 deletions.
9 changes: 9 additions & 0 deletions Code/Mantid/instrument/LET_Parameters_dr2to9.xml
Expand Up @@ -106,6 +106,15 @@
<value val="wb-integr-min:wb-integr-max"/>
</parameter>

<!-- Usually one wants to avoid loading monitors together with data except in special cases. One of this cases is
MARI which monitors nimbers are in the beginning of the spectra. If one loads them separately,
spectra numbers change and ISIS hard masks (msk) prepared for workspace with monitors become invalid.
This parameter is actual untill Mantid Masking change
-->
<parameter name="load_monitors_with_workspace" type="bool">
<value val="False"/>
</parameter>



<!-- integration range for background tests (in TOF) - composite property
Expand Down
8 changes: 8 additions & 0 deletions Code/Mantid/instrument/MAPS_Parameters.xml
Expand Up @@ -65,6 +65,14 @@
<value val="norm-mon1-min:norm-mon1-max"/>
</parameter>

<!-- Usually one wants to avoid loading monitors together with data except in special cases. One of this cases is
MARI which monitors nimbers are in the beginning of the spectra. If one loads them separately,
spectra numbers change and ISIS hard masks (msk) prepared for workspace with monitors become invalid.
This parameter is actual untill Mantid Masking change
-->
<parameter name="load_monitors_with_workspace" type="bool">
<value val="False"/>
</parameter>

<!-- First spectra number (monitor number) to use when measuring incident energy
Should be spectra with well defined energy peak -->
Expand Down
9 changes: 9 additions & 0 deletions Code/Mantid/instrument/MARI_Parameters.xml
Expand Up @@ -64,6 +64,15 @@
<value val="norm-mon1-min:norm-mon1-max"/>
</parameter>

<!-- Usually one wants to avoid loading monitors together with data except in special cases. One of this cases is
MARI which monitors numbers are in the beginning of the spectra. If one loads them separately,
spectra numbers change and ISIS hard masks (msk) prepared for workspace with monitors become invalid.
This parameter is actual untill Mantid Masking change
-->
<parameter name="load_monitors_with_workspace" type="bool">
<value val="True"/>
</parameter>


<!-- First spectra number (monitor number) to use when measuring incident energy
Should be spectra with well defined energy peak -->
Expand Down
10 changes: 10 additions & 0 deletions Code/Mantid/instrument/MERLIN_Parameters.xml
Expand Up @@ -65,6 +65,16 @@
<value val="norm-mon1-min:norm-mon1-max"/>
</parameter>

<!-- Usually one wants to avoid loading monitors together with data except in special cases. One of this cases is
MARI which monitors nimbers are in the beginning of the spectra. If one loads them separately,
spectra numbers change and ISIS hard masks (msk) prepared for workspace with monitors become invalid.
This parameter is actual untill Mantid Masking change
-->
<parameter name="load_monitors_with_workspace" type="bool">
<value val="False"/>
</parameter>



<!-- First spectra number (monitor number) to use when measuring incident energy
Should be spectra with well defined energy peak -->
Expand Down
8 changes: 8 additions & 0 deletions Code/Mantid/instrument/MERLIN_Parameters_after2014_4.xml
Expand Up @@ -87,6 +87,14 @@
<parameter name="spectra_to_monitors_list" type="string">
<value val="None"/>
</parameter>
<!-- Usually one wants to avoid loading monitors together with data except in special cases. One of this cases is
MARI which monitors nimbers are in the beginning of the spectra. If one loads them separately,
spectra numbers change and ISIS hard masks (msk) prepared for workspace with monitors become invalid.
This parameter is actual untill Mantid Masking change
-->
<parameter name="load_monitors_with_workspace" type="bool">
<value val="False"/>
</parameter>



Expand Down
12 changes: 8 additions & 4 deletions Code/Mantid/scripts/Inelastic/CommonFunctions.py
Expand Up @@ -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.
"""
Expand All @@ -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
Expand Down Expand Up @@ -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'

Expand Down
22 changes: 20 additions & 2 deletions Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py
Expand Up @@ -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:
Expand Down Expand Up @@ -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):

Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/scripts/Inelastic/dgreduce.py
Expand Up @@ -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):
Expand All @@ -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;

Expand Down
11 changes: 11 additions & 0 deletions Code/Mantid/scripts/test/DirectEnergyConversionTest.py
Expand Up @@ -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
Expand Down

0 comments on commit 9622a0d

Please sign in to comment.