Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into issue_3_lh5_store_refactor
  • Loading branch information
MoritzNeuberger committed Oct 30, 2023
2 parents c339385 + f71afff commit 51a34db
Show file tree
Hide file tree
Showing 9 changed files with 456 additions and 207 deletions.
35 changes: 35 additions & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,41 @@ local systems with `pip <3_>`_:
instructions on the `LEGEND wiki
<https://legend-exp.atlassian.net/l/cp/nF1ww5KH>`_.

Inspecting LH5 files from the command line
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

The ``lh5ls`` shell command uses :func:`.lh5_store.show` to print a pretty
representation of a LH5 file's contents

.. code-block:: console
$ lh5ls -a legend-testdata/data/lh5/LDQTA_r117_20200110T105115Z_cal_geds_raw.lh5
/
└── geds · HDF5 group
└── raw · table{packet_id,ievt,timestamp,numtraces,tracelist,baseline,energy,channel,wf_max,wf_std,waveform}
├── baseline · array<1>{real}
├── channel · array<1>{real}
├── energy · array<1>{real}
├── ievt · array<1>{real}
├── numtraces · array<1>{real}
├── packet_id · array<1>{real}
├── timestamp · array<1>{real} ── {'units': 's'}
├── tracelist · array<1>{array<1>{real}}
│ ├── cumulative_length · array<1>{real}
│ └── flattened_data · array<1>{real}
├── waveform · table{t0,dt,values}
│ ├── dt · array<1>{real} ── {'units': 'ns'}
│ ├── t0 · array<1>{real} ── {'units': 'ns'}
│ └── values · array_of_equalsized_arrays<1,1>{real}
├── wf_max · array<1>{real}
└── wf_std · array<1>{real}
For more information, have a look at the command's help section:

.. code-block:: console
$ lh5ls --help
Next steps
----------

Expand Down
56 changes: 56 additions & 0 deletions src/lgdo/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
"""legend-pydataobj's command line interface utilities."""
import argparse
import logging
import sys

import lgdo
import lgdo.logging
from lgdo import show


def lh5ls():
""":func:`.show` command line interface."""
parser = argparse.ArgumentParser(
prog="lh5ls", description="Inspect LEGEND HDF5 (LH5) file contents"
)

# global options
parser.add_argument(
"--version", action="store_true", help="""Print lgdo version and exit"""
)
parser.add_argument(
"--verbose",
"-v",
action="store_true",
help="""Increase the program verbosity""",
)
parser.add_argument(
"--debug",
"-d",
action="store_true",
help="""Increase the program verbosity to maximum""",
)

parser.add_argument(
"lh5_file",
help="""Input LH5 file.""",
)
parser.add_argument("lh5_group", nargs="?", help="""LH5 group.""", default="/")
parser.add_argument(
"--attributes", "-a", action="store_true", help="""Print HDF5 attributes too"""
)

args = parser.parse_args()

if args.verbose:
lgdo.logging.setup(logging.DEBUG)
elif args.debug:
lgdo.logging.setup(logging.DEBUG, logging.root)
else:
lgdo.logging.setup()

if args.version:
print(lgdo.__version__) # noqa: T201
sys.exit()

show(args.lh5_file, args.lh5_group, attrs=args.attributes)
2 changes: 2 additions & 0 deletions src/lgdo/compression/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import re
from dataclasses import asdict, dataclass

numba_defaults: dict = {"nopython": True, "cache": True}


@dataclass(frozen=True)
class WaveformCodec:
Expand Down
Loading

0 comments on commit 51a34db

Please sign in to comment.