selections#

Dataset wrangling module.

Classes:

Repository([local_root, remote_root, username])

Data file repository.

Dataset(key, livetime, sig[, data, bg, ...])

Background and signal data.

Exceptions:

StopModifications(*a, **kw)

class csky.selections.Repository(local_root=None, remote_root=None, username=None)[source]#

Bases: object

Data file repository.

This class provides a mechanism for loading data from the UW-Madison stores. If working elsewhere, it is possible to mirror the required data on request.

Methods:

__init__([local_root, remote_root, username])

Construct a Repository.

ensure(path)

Ensure that the specified file is locally accessible.

load(path[, backend, target_class, quiet, ...])

Load a file.

__init__(local_root=None, remote_root=None, username=None)[source]#

Construct a Repository.

Parameters:

local_root (str) – local directory in which to read/write files

ensure(path)[source]#

Ensure that the specified file is locally accessible.

load(path, backend=None, target_class=<class 'csky.utils.Arrays'>, quiet=False, kw={'convert': True}, mmap=False)[source]#

Load a file.

class csky.selections.Dataset(key, livetime, sig, data=None, bg=None, cascades=False, grl=None, range_sindec=(-1, 1))[source]#

Bases: object

Background and signal data.

These normally should not be constructed directly; see csky.utils.get_analysis().

Methods:

__init__(key, livetime, sig[, data, bg, ...])

Construct a Dataset.

__init__(key, livetime, sig, data=None, bg=None, cascades=False, grl=None, range_sindec=(-1, 1))[source]#

Construct a Dataset.

Parameters:
  • key (str) – a unique identifier for these datasets

  • livetime (float) – The livetime of this analysis.

  • sig (mapping or object) – an object containing at least the following members or keys: dec, ra, true_dec, true_ra, true_energy, oneweight (OneWeight/ngen). Corresponding values should be per-event numpy arrays.

  • bg (mapping or object, optional) – like data, but must include weight.

  • data (mapping or object, optional) – an object containing at least the following members or keys: dec, ra, weight. Corresponding values should be per-event numpy arrays, except for weight which may be None.

  • cascades (bool) – whether this is cascade data as opposed to tracks

  • grl (csky.utils.Arrays) – the good run list

One of bg or data must be provided. sig, bg, and data will generally need additional keys such as energy (for use with energy PDFs) and/or sigma (for per-event Gaussian signal space PDFs).

exception csky.selections.StopModifications(*a, **kw)[source]#

Bases: Exception

Methods:

__init__(*a, **kw)

add_note

Exception.add_note(note) -- add a note to the exception

with_traceback

Exception.with_traceback(tb) -- set self.__traceback__ to tb and return self.

__init__(*a, **kw)[source]#
add_note()#

Exception.add_note(note) – add a note to the exception

with_traceback()#

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.