Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
faec9b26
Commit
faec9b26
authored
9 years ago
by
Marina Ganeva
Browse files
Options
Downloads
Patches
Plain Diff
Member wsNames removed.
parent
0ae726e1
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py
+15
-14
15 additions, 14 deletions
...ork/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py
with
15 additions
and
14 deletions
Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py
+
15
−
14
View file @
faec9b26
...
@@ -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
.
wsNam
es
.
extend
(
wks
.
getNames
())
input_workspac
es
.
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
.
ws
N
ames
,
self
.
mandatory_properties
,
self
.
log
())
mlzutils
.
compare_mandatory
(
ws
n
ames
,
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
.
ws
N
ames
)
self
.
timingsMatch
(
ws
n
ames
)
# Check sample logs for must have properties
# Check sample logs for must have properties
for
wsname
in
self
.
ws
N
ames
:
for
wsname
in
ws
n
ames
:
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
.
ws
N
ames
[
0
])
ws1
=
api
.
AnalysisDataService
.
retrieve
(
ws
n
ames
[
0
])
run1
=
ws1
.
getRun
()
run1
=
ws1
.
getRun
()
for
wsname
in
self
.
ws
N
ames
[
1
:]:
for
wsname
in
ws
n
ames
[
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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment