Skip to content

Commit

Permalink
Merge pull request #79 from grand-mother/dev_update_trace_ci32
Browse files Browse the repository at this point in the history
Dev update trace ci32
  • Loading branch information
mjtueros authored Mar 8, 2024
2 parents b7c6113 + 7b4a866 commit 6b16bda
Show file tree
Hide file tree
Showing 22 changed files with 2,576 additions and 659 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@ docs/apidoc-only/sphinx/source/grand.*
# mac
.DS_Store

*.pyc
sim2root/CoREASRawRoot/__pycache__/CorsikaInfoFuncs.cpython-310.pyc
*.pyc


3 changes: 2 additions & 1 deletion env/_setup_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ echo "add grand/quality to PATH"
echo "=============================="

export PATH=$GRAND_ROOT/scripts:$PATH
echo "add grand/scripts to PATH "
export PATH=$GRAND_ROOT/examples/dataio:$PATH
echo "add scripts to PATH "
echo "=============================="

export PYTHONPATH=$GRAND_ROOT:$PYTHONPATH
Expand Down
1,206 changes: 1,206 additions & 0 deletions examples/basis/class_Handling3dTraces.ipynb

Large diffs are not rendered by default.

48 changes: 34 additions & 14 deletions examples/dataio/ioroot_3dtraces.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#! /usr/bin/env python3

import argparse
from grand.dataio.root_files import get_file_event, get_ttree_in_file
from grand.basis.traces_event import Handling3dTracesOfEvent
from grand.dataio.root_files import get_file_event, _get_ttree_in_file
from grand.basis.traces_event import Handling3dTraces
import grand.manage_log as mlg
import matplotlib.pylab as plt

Expand Down Expand Up @@ -41,6 +41,12 @@ def manage_args():
help="plot trace x,y,z and power spectrum of detector unit (DU)",
default=-100,
)
parser.add_argument(
"--idx_evt",
type=int,
help="Select event with index <idx_evt>, given by -i option, idx_evt is always > 0 or = 0",
default=-100,
)
parser.add_argument(
"--trace_image",
action="store_true",
Expand All @@ -64,14 +70,14 @@ def manage_args():
type=int,
default=-100,
help="dump trace of DU",
) # retrieve argument
) # retrieve argument
parser.add_argument(
"-i",
"--info",
action="store_true",
required=False,
help="some information about the contents of the file",
) # retrieve argument
) # retrieve argument
return parser.parse_args()


Expand All @@ -81,39 +87,53 @@ def main():

args = manage_args()
d_event = get_file_event(args.file.name)
if args.idx_evt != -100:
if args.idx_evt < 0:
logger.error("index events must >= 0")
return
if args.idx_evt >= d_event.get_nb_events():
logger.error(f"index events must < {d_event.get_nb_events()}")
return
d_event.load_event_idx(args.idx_evt)
o_tevent = d_event.get_obj_handling3dtraces()
if args.info:
print(f"Nb events : {d_event.get_nb_events()}")
print("Idx\trun_nb\tevent_nb")
for idx, evt in enumerate(d_event.l_events):
print(f"{idx}\t{evt[1]}\t{evt[0]}")
print(f"Select event index: {d_event.idx_event}")
print("===================")
print(f"Nb DU : {d_event.get_du_count()}")
print(f"Size trace : {d_event.get_size_trace()}")
print(f"TTree : {get_ttree_in_file(args.file.name)}")
assert isinstance(o_tevent, Handling3dTracesOfEvent)

assert isinstance(o_tevent, Handling3dTraces)
if args.list_du:
print(f"Identifier DU : {o_tevent.d_idxdu.keys()}")
print(f"Identifier DU : {o_tevent.idx2idt}")
if args.trace_image:
o_tevent.plot_all_traces_as_image()
if args.footprint:
o_tevent.plot_footprint_4d_max()
o_tevent.plot_footprint_val_max()
if args.time_val:
o_tevent.plot_footprint_val_max_inter()
o_tevent.plot_footprint_time_slider()
if args.trace != -100:
if not args.trace in o_tevent.d_idxdu.keys():
if not args.trace in o_tevent.idt2idx.keys():
logger.error(f"ERROR: unknown DU identifer")
return
o_tevent.plot_trace_du(args.trace)
o_tevent.plot_ps_trace_du(args.trace)
o_tevent.plot_psd_trace_du(args.trace)
if args.list_ttree:
print(get_ttree_in_file(args.file.name))
print(_get_ttree_in_file(args.file.name))
if args.dump != -100:
if not args.dump in o_tevent.d_idxdu.keys():
if not args.dump in o_tevent.idt2idx.keys():
logger.error(f"ERROR: unknown DU identifer")
return
idx_du = o_tevent.d_idxdu[args.dump]
idx_du = o_tevent.idt2idx[args.dump]
tr_du = o_tevent.traces[idx_du]
t_tr = o_tevent.t_samples[idx_du]
for idx in range(o_tevent.get_size_trace()):
print(f"{t_tr[idx]} {tr_du[0,idx]} {tr_du[1,idx]} {tr_du[2,idx]}")


if __name__ == "__main__":
logger.info(mlg.string_begin_script())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@
" ├── basis\n",
" │ ├── __init__.py \n",
" │ ├── test_DetectorUnitNetwork.py\n",
" │ └── test_Handling3dTracesOfEvent.py\n",
" │ └── test_Handling3dTraces.py\n",
" ├── core\n",
" │ ├── __init__.py\n",
" │ ├── __main__.py\n",
Expand Down Expand Up @@ -744,7 +744,7 @@
"id": "e3a1225f",
"metadata": {},
"source": [
"`FileEfield` is a data class without feature to handle traces. You can use `Handling3dTracesOfEvent()` in grand.basis.traces_event.py to handle traces."
"`FileEfield` is a data class without feature to handle traces. You can use `Handling3dTraces()` in grand.basis.traces_event.py to handle traces."
]
},
{
Expand Down
267 changes: 267 additions & 0 deletions examples/grandlib_introduction_v2.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 6b16bda

Please sign in to comment.