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
13def540
Commit
13def540
authored
2 years ago
by
Danilo Ferreira de Lima
Browse files
Options
Downloads
Patches
Plain Diff
Started simplified setup and clean up.
parent
c198865e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/test_analysis.py
+52
-0
52 additions, 0 deletions
scripts/test_analysis.py
with
52 additions
and
0 deletions
scripts/test_analysis.py
0 → 100644
+
52
−
0
View file @
13def540
#!/usr/bin/env python
from
extra_data
import
RunDirectory
,
by_id
from
pes_to_spec.model
import
Model
,
matching_ids
import
matplotlib
matplotlib
.
use
(
'
Agg
'
)
import
matplotlib.pyplot
as
plt
def
main
():
"""
Main entry point. Reads some data, trains and predicts.
"""
run_dir
=
"
/gpfs/exfel/exp/SA3/202121/p002935/raw
"
run_id
=
"
r0015
"
# get run
run
=
RunDirectory
(
f
"
{
run_dir
}
/
{
run_id
}
"
)
# get train IDs and match them, so we are sure to have information from all needed sources
# in this example, there is an offset of -2 in the SPEC train ID, so correct for it
spec_offset
=
-
2
spec_tid
=
spec_offset
+
run
[
'
SA3_XTD10_SPECT/MDL/FEL_BEAM_SPECTROMETER_SQS1:output
'
,
f
"
data.trainId
"
].
ndarray
()
pes_tid
=
run
[
'
SA3_XTD10_PES/ADC/1:network
'
,
f
"
digitizers.trainId
"
].
ndarray
()
xgm_tid
=
run
[
'
SA3_XTD10_XGM/XGM/DOOCS:output
'
,
f
"
data.trainId
"
].
ndarray
()
# these are the train ID intersection
# this could have been done by a select call in the RunDirectory, but it would not correct for the spec_offset
tids
=
matching_ids
(
spec_tid
,
pes_tid
,
xgm_tid
)
# read the spec photon energy and intensity
spec_raw_pe
=
run
[
'
SA3_XTD10_SPECT/MDL/FEL_BEAM_SPECTROMETER_SQS1:output
'
,
f
"
data.photonEnergy
"
].
select_trains
(
by_id
[
tids
-
spec_offset
]).
ndarray
()
spec_raw_int
=
run
[
'
SA3_XTD10_SPECT/MDL/FEL_BEAM_SPECTROMETER_SQS1:output
'
,
f
"
data.intensityDistribution
"
].
select_trains
(
by_id
[
tids
-
spec_offset
]).
ndarray
()
# read the PES data for each channel
channels
=
[
f
"
channel_
{
i
}
_
{
l
}
"
for
i
,
l
in
zip
(
range
(
1
,
5
),
[
"
A
"
,
"
B
"
,
"
C
"
,
"
D
"
])]
pes_raw
=
{
ch
:
run
[
'
SA3_XTD10_PES/ADC/1:network
'
,
f
"
digitizers.
{
ch
}
.raw.samples
"
].
select_trains
(
by_id
[
tids
]).
ndarray
()
for
ch
in
channels
}
# read the XGM information
xgm_pressure
=
run
[
'
SA3_XTD10_XGM/XGM/DOOCS
'
,
f
"
pressure.pressureFiltered.value
"
].
select_trains
(
by_id
[
tids
]).
ndarray
()
xgm_pe
=
run
[
'
SA3_XTD10_XGM/XGM/DOOCS:output
'
,
f
"
data.intensitySa3TD
"
].
select_trains
(
by_id
[
tids
]).
ndarray
()
retvol_raw
=
run
[
"
SA3_XTD10_PES/MDL/DAQ_MPOD
"
,
"
u212.value
"
].
select_trains
(
by_id
[
tids
]).
ndarray
()
retvol_raw_timestamp
=
run
[
"
SA3_XTD10_PES/MDL/DAQ_MPOD
"
,
"
u212.timestamp
"
].
select_trains
(
by_id
[
tids
]).
ndarray
()
model
=
Model
()
model
.
fit
(
pes_raw
,
spec_raw_int
)
# test
model
.
predict
(
pes_raw
)
if
__name__
==
'
__main__
'
:
main
()
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