xopto.pf.util.pfmapgk module

class GkMap(ggk: Optional[numpy.ndarray] = None, a: Optional[numpy.ndarray] = None, ng: int = 15, filename: Optional[str] = None, ncostheta: Optional[int] = None)[source]

Bases: xopto.pf.util.pfmapbase.PfMap2DBase

Prepares maps of the first ng Legendre moments of the Gegenbauer Kernel (GK) scattering phase function, over the specified range of the GK parameters gg and a. 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 GK scattering phase function parameters from given Legendre moments, gamma and/or delta.

Parameters
  • ggk (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the gg parameter of the GK scattering phase function.

  • a (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the a parameter of the GK scattering phase function.

  • 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 GK parameters given a) g and gamma are known b) gamma and delta are known.

>>> import numpy as np
>>>
>>> m = GkMap(np.linspace(0.0, 0.98, 100), np.linspace(-0.5, 5.0, 100), ng=3)
>>> ggk, a = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'ggk:', ggk, 'a:', a)
>>> ggk, a = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'ggk:', ggk, 'a:', a)
>>>

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

>>> m = GkMap.fromfile()
>>> ggk, a = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'ggk:', ggk, 'a:', a)
>>> ggk, a = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'ggk:', ggk, 'a:', a)
>>>
DEFAULT_MAP_FILE = 'gk_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 = '$g_{gk}$'
YLABEL = '$\\alpha_{gk}$'
a()numpy.ndarray[source]

Returns a vector of points defining the grid of parameter a of the GK scattering phase function.

a_grid()numpy.ndarray[source]

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

ggk()numpy.ndarray[source]

Returns a vector of points defining the grid of gg GK parameter

ggk_grid()numpy.ndarray[source]

Returns a 2D map (meshgrid) of the first parameter ggk of the GK scattering phase function input parameter.

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

Precalculate the Gk 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.