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
5e472783
Commit
5e472783
authored
6 years ago
by
Sam Jenkins
Browse files
Options
Downloads
Patches
Plain Diff
Re #23214 Added check for gem, and function to crop focused workspace
function cropsworkspace at values less than 1% of the max value.
parent
60c988cc
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
scripts/Diffraction/isis_powder/abstract_inst.py
+3
-0
3 additions, 0 deletions
scripts/Diffraction/isis_powder/abstract_inst.py
scripts/Diffraction/isis_powder/routines/focus.py
+48
-8
48 additions, 8 deletions
scripts/Diffraction/isis_powder/routines/focus.py
with
51 additions
and
8 deletions
scripts/Diffraction/isis_powder/abstract_inst.py
+
3
−
0
View file @
5e472783
...
...
@@ -183,6 +183,9 @@ class AbstractInst(object):
"""
return
None
def
get_instrument_prefix
(
self
):
return
self
.
_inst_prefix
def
_get_input_batching_mode
(
self
):
"""
Returns the user specified input batching (e.g. summed or individual processing). This is set to summed
...
...
This diff is collapsed.
Click to expand it.
scripts/Diffraction/isis_powder/routines/focus.py
+
48
−
8
View file @
5e472783
...
...
@@ -55,7 +55,8 @@ def _focus_one_ws(input_workspace, run_number, instrument, perform_vanadium_norm
focused_ws
=
mantid
.
DiffractionFocussing
(
InputWorkspace
=
aligned_ws
,
GroupingFileName
=
run_details
.
grouping_file_path
)
calibrated_spectra
=
_apply_vanadium_corrections
(
input_workspace
=
focused_ws
,
calibrated_spectra
=
_apply_vanadium_corrections
(
instrument
=
instrument
,
input_workspace
=
focused_ws
,
perform_vanadium_norm
=
perform_vanadium_norm
,
vanadium_splines
=
vanadium_path
)
...
...
@@ -82,13 +83,14 @@ def _focus_one_ws(input_workspace, run_number, instrument, perform_vanadium_norm
return
d_spacing_group
def
_apply_vanadium_corrections
(
input_workspace
,
perform_vanadium_norm
,
vanadium_splines
):
def
_apply_vanadium_corrections
(
instrument
,
input_workspace
,
perform_vanadium_norm
,
vanadium_splines
):
input_workspace
=
mantid
.
ConvertUnits
(
InputWorkspace
=
input_workspace
,
OutputWorkspace
=
input_workspace
,
Target
=
"
TOF
"
)
split_data_spectra
=
common
.
extract_ws_spectra
(
input_workspace
)
if
perform_vanadium_norm
:
processed_spectra
=
_divide_by_vanadium_splines
(
spectra_list
=
split_data_spectra
,
vanadium_splines
=
vanadium_splines
)
vanadium_splines
=
vanadium_splines
,
instrument
=
instrument
)
else
:
processed_spectra
=
split_data_spectra
...
...
@@ -111,16 +113,21 @@ def _batched_run_focusing(instrument, perform_vanadium_norm, run_number_string,
return
output
def
_divide_one_spectrum_by_spline
(
spectrum
,
spline
):
def
_divide_one_spectrum_by_spline
(
spectrum
,
spline
,
instrument
):
rebinned_spline
=
mantid
.
RebinToWorkspace
(
WorkspaceToRebin
=
spline
,
WorkspaceToMatch
=
spectrum
,
StoreInADS
=
False
)
print
(
instrument
.
get_instrument_prefix
())
if
instrument
.
get_instrument_prefix
()
==
"
GEM
"
:
divided
=
mantid
.
Divide
(
LHSWorkspace
=
spectrum
,
RHSWorkspace
=
rebinned_spline
,
OutputWorkspace
=
spectrum
,
StoreInADS
=
False
)
output
=
_crop_spline_to_percent_of_max
(
rebinned_spline
,
divided
)
mantid
.
mtd
[
'
output
'
]
=
output
return
output
divided
=
mantid
.
Divide
(
LHSWorkspace
=
spectrum
,
RHSWorkspace
=
rebinned_spline
,
OutputWorkspace
=
spectrum
)
divided
=
mantid
.
ReplaceSpecialValues
(
rebinned_spline
,
InfinityValue
=
0
,
OutputWorkspace
=
spectrum
)
return
divided
def
_divide_by_vanadium_splines
(
spectra_list
,
vanadium_splines
):
def
_divide_by_vanadium_splines
(
spectra_list
,
vanadium_splines
,
instrument
):
if
hasattr
(
vanadium_splines
,
"
OutputWorkspace
"
):
# vanadium_splines is a group
vanadium_splines
=
vanadium_splines
.
OutputWorkspace
...
...
@@ -131,7 +138,7 @@ def _divide_by_vanadium_splines(spectra_list, vanadium_splines):
raise
RuntimeError
(
"
Mismatch between number of banks in vanadium and number of banks in workspace to focus
"
"
\n
There are {} banks for vanadium but {} for the run
"
.
format
(
num_splines
,
num_spectra
))
output_list
=
[
_divide_one_spectrum_by_spline
(
data_ws
,
van_ws
)
output_list
=
[
_divide_one_spectrum_by_spline
(
data_ws
,
van_ws
,
instrument
)
for
data_ws
,
van_ws
in
zip
(
spectra_list
,
vanadium_splines
)]
return
output_list
...
...
@@ -162,3 +169,36 @@ def _test_splined_vanadium_exists(instrument, run_details):
raise
ValueError
(
"
Processed vanadium runs not found at this path:
"
+
str
(
run_details
.
splined_vanadium_file_path
)
+
"
\n
Have you run the method to create a Vanadium spline with these settings yet?
\n
"
)
def
_crop_spline_to_percent_of_max
(
spline
,
input_ws
):
print
(
"
Cropping
"
)
y_val
=
0
spline_spectrum
=
spline
.
readY
(
0
)
for
i
in
range
(
spline
.
blocksize
()):
temp
=
spline_spectrum
[
i
]
if
float
(
y_val
)
<
float
(
temp
):
y_val
=
temp
print
(
"
y_max =
"
+
str
(
y_val
))
y_val
=
y_val
/
100
x_min
=
0
before_min
=
True
x_list
=
input_ws
.
readX
(
0
)
x_max
=
x_list
[
-
1
]
for
i
in
range
(
spline
.
blocksize
()):
if
before_min
:
if
float
(
y_val
)
>
float
(
spline_spectrum
[
i
]):
x_min
=
x_list
[
i
]
else
:
print
(
"
y_val:
"
+
str
(
y_val
)
+
"
< x_val:
"
+
str
(
spline_spectrum
[
i
]))
before_min
=
False
else
:
if
float
(
y_val
)
<
float
(
spline_spectrum
[
i
]):
x_max
=
x_list
[
i
]
print
(
"
block_size =
"
+
str
(
input_ws
.
blocksize
()))
print
(
"
x_min =
"
+
str
(
x_min
))
print
(
"
x_max =
"
+
str
(
x_max
))
output
=
mantid
.
CropWorkspace
(
inputWorkspace
=
input_ws
,
XMin
=
x_min
,
XMax
=
x_max
,
StoreInADS
=
False
)
return
output
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