eradiate.ckd.BinSet#

class eradiate.ckd.BinSet(id, quad, bins)[source]#

Bases: object

A data class representing a quadrature definition used in CKD mode.

Parameters
  • id (str) – Bin set identifier.

  • quad (Quad) – Quadrature rule associated with this spectral bin set.

  • bins (sequence of Bin) – Sequence of bins (automatically ordered upon setting).

Fields
  • id (str) – Bin set identifier.

  • quad (Quad) – Quadrature rule associated with this spectral bin set.

  • bins (tuple of Bin) – Sequence of bins (automatically ordered upon setting).

classmethod convert(value)[source]#

If value is a string, query quadrature definition database with it. Otherwise, return value unchanged.

filter_bins(*filters)[source]#

Filter bins based on callables.

Parameters

filters (callable()) – One or several callables with signature filter(x: Bin) -> bool.

Returns

dict[str, Bin] – Only bins for which filter(bin) is True are returned, ordered by their lower bound.

static from_dataset(id, ds)[source]#

Convert a dataset-based bin set definition to a BinSet instance.

Parameters
  • id (str) – Data set identifier.

  • ds (Dataset) – Dataset from which bin set definition information is to be extracted.

Returns

BinSet – Bin set definition.

static from_db(id)[source]#

Get a bin set definition from Eradiate’s database.

Note

This static function is cached using functools.lru_cache() for optimal performance.

Parameters

id (str) – Data set identifier. The eradiate.data.open() function will be used to load the requested data set.

Returns

BinSet – Bin set definition.

static from_node_dataset(ds)[source]#

Get bin set from node data.

Parameters

ds (Dataset) – Node data to get the bin set for. Data set attributes must have a bin_set field referencing a registered bin set definition in the Eradiate database.

Returns

BinSet – Bin set definition associated with the passed CKD node data.

select_bins(*filter_specs)[source]#

Select a subset of CKD bins. This method is a high-level wrapper for filter_bins().

Parameters

filter_specs (sequence of {str, callable, sequence, dict}) – One or several bin filter specifications. The following are supported:

  • a string will select a bin with matching ID (internally, this results in a call to bin_filter_ids());

  • a callable will be directly used;

  • a (str, dict) will be interpreted as the type and filter_kwargs arguments of bin_filter();

  • a dict with keys type and filter_kwargs will be directly forwarded as keyword arguments to bin_filter().

Returns

dict[str, Bin] – Selected bins.

property bin_ids#

Return the identifiers of defined spectral bins.

Type

list of str

property bin_wmaxs#

Return the upper bounds of defined spectral bins.

Type

quantity

property bin_wmins#

Return the lower bounds of defined spectral bins.

Type

quantity