Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for NeXus files in LoadVesuvio #18884

Merged
merged 9 commits into from Feb 23, 2017
43 changes: 18 additions & 25 deletions Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py
Expand Up @@ -37,7 +37,6 @@ class LoadVesuvio(LoadEmptyVesuvio):
_ws_index = None
_spectrum_no = None
foil_map = None
_inst_prefix = None
_back_scattering = None
_load_common_called = False
_load_monitors = False
Expand Down Expand Up @@ -324,12 +323,9 @@ def _exec_single_foil_state_mode(self):
self._setup_raw(all_spectra)
else:
isis = config.getFacility("ISIS")
inst_prefix = isis.instrument("VESUVIO").shortName()

try:
run_str = inst_prefix + runs[0] +'.raw'
except ValueError:
run_str = runs[0]
vesuvio = isis.instrument("VESUVIO")
run_no = runs[0]
run_str = vesuvio.filePrefix(int(run_no)) + run_no

self._raise_error_period_scatter(run_str, self._back_scattering)
all_spectra = [item for sublist in self._spectra for item in sublist]
Expand Down Expand Up @@ -406,7 +402,7 @@ def _exec_single_foil_state_mode(self):
if self._sumspectra:
self._sum_all_spectra()

ms.DeleteWorkspace(Workspace=SUMMED_WS)
ms.DeleteWorkspace(Workspace=SUMMED_WS, EnableLogging=_LOGGING_)
self._store_results()
self._cleanup_raw()

Expand All @@ -423,13 +419,13 @@ def _load_single_run_spec_and_mon(self, all_spectra, run_str):
logger.warning("LoadMonitors is true while monitor spectra are defined in the spectra list.")
logger.warning("Monitors have been loaded into the data workspace not separately.")
if mons_in_ws:
ms.LoadRaw(Filename=run_str, OutputWorkspace=SUMMED_WS, SpectrumList=all_spectra,
EnableLogging=_LOGGING_)
ms.Load(Filename=run_str, OutputWorkspace=SUMMED_WS, SpectrumList=all_spectra,
EnableLogging=_LOGGING_)
else:
all_spec_inc_mon = self._mon_spectra
all_spec_inc_mon.extend(all_spectra)
ms.LoadRaw(Filename=run_str, OutputWorkspace=SUMMED_WS, SpectrumList=all_spec_inc_mon,
LoadMonitors='Separate', EnableLogging=_LOGGING_)
ms.Load(Filename=run_str, OutputWorkspace=SUMMED_WS, SpectrumList=all_spec_inc_mon,
LoadMonitors='Separate', EnableLogging=_LOGGING_)
if self._load_monitors:
monitor_group = mtd[SUMMED_WS +'_monitors']
mon_out_name = self.getPropertyValue(WKSP_PROP) + "_monitors"
Expand All @@ -441,6 +437,7 @@ def _load_single_run_spec_and_mon(self, all_spectra, run_str):
self._load_monitors_workspace = self._sum_monitors_in_group(monitor_group,
self._load_monitors_workspace)
self._raw_monitors = mtd[SUMMED_WS +'_monitors']

#----------------------------------------------------------------------------------------

def _load_common_inst_parameters(self):
Expand All @@ -451,7 +448,6 @@ def _load_common_inst_parameters(self):
if self._load_common_called:
return

isis = config.getFacility("ISIS")
empty_vesuvio_ws = self._load_empty_evs()
empty_vesuvio = empty_vesuvio_ws.getInstrument()

Expand All @@ -461,7 +457,6 @@ def to_int_list(str_param):
return list(range(int(elements[0]),int(elements[1]) + 1)) # range goes x_l,x_h-1

# Attach parameters as attributes
self._inst_prefix = isis.instrument("VESUVIO").shortName()
parnames = empty_vesuvio.getParameterNames(False)
for name in parnames:
# Irritating parameter access doesn't let you query the type
Expand Down Expand Up @@ -585,28 +580,26 @@ def _load_and_sum_runs(self, spectra):
@returns a tuple of length 2 containing (main_detector_ws, monitor_ws)
"""
isis = config.getFacility("ISIS")
inst_prefix = isis.instrument("VESUVIO").shortName()

vesuvio = isis.instrument("VESUVIO")
runs = self._get_runs()

self.summed_ws, self.summed_mon = "__loadraw_evs", "__loadraw_evs_monitors"
spec_inc_mon = self._mon_spectra
spec_inc_mon.extend(spectra)
for index, run in enumerate(runs):
run = inst_prefix + str(run)
self._raise_error_period_scatter(run, self._back_scattering)
filename = vesuvio.filePrefix(int(run)) + str(run)
self._raise_error_period_scatter(filename, self._back_scattering)
if index == 0:
out_name, out_mon = SUMMED_WS, SUMMED_WS + '_monitors'
else:
out_name, out_mon = SUMMED_WS + 'tmp', SUMMED_WS + 'tmp_monitors'

# Load data
raw_filepath = FileFinder.findRuns(run)[0]
ms.LoadRaw(Filename=raw_filepath,
SpectrumList=spec_inc_mon,
OutputWorkspace=out_name,
LoadMonitors='Separate',
EnableLogging=_LOGGING_)
ms.Load(Filename=filename,
SpectrumList=spec_inc_mon,
OutputWorkspace=out_name,
LoadMonitors='Separate',
EnableLogging=_LOGGING_)

# Sum
if index > 0:
Expand Down Expand Up @@ -685,7 +678,7 @@ def _get_runs(self):
runs = list(range(int(lower), int(upper)+1))

elif "," in run_str:
runs = run_str.split(",")
runs = run_str.split(",")
else:
runs = [run_str]

Expand Down
1 change: 1 addition & 0 deletions docs/source/release/v3.10.0/indirect_inelastic.rst
Expand Up @@ -12,6 +12,7 @@ Algorithms
##########

- A new input property *RebinCanToSample* was added to :ref:`ApplyPaalmanPingsCorrection <algm-ApplyPaalmanPingsCorrection>` which enables or disables the rebinning of the empty container workspace.
- :ref:`LoadVesuvio <algm-LoadVesuvio> can now load NeXus files as well as raw files

Data Analysis
#############
Expand Down