xopto.pf.util.helpers module¶
- delta2g3(delta: float, g1: float) → float[source]¶
Computes the third Legendre moment from delta and the first Legendre moment of the scattering phase function.
delta = (1 - g3)/(1 - g1)
g3 = 1 - delta*(1 - g1)
- Parameters
g1 (float) – First Legendre moment of the scattering phase function.
gamma (float) – Parameter gamma.
- Returns
g3 – Third Legendre moment of the scattering phase function.
- Return type
float
- g2delta(g1: float, g3: float) → float[source]¶
Computes and delta from the first and third Legendre moment.
delta = (1 - g3)/(1 - g1)
- Parameters
g1 (float) – First Legendre moment of the scattering phase function.
g3 (float) – Third Legendre moment of the scattering phase function.
- Returns
delta – Similarity parameter delta.
- Return type
float
- g2gamma(g1: float, g2: float) → float[source]¶
Computes and return gamma from the first and second Legendre moment.
gamma = (1 - g2)/(1 - g1)
- Parameters
g1 (float) – First Legendre moment of the scattering phase function.
g2 (float) – Second Legendre moment of the scattering phase function.
- Returns
gamma – Similarity parameter gamma.
- Return type
float
- g2gammadelta(g1: float, g2: float, g3: float) → Tuple[float, float, float][source]¶
Computes the gamma and delta from the first three Legendre moments of the scattering phase function. Returns (g1, gamma, delta).
gamma = (1 - g2)/(1 - g1)
delta = (1 - g3)/(1 - g1)
- Parameters
g1 (float) – First Legendre moment of the scattering phase function.
gamma (float) – Parameter gamma.
delta (float) – Parameter delta.
- Returns
g – The first three Legendre moments (g1, gamma, delta).
- Return type
tuple of 3 elements
- gamma2g2(gamma: float, g1: float) → float[source]¶
Computes the second Legendre moment from gamma and the first Legendre moment of the scattering phase function.
gamma = (1 - g2)/(1 - g1)
g2 = 1 - gamma*(1 - g1)
- Parameters
g1 (float) – First Legendre moment of the scattering phase function.
gamma (float) – Parameter gamma.
- Returns
g2 – Second Legendre moment of the scattering phase function.
- Return type
float
- gammadelta2g(g1: float, gamma: float, delta: float) → Tuple[float, float, float][source]¶
Computes the second and third Legendre moment from gamma and delta parameters. Returns (g1, g2, g3).
gamma = (1 - g2)/(1 - g1)
delta = (1 - g3)/(1 - g1)
g2 = 1 - gamma*(1 - g1)
g3 = 1 - delta*(1 - g1)
- Parameters
g1 (float) – First Legendre moment of the scattering phase function.
gamma (float) – Parameter gamma.
delta (float) – Parameter delta.
- Returns
g – The first three Legendre moments (g1, g2, g3).
- Return type
tuple of 3 elements
- mhg_inverse_g1gamma(g1: float, gamma: float) → Tuple[float, float, bool][source]¶
Estimates the parameters g and b of the modified Henyey-Greenstein (MHG) scattering phase function that best fit the given values of g1 and gamma, where g1 is the first Legendre moment of the MHG phase function and gamma:
gamma = (1 - g2) / (1 - g1).
Parameters g and b of the scattering phase function MHG can be computed analytically.
Forward analytical model (Calabro et al. JBO 19(7) 2014):
g1 = b * g
g2 = b * g^2 + 2/5 (1 - b)
g3 = b * g^3
g_k = b * g^k where k > 2
…
Parameters g and b can be derived from a quadratic equation. The obtained values are valid only if:
b < 1 (if b == 1 … MHG simplifies to HG) or gamma < 1 + g1.
- Parameters
g1 (float) – Target value of the first Legendre moment.
gamma (float) – Target value of parameter gamma = (1 - g2)/(1 - g1).
- Returns
g (float) – Estimated values of parameter g.
b (float) – Estimated values of parameter b.
valid (bool) – A binary mask indicating valid values of g and b.
- mhg_inverse_gammadelta(gamma: float, delta: float) → Tuple[float, float, bool][source]¶
Estimates the parameters g and b of the modified Henyey-Greenstein (MHG) scattering phase function that best fit the given values of gamma and delta, where gamma is
gamma = (1 - g2) / (1 - g1),
and delta is:
delta = (1 - g3) / (1 - g1),
Parameters g and b of the scattering phase function MHG can be computed analytically.
Forward analytical model (Calabro et al. JBO 19(7) 2014):
g1 = b * g
g2 = b * g^2 + 2/5 (1 - b)
g3 = b * g^3
g_k = b * g^k where k > 2
…
Parameters g and b can be derived from a third-order equation. The obtained values are valid only if 0 <= b <= 1.
- Parameters
gamma (float or np.ndarray) – Target value of parameter gamma = (1 - g2)/(1 - g1).
delta (float or np.ndarray) – Target value of parameter delta = (1 - g3)/(1 - g1).
- Returns
g (float or np.ndarray) – Estimated values of parameter g.
b (float or np.ndarray) – Estimated values of parameter b.
valid (bool or np.ndarray) – A binary mask indicating valid values of g and b.
- sigma(gs: list) → float[source]¶
Computes parameter sigma from the given Legendre moments.
sigma = sum( (-0.5)^(i - 2) (1 - gi)/(1 - g1), for i = 2, 3, …
where gi is the i-th Legendre moment.
References:
Bodenschatz et al, JBO, 21(3) 2016.
- Parameters
gs (tuple, list, ndarray) – First n Legendre moments as (g0, g1, g2, g3, …, gn)
- Returns
sigma – Parameter sigma
- Return type
float