eradiate.data.convert.libradtran_to_prt#

eradiate.data.convert.libradtran_to_prt(ds, attrs=None, fallback_units=None, normalize=False, check='full', *, reff=None, veff=None, hum=None, squeeze=False, tolerance=None, wbounds=(None, None))#

Convert a libRadtran scattering particle property dataset to Prt v1.

The output variant depends on the dimensions remaining after point selection (see reff and hum): Prt-MS v1 if a reff dimension remains, Prt-Hum v1 if a hum dimension remains, Prt-Core v1 otherwise.

Parameters:
  • ds (Dataset or path-like) – A dataset in the libRadtran format. If a path is passed, it is resolved by the file resolver and loaded into memory.

  • attrs (dict, optional) – Additional metadata applied to the converted dataset.

  • fallback_units (dict, optional) – A mapping that specifies units to apply to variables that are missing them.

  • normalize (bool, default: False) – If True, rescale the phase matrix so that p₁₁ integrates to 2 over μ ∈ [-1, 1]. Passed to make_prt_v1(); see that function for details.

  • check ({"none", "fast", "full"}, default: "full") – Apply validation checks to the output.

  • reff (float or quantity or array-like, optional) – Effective radius points to select (nearest neighbour), for datasets with an effective radius dimension. Selection follows xarray.Dataset.sel(): a scalar drops the dimension, a 1D array keeps it. If unset, no selection is performed and the dimension is kept (see squeeze). Unitless values are interpreted in µm.

  • veff (float, optional) – The effective variance attached to Prt-MS v1 output, as a size-1 veff dimension. If unset, it defaults to 1 / (param_alpha + 3), the standard gamma-distribution relation, computed from ds.attrs["param_alpha"]; if that attribute is missing, the output has no veff dimension. Ignored if the output has no reff dimension.

  • hum (float or quantity or array-like, optional) – Relative humidity points to select (nearest neighbour), for datasets with a humidity dimension. Same selection rules as reff. Unitless values are interpreted in percent.

  • squeeze (bool, default: False) – If True, drop size-1 reff and hum dimensions on which no selection is performed.

  • tolerance (dict, optional) – Maximum distance for the nearest-neighbour lookup, indexed by "reff" and "hum". Units follow the same rules as for the reff and hum parameters.

  • wbounds (tuple, default: (None, None)) – Bounds restricting the spectral domain where conversion is performed, as a (min, max) pair; use None to leave a bound open. Examples: (300, 3000), (None, 3000), (0.3, 3) * ureg.micron. Unitless values are interpreted in ucc.get("wavelength") units.

Returns:

xr.Dataset

Raises:

ValueError – If a variable has no units and fallback_units does not provide them.

Notes

  • All conversion is done in memory: very large datasets might result in massive converted data. In such cases, restrict the spectral domain using wbounds.

  • The Prt-Core v1 format has a single angular discretization common to all phase matrix coefficients, while libRadtran’s data aerosol format allows for a different one for each coefficient. The angular grid of the output dataset is constructed as the union of the libRadtran grids for all coefficients; all coefficients are then interpolated linearly in μ space on the angular points that were missing for them. The same construction applies independently at each reff or hum point.