Skip to content

Commit

Permalink
refs #8614 Should fix the issue.
Browse files Browse the repository at this point in the history
Though careful checks are needed. (and system tests as well)
  • Loading branch information
abuts committed Dec 12, 2013
1 parent 5f1b228 commit a41f3e4
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
5 changes: 4 additions & 1 deletion Code/Mantid/instrument/LET_Parameters.xml
Expand Up @@ -34,7 +34,10 @@
<value val="LET_rings_123.map"/>
</parameter>


<!-- Parameter describes if nexus data files are written in event mode or not -->
<parameter name="nexus_in_event_mode" type="bool">
<value val = "True"/>
</parameter>


<!-- RunNumber to use for diag instead of the input run number if none - use input run -->
Expand Down
12 changes: 8 additions & 4 deletions Code/Mantid/scripts/Inelastic/CommonFunctions.py
Expand Up @@ -69,7 +69,7 @@ def mark_as_loaded(filename):
logger.notice("Marking %s as loaded." % filename)
_loaded_data.append(data_name)

def load_runs(runs, sum=True):
def load_runs(runs, sum=True,event_mode = False):
"""
Loads a list of files, summing if the required.
"""
Expand All @@ -95,9 +95,10 @@ def load_runs(runs, sum=True):
return loaded
else:
# Try a single run
return load_run(runs)
force = False
return load_run(runs,force,event_mode)

def load_run(run_number, force=False):
def load_run(run_number, force=False,event_mode = False):
"""Loads run into the given workspace.
The AddSampleLog algorithm is used to add a Filename property
Expand Down Expand Up @@ -136,7 +137,10 @@ def load_run(run_number, force=False):
if filename.endswith("_event.nxs"):
LoadEventNexus(Filename=filename, OutputWorkspace=output_name)
elif ext.startswith(".n"):
LoadNexus(Filename=filename,OutputWorkspace=output_name)
if event_mode :
LoadEventNexus(Filename=filename,OutputWorkspace=output_name,LoadMonitors='1')
else:
LoadNexus(Filename=filename,OutputWorkspace=output_name)
elif filename.endswith("_event.dat"):
#load the events
LoadEventPreNexus(EventFilename=filename, OutputWorkspace=output_name)
Expand Down
22 changes: 20 additions & 2 deletions Code/Mantid/scripts/Inelastic/DirectEnergyConversion.py
Expand Up @@ -577,12 +577,25 @@ def get_ei(self, input_ws, resultws_name, ei_guess):
raise TypeError('Unknown option passed to get_ei "%s"' % fix_ei)

self.incident_energy= ei_guess
monitor_ws = input_ws;
if type(monitor_ws) is str:
pws = mtd[monitor_ws]
else:
pws = monitor_ws;
try:
nsp = pws.getSpectrum(int(self.ei_mon_spectra[0]));
except:
monitor_ws = pws.getName()+'_monitors'

# Calculate the incident energy
ei,mon1_peak,mon1_index,tzero = \
GetEi(InputWorkspace=input_ws, Monitor1Spec=int(self.ei_mon_spectra[0]), Monitor2Spec=int(self.ei_mon_spectra[1]),
GetEi(InputWorkspace=monitor_ws, Monitor1Spec=int(self.ei_mon_spectra[0]), Monitor2Spec=int(self.ei_mon_spectra[1]),
EnergyEstimate=ei_guess,FixEi=self.fix_ei)


self.incident_energy = ei
AddSampleLog(Workspace=input_ws,LogName='Ei',LogText=str(ei),LogType='Number')

# Adjust the TOF such that the first monitor peak is at t=0
ChangeBinOffset(InputWorkspace=input_ws,OutputWorkspace= resultws_name,Offset= -float(str(mon1_peak)))
mon1_det = input_ws.getDetector(mon1_index)
Expand Down Expand Up @@ -768,7 +781,12 @@ def load_data(self, runs,new_ws_name=None,keep_previous_ws=False):
Load a run or list of runs. If a list of runs is given then
they are summed into one.
"""
result_ws = common.load_runs(runs, sum=True)
event_mode = False;
if hasattr(self, 'nexus_in_event_mode') and self.nexus_in_event_mode:
event_mode = True;

sum = True
result_ws = common.load_runs(runs, sum,event_mode)
if new_ws_name != None :
if keep_previous_ws:
result_ws = CloneWorkspace(InputWorkspace = result_ws,OutputWorkspace = new_ws_name)
Expand Down

0 comments on commit a41f3e4

Please sign in to comment.