Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pes_to_spec
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Machine Learning projects.
pes_to_spec
Commits
03e15610
Commit
03e15610
authored
1 year ago
by
Danilo Ferreira de Lima
Browse files
Options
Downloads
Patches
Plain Diff
Updated plotting script.
parent
f145f5cb
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!14
Corrected bugs in the BNN and added many plotting scripts adapted for the paper
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pes_to_spec/test/prepare_plots.py
+83
-18
83 additions, 18 deletions
pes_to_spec/test/prepare_plots.py
with
83 additions
and
18 deletions
pes_to_spec/test/prepare_plots.py
+
83
−
18
View file @
03e15610
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
import
os
import
os
import
re
import
re
from
typing
import
Optional
,
Tuple
,
Dict
import
matplotlib
import
matplotlib
matplotlib
.
use
(
'
Agg
'
)
matplotlib
.
use
(
'
Agg
'
)
import
pandas
as
pd
import
pandas
as
pd
...
@@ -238,7 +240,7 @@ def plot_wiener(df: pd.DataFrame, filename: str):
...
@@ -238,7 +240,7 @@ def plot_wiener(df: pd.DataFrame, filename: str):
fig
.
savefig
(
filename
)
fig
.
savefig
(
filename
)
plt
.
close
(
fig
)
plt
.
close
(
fig
)
def
plot_pes
(
df
:
pd
.
DataFrame
,
channel
:
str
,
filename
:
str
):
def
plot_pes
(
df
:
pd
.
DataFrame
,
channel
:
Dict
[
str
,
int
],
filename
:
str
,
fast_range
:
Optional
[
Tuple
[
int
,
int
]]
=
None
,
Ne1s
:
Optional
[
Tuple
[
int
,
int
]]
=
None
,
label
:
Optional
[
Dict
[
str
,
str
]]
=
None
,
refs
:
Optional
[
Dict
[
str
,
Dict
[
int
,
float
]]]
=
None
,
counts_to_mv
:
Optional
[
float
]
=
None
):
"""
"""
Plot low-resolution spectrum.
Plot low-resolution spectrum.
...
@@ -255,31 +257,92 @@ def plot_pes(df: pd.DataFrame, channel:str, filename: str):
...
@@ -255,31 +257,92 @@ def plot_pes(df: pd.DataFrame, channel:str, filename: str):
last
=
last
-
270
last
=
last
-
270
print
(
"
Range:
"
,
first
,
last
)
print
(
"
Range:
"
,
first
,
last
)
sel
=
(
df
.
bin
>=
first
)
&
(
df
.
bin
<
last
)
sel
=
(
df
.
bin
>=
first
)
&
(
df
.
bin
<
last
)
x
=
df
.
loc
[
sel
,
"
bin
"
]
x
=
df
.
loc
[
sel
,
"
bin
"
].
to_numpy
()
if
channel
==
"
sum
"
:
col
=
dict
()
y
=
df
.
loc
[
sel
,
[
k
for
k
in
df
.
columns
if
"
channel_
"
in
k
]].
sum
(
axis
=
1
)
colors
=
[
"
tab:red
"
,
"
tab:blue
"
]
ax
.
plot
(
x
,
y
,
c
=
'
b
'
,
lw
=
5
)
p
=
list
()
elif
isinstance
(
channel
,
list
):
# plot each channel
for
ch
in
channel
:
for
ich
,
ch
in
enumerate
(
channel
.
keys
()):
sch
=
ch
.
replace
(
'
_
'
,
'
'
)
if
label
is
None
:
y
=
df
.
loc
[
sel
,
ch
]
sch
=
ch
.
replace
(
'
_
'
,
''
)[
-
2
:]
ax
.
plot
(
x
,
y
,
lw
=
5
,
label
=
sch
)
else
:
else
:
sch
=
label
[
ch
]
y
=
df
.
loc
[
sel
,
channel
]
y
=
df
.
loc
[
sel
,
ch
].
to_numpy
().
astype
(
np
.
float32
)
ax
.
plot
(
x
,
y
,
c
=
'
b
'
,
lw
=
5
)
if
counts_to_mv
is
not
None
:
ax
.
legend
(
frameon
=
False
)
y
*=
counts_to_mv
c
=
colors
[
ich
]
col
[
ch
]
=
c
p
+=
[
ax
.
plot
(
x
,
y
,
lw
=
2
,
c
=
c
,
label
=
sch
)]
ax
.
set
(
title
=
f
""
,
ax
.
set
(
title
=
f
""
,
xlabel
=
"
Time-of-flight index
"
,
ylim
=
(
0
,
None
),
ylabel
=
"
Counts [a.u.]
"
)
#xlabel="Time-of-flight index",
xlabel
=
"
Samples
"
,
ylabel
=
"
Counts [a.u.]
"
if
counts_to_mv
is
None
else
"
Digitizer reading [mV]
"
)
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
ax
.
spines
[
'
top
'
].
set_visible
(
False
)
ax
.
spines
[
'
right
'
].
set_visible
(
False
)
ax
.
spines
[
'
right
'
].
set_visible
(
False
)
minY
,
maxY
=
ax
.
get_ylim
()
# show reference energy lines
if
refs
is
not
None
:
for
ich
,
ch
in
enumerate
(
channel
.
keys
()):
for
tof
,
energy
in
refs
[
ch
].
items
():
ax
.
axvline
(
tof
,
0
,
0.5
+
ich
*
0.17
,
ls
=
'
-.
'
,
lw
=
1
,
c
=
col
[
ch
])
ax
.
text
(
tof
-
1
,
(
0.51
+
ich
*
0.18
)
*
maxY
,
f
"
{
energy
}
eV
"
,
fontsize
=
14
,
rotation
=
"
vertical
"
,
color
=
col
[
ch
])
# show prompt line
for
ch
,
prompt
in
channel
.
items
():
ax
.
axvline
(
x
=
prompt
,
ls
=
'
--
'
,
lw
=
1
,
c
=
col
[
ch
])
ax
.
text
(
prompt
-
3
,
0.5
*
maxY
,
"
Prompt
"
,
fontsize
=
16
,
rotation
=
"
vertical
"
,
color
=
col
[
ch
])
# show the fast electrons range
if
fast_range
is
not
None
:
x1
,
x2
=
fast_range
xtext
=
int
(
x1
+
(
x2
-
x1
)
*
0.3
)
ytext
=
0.9
*
maxY
ax
.
fill_between
([
x1
,
x2
],
minY
,
maxY
,
alpha
=
0.2
,
facecolor
=
"
tab:olive
"
)
ax
.
text
(
xtext
,
ytext
,
"
Valence
"
,
fontsize
=
18
,
fontweight
=
'
bold
'
)
ax
.
text
(
xtext
,
ytext
-
0.05
*
maxY
,
"
Auger
"
,
fontsize
=
18
,
fontweight
=
'
bold
'
)
# show the Ne 1s range
if
Ne1s
is
not
None
:
x1
,
x2
=
Ne1s
xtext
=
int
(
x1
+
(
x2
-
x1
)
*
0.3
)
ytext
=
0.9
*
maxY
ax
.
fill_between
([
x1
,
x2
],
minY
,
maxY
,
alpha
=
0.2
,
facecolor
=
"
tab:cyan
"
)
ax
.
text
(
xtext
,
ytext
,
"
Ne 1s
"
,
fontsize
=
22
,
fontweight
=
'
bold
'
)
ns_per_sample
=
0.5
cax
=
dict
()
def
f_
(
ch
):
return
(
lambda
kk
:
(
np
.
array
(
kk
)
-
int
(
channel
[
ch
]))
*
ns_per_sample
)
def
i_
(
ch
):
return
(
lambda
kk
:
np
.
array
(
kk
)
/
ns_per_sample
+
int
(
channel
[
ch
]))
forward_
=
{
ch
:
f_
(
ch
)
for
ch
in
channel
}
inverse_
=
{
ch
:
i_
(
ch
)
for
ch
in
channel
}
for
ich
,
(
ch
,
prompt
)
in
enumerate
(
channel
.
items
()):
cax
[
ch
]
=
ax
.
secondary_xaxis
(
1.0
+
0.07
*
ich
,
functions
=
(
forward_
[
ch
],
inverse_
[
ch
]))
#cax[ch].spines['left'].set_visible(False)
cax
[
ch
].
spines
[
'
top
'
].
set_position
((
'
outward
'
,
10
))
cax
[
ch
].
spines
[
'
top
'
].
set_color
(
col
[
ch
])
cax
[
ch
].
tick_params
(
axis
=
'
x
'
,
colors
=
col
[
ch
],
labelsize
=
16
)
if
ich
==
len
(
channel
)
-
1
:
cax
[
ch
].
set_xlabel
(
'
Time-of-flight [ns]
'
,
fontsize
=
16
)
#cax[ch].xaxis.label.set_color(col[ch])
#cax[ch].title.set_color(col[ch])
ax
.
legend
(
frameon
=
False
,
loc
=
'
center
'
)
plt
.
tight_layout
()
plt
.
tight_layout
()
fig
.
savefig
(
filename
)
fig
.
savefig
(
filename
)
plt
.
close
(
fig
)
plt
.
close
(
fig
)
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
indir
=
'
p900331r69t70
'
indir
=
'
p900331r69t70
'
channel
=
[
'
channel_1_A
'
,
'
channel_4_A
'
,
'
channel_3_B
'
]
channel
=
{
'
channel_4_A
'
:
2639
,
'
channel_3_B
'
:
2646
,
}
label
=
{
'
channel_4_A
'
:
r
'
22.5$^\circ$
'
,
'
channel_3_B
'
:
r
'
225$^\circ$
'
,
}
Ne1s
=
(
2710
,
2742
)
fast_range
=
(
2650
,
2670
)
refs
=
{
'
channel_4_A
'
:
{
2716
:
1002.5
,
2722
:
997.5
},
'
channel_3_B
'
:
{
2723
:
1002.5
,
2729
:
997.5
}
}
counts_to_mv
=
40.0
/
100.0
#channel = 'sum'
#channel = 'sum'
#for fname in os.listdir(indir):
#for fname in os.listdir(indir):
# if re.match(r'test_q100_[0-9]*\.csv', fname):
# if re.match(r'test_q100_[0-9]*\.csv', fname):
...
@@ -290,7 +353,9 @@ if __name__ == '__main__':
...
@@ -290,7 +353,9 @@ if __name__ == '__main__':
for
fname
in
(
'
test_q100_1724098413
'
,
'
test_q100_1724098596
'
,
'
test_q50_1724099445
'
):
for
fname
in
(
'
test_q100_1724098413
'
,
'
test_q100_1724098596
'
,
'
test_q50_1724099445
'
):
plot_final
(
pd
.
read_csv
(
f
'
{
indir
}
/
{
fname
}
.csv
'
),
f
'
{
fname
}
.pdf
'
)
plot_final
(
pd
.
read_csv
(
f
'
{
indir
}
/
{
fname
}
.csv
'
),
f
'
{
fname
}
.pdf
'
)
plot_pes
(
pd
.
read_csv
(
f
'
{
indir
}
/
{
fname
}
_pes.csv
'
),
channel
,
f
'
{
fname
}
_pes.pdf
'
)
plot_pes
(
pd
.
read_csv
(
f
'
{
indir
}
/
{
fname
}
_pes.csv
'
),
channel
,
f
'
{
fname
}
_pes.pdf
'
,
fast_range
=
fast_range
,
Ne1s
=
Ne1s
,
label
=
label
,
refs
=
refs
,
counts_to_mv
=
counts_to_mv
)
plot_chi2
(
pd
.
read_csv
(
f
'
{
indir
}
/quality.csv
'
),
f
'
chi2_prepca.pdf
'
)
plot_chi2
(
pd
.
read_csv
(
f
'
{
indir
}
/quality.csv
'
),
f
'
chi2_prepca.pdf
'
)
plot_chi2_intensity
(
pd
.
read_csv
(
f
'
{
indir
}
/quality.csv
'
),
f
'
intensity_vs_chi2_prepca.pdf
'
)
plot_chi2_intensity
(
pd
.
read_csv
(
f
'
{
indir
}
/quality.csv
'
),
f
'
intensity_vs_chi2_prepca.pdf
'
)
...
...
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