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
d28eb92a
Commit
d28eb92a
authored
4 months ago
by
Laurent Mercadier
Browse files
Options
Downloads
Patches
Plain Diff
pep8 and logging
parent
269cfde6
No related branches found
Branches containing commit
No related tags found
1 merge request
!312
Extract peaks
Pipeline
#156745
passed
4 months ago
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/toolbox_scs/detectors/digitizers.py
+14
-13
14 additions, 13 deletions
src/toolbox_scs/detectors/digitizers.py
with
14 additions
and
13 deletions
src/toolbox_scs/detectors/digitizers.py
+
14
−
13
View file @
d28eb92a
...
...
@@ -322,7 +322,8 @@ def get_peaks(run,
else
:
mask
=
is_pulse_at
(
bpt
.
sel
(
trainId
=
valid_tid
),
pattern
)
mask
=
mask
.
rename
({
'
pulse_slot
'
:
extra_dim
})
mask
=
mask
.
assign_coords
({
extra_dim
:
np
.
arange
(
bpt
.
sizes
[
'
pulse_slot
'
])})
mask
=
mask
.
assign_coords
(
{
extra_dim
:
np
.
arange
(
bpt
.
sizes
[
'
pulse_slot
'
])})
mask_on
=
mask
.
where
(
mask
,
drop
=
True
).
fillna
(
False
).
astype
(
bool
)
log
.
info
(
f
'
Bunch pattern of
{
pattern
}
changed during the run.
'
)
pid
=
mask_on
.
coords
[
extra_dim
]
...
...
@@ -383,7 +384,7 @@ def get_dig_avg_trace(run, mnemonic, ntrains=None):
total_tid
=
len
(
run
.
train_ids
)
stride
=
int
(
np
.
max
([
1
,
np
.
floor
(
total_tid
/
ntrains
)]))
sel
=
run
.
select_trains
(
np
.
s_
[
0
:
None
:
stride
])
m
=
run_mnemonics
[
mnemonic
]
m
=
run_mnemonics
[
mnemonic
]
raw_trace
=
sel
.
get_array
(
m
[
'
source
'
],
m
[
'
key
'
],
m
[
'
dim
'
])
raw_trace
=
raw_trace
.
mean
(
dim
=
'
trainId
'
)
return
raw_trace
...
...
@@ -737,7 +738,8 @@ def check_peak_params(run, mnemonic, raw_trace=None, ntrains=200, params=None,
return
params
def
plotPeakIntegrationWindow
(
raw_trace
,
params
,
bp_params
=
None
,
show_all
=
False
):
def
plotPeakIntegrationWindow
(
raw_trace
,
params
,
bp_params
=
None
,
show_all
=
False
):
if
show_all
:
fig
,
ax
=
plt
.
subplots
(
figsize
=
(
6
,
3
),
constrained_layout
=
True
)
n
=
params
[
'
npulses
'
]
...
...
@@ -818,7 +820,7 @@ def digitizer_type(run, source):
Finds the digitizer type based on the class Id / name of the source.
Example source:
'
SCS_UTC1_MCP/ADC/1
'
. Defaults to ADQ412 if not found.
"""
ret
=
None
ret
=
None
if
'
_MCP/ADC/1
'
in
source
:
ret
=
'
FastADC
'
if
'
_ADQ/ADC/1
'
in
source
:
...
...
@@ -828,8 +830,7 @@ def digitizer_type(run, source):
'
FastAdcLegacy
'
:
'
FastADC
'
,
'
AdqDigitizer
'
:
'
ADQ412
'
,
'
PyADCChannel
'
:
'
FastADC
'
,
'
PyADCChannelLegacy
'
:
'
FastADC
'
}
'
PyADCChannelLegacy
'
:
'
FastADC
'
}
try
:
source
=
source
.
split
(
'
:
'
)[
0
]
classId
=
run
.
get_run_value
(
source
,
'
classId.value
'
)
...
...
@@ -1327,7 +1328,7 @@ def extract_digitizer_peaks(proposal, runNB, mnemonic, bunchPattern=None,
if
bunchPattern
==
'
scs_ppl
'
:
pattern
=
OpticalLaserPulses
(
run
)
except
Exception
as
e
:
pr
in
t
(
e
)
log
.
warn
in
g
(
e
)
bunchPattern
=
None
if
integParams
is
not
None
:
...
...
@@ -1347,10 +1348,11 @@ def extract_digitizer_peaks(proposal, runNB, mnemonic, bunchPattern=None,
period_from_bp
=
min
(
np
.
diff
(
pulse_ids
))
*
pulse_period
if
(
npulses_from_bp
!=
params
[
'
npulses
'
]
or
period_from_bp
!=
params
[
'
period
'
]):
print
(
f
'
Integration parameters (npulses=
{
params
[
"
npulses
"
]
}
,
'
f
'
period=
{
params
[
"
period
"
]
}
) do not match
'
f
'
the bunch pattern (npulses=
{
npulses_from_bp
}
,
'
f
'
period=
{
period_from_bp
}
). Using bunch pattern parameters.
'
)
log
.
warning
(
f
'
Integration parameters
'
f
'
(npulses=
{
params
[
"
npulses
"
]
}
,
'
f
'
period=
{
params
[
"
period
"
]
}
) do not match the
'
f
'
the bunch pattern (npulses=
{
npulses_from_bp
}
,
'
f
'
period=
{
period_from_bp
}
). Using bunch pattern parameters.
'
)
params
[
'
npulses
'
]
=
npulses_from_bp
params
[
'
period
'
]
=
period_from_bp
else
:
...
...
@@ -1393,12 +1395,11 @@ def extract_digitizer_peaks(proposal, runNB, mnemonic, bunchPattern=None,
'
pattern parameters.
'
)
params
[
'
period
'
]
=
period
params
[
'
npulses
'
]
=
min
(
len
(
trace
)
//
period
,
npulses
)
print
(
params
[
'
npulses
'
])
if
pulse_ids
is
None
:
pulse_ids
=
np
.
arange
(
params
[
'
npulses
'
],
dtype
=
np
.
uint64
)
if
params
is
None
:
pr
in
t
(
'
Could not find peak integration parameters.
'
)
log
.
warn
in
g
(
'
Could not find peak integration parameters.
'
)
return
xr
.
DataArray
()
# extract peaks
...
...
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