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
a31982f5
Commit
a31982f5
authored
9 years ago
by
Marina Ganeva
Browse files
Options
Downloads
Patches
Plain Diff
Checks whether detector is masked.
parent
d278965a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py
+14
-9
14 additions, 9 deletions
...Interface/plugins/algorithms/ComputeCalibrationCoefVan.py
Framework/PythonInterface/plugins/algorithms/mlzutils.py
+1
-2
1 addition, 2 deletions
Framework/PythonInterface/plugins/algorithms/mlzutils.py
with
15 additions
and
11 deletions
Framework/PythonInterface/plugins/algorithms/ComputeCalibrationCoefVan.py
+
14
−
9
View file @
a31982f5
...
@@ -97,10 +97,16 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
...
@@ -97,10 +97,16 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
dataX
=
self
.
vanaws
.
readX
(
0
)
dataX
=
self
.
vanaws
.
readX
(
0
)
coefY
=
np
.
zeros
(
nhist
)
coefY
=
np
.
zeros
(
nhist
)
coefE
=
np
.
zeros
(
nhist
)
coefE
=
np
.
zeros
(
nhist
)
instrument
=
self
.
vanaws
.
getInstrument
()
detID_offset
=
self
.
get_detID_offset
()
for
idx
in
range
(
nhist
):
for
idx
in
range
(
nhist
):
prog_reporter
.
report
(
"
Setting %dth spectrum
"
%
idx
)
prog_reporter
.
report
(
"
Setting %dth spectrum
"
%
idx
)
dataY
=
self
.
vanaws
.
readY
(
idx
)
dataY
=
self
.
vanaws
.
readY
(
idx
)
if
np
.
max
(
dataY
)
!=
0
:
det
=
instrument
.
getDetector
(
idx
+
detID_offset
)
if
np
.
max
(
dataY
)
==
0
or
det
.
isMasked
():
coefY
[
idx
]
=
0.
coefE
[
idx
]
=
0.
else
:
dataE
=
self
.
vanaws
.
readE
(
idx
)
dataE
=
self
.
vanaws
.
readE
(
idx
)
peak_centre
,
sigma
=
mlzutils
.
do_fit_gaussian
(
self
.
vanaws
,
idx
,
self
.
log
())
peak_centre
,
sigma
=
mlzutils
.
do_fit_gaussian
(
self
.
vanaws
,
idx
,
self
.
log
())
fwhm
=
sigma
*
2.
*
np
.
sqrt
(
2.
*
np
.
log
(
2.
))
fwhm
=
sigma
*
2.
*
np
.
sqrt
(
2.
*
np
.
log
(
2.
))
...
@@ -108,9 +114,6 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
...
@@ -108,9 +114,6 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
idxmax
=
(
np
.
fabs
(
dataX
-
peak_centre
-
3.
*
fwhm
)).
argmin
()
idxmax
=
(
np
.
fabs
(
dataX
-
peak_centre
-
3.
*
fwhm
)).
argmin
()
coefY
[
idx
]
=
dwf
[
idx
]
*
sum
(
dataY
[
idxmin
:
idxmax
+
1
])
coefY
[
idx
]
=
dwf
[
idx
]
*
sum
(
dataY
[
idxmin
:
idxmax
+
1
])
coefE
[
idx
]
=
dwf
[
idx
]
*
sum
(
dataE
[
idxmin
:
idxmax
+
1
])
coefE
[
idx
]
=
dwf
[
idx
]
*
sum
(
dataE
[
idxmin
:
idxmax
+
1
])
else
:
coefY
[
idx
]
=
0.
coefE
[
idx
]
=
0.
# create X array, X data are the same for all detectors, so
# create X array, X data are the same for all detectors, so
coefX
=
np
.
zeros
(
nhist
)
coefX
=
np
.
zeros
(
nhist
)
...
@@ -124,6 +127,12 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
...
@@ -124,6 +127,12 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
self
.
setProperty
(
"
OutputWorkspace
"
,
outws
)
self
.
setProperty
(
"
OutputWorkspace
"
,
outws
)
def
get_detID_offset
(
self
):
"""
returns ID of the first detector
"""
return
self
.
vanaws
.
getSpectrum
(
0
).
getDetectorIDs
()[
0
]
def
calculate_dwf
(
self
):
def
calculate_dwf
(
self
):
"""
"""
Calculates Debye-Waller factor according to
Calculates Debye-Waller factor according to
...
@@ -134,11 +143,7 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
...
@@ -134,11 +143,7 @@ class ComputeCalibrationCoefVan(PythonAlgorithm):
thetasort
=
np
.
zeros
(
nhist
)
# theta in radians !!!NOT 2Theta
thetasort
=
np
.
zeros
(
nhist
)
# theta in radians !!!NOT 2Theta
instrument
=
self
.
vanaws
.
getInstrument
()
instrument
=
self
.
vanaws
.
getInstrument
()
detID_offset
=
0
detID_offset
=
self
.
get_detID_offset
()
try
:
instrument
.
getDetector
(
0
)
except
RuntimeError
:
detID_offset
=
1
for
i
in
range
(
nhist
):
for
i
in
range
(
nhist
):
det
=
instrument
.
getDetector
(
i
+
detID_offset
)
det
=
instrument
.
getDetector
(
i
+
detID_offset
)
...
...
This diff is collapsed.
Click to expand it.
Framework/PythonInterface/plugins/algorithms/mlzutils.py
+
1
−
2
View file @
a31982f5
...
@@ -220,6 +220,5 @@ def do_fit_gaussian(workspace, index, logger):
...
@@ -220,6 +220,5 @@ def do_fit_gaussian(workspace, index, logger):
logger
.
error
(
message
)
logger
.
error
(
message
)
raise
RuntimeError
(
message
)
raise
RuntimeError
(
message
)
result
=
param_table
.
column
(
1
)[
1
:
3
]
# return list: [peak_centre, sigma]
# return list: [peak_centre, sigma]
return
result
return
param_table
.
column
(
1
)[
1
:
3
]
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