Skip to content
Snippets Groups Projects
Commit 04850067 authored by Raquel Alvarez's avatar Raquel Alvarez
Browse files

Merge pull request #13930 from mantidproject/13928_better_failure_messages_in_LoadVesuvio

Add additional property validation to LoadVesuvio
parents d996b9a7 0f7191cc
No related branches found
No related tags found
No related merge requests found
...@@ -132,6 +132,20 @@ class LoadVesuvio(LoadEmptyVesuvio): ...@@ -132,6 +132,20 @@ class LoadVesuvio(LoadEmptyVesuvio):
else: else:
self._exec_single_foil_state_mode() self._exec_single_foil_state_mode()
#----------------------------------------------------------------------------------------
def validateInputs(self):
issues = {}
# Validtae run number ranges
run_str = self.getProperty(RUN_PROP).value
if "-" in run_str:
lower, upper = run_str.split("-")
if upper < lower:
issues[RUN_PROP] = "Range must be in format lower-upper"
return issues
#---------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------
def _exec_difference_mode(self): def _exec_difference_mode(self):
...@@ -346,24 +360,42 @@ class LoadVesuvio(LoadEmptyVesuvio): ...@@ -346,24 +360,42 @@ class LoadVesuvio(LoadEmptyVesuvio):
if index == 0: if index == 0:
out_name, out_mon = SUMMED_WS, SUMMED_MON out_name, out_mon = SUMMED_WS, SUMMED_MON
else: else:
out_name, out_mon = SUMMED_WS+'tmp', SUMMED_MON + 'tmp' out_name, out_mon = SUMMED_WS + 'tmp', SUMMED_MON + 'tmp'
# Load data # Load data
ms.LoadRaw(Filename=run, SpectrumList=spectra, ms.LoadRaw(Filename=run,
OutputWorkspace=out_name, LoadMonitors='Exclude',EnableLogging=_LOGGING_) SpectrumList=spectra,
ms.LoadRaw(Filename=run,SpectrumList=self._mon_spectra, OutputWorkspace=out_name,
OutputWorkspace=out_mon,EnableLogging=_LOGGING_) LoadMonitors='Exclude',
if index > 0: # sum EnableLogging=_LOGGING_)
ms.Plus(LHSWorkspace=SUMMED_WS, RHSWorkspace=out_name, ms.LoadRaw(Filename=run,
OutputWorkspace=SUMMED_WS,EnableLogging=_LOGGING_) SpectrumList=self._mon_spectra,
ms.Plus(LHSWorkspace=SUMMED_MON, RHSWorkspace=out_mon, OutputWorkspace=out_mon,
OutputWorkspace=SUMMED_MON,EnableLogging=_LOGGING_) EnableLogging=_LOGGING_)
ms.DeleteWorkspace(out_name,EnableLogging=_LOGGING_)
ms.DeleteWorkspace(out_mon,EnableLogging=_LOGGING_) # Sum
if index > 0:
ms.CropWorkspace(Inputworkspace= SUMMED_WS, OutputWorkspace= SUMMED_WS, ms.Plus(LHSWorkspace=SUMMED_WS,
XMax=self._tof_max,EnableLogging=_LOGGING_) RHSWorkspace=out_name,
ms.CropWorkspace(Inputworkspace= SUMMED_MON, OutputWorkspace= SUMMED_MON, OutputWorkspace=SUMMED_WS,
XMax=self._mon_tof_max, EnableLogging=_LOGGING_) EnableLogging=_LOGGING_)
ms.Plus(LHSWorkspace=SUMMED_MON,
RHSWorkspace=out_mon,
OutputWorkspace=SUMMED_MON,
EnableLogging=_LOGGING_)
ms.DeleteWorkspace(out_name, EnableLogging=_LOGGING_)
ms.DeleteWorkspace(out_mon, EnableLogging=_LOGGING_)
ms.CropWorkspace(Inputworkspace= SUMMED_WS,
OutputWorkspace=SUMMED_WS,
XMax=self._tof_max,
EnableLogging=_LOGGING_)
ms.CropWorkspace(Inputworkspace= SUMMED_MON,
OutputWorkspace=SUMMED_MON,
XMax=self._mon_tof_max,
EnableLogging=_LOGGING_)
return mtd[SUMMED_WS], mtd[SUMMED_MON] return mtd[SUMMED_WS], mtd[SUMMED_MON]
#---------------------------------------------------------------------------------------- #----------------------------------------------------------------------------------------
...@@ -375,9 +407,9 @@ class LoadVesuvio(LoadEmptyVesuvio): ...@@ -375,9 +407,9 @@ class LoadVesuvio(LoadEmptyVesuvio):
run_str = self.getProperty(RUN_PROP).value run_str = self.getProperty(RUN_PROP).value
# Load is not doing the right thing when summing. The numbers don't look correct # Load is not doing the right thing when summing. The numbers don't look correct
if "-" in run_str: if "-" in run_str:
lower,upper = run_str.split("-") lower, upper = run_str.split("-")
# Range goes lower to up-1 but we want to include the last number # Range goes lower to up-1 but we want to include the last number
runs = range(int(lower),int(upper)+1) runs = range(int(lower), int(upper)+1)
elif "," in run_str: elif "," in run_str:
runs = run_str.split(",") runs = run_str.split(",")
......
...@@ -238,6 +238,10 @@ class VesuvioTests(unittest.TestCase): ...@@ -238,6 +238,10 @@ class VesuvioTests(unittest.TestCase):
#================== Failure cases ================================ #================== Failure cases ================================
def test_run_range_bad_order_raises_error(self):
self.assertRaises(RuntimeError, ms.LoadVesuvio, Filename="14188-14187",
OutputWorkspace=self.ws_name)
def test_missing_spectra_property_raises_error(self): def test_missing_spectra_property_raises_error(self):
self.assertRaises(RuntimeError, ms.LoadVesuvio, Filename="14188", self.assertRaises(RuntimeError, ms.LoadVesuvio, Filename="14188",
OutputWorkspace=self.ws_name) OutputWorkspace=self.ws_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment