eradiate.spectral.CKDSpectralGrid#
- class eradiate.spectral.CKDSpectralGrid(wmins, wmaxs, wcenters=None, fix_bounds='keep_min', epsilon=1e-06)[source]#
Bases:
SpectralGrid
A spectral grid that splits the spectral dimensions into bins characterized by their bounds.
- Parameters:
wmins (
quantity
or array-like) – Lower bound of all bins. Unitless values are interpreted as default wavelength config units.wmaxs (
quantity
or array-like) – Upper bound of all bins. Unitless values are interpreted as default wavelength config units.wcenters (
quantity
or array-like) – Central wavelength of all bins. Unitless values are interpreted as default wavelength config units. If unset, bin centers are computed automatically from bin bounds. Bin centers are allowed to be different from the middle of the bin interval and, when the grid is tied to a database, are expected to match the values of the wavelength coordinate in the database. However, this is considered as a workaround to deal with poorly indexed databases, and users should try to set central wavelengths to the middle of spectral bins.fix_bounds (
{"keep_min", "keep_max"}
orFalse
, default:"keep_min"
) – Unless told no to, the constructor will detect lower and upper bound values close to each other within a tolerance and flag them as matching. If this parameter is set to"keep_min"
or"keep_max"
, the constructor make sure that matching bounds effectively match exactly. If it is set to"raise"
, it will raise an exception. If it is set to"ignore"
, no action will be taken. The tolerance is controlled by theepsilon
parameter.epsilon (
float
, default:1e-6
) – Absolute tolerance for matching bound detection.
- Fields:
- Raises:
ValueError – If matching bound misalignment is detected and
fix_bounds
is set to"raise"
.
- static arange(start, stop, step)[source]#
Generate a CKD spectral grid with equally-sized bins.
- Parameters:
start (
quantity
orfloat
) – Central wavelength of the first bin. If a unitless value is passed, it is interpreted in default wavelength units (usually nm).stop (
quantity
orfloat
) – Wavelength after which bin generation stops. If a unitless value is passed, it is interpreted in default wavelength units (usually nm).step (
quantity
orfloat
) – Spectral bin size. If a unitless value is passed, it is interpreted in default wavelength units (usually nm).
- Returns:
CKDSpectralGrid
– Generated CKD spectral grid.
- static default()[source]#
Generate a default CKD spectral that covers the default spectral range with 10 nm spacing.
- classmethod from_absorption_database(abs_db)[source]#
Retrieve the spectral grid from a CKD absorption database.
- Parameters:
abs_db (
CKDAbsorptionDatabase
)
- merge(other)[source]#
Merge two spectral grids, applying a boolean “OR” operation.
- Parameters:
other (
SpectralGrid
) – Other spectral, of the same type, to merge with the current one.- Returns:
SpectralGrid
– A new spectral grid of the same type that merges the two.
- select(srf)#
Select a subset of the spectral grid based on a spectral response function.
- Parameters:
srf – A value that is either a
SpectralResponseFunction
instance or convertible to aSpectralResponseFunction
by theSpectralResponseFunction.convert()
method.- Returns:
SpectralGrid
– New spectral grid instance covering the extent of the filtering SRF.
Notes
The implementation of this method uses single dispatch based on the type of the
srf
parameter.
- walk_indices(ckd_quad_config, abs_db=None)[source]#
Walk the spectral grid and retrieve, based on a quadrature configuration and, if necessary, an absorption database, the sequence of spectral indexes driving the spectral loop.
- Parameters:
ckd_quad_config (
CKDQuadConfig
) – CKD quadrature configuration.abs_db (
CKDAbsorptionDatabase
, optional) – Molecular absorption database used to build quadrature rules for each spectral bin. This parameter is required only if an adaptive quadrature generation policy is used, otherwise it is ignored.
- Yields:
si (
CKDSpectralIndex
) – Generated spectral index.
- walk_quads(ckd_quad_config, abs_db=None)[source]#
Walk the spectral grid and retrieve, based on a quadrature configuration and, if necessary, an absorption database, the spectral quadrature for each spectral bin.
- Parameters:
ckd_quad_config (
CKDQuadConfig
) – CKD quadrature configuration.abs_db (
CKDAbsorptionDatabase
, optional) – Molecular absorption database used to build quadrature rules for each spectral bin. This parameter is required only if an adaptive quadrature generation policy is used, otherwise it is ignored.
- Yields:
- property wavelengths#
Convenience accessor to characteristic wavelengths of this spectral grid.