xopto.pf.util.pfmapmie module

class MieFractalPolystyreneMap(alpha: Optional[numpy.ndarray] = None, wavelength: Optional[numpy.ndarray] = None, ng: int = 15, drange: Tuple[float, float] = (5e-09, 3e-05), nd: int = 1000, 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 MieFractalPolystyrene (FMIE) phase function, over the specified range of the FMIE parameters alpha and wavelength. If ng >= 2, a map of gamma is preapred and if ng >= 3 maps of delta and sigma are prepared as well. The maps are used to obtain an initial estimate when calculateng the FMIE phase function parameters from given Legendre moments, gamma and/or delta.

Parameters
  • alpha (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the alpha parameter of the Fractal Mie phase function.

  • wavelength (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the a wavelength parameter of Fractal Mie phase function [m].

  • drange (list, tuple of two float) – Finite range (m) of the particle diameter used to compute the scattering phase function given as (dmin, dmax). If None, default a range [5e-9, 30e-6] m is used.

  • nd (int) – Number of equally spaced control points between dmin and dmax that are used to estimate the phase function. A fixed-step Simpson numerical integration is used to estimate the phase function at the given deflection angle cosines. If nd is None, adaptive-step numerical integration is used (note that the computational time might increase dramatically!!!).

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

>>> import numpy as np
>>>
>>> m = MieFractalPolystyreneMap(np.linspace(2, 6, 30), np.linspace(0.4e-6, 1e-6, 60), ng=3)
>>> alpha, wavelength = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'alpha:', alpha, 'wavelength:', wavelength)
>>> alpha, wavelength = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'alpha:', alpha, 'wavelength:', wavelength)
>>>

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

>>> m = MieFractalPolystyreneMap.fromfile()
>>> alpha, wavelength = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'alpha:', alpha, 'wavelength:', wavelength)
>>> alpha, wavelength = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'alpha:', alpha, 'wavelength:', wavelength)
>>>
DEFAULT_MAP_FILE = 'fractal_mie_polystyrene_map.npz'

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

PLOTSCALEFACTORX = 1.0
PLOTSCALEFACTORY = 1000000000.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 = '$\\alpha$'
YLABEL = '$\\lambda (nm)$'
alpha()numpy.ndarray[source]

Returns a vector of points defining the grid of alpha parameter.

alpha_grid()numpy.ndarray[source]

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

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

Precalculate fractal Mie polystyrene 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.

wavelength()numpy.ndarray[source]

Returns a vector of points defining the grid of wavelengths.

wavelength_grid()numpy.ndarray[source]

Returns a 2D map (meshgrid) of the second parameter of the scatterin phase function wavelength.

class MiePolystyreneMap(diameter: Optional[numpy.ndarray] = None, wavelength: Optional[numpy.ndarray] = None, ng: int = 15, filename: Optional[str] = None)[source]

Bases: xopto.pf.util.pfmapbase.PfMap2DBase

Prepares maps of the first ng Legendre moments of the MiePolystyrene scattering phase function, over the specified range of spherical particle diameters and wavelengths. 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 MIE scattering phase function parameters from the given Legendre moments, gamma and/or delta.

Parameters
  • diameter (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the micro-sphere diameter parameter of Mie phase function[m].

  • wavelength (np.ndarray vector) – A Vector of equally spaced values defining the grid density of the a wavelength parameter of Mie phase function[m].

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

>>> import numpy as np
>>>
>>> m = MiePolystyreneMap(np.linspace(0.2e-6, 5e-6, 100), np.linspace(0.4e-6, 1e-6, 100), ng=3)
>>> diameter, wavelength = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'diameter:', diameter, 'wavelength:', wavelength)
>>> diameter, wavelength = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'diameter:', diameter, 'wavelength:', wavelength)
>>>

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

>>> m = MiePolystyreneMap.fromfile()
>>> diameter, wavelength = m.invgammadelta(gamma=2.2, delta=3.5)
>>> print('gamma=2.2, delta=3.5 ==>', 'diameter:', diameter, 'wavelength:', wavelength)
>>> diameter, wavelength = m.invgamma(g=0.8, gamma=2.2)
>>> print('g=0.8, gamma=2.2 ==>', 'diameter:', diameter, 'wavelength:', wavelength)
>>>
DEFAULT_MAP_FILE = 'mie_polystyrene_map.npz'

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

PLOTSCALEFACTORX = 1000000000.0
PLOTSCALEFACTORY = 1000000000.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 = '$d (nm)$'
YLABEL = '$\\lambda (nm)$'
diameter()numpy.ndarray[source]

Returns a vector of points defining the grid of diameters.

diameter_grid()[source]

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

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

Precalculate monodisperse Mie polystyrene 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.

wavelength()numpy.ndarray[source]

Returns a vector of points defining the grid of wavelengths.

wavelength_grid()[source]

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