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
122bc517
Commit
122bc517
authored
9 years ago
by
Marina Ganeva
Browse files
Options
Downloads
Patches
Plain Diff
Checking code has been moved to the validateInputs.
parent
a21cce60
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py
+19
-16
19 additions, 16 deletions
...PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py
with
19 additions
and
16 deletions
Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py
+
19
−
16
View file @
122bc517
...
...
@@ -35,29 +35,32 @@ class TOFTOFCropWorkspace(PythonAlgorithm):
doc
=
"
Name of the workspace that will contain the results
"
)
return
def
validateInputs
(
self
):
issues
=
dict
()
input_workspace
=
self
.
getProperty
(
"
InputWorkspace
"
).
value
xunit
=
input_workspace
.
getAxis
(
0
).
getUnit
().
unitID
()
if
xunit
!=
'
TOF
'
:
issues
[
'
InputWorkspace
'
]
=
"
X axis units must be TOF.
"
# check for required properties
run
=
input_workspace
.
getRun
()
if
not
run
.
hasProperty
(
'
channel_width
'
):
issues
[
'
InputWorkspace
'
]
=
"
Input workpsace must have sample log channel_width.
"
if
not
run
.
hasProperty
(
'
full_channels
'
):
issues
[
'
InputWorkspace
'
]
=
"
Input workpsace must have sample log full_channels.
"
return
issues
def
PyExec
(
self
):
"""
Main execution body
"""
inputws
=
self
.
getProperty
(
"
InputWorkspace
"
).
value
# check X units, will be not needed if validator will work
xunit
=
inputws
.
getAxis
(
0
).
getUnit
().
unitID
()
if
xunit
!=
'
TOF
'
:
message
=
"
Workspace
"
+
inputws
.
getName
()
+
"
has invalid X axis units
"
+
str
(
xunit
)
+
\
"
. X axis units must be TOF.
"
self
.
log
().
error
(
message
)
raise
ValueError
(
message
)
outputws
=
self
.
getProperty
(
"
OutputWorkspace
"
).
value
# check for required properties
run
=
inputws
.
getRun
()
if
run
.
hasProperty
(
'
channel_width
'
)
and
run
.
hasProperty
(
'
full_channels
'
):
channel_width
=
float
(
run
.
getLogData
(
'
channel_width
'
).
value
)
full_channels
=
float
(
run
.
getLogData
(
'
full_channels
'
).
value
)
else
:
message
=
"
Workspace
"
+
inputws
.
getName
()
+
"
does not contain required sample logs. Cannot crop.
"
self
.
log
().
error
(
"
message
"
)
raise
RuntimeError
(
message
)
channel_width
=
float
(
run
.
getLogData
(
'
channel_width
'
).
value
)
full_channels
=
float
(
run
.
getLogData
(
'
full_channels
'
).
value
)
outputws
=
api
.
CropWorkspace
(
inputws
,
XMin
=
0.
,
XMax
=
full_channels
*
channel_width
,
OutputWorkspace
=
outputws
)
self
.
setProperty
(
"
OutputWorkspace
"
,
outputws
)
...
...
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