Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
ToolBox
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
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
SCS
ToolBox
Commits
9deda5ed
Commit
9deda5ed
authored
6 months ago
by
Laurent Mercadier
Committed by
Loïc Le Guyader
4 months ago
Browse files
Options
Downloads
Patches
Plain Diff
avoid modifying integParams in get_peaks()
parent
dc092fc6
No related branches found
No related tags found
1 merge request
!313
Adds AppleX FEL Polarization
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/toolbox_scs/detectors/digitizers.py
+11
-22
11 additions, 22 deletions
src/toolbox_scs/detectors/digitizers.py
with
11 additions
and
22 deletions
src/toolbox_scs/detectors/digitizers.py
+
11
−
22
View file @
9deda5ed
...
...
@@ -268,20 +268,21 @@ def get_peaks(run,
min_distance
=
24
if
digitizer
==
'
ADQ412
'
:
min_distance
=
440
params
=
integParams
.
copy
()
if
autoFind
:
stride
=
int
(
np
.
max
([
1
,
np
.
floor
(
arr
.
sizes
[
'
trainId
'
]
/
200
)]))
trace
=
arr
.
isel
(
trainId
=
slice
(
0
,
None
,
stride
)).
mean
(
dim
=
'
trainId
'
)
try
:
integP
arams
=
find_integ_params
(
trace
)
p
arams
=
find_integ_params
(
trace
)
except
ValueError
as
err
:
log
.
warning
(
f
'
{
err
}
, trying with averaged trace over all trains.
'
)
trace
=
arr
.
mean
(
dim
=
'
trainId
'
)
integP
arams
=
find_integ_params
(
trace
)
log
.
debug
(
f
'
Auto find peaks result:
{
integP
arams
}
'
)
p
arams
=
find_integ_params
(
trace
)
log
.
debug
(
f
'
Auto find peaks result:
{
p
arams
}
'
)
required_keys
=
[
'
pulseStart
'
,
'
pulseStop
'
,
'
baseStart
'
,
'
baseStop
'
,
'
period
'
,
'
npulses
'
]
if
integP
arams
is
None
or
not
all
(
name
in
integP
arams
if
p
arams
is
None
or
not
all
(
name
in
p
arams
for
name
in
required_keys
):
raise
TypeError
(
'
All keys of integParams argument
'
f
'
{
required_keys
}
are required when
'
...
...
@@ -290,16 +291,10 @@ def get_peaks(run,
# 2.1. No bunch pattern provided
if
bpt
is
None
:
log
.
info
(
'
Missing bunch pattern info.
'
)
log
.
debug
(
f
'
Retrieving
{
integP
arams
[
"
npulses
"
]
}
pulses.
'
)
log
.
debug
(
f
'
Retrieving
{
p
arams
[
"
npulses
"
]
}
pulses.
'
)
if
extra_dim
is
None
:
extra_dim
=
'
pulseId
'
return
peaks_from_raw_trace
(
arr
,
integParams
[
'
pulseStart
'
],
integParams
[
'
pulseStop
'
],
integParams
[
'
baseStart
'
],
integParams
[
'
baseStop
'
],
integParams
[
'
period
'
],
integParams
[
'
npulses
'
],
extra_dim
=
extra_dim
)
return
peaks_from_raw_trace
(
arr
,
**
params
,
extra_dim
=
extra_dim
)
# 2.2 Bunch pattern is provided
# load mask and extract pulse Id:
...
...
@@ -327,7 +322,7 @@ def get_peaks(run,
period_bpt
=
0
else
:
period_bpt
=
np
.
min
(
np
.
diff
(
pid
))
if
autoFind
and
period_bpt
*
min_distance
!=
integP
arams
[
'
period
'
]:
if
autoFind
and
period_bpt
*
min_distance
!=
p
arams
[
'
period
'
]:
log
.
warning
(
'
The period from the bunch pattern is different than
'
'
that found by the peak-finding algorithm. Either
'
'
the algorithm failed or the bunch pattern source
'
...
...
@@ -335,15 +330,9 @@ def get_peaks(run,
# create array of sample indices for peak integration
sample_id
=
(
pid
-
pid
[
0
])
*
min_distance
# override auto find parameters
if
isinstance
(
integParams
[
'
pulseStart
'
],
(
int
,
np
.
integer
)):
integParams
[
'
pulseStart
'
]
=
integParams
[
'
pulseStart
'
]
+
sample_id
peaks
=
peaks_from_raw_trace
(
valid_arr
,
integParams
[
'
pulseStart
'
],
integParams
[
'
pulseStop
'
],
integParams
[
'
baseStart
'
],
integParams
[
'
baseStop
'
],
integParams
[
'
period
'
],
integParams
[
'
npulses
'
],
extra_dim
)
if
isinstance
(
params
[
'
pulseStart
'
],
(
int
,
np
.
integer
)):
params
[
'
pulseStart
'
]
=
params
[
'
pulseStart
'
]
+
sample_id
peaks
=
peaks_from_raw_trace
(
valid_arr
,
**
params
,
extra_dim
=
extra_dim
)
if
pattern_changed
:
peaks
=
peaks
.
where
(
mask_on
,
drop
=
True
)
return
peaks
.
assign_coords
({
extra_dim
:
pid
})
...
...
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