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
1242701f
Commit
1242701f
authored
1 year ago
by
Danilo Ferreira de Lima
Browse files
Options
Downloads
Patches
Plain Diff
Bug fix in pedestal estimate.
parent
095cb4ea
No related branches found
Branches containing commit
No related tags found
1 merge request
!19
Handle pedestal in PES and use GPU if available in BNN
Pipeline
#120507
failed
1 year ago
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pes_to_spec/model.py
+11
-1
11 additions, 1 deletion
pes_to_spec/model.py
with
11 additions
and
1 deletion
pes_to_spec/model.py
+
11
−
1
View file @
1242701f
...
...
@@ -4,6 +4,7 @@ from typing import Any, Dict, List, Optional, Union, Tuple, Literal
import
sys
import
joblib
import
dask.array
as
da
import
numpy
as
np
import
scipy
...
...
@@ -315,6 +316,9 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator):
for
delta
in
pulse_spacing
[
channel
]]
for
channel
,
item
in
X
.
items
()
if
channel
in
self
.
channels
}
# convert to Numpy if it is a Dask array
y
=
{
ch
:
[
item
.
compute
()
if
isinstance
(
item
,
da
.
Array
)
else
item
for
item
in
v
]
for
ch
,
v
in
y
.
items
()}
# pad it with zeros, if we reach the edge of the array
for
channel
in
y
.
keys
():
y
[
channel
]
=
[
np
.
pad
(
y
[
channel
][
j
],
((
0
,
0
),
(
0
,
2
*
self
.
delta_tof
-
y
[
channel
][
j
].
shape
[
1
])))
...
...
@@ -340,6 +344,9 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator):
"""
# reduce on channel and on train ID
sum_low_res
=
np
.
mean
(
sum
([
-
(
v
-
self
.
pedestal
[
ch
])
for
ch
,
v
in
X
.
items
()]),
axis
=
0
)
# convert to Numpy if it is a Dask array
if
isinstance
(
sum_low_res
,
da
.
Array
):
sum_low_res
=
sum_low_res
.
compute
()
axis
=
np
.
arange
(
0.0
,
sum_low_res
.
shape
[
0
],
1.0
)
#widths = np.arange(10, 50, step=5)
#peak_idx = find_peaks_cwt(sum_low_res, widths)
...
...
@@ -371,8 +378,11 @@ class SelectRelevantLowResolution(TransformerMixin, BaseEstimator):
Returns: The object itself.
"""
# estimate pedestal
X_
pedestal
=
{
ch
:
np
.
mean
(
v
[:
10
])
self
.
pedestal
=
{
ch
:
np
.
mean
(
v
[:
10
])
for
ch
,
v
in
X
.
items
()}
# convert to Numpy if it is a Dask array
self
.
pedestal
=
{
ch
:
v
.
compute
()
if
isinstance
(
v
,
da
.
Array
)
else
v
for
ch
,
v
in
self
.
pedestal
.
items
()}
self
.
tof_start
=
self
.
estimate_prompt_peak
(
X
)
X_tr
=
self
.
transform
(
X
,
keep_dictionary_structure
=
True
)
self
.
mean
=
{
ch
:
np
.
mean
(
X_tr
[
ch
],
axis
=
0
,
keepdims
=
True
)
...
...
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