eradiate.radprops.MonoAbsorptionDatabase#
- class eradiate.radprops.MonoAbsorptionDatabase(dir_path, index, spectral_coverage, metadata=NOTHING, lazy=False, cache=NOTHING)[source]#
Bases:
AbsorptionDatabase
Absorption coefficient database (monochromatic variant).
See also
- cache_clear()#
Clear the cache.
- cache_close()#
Close all cached datasets.
- cache_reset(maxsize)#
Reset the cache with the specified maximum size.
- static convert(value)#
Attempt conversion of a value to an absorption database.
- Parameters:
value – The value for which conversion is attempted.
- Returns:
Notes
Conversion rules are as follows:
If
value
is a string, try converting using thefrom_name()
constructor. Do not raise if this fails.If
value
is a string or a path, try converting using thefrom_directory()
constructor. The returned type is consistent with the active mode.If
value
is a dict, try converting using thefrom_dict()
constructor. The returned type is consistent with the active mode.Otherwise, do not convert.
- static default()#
Return a default database, depending on the active mode.
Defaults are as follows:
Monochromatic:
"komodo"
CKD:
"monotropa"
- Returns:
- eval_sigma_a_ckd(w, g, thermoprops, error_handling_config=None)#
Compute the absorption coefficient given spectral coordinates and a thermophysical profile (CKD variant).
- Parameters:
w (
quantity
) – The wavelength for which the absorption coefficient is evaluated.g (
float
) – The g-point for which the absorption coefficient is evaluated.thermoprops (
Dataset
) – The thermophysical profile for which the absorption coefficient is evaluated.error_handling_config (
ErrorHandlingConfiguration
, optional) – The error handling policy applied if corrdinates are missing, do not have the appropriate dimension or are out of the dataset’s bounds. If unset, the default policy specified by theabsorption_dataset.error_handling
setting is applied.
- Returns:
DataArray
– A data array containing the evaluated absorption coefficient as a function of the spectral coordinate and altitude.
See also
- eval_sigma_a_mono(w, thermoprops, error_handling_config=None)[source]#
Compute the absorption coefficient given spectral coordinates and a thermophysical profile (mono variant).
- Parameters:
w (
quantity
) – The wavelength for which the absorption coefficient is evaluated.thermoprops (
Dataset
) – The thermophysical profile for which the absorption coefficient is evaluated.error_handling_config (
ErrorHandlingConfiguration
, optional) – The error handling policy applied if corrdinates are missing, do not have the appropriate dimension or are out of the dataset’s bounds. If unset, the default policy specified by theabsorption_dataset.error_handling
setting is applied.
- Returns:
DataArray
– A data array containing the evaluated absorption coefficient as a function of the spectral coordinate and altitude.
See also
- classmethod from_dict(value)[source]#
Construct from a dictionary. The dictionary has a required entry
"construct"
that specifies the constructor that will be used to instantiate the database. Additional entries are keyword arguments passed to the selected constructor.- Parameters:
value (
dict
) – Converted value.- Returns:
- classmethod from_directory(dir_path, lazy=False, fix=True)#
Initialize a CKD database from a directory that contains one or several datasets.
- Parameters:
- Returns:
- Raises:
FileNotFoundError – If an index file is missing and
fix
isFalse
.
- static from_name(name, **kwargs)#
Initialize a database from a name.
- Parameters:
name (path-like) – Name of the requested CKD database.
kwargs – Additional keyword arguments are forwarded to the
from_directory()
constructor.
- Returns:
- load_dataset(fname)#
Convenience method to load a dataset. This method is decorated with
functools.lru_cache()
withmaxsize=1
, which limits the number of reload events when repeatedly querying the same file.The behaviour of this method is also affected by the
lazy
parameter: iflazy
isFalse
, files are loaded eagerly withxarray.load_dataset()
; iflazy
isTrue
, files are loaded lazily withxarray.open_dataset()
.
- lookup_datasets(**kwargs)#
Perform a dataset lookup based on the requested spectral coordinate. See
lookup_filenames()
for the accepted arguments.
- lookup_filenames(**kwargs)#
Look up a filename in the index table from the coordinate values passed as keyword arguments.
- Parameters:
wl (
quantity
or array-like, optional) – Wavelength (scalar or array, quantity or unitless). If passed as a unitless value, it is interpreted using the units of the wavelength chunk bounds.wn (
quantity
or array-like, optional) – Wavenumber (scalar or array, quantity or unitless). If passed as a unitless value, it is interpreted using the units of the wavenumber chunk bounds.
- Returns:
filenames (
list
ofstr
) – Names of the successfully looked up files, relative to the database root directory.- Raises:
ValueError – If the requested spectral coordinate is out of bounds.
Notes
Depending on the specified keyword argument (
wl
orwn
), the lookup will be performed in wavelength or wavenumber mode. Both are equivalent.