Skip to content
Snippets Groups Projects
Commit faec9b26 authored by Marina Ganeva's avatar Marina Ganeva
Browse files

Member wsNames removed.

parent 0ae726e1
No related merge requests found
...@@ -20,7 +20,6 @@ class TOFTOFMergeRuns(PythonAlgorithm): ...@@ -20,7 +20,6 @@ class TOFTOFMergeRuns(PythonAlgorithm):
Init Init
""" """
PythonAlgorithm.__init__(self) PythonAlgorithm.__init__(self)
self.wsNames = []
def category(self): def category(self):
""" Return category """ Return category
...@@ -54,6 +53,7 @@ class TOFTOFMergeRuns(PythonAlgorithm): ...@@ -54,6 +53,7 @@ class TOFTOFMergeRuns(PythonAlgorithm):
""" """
workspaces = self.getProperty("InputWorkspaces").value workspaces = self.getProperty("InputWorkspaces").value
mlzutils.ws_exist(workspaces, self.log()) mlzutils.ws_exist(workspaces, self.log())
input_workspaces = []
if len(workspaces) < 1: if len(workspaces) < 1:
message = "List of workspaces is empty. Nothing to merge." message = "List of workspaces is empty. Nothing to merge."
self.log().error(message) self.log().error(message)
...@@ -61,23 +61,24 @@ class TOFTOFMergeRuns(PythonAlgorithm): ...@@ -61,23 +61,24 @@ class TOFTOFMergeRuns(PythonAlgorithm):
for wsname in workspaces: for wsname in workspaces:
wks = api.AnalysisDataService.retrieve(wsname) wks = api.AnalysisDataService.retrieve(wsname)
if isinstance(wks, WorkspaceGroup): if isinstance(wks, WorkspaceGroup):
self.wsNames.extend(wks.getNames()) input_workspaces.extend(wks.getNames())
else: else:
self.wsNames.append(wsname) input_workspaces.append(wsname)
return input_workspaces
def _can_merge(self): def _can_merge(self, wsnames):
""" """
Checks whether given workspaces can be merged Checks whether given workspaces can be merged
""" """
# mandatory properties must be identical # mandatory properties must be identical
mlzutils.compare_mandatory(self.wsNames, self.mandatory_properties, self.log()) mlzutils.compare_mandatory(wsnames, self.mandatory_properties, self.log())
# timing (x-axis binning) must match # timing (x-axis binning) must match
# is it possible to use WorkspaceHelpers::matchingBins from python? # is it possible to use WorkspaceHelpers::matchingBins from python?
self.timingsMatch(self.wsNames) self.timingsMatch(wsnames)
# Check sample logs for must have properties # Check sample logs for must have properties
for wsname in self.wsNames: for wsname in wsnames:
wks = api.AnalysisDataService.retrieve(wsname) wks = api.AnalysisDataService.retrieve(wsname)
run = wks.getRun() run = wks.getRun()
for prop in self.must_have_properties: for prop in self.must_have_properties:
...@@ -88,9 +89,9 @@ class TOFTOFMergeRuns(PythonAlgorithm): ...@@ -88,9 +89,9 @@ class TOFTOFMergeRuns(PythonAlgorithm):
raise RuntimeError(message) raise RuntimeError(message)
# warnig if optional properties are not identical must be given # warnig if optional properties are not identical must be given
ws1 = api.AnalysisDataService.retrieve(self.wsNames[0]) ws1 = api.AnalysisDataService.retrieve(wsnames[0])
run1 = ws1.getRun() run1 = ws1.getRun()
for wsname in self.wsNames[1:]: for wsname in wsnames[1:]:
wks = api.AnalysisDataService.retrieve(wsname) wks = api.AnalysisDataService.retrieve(wsname)
run = wks.getRun() run = wks.getRun()
mlzutils.compare_properties(run1, run, self.optional_properties, self.log(), tolerance=0.01) mlzutils.compare_properties(run1, run, self.optional_properties, self.log(), tolerance=0.01)
...@@ -100,8 +101,8 @@ class TOFTOFMergeRuns(PythonAlgorithm): ...@@ -100,8 +101,8 @@ class TOFTOFMergeRuns(PythonAlgorithm):
""" Main execution body """ Main execution body
""" """
# get list of input workspaces # get list of input workspaces
self._validate_input() input_workspace_list = self._validate_input()
workspaceCount = len(self.wsNames) workspaceCount = len(input_workspace_list)
self.log().information("Workspaces to merge " + str(workspaceCount)) self.log().information("Workspaces to merge " + str(workspaceCount))
wsOutput = self.getPropertyValue("OutputWorkspace") wsOutput = self.getPropertyValue("OutputWorkspace")
...@@ -111,14 +112,14 @@ class TOFTOFMergeRuns(PythonAlgorithm): ...@@ -111,14 +112,14 @@ class TOFTOFMergeRuns(PythonAlgorithm):
return return
# check whether given workspaces can be merged # check whether given workspaces can be merged
self._can_merge() self._can_merge(input_workspace_list)
# delete output workspace if it exists # delete output workspace if it exists
if api.mtd.doesExist(wsOutput): if api.mtd.doesExist(wsOutput):
api.DeleteWorkspace(Workspace=wsOutput) api.DeleteWorkspace(Workspace=wsOutput)
# Merge runs # Merge runs
api.MergeRuns(InputWorkspaces=self.wsNames, OutputWorkspace=wsOutput) api.MergeRuns(InputWorkspaces=input_workspace_list, OutputWorkspace=wsOutput)
# Merge logs # Merge logs
# MergeRuns by default copies all logs from the first workspace # MergeRuns by default copies all logs from the first workspace
...@@ -126,7 +127,7 @@ class TOFTOFMergeRuns(PythonAlgorithm): ...@@ -126,7 +127,7 @@ class TOFTOFMergeRuns(PythonAlgorithm):
for prop in self.properties_to_merge: for prop in self.properties_to_merge:
pdict[prop] = [] pdict[prop] = []
for wsname in self.wsNames: for wsname in input_workspace_list:
wks = api.AnalysisDataService.retrieve(wsname) wks = api.AnalysisDataService.retrieve(wsname)
run = wks.getRun() run = wks.getRun()
for prop in self.properties_to_merge: for prop in self.properties_to_merge:
......
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