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
2381e2f3
Commit
2381e2f3
authored
10 years ago
by
Dan Nixon
Browse files
Options
Downloads
Patches
Plain Diff
Added Vesuvio resolution algorithm
Refs #10346
parent
4dfd2a81
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Mantid/Framework/PythonInterface/plugins/algorithms/VesuvioResolution.py
+78
-0
78 additions, 0 deletions
...k/PythonInterface/plugins/algorithms/VesuvioResolution.py
with
78 additions
and
0 deletions
Code/Mantid/Framework/PythonInterface/plugins/algorithms/VesuvioResolution.py
0 → 100644
+
78
−
0
View file @
2381e2f3
from
mantid.simpleapi
import
*
from
mantid.api
import
*
from
mantid.kernel
import
*
import
mantid
class
VesuvioResolution
(
PythonAlgorithm
):
def
category
(
self
):
return
'
Inelastic
'
def
summary
(
self
):
return
'
Calculates the resolution function for VESUVIO
'
def
PyInit
(
self
):
self
.
declareProperty
(
WorkspaceProperty
(
name
=
'
Sample
'
,
defaultValue
=
''
,
direction
=
Direction
.
Input
),
doc
=
'
Sample workspace
'
)
self
.
declareProperty
(
name
=
'
SpectraIndex
'
,
defaultValue
=
0
,
doc
=
'
Spectra index to use for resolution
'
)
self
.
declareProperty
(
name
=
'
Mass
'
,
defaultValue
=
100.0
,
doc
=
'
The mass defining the recoil peak in AMU
'
)
self
.
declareProperty
(
name
=
'
OutputMode
'
,
defaultValue
=
'
TOF
'
,
validator
=
StringListValidator
([
'
TOF
'
,
'
y-Space
'
]),
doc
=
''
)
self
.
declareProperty
(
WorkspaceProperty
(
name
=
'
OutputWorkspace
'
,
defaultValue
=
''
,
direction
=
Direction
.
Output
),
doc
=
'
Output resolution workspace
'
)
def
PyExec
(
self
):
sample_ws
=
self
.
getPropertyValue
(
'
Sample
'
)
out_ws
=
self
.
getPropertyValue
(
'
OutputWorkspace
'
)
spectrum_index
=
self
.
getProperty
(
'
SpectraIndex
'
).
value
mass
=
self
.
getProperty
(
'
Mass
'
).
value
output_mode
=
self
.
getPropertyValue
(
'
OutputMode
'
)
function
=
'
name=VesuvioResolution, Mass=%f
'
%
mass
fit_naming_stem
=
'
__vesuvio_res_fit
'
# Execute the resolution function using fit.
# Functions can't currently be executed as stand alone objects,
# so for now we will run fit with zero iterations to achieve the same result.
fit
=
mantid
.
api
.
AlgorithmManager
.
createUnmanaged
(
'
Fit
'
)
fit
.
initialize
()
fit
.
setChild
(
True
)
fit
.
setLogging
(
False
)
mantid
.
simpleapi
.
_set_properties
(
fit
,
function
,
sample_ws
,
MaxIterations
=
0
,
CreateOutput
=
True
,
Output
=
fit_naming_stem
,
WorkspaceIndex
=
spectrum_index
,
OutputCompositeMembers
=
True
)
fit
.
execute
()
fit_ws
=
fit
.
getProperty
(
"
OutputWorkspace
"
).
value
# Extract just the function values from the fit spectrum
extract
=
mantid
.
api
.
AlgorithmManager
.
createUnmanaged
(
'
ExtractSingleSpectrum
'
)
extract
.
initialize
()
extract
.
setChild
(
True
)
extract
.
setLogging
(
False
)
extract
.
setProperty
(
"
InputWorkspace
"
,
fit_ws
)
extract
.
setProperty
(
"
OutputWorkspace
"
,
out_ws
)
extract
.
setProperty
(
"
WorkspaceIndex
"
,
1
)
extract
.
execute
()
out_ws
=
extract
.
getProperty
(
'
OutputWorkspace
'
).
value
# Convert to y-Space if needed
if
output_mode
==
'
y-Space
'
:
pass
self
.
setProperty
(
'
OutputWorkspace
'
,
out_ws
)
AlgorithmFactory
.
subscribe
(
VesuvioResolution
)
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