xopto.pf.util.pfmapmpc module

class MPcMap(n=None, b=None, ng=15, filename=None, ncostheta=None)[source]

Bases: xopto.pf.util.pfmapbase.PfMap2DBase

Prepares maps of the first ng Legendre moments of the Modified Power of Cosine (MPC) scattering phase function, over the specified range of the MPC parameters n and b. If ng >= 2, a map of gamma is prepared and if ng >= 3 maps of delta and sigma are prepared as well. The maps are used to obtain an initial estimate when calculating the MPC scattering phase function parameters from given Legendre moments, gamma and/or delta.

Parameters
  • n (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the n MPC parameter.

  • b (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the b MPC parameter (Power of cosine scattering phase function contribution).

  • ng (int) – Maps are created for the first ng Legendre moments. If ng >= 2, a map of gamma is prepared and if g >= 3 maps of delta and sigma are prepared as well.

  • filename (str) – File with saved data. The values of all the other parameters are ignored and restored from the file.

  • ncostheta (int) – Number of nodes used to compute the Legendre moments. Use a large number (> 1000) for accurate results. If None, adaptive step integration is used, which is accurate but can become slow.

Note

The value of parameter ng should be >> 3 to accurately estimate the value of parameter sigma.

Examples

Prepares maps of gamma and delta, and estimates the MHG parameters given a) g and gamma are known b) gamma and delta are known.

>>> import numpy as np
>>>
>>> m = MPcMap(np.linspace(0.0, 10, 100), np.linspace(0.0, 0.99, 100), ng=3)
>>> n, b = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'n:', n, 'b:', b)
>>> n, b = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'n:', n, 'b:', b)
>>>

Load maps from the default file included in the data/pf folder.

>>> m = MPcMap.fromfile()
>>> n, b = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'n:', n, 'b:', b)
>>> n, b = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'n:', n, 'b:', b)
>>>
DEFAULT_MAP_FILE = 'mpc_map.npz'

A filename for the default map. Overload this static member in derived classes.

PLOTSCALEFACTORX = 1.0
PLOTSCALEFACTORY = 1.0

Base class for computing maps of scattering phase function quantifiers as a function ot the scattering phase functions parameters - only for two-parametric scattering phase functions.

XLABEL = 'n'
YLABEL = 'b'
b()numpy.ndarray[source]

Returns a vector of points defining the grid of the first MPC parameter b.

b_grid()numpy.ndarray[source]

Returns a 2D map (meshgrid) of the second parameter b of the MPC scattering phase function.

n()numpy.ndarray[source]

Returns a vector of points defining the grid of the first MPC parameter n.

n_grid()numpy.ndarray[source]

Returns a 2D map (meshgrid) of the first parameter n of the MPC scattering phase function.

classmethod precalculate(n: int = 500, filename: Optional[str] = None, verbose: bool = True)[source]

Precalculate MPc scattering phase function lookup table.

Parameters
  • n (int) – Number of steps along the scattering phase function parameters.

  • filename (str) – Output file or None to save as the default lookup table.

  • verbose (bool) – Turn on verbose progress report.