Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
est
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
workflow
ewoksapps
est
Commits
54a45434
Commit
54a45434
authored
2 years ago
by
Wout De Nolf
Browse files
Options
Downloads
Patches
Plain Diff
add metadata to plotspectrumdata output
parent
8e0eb8ed
No related branches found
No related tags found
1 merge request
!106
Metadata output from spectrumdata task
Pipeline
#84308
passed
2 years ago
Stage: style
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/est/core/process/plotspectrumdata.py
+60
-27
60 additions, 27 deletions
src/est/core/process/plotspectrumdata.py
src/est/tests/test_plotspectrumdata.py
+0
-2
0 additions, 2 deletions
src/est/tests/test_plotspectrumdata.py
with
60 additions
and
29 deletions
src/est/core/process/plotspectrumdata.py
+
60
−
27
View file @
54a45434
...
@@ -11,6 +11,19 @@ _Y_TO_X_NAME = {
...
@@ -11,6 +11,19 @@ _Y_TO_X_NAME = {
"
ft_mag
"
:
"
R
"
,
"
ft_mag
"
:
"
R
"
,
"
noise_savgol
"
:
"
energy
"
,
"
noise_savgol
"
:
"
energy
"
,
}
}
_Y_TO_INFO_ATTRS
=
{
"
normalized_mu
"
:
[
"
e0
"
,
"
edge_step
"
],
"
flatten_mu
"
:
[
"
e0
"
,
"
edge_step
"
],
"
noise_savgol
"
:
[
"
raw_noise_savgol
"
,
"
norm_noise_savgol
"
,
"
edge_step
"
,
"
e0
"
],
}
_Y_TO_HLINE_ATTRS
=
{
"
noise_savgol
"
:
[
"
raw_noise_savgol
"
]}
_Y_TO_VLINE_ATTRS
=
{
"
noise_savgol
"
:
[
"
noise_e_min
"
,
"
noise_e_max
"
]}
_LARCH_ATTRS
=
(
"
noise_e_min
"
,
"
noise_e_max
"
)
_INFO_ATTRS_TO_NAMES
=
{
"
raw_noise_savgol
"
:
"
raw_noise
"
,
"
norm_noise_savgol
"
:
"
norm_noise
"
,
"
edge_step
"
:
"
edge_step
"
,
}
_LABELS
=
{
_LABELS
=
{
"
energy
"
:
"
Energy (eV)
"
,
"
energy
"
:
"
Energy (eV)
"
,
"
mu
"
:
"
μ(E)
"
,
"
mu
"
:
"
μ(E)
"
,
...
@@ -30,40 +43,60 @@ def process_plotspectrumdata(
...
@@ -30,40 +43,60 @@ def process_plotspectrumdata(
)
->
Dict
[
str
,
dict
]:
)
->
Dict
[
str
,
dict
]:
kweight
=
spectrum
.
larch_dict
[
"
xftf_k_weight
"
]
kweight
=
spectrum
.
larch_dict
[
"
xftf_k_weight
"
]
params
=
{
"
kweight
"
:
kweight
,
"
kweightp1
"
:
kweight
+
1
}
params
=
{
"
kweight
"
:
kweight
,
"
kweightp1
"
:
kweight
+
1
}
plot_data
=
dict
()
plot_data
=
dict
()
if
not
plot_names
:
if
not
plot_names
:
plot_names
=
(
"
flatten_mu
"
,
"
chi_weighted_k
"
,
"
ft_mag
"
,
"
noise_savgol
"
)
plot_names
=
(
"
flatten_mu
"
,
"
chi_weighted_k
"
,
"
ft_mag
"
,
"
noise_savgol
"
)
for
yname
in
plot_names
:
for
yname
in
plot_names
:
ylabel
=
_LABELS
[
yname
]
plot_data
[
yname
]
=
get_plotspectrumdata
(
spectrum
,
yname
,
params
)
xname
=
_Y_TO_X_NAME
[
yname
]
return
plot_data
xlabel
=
_LABELS
[
xname
]
if
yname
==
"
ft_mag
"
:
x
=
spectrum
.
ft
[
"
FTRadius
"
]
y
=
spectrum
.
ft
[
"
FTIntensity
"
]
xlabel
=
_LABELS
[
"
R
"
]
ylabel
=
_LABELS
[
"
ft_mag
"
]
else
:
try
:
x
=
getattr
(
spectrum
,
xname
)
y
=
getattr
(
spectrum
,
yname
)
except
Exception
:
breakpoint
()
xlabel
=
xlabel
.
format
(
**
params
)
def
get_plotspectrumdata
(
spectrum
,
yname
,
params
):
ylabel
=
ylabel
.
format
(
**
params
)
xname
=
_Y_TO_X_NAME
[
yname
]
if
yname
==
"
ft_mag
"
:
x
=
spectrum
.
ft
[
"
FTRadius
"
]
y
=
spectrum
.
ft
[
"
FTIntensity
"
]
else
:
x
=
getattr
(
spectrum
,
xname
)
y
=
getattr
(
spectrum
,
yname
)
plot_data
[
yname
]
=
{
xlabel
=
_LABELS
[
xname
]
"
name
"
:
yname
,
ylabel
=
_LABELS
[
yname
]
"
x
"
:
x
,
xlabel
=
xlabel
.
format
(
**
params
)
"
y
"
:
y
,
ylabel
=
ylabel
.
format
(
**
params
)
"
xlabel
"
:
xlabel
,
"
ylabel
"
:
ylabel
,
info
=
dict
()
"
ylog
"
:
yname
==
"
noise_savgol
"
,
for
attr
in
_Y_TO_INFO_ATTRS
.
get
(
yname
,
list
()):
}
value
=
get_spectrum_value
(
spectrum
,
attr
)
return
plot_data
key
=
_INFO_ATTRS_TO_NAMES
.
get
(
attr
,
attr
)
info
[
key
]
=
value
hlines
=
[
get_spectrum_value
(
spectrum
,
attr
)
for
attr
in
_Y_TO_HLINE_ATTRS
.
get
(
yname
,
list
())
]
vlines
=
[
get_spectrum_value
(
spectrum
,
attr
)
for
attr
in
_Y_TO_VLINE_ATTRS
.
get
(
yname
,
list
())
]
return
{
"
name
"
:
yname
,
"
x
"
:
x
,
"
y
"
:
y
,
"
xlabel
"
:
xlabel
,
"
ylabel
"
:
ylabel
,
"
info
"
:
info
,
"
hlines
"
:
hlines
,
"
vlines
"
:
vlines
,
}
def
get_spectrum_value
(
spectrum
,
attr
):
if
attr
in
_LARCH_ATTRS
:
return
spectrum
.
larch_dict
[
attr
]
else
:
return
getattr
(
spectrum
,
attr
)
class
PlotSpectrumData
(
class
PlotSpectrumData
(
...
...
This diff is collapsed.
Click to expand it.
src/est/tests/test_plotspectrumdata.py
+
0
−
2
View file @
54a45434
...
@@ -89,8 +89,6 @@ def test_larch_plotspectrumdata(filename_cu_from_pymca):
...
@@ -89,8 +89,6 @@ def test_larch_plotspectrumdata(filename_cu_from_pymca):
ax
.
plot
(
data
[
"
x
"
],
data
[
"
y
"
])
ax
.
plot
(
data
[
"
x
"
],
data
[
"
y
"
])
ax
.
set_xlabel
(
data
[
"
xlabel
"
])
ax
.
set_xlabel
(
data
[
"
xlabel
"
])
ax
.
set_ylabel
(
data
[
"
ylabel
"
])
ax
.
set_ylabel
(
data
[
"
ylabel
"
])
if
data
[
"
ylog
"
]:
ax
.
set_yscale
(
"
log
"
)
plt
.
show
()
plt
.
show
()
...
...
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