eradiate.data.convert.make_prt_v1#
- eradiate.data.convert.make_prt_v1(w, phamat, mu, theta, ext, ssa, phase, state_dims=None, nangles=None, pmom=None, nmom=None, grid_res=3, attrs=None, normalize=False, check=None)#
Create a new dataset in any variant of the Prt v1 format.
All Prt variants share the core dimensions
w,phamat,iangleandimom. Variants add state dimensions, inserted afterw(see Extensions): e.g. Prt-MS addsreffandveff, Prt-Hum addshum. These are passed throughstate_dims; in the shapes below,*statestands for their sizes, in the order ofstate_dims. Without state dimensions, the output is in the Prt-Core format.- Parameters:
w (
quantity) – Wavelength, shape (nw,).phamat (
listofstr) – Phase matrix component list, shape (nphamat,).mu (
quantity) – Scattering angle cosine, shape (nw, *state, nangle).theta (
quantity) – Scattering angle, shape (nw, *state, nangle).ext (
quantity) – Extinction coefficient, shape (nw, *state).ssa (
quantity) – Single-scattering albedo, shape (nw, *state).phase (
quantity) – Phase matrix values, shape (nphamat, nw, *state, nangle). Integral normalized to 2 (i.e. ∫ p(μ) dμ = 2).state_dims (
dict, optional) – Mapping of state dimension names to their coordinate values, each of shape (n,) and strictly increasing (irregular grids are supported). Known dimensions (reff,veff,hum) get CF metadata; unknown ones use their name as standard and long name.nangles (
ndarray, optional) – Number of valid angular samples, shape (nw, *state), dtype int. When provided, entries beyondnanglesinmu,theta, andphasemust be NaN-padded. Thenanglesdataset 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, *state, nimom). If not provided, they are computed automatically fromphaseandthetausingcompute_pmom()withcoefficients=True.nmom (
intorndarray, optional) – Controls the number of Legendre polynomials. Thenmomdataset variable is always written whenpmomis present.None(default) — whenpmomis not provided, compute 129 coefficients and store their count as a uniformnmomarray; whenpmomis provided explicitly, infer 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 uniformnmomarray.ndarrayshape(nw, *state)— count stored as-is.pmommust be provided explicitly whennmomis an ndarray.
grid_res (
int, default:3) – Angular grid resolution passed tocompute_pmom()whenpmomis computed automatically.3uses the input grid with the exact BDE method (recommended). Seecompute_pmom()for all options.attrs (
dict) – Dataset attributes.normalize (
bool, default:False) – IfTrue, rescale the phase matrix so thatp₁₁integrates to 2 over μ ∈ [-1, 1]. All phase matrix components are multiplied by the same factor (2 / ∫p₁₁ dμ), preserving their relative magnitudes. WhenFalse(default), the caller is responsible for providing a pre-normalizedphasearray.check (
{"none", "fast", "full"}, optional) – Controls validation of themuangular grid sort order.Noneor"none"— no check (default)."fast"— sampling-based check: validates a random 10 % of entries (at least one). Intended as a cheap guard during bulk production runs."full"— validates every entry.
A
ValueErroris raised if any sampled row is not strictly monotonically increasing in μ. Only the valid (non-NaN) portion of each row is checked (bounded bynangles).
- Returns:
- Raises:
ValueError – If a value check fails, if
mudoes not have one dimension per core and state dimension, or if a state dimension coordinate is not strictly increasing.TypeError – If
nmomis an ndarray butpmomis not provided.