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
ba6e3ce8
Commit
ba6e3ce8
authored
4 years ago
by
Kendrick, Coleman
Browse files
Options
Downloads
Patches
Plain Diff
Add bad count labels to plot
parent
32a5a247
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/Calibration/tofpd/diagnostics.py
+15
-9
15 additions, 9 deletions
scripts/Calibration/tofpd/diagnostics.py
with
15 additions
and
9 deletions
scripts/Calibration/tofpd/diagnostics.py
+
15
−
9
View file @
ba6e3ce8
...
...
@@ -95,13 +95,13 @@ def __get_regions(x):
i
=
0
for
start
,
stop
in
zip
(
lower
,
upper
):
if
i
==
0
:
regions
.
append
((
int
(
np
.
min
(
x
)),
start
))
regions
.
append
((
int
(
np
.
min
(
x
)),
int
(
start
-
1
)
))
else
:
regions
.
append
((
upper
[
i
-
1
]
,
start
))
regions
.
append
((
int
(
upper
[
i
-
1
]
+
1
),
int
(
start
-
1
)
))
i
=
i
+
1
# Add ending region if there was atleast one region found:
if
i
>
0
:
regions
.
append
((
upper
[
i
-
1
],
int
(
np
.
max
(
x
))))
regions
.
append
((
int
(
upper
[
i
-
1
]
+
1
)
,
int
(
np
.
max
(
x
))))
return
regions
...
...
@@ -394,7 +394,7 @@ def extract_peak_info(wksp, outputname: str, peak_position: float):
return
mtd
[
outputname
]
def
plot_peakd
(
wksp
,
peak_positions
,
mask_ws
=
Non
e
,
drange
=
(
0
,
0
),
threshold
=
0.01
):
def
plot_peakd
(
wksp
,
peak_positions
,
plot_regions
=
True
,
show_bad_cnt
=
Tru
e
,
drange
=
(
0
,
0
),
threshold
=
0.01
):
"""
Plots peak d spacing value for each peak position in peaks
:param wksp: Workspace returned from collect_peaks
...
...
@@ -412,9 +412,6 @@ def plot_peakd(wksp, peak_positions, mask_ws=None, drange=(0,0), threshold=0.01)
if
not
mtd
.
doesExist
(
str
(
wksp
)):
raise
ValueError
(
"
Could not find provided workspace in ADS
"
)
if
mask_ws
:
mask_ws
=
mtd
[
str
(
mask_ws
)]
fig
,
ax
=
plt
.
subplots
()
ax
.
set_xlabel
(
"
det IDs
"
)
ax
.
set_ylabel
(
"
rel strain
"
)
...
...
@@ -454,12 +451,21 @@ def plot_peakd(wksp, peak_positions, mask_ws=None, drange=(0,0), threshold=0.01)
stddevs
.
append
(
np
.
std
(
y_val
[
cut_id
[
0
]:
cut_id
[
1
]]))
# Draw vertical lines between detector regions
if
not
regions
:
if
plot_regions
and
not
regions
:
regions
=
__get_regions
(
x
[
cut_id
[
0
]:
cut_id
[
1
]])
for
region
in
regions
:
ax
.
axvline
(
x
=
region
[
0
])
ax
.
axvline
(
x
=
region
[
1
])
region_cnts
.
append
(
__get_bad_counts
(
y
[
region
[
0
]:
region
[
1
]],
means
[
len
(
means
)
-
1
]))
det_start
=
single
.
yIndexOfX
(
region
[
0
])
det_end
=
single
.
yIndexOfX
(
region
[
1
])
cnt
=
__get_bad_counts
(
y
[
det_start
:
det_end
],
means
[
len
(
means
)
-
1
])
region_cnts
.
append
(
cnt
)
if
show_bad_cnt
:
mid_region
=
0.5
*
(
region
[
1
]
-
region
[
0
])
text
=
ax
.
annotate
(
"
{}
"
.
format
(
cnt
),
xy
=
(
mid_region
,
0.05
),
xycoords
=
(
'
data
'
,
'
axes fraction
'
),
clip_on
=
True
)
width
=
text
.
get_window_extent
(
renderer
=
fig
.
canvas
.
get_renderer
()).
width
text
.
set_x
(
region
[
0
]
+
mid_region
-
0.5
*
width
)
ax
.
plot
(
x
[
cut_id
[
0
]:
cut_id
[
1
]],
y
[
cut_id
[
0
]:
cut_id
[
1
]],
marker
=
"
x
"
,
linestyle
=
"
None
"
,
label
=
"
{:0.6f}
"
.
format
(
peak
))
ax
.
legend
(
bbox_to_anchor
=
(
1
,
1
),
loc
=
"
upper left
"
)
...
...
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