pygama.hit package¶
Routines for applying columnar transformations to tabular data. Specifically, to produce the hit-tier from the dsp-tier.
Submodules¶
pygama.hit.build_hit module¶
This module implements routines to evaluate expressions to columnar data.
- pygama.hit.build_hit._get_dependencies(config, par, pars=None)¶
Recursive func to iterate back through tree of input blocks for a given output block
- pygama.hit.build_hit._remove_uneeded_operations(config, outpars)¶
Function that removes any operations not needed to generate outpars from the config dictionary Returns the config without these blocks as well as a list of input keys from the dsp file needed to generate outpars
- pygama.hit.build_hit._reorder_table_operations(config)¶
Reorder operations in config according to mutual dependency.
- Return type:
- pygama.hit.build_hit.build_hit(infile, outfile=None, hit_config=None, lh5_tables=None, lh5_tables_config=None, n_max=inf, wo_mode='write_safe', buffer_len=3200)¶
Transform a
Tableinto a newTableby evaluating strings describing column operations.Operates on columns only, not specific rows or elements. Relies on
eval().- Parameters:
infile (str) – input LH5 file name containing tables to be processed.
outfile (str | None) – name of the output LH5 file. If
None, create a file in the same directory and append _hit to its name.hit_config (str | Mapping | None) –
dictionary or name of JSON file defining column transformations. Must contain an
outputsand anoperationskeys. For example:{ "outputs": ["calE", "AoE"], "operations": { "calE": { "expression": "sqrt(a + b * trapEmax**2)", "parameters": {"a": "1.23", "b": "42.69"}, }, "AoE": {"expression": "A_max/calE"}, } }
The
outputsarray lists columns that will be effectively written in the output LH5 file. Add here columns that will be simply forwarded as they are from the DSP tier.lh5_tables (Iterable[str] | None) – tables to consider in the input file. if
None, tables with name dsp will be searched for in the file, even nested by one level.lh5_tables_config (str | Mapping[str, Mapping] | None) – dictionary or JSON file defining the mapping between LH5 tables in infile and hit configuration. Table names can be directly mapped to configuration blocks or to JSON files containing them. This option is mutually exclusive with hit_config and lh5_tables.
n_max (int) – maximum number of rows to process
wo_mode (str) – forwarded to
lh5.io.core.write().
See also