lgdo package¶
LEGEND Data Objects (LGDO) are defined in the LEGEND data format specification. This package
serves as the Python implementation of that specification. The general strategy
for the implementation is to dress standard Python and NumPy objects with an
attr dictionary holding LGDO metadata, plus some convenience functions. The
basic data object classes are:
LGDO: abstract base class for all LGDOsScalar: typed Python scalar. Access data via thevalueattributeArray: basicnumpy.ndarray. Access data via thendaattribute.FixedSizeArray: basicnumpy.ndarray. Access data via thendaattribute.ArrayOfEqualSizedArrays: multi-dimensionalnumpy.ndarray. Access data via thendaattribute.VectorOfVectors: an n-dimensional variable length array of variable length arrays. Implemented as a pair of datasets:flattened_dataholding the raw data (ArrayorVectorOfVectors, if the vector dimension is greater than 2), andcumulative_length(always anArray) whose i-th element is the sum of the lengths of the vectors withindex <= iVectorOfEncodedVectors: an array of variable length encoded arrays. Implemented as aVectorOfVectorsencoded_dataholding the encoded vectors and anArraydecoded_sizespecifying the size of each decoded vector. Mainly used to represent a list of compressed waveforms.ArrayOfEncodedEqualSizedArrays: an array of equal sized encoded arrays. Similar toVectorOfEncodedVectorsexcept fordecoded_size, which is now a scalar.Struct: a dictionary containing LGDO objects. Derives fromdictTable: aStructwhose elements (“columns”) are all array types with the same length (number of rows)Histogram: holds an array of histogrammed data, and the associated binning of arbitrary dimensionality.
Currently the primary on-disk format for LGDO object is LEGEND HDF5 (LH5) files. IO
is done via the class lh5_store.LH5Store. LH5 files can also be
browsed easily in python like any HDF5 file using
h5py.
Subpackages¶
- lgdo.compression package
- lgdo.lh5 package
- Subpackages
- Submodules
- lgdo.lh5.concat module
- lgdo.lh5.core module
- lgdo.lh5.datatype module
- lgdo.lh5.exceptions module
- lgdo.lh5.iterator module
LH5IteratorLH5Iterator._get_file_cumentries()LH5Iterator._get_file_cumlen()LH5Iterator.current_entryLH5Iterator.current_filesLH5Iterator.current_global_entriesLH5Iterator.current_groupsLH5Iterator.current_local_entriesLH5Iterator.get_file_entrylist()LH5Iterator.get_global_entrylist()LH5Iterator.read()LH5Iterator.reset_field_mask()
- lgdo.lh5.store module
- lgdo.lh5.tools module
- lgdo.lh5.utils module
- lgdo.types package
- Submodules
- lgdo.types.array module
- lgdo.types.arrayofequalsizedarrays module
- lgdo.types.encoded module
ArrayOfEncodedEqualSizedArraysArrayOfEncodedEqualSizedArrays.append()ArrayOfEncodedEqualSizedArrays.datatype_name()ArrayOfEncodedEqualSizedArrays.form_datatype()ArrayOfEncodedEqualSizedArrays.get_capacity()ArrayOfEncodedEqualSizedArrays.insert()ArrayOfEncodedEqualSizedArrays.replace()ArrayOfEncodedEqualSizedArrays.reserve_capacity()ArrayOfEncodedEqualSizedArrays.resize()ArrayOfEncodedEqualSizedArrays.trim_capacity()ArrayOfEncodedEqualSizedArrays.view_as()
VectorOfEncodedVectorsVectorOfEncodedVectors.datatype_name()VectorOfEncodedVectors.form_datatype()VectorOfEncodedVectors.get_capacity()VectorOfEncodedVectors.insert()VectorOfEncodedVectors.replace()VectorOfEncodedVectors.reserve_capacity()VectorOfEncodedVectors.resize()VectorOfEncodedVectors.trim_capacity()VectorOfEncodedVectors.view_as()
- lgdo.types.fixedsizearray module
- lgdo.types.histogram module
- lgdo.types.lgdo module
- lgdo.types.scalar module
- lgdo.types.struct module
- lgdo.types.table module
- lgdo.types.vectorofvectors module
VectorOfVectorsVectorOfVectors._set_vector_unsafe()VectorOfVectors.append()VectorOfVectors.datatype_name()VectorOfVectors.dtypeVectorOfVectors.form_datatype()VectorOfVectors.get_capacity()VectorOfVectors.insert()VectorOfVectors.ndimVectorOfVectors.replace()VectorOfVectors.reserve_capacity()VectorOfVectors.resize()VectorOfVectors.to_aoesa()VectorOfVectors.trim_capacity()VectorOfVectors.view_as()
_to_aoesa
- lgdo.types.vovutils module
- lgdo.types.waveformtable module
Submodules¶
lgdo.cli module¶
legend-pydataobj’s command line interface utilities.
- lgdo.cli.lh5concat_cli(args=None)¶
Command line interface for concatenating array-like LGDOs in LH5 files.
- lgdo.cli.lh5ls(args=None)¶
lh5.show()command line interface.
lgdo.lgdo_utils module¶
- lgdo.lgdo_utils.copy(obj, dtype=None)¶
- lgdo.lgdo_utils.expand_path(path, substitute=None, list=False, base_path=None)¶
lgdo.logging module¶
This module implements some helpers for setting up logging.
- lgdo.logging.setup(level=20, logger=None)¶
Setup a colorful logging output.
If logger is None, sets up only the
lgdologger.- Parameters:
Examples
>>> from lgdo import logging >>> logging.setup(level=logging.DEBUG)
lgdo.units module¶
lgdo.utils module¶
Implements utilities for LEGEND Data Objects.
- class lgdo.utils.NumbaDefaults¶
Bases:
MutableMappingBare-bones class to store some Numba default options. Defaults values are set from environment variables
Examples
Set all default option values for a processor at once by expanding the provided dictionary:
>>> from numba import guvectorize >>> from lgdo.utils import numba_defaults_kwargs as nb_kwargs >>> @guvectorize([], "", **nb_kwargs, nopython=True) # def proc(...): ...
Customize one argument but still set defaults for the others:
>>> from lgdo.utils import numba_defaults as nb_defaults >>> @guvectorize([], "", **nb_defaults(cache=False) # def proc(...): ...
Override global options at runtime:
>>> from lgdo.utils import numba_defaults >>> # must set options before explicitly importing lgdo modules! >>> numba_defaults.cache = False >>> numba_defaults.boundscheck = True >>> from lgdo import compression # imports of numbified functions happen here >>> compression.encode(...)
- lgdo.utils.get_element_type(obj)¶
Get the LGDO element type of a scalar or array.
For use in LGDO datatype attributes.
- Parameters:
obj (object) – if a
str, will automatically returnstringif the object has anumpy.dtype, that will be used for determining the element type otherwise will attempt to case the type of the object to anumpy.dtype.- Returns:
element_type – A string stating the determined element type of the object.
- Return type: