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:
- Fields:
- classmethod convert(value)[source]#
If
value
is a string, query quadrature definition database with it. Otherwise, returnvalue
unchanged.
- filter_bins(*filters)[source]#
Filter bins based on callables.
- Parameters:
filters (
callable()
) – One or several callables with signaturefilter(x: Bin) -> bool
.- Returns:
dict[str
,Bin
] – Only bins for whichfilter(bin)
isTrue
are returned, ordered by their lower bound.
- static from_dataset(id, ds)[source]#
Convert a dataset-based bin set definition to a
BinSet
instance.
- static from_db(id)[source]#
Get a bin set definition from Eradiate’s database.
- Parameters:
id (
str
) – Data set identifier. Theeradiate.data.open()
function will be used to load the requested data set.- Returns:
BinSet
– Bin set definition.
Notes
This static function is cached using
functools.lru_cache()
for optimal performance.
- 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
andfilter_kwargs
arguments ofbin_filter()
;a dict with keys
type
andfilter_kwargs
will be directly forwarded as keyword arguments tobin_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