eradiate.data.convert.make_aer_core_v2

eradiate.data.convert.make_aer_core_v2(w, phamat, mu, theta, ext, ssa, phase, nangles=None, pmom=None, nmom=None, grid_res=3, attrs=None, normalize=False, check=None)

Create a new dataset in the Aer-Core v2 format.

Parameters:
  • w (quantity) – Wavelength, shape (nw,).

  • phamat (list of str) – Phase matrix component list, shape (nphamat,).

  • mu (quantity) – Scattering angle cosine, shape (nw, nangle).

  • theta (quantity) – Scattering angle, shape (nw, nangle).

  • ext (quantity) – Extinction coefficient, shape (nw,).

  • ssa (quantity) – Single-scattering albedo, shape (nw,).

  • phase (quantity) – Phase matrix values, shape (nphamat, nw, nangle). Integral normalized to 2 (i.e. ∫ p(μ) dμ = 2).

  • nangles (ndarray, optional) – Number of valid angular samples per wavelength, shape (nw,), dtype int. When provided, entries at indices >= nangles[iw] in mu, theta, and phase must be NaN-padded. The nangles dataset variable is always written; if not provided, it is inferred by counting non-NaN entries in the first phase matrix component.

  • pmom (ndarray, optional) – Legendre polynomials for the (1,1) phase matrix element, shape (nw, nimom). If not provided, they are computed automatically from phase and theta using compute_pmom() with coefficients=True.

  • nmom (int or ndarray, optional) – Controls the number of Legendre polynomials. The nmom dataset variable is always written when pmom is present.

    • None (default) — when pmom is not provided, compute 129 coefficients and store their count as a uniform nmom array; when pmom is provided explicitly, infer per-wavelength counts by counting non-NaN entries in the first phase matrix component, consistent with the NaN-padding convention.

    • int — scalar moment count; used as the target for automatic computation and stored as a uniform nmom array.

    • ndarray shape (nw,) — per-wavelength count stored as-is. pmom must be provided explicitly when nmom is an ndarray.

  • grid_res (int, default: 3) – Angular grid resolution passed to compute_pmom() when pmom is computed automatically. 3 uses the input grid with the exact BDE method (recommended). See compute_pmom() for all options.

  • attrs (dict) – Dataset attributes.

  • normalize (bool, default: False) – If True, rescale the phase matrix so that p₁₁ integrates to 2 over μ ∈ [-1, 1]. All phase matrix components are multiplied by the same factor (2 / ∫p₁₁ dμ), preserving their relative magnitudes. When False (default), the caller is responsible for providing a pre-normalized phase array.

  • check ({"none", "fast", "full"}, optional) – Controls validation of the mu angular grid sort order.

    • None or "none" — no check (default).

    • "fast" — sampling-based check: validates a random 10 % of wavelengths (at least one). Intended as a cheap guard during bulk production runs.

    • "full" — validates every wavelength.

    A ValueError is raised if any sampled row is not strictly monotonically increasing in μ. Only the valid (non-NaN) portion of each row is checked (bounded by nangles[iw]).

Returns:

Dataset

Raises:

ValueError – If a value check fails, or if nmom is an ndarray but pmom is not provided.