pygama package

Pygama: decoding and processing digitizer data. Check out the online documentation

Subpackages

Submodules

pygama.cli module

pygama’s command line interface utilities.

pygama.cli.add_build_hit_parser(subparsers)

Configure hit.build_hit.build_hit() command line interface

pygama.cli.build_hit_cli(args)

Passes command line arguments to hit.build_hit.build_hit().

pygama.cli.pygama_cli()

pygama’s command line interface.

Defines the command line interface (CLI) of the package, which exposes some of the most used functions to the console. This function is added to the entry_points.console_scripts list and defines the pygama executable (see setuptools’ documentation). To learn more about the CLI, have a look at the help section:

$ pygama --help
$ pygama build-hit --help  # help section for a specific sub-command

pygama.logging module

This module implements some helpers for setting up logging.

pygama.logging.setup(level=20, logger=None)

Setup a colorful logging output.

If logger is None, sets up only the pygama logger.

Parameters:
  • level (int) – logging level (see logging module).

  • logger (Logger) – if not None, setup this logger.

Examples

>>> from pygama import logging
>>> logging.setup(level=logging.DEBUG)

pygama.utils module

class pygama.utils.NumbaPygamaDefaults

Bases: MutableMapping

Bare-bones class to store some Numba default options. Defaults values are set from environment variables. Useful for the pygama.math distributions

Examples

Set all default option values for a numba wrapped function at once by expanding the provided dictionary:

>>> from numba import njit
>>> from pygama.utils import numba_math_defaults_kwargs as nb_kwargs
>>> @njit([], "", **nb_kwargs, nopython=True) # def dist(...): ...

Customize one argument but still set defaults for the others:

>>> from pygama.utils import numba_math_defaults as nb_defaults
>>> @njit([], "", **nb_defaults(cache=False) # def dist(...): ...

Override global options at runtime:

>>> from pygama.utils import numba_math_defaults
>>> # must set options before explicitly importing pygama.math.distributions!
>>> numba_math_defaults.cache = False
_abc_impl = <_abc._abc_data object>
pygama.utils.getenv_bool(name, default=False)

Get environment value as a boolean, returning True for 1, t and true (caps-insensitive), and False for any other value and default if undefined.

Return type:

bool

pygama.utils.load_dict(fname, ftype=None)

Load a text file as a Python dict.

Return type:

dict