Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
km3io
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
km3py
km3io
Commits
2daf6f5e
Commit
2daf6f5e
authored
3 years ago
by
Rodri
Browse files
Options
Downloads
Patches
Plain Diff
optional command line options
parent
7db508b2
No related branches found
Branches containing commit
No related tags found
1 merge request
!67
Draft: Resolve "Reading summary slices and extracting the rates of each optical module"
Pipeline
#25364
passed with warnings
3 years ago
Stage: test
Stage: coverage
Stage: doc
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
km3io/utils/KModuleRates.py
+19
-7
19 additions, 7 deletions
km3io/utils/KModuleRates.py
with
19 additions
and
7 deletions
km3io/utils/KModuleRates.py
+
19
−
7
View file @
2daf6f5e
"""
"""
Usage: extract-dom-rates.py -
f
INPUT_FILE -o OUTPUT_FILE -
a
DETECTOR_FILE
Usage: extract-dom-rates.py -
i
INPUT_FILE
[
-o OUTPUT_FILE -
d
DETECTOR_FILE
]
Options:
Options:
-h --help Help.
-h --help Help.
-
f
--input_file INPUT_FILE Input file.
-
i
--input_file INPUT_FILE Input file.
-o --output_file OUTPUT_FILE Output file.
-o --output_file OUTPUT_FILE Output file.
-
a
--detector_file DETECTOR_FILE Detector file.
-
d
--detector_file DETECTOR_FILE Detector file.
-s --chunk_size CHUNK_SIZE Number of slices dumped to memory at once.[default: 10000]
-s --chunk_size CHUNK_SIZE Number of slices dumped to memory at once.
[default: 10000]
"""
"""
from
docopt
import
docopt
from
docopt
import
docopt
...
@@ -16,7 +16,7 @@ import km3pipe.hardware
...
@@ -16,7 +16,7 @@ import km3pipe.hardware
import
os
import
os
import
numpy
as
np
import
numpy
as
np
import
h5py
import
h5py
from
pathlib
import
Path
def
create_matrix
(
dom_ids
,
dom_rates
,
dom_map
):
def
create_matrix
(
dom_ids
,
dom_rates
,
dom_map
):
rows
=
len
(
dom_map
)
rows
=
len
(
dom_map
)
...
@@ -53,8 +53,21 @@ def main():
...
@@ -53,8 +53,21 @@ def main():
for
key
in
arguments
:
for
key
in
arguments
:
data
[
key
.
replace
(
"
-
"
,
""
)]
=
arguments
[
key
]
data
[
key
.
replace
(
"
-
"
,
""
)]
=
arguments
[
key
]
if
(
data
[
"
output_file
"
]
==
None
):
data
[
"
output_file
"
]
=
Path
(
arguments
[
'
--input_file
'
]).
stem
+
'
.rates.hdf5
'
# Read list of modules from detector file, and map to indices.
# Read list of modules from detector file, and map to indices.
detector
=
km3pipe
.
hardware
.
Detector
(
data
[
"
detector_file
"
])
reader
=
km3io
.
online
.
SummarysliceReader
(
data
[
"
input_file
"
],
10000
)
dom_ids
=
[]
if
(
data
[
"
detector_file
"
]
==
None
):
print
(
"
No detector file supplied, analysing summaryslices to check for available module IDs.
"
)
for
s
in
reader
.
summaryslices
:
dom_ids
.
append
(
np
.
unique
(
ak
.
flatten
(
s
.
slices
.
dom_id
)))
np
.
unique
(
ak
.
flatten
(
dom_ids
))
else
:
dom_ids
=
km3pipe
.
hardware
.
Detector
(
data
[
"
detector_file
"
]).
dom_ids
dom2index
=
{}
dom2index
=
{}
index2dom
=
{}
index2dom
=
{}
...
@@ -70,7 +83,6 @@ def main():
...
@@ -70,7 +83,6 @@ def main():
h5
.
create_dataset
(
"
frame_indices
"
,
(
0
,),
maxshape
=
(
None
,))
h5
.
create_dataset
(
"
frame_indices
"
,
(
0
,),
maxshape
=
(
None
,))
# Read the channel rates from the summary slices, calculate the total module rates, and save them to the output file
# Read the channel rates from the summary slices, calculate the total module rates, and save them to the output file
reader
=
km3io
.
online
.
SummarysliceReader
(
data
[
"
input_file
"
],
10000
)
for
ss_chunk
in
reader
:
for
ss_chunk
in
reader
:
frame_indices
=
ss_chunk
.
headers
.
frame_index
frame_indices
=
ss_chunk
.
headers
.
frame_index
...
...
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