Skip to content
Snippets Groups Projects
Commit 2daf6f5e authored by Rodri's avatar Rodri
Browse files

optional command line options

parent 7db508b2
No related branches found
No related tags found
1 merge request!67Draft: Resolve "Reading summary slices and extracting the rates of each optical module"
Pipeline #25364 passed with warnings
"""
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:
-h --help Help.
-f --input_file INPUT_FILE Input file.
-i --input_file INPUT_FILE Input file.
-o --output_file OUTPUT_FILE Output file.
-a --detector_file DETECTOR_FILE Detector file.
-s --chunk_size CHUNK_SIZE Number of slices dumped to memory at once.[default: 10000]
-d --detector_file DETECTOR_FILE Detector file.
-s --chunk_size CHUNK_SIZE Number of slices dumped to memory at once. [default: 10000]
"""
from docopt import docopt
......@@ -16,7 +16,7 @@ import km3pipe.hardware
import os
import numpy as np
import h5py
from pathlib import Path
def create_matrix(dom_ids, dom_rates, dom_map):
rows = len(dom_map)
......@@ -53,8 +53,21 @@ def main():
for key in arguments:
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.
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 = {}
index2dom = {}
......@@ -70,7 +83,6 @@ def main():
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
reader = km3io.online.SummarysliceReader(data["input_file"], 10000)
for ss_chunk in reader:
frame_indices = ss_chunk.headers.frame_index
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment