xopto.pf.util.pfpolygonbase module

class GammaDeltaPolygonBase(gamma: numpy.ndarray, delta: numpy.ndarray, filename: Optional[str] = None)[source]

Bases: object

Constructor of a domain boundary polygon.

Parameters
  • gamma (np.ndarray vector) – A vector of gamma coordinates that lie on the boundary.

  • delta (np.ndarray vector) – A corresponding vector of delta coordinates that lie on the boundary.

  • filename (str) – Load boundary from a file.

DEFAULT_POLYGON_FILE = None
DEFAULT_POLYGON_PATH = '/home/miran/.xopto/pyxopto/data/pf'
NUM_POINTS = 10000
boundary()Tuple[numpy.ndarray, numpy.ndarray][source]

Returns points along the boundary of the domain as two ndarray vectors gamma, delta.

Returns

  • gamma (np.ndarray vector) – Gamma coordinates of the points along the boundary of the domain.

  • delta (np.ndarray vector) – Delta coordinates of the points along the boundary of the domain.

contains(gamma: float, delta: float, boundary: bool = True)bool[source]

Fast polygon-based validation of the scattering phase function gamma-delta domain.

Parameters
  • gamma (float or np.ndarray) – Parameter gamma

  • delta (float or np.ndarray) – Parameter delta

  • boundary (bool) – If True the region includes the boundary, else not.

Returns

valid – True if valid (gamma and delta lie within the domain boundary), else False.

Return type

bool, ndarray

classmethod default_data_file()[source]

Creates a full filename for the default data file.

Returns

filename – Full filename of the default data file.

Return type

str

delta(gamma: float)Tuple[numpy.ndarray, numpy.ndarray][source]

Returns two nearest points on boundary of the domain for the given gamma value or None if the given gamma value is out of range.

Parameters

gamma (float) – Gamma value at which to find two nearets points on the boundary of the domain.

Returns

  • gamma (np.ndarray vector of 2 floats) – Gamma coordinates of the nearest two points on the boundary of the domain.

  • delta (np.ndarray vector of 2 floats) – Delta coordinates of the nearest two points on the boundary of the domain.

classmethod fromfile(filename: Optional[str] = None)xopto.pf.util.pfpolygonbase.GammaDeltaPolygonBase[source]

Loads a domain polygon of GK scattering phase function from a file.

Parameters

filename (str) – File with the parameter map data. If None, attempts to load a default map file from data/pf folder.

Returns

polygon – A GkPolygon instance

Return type

GkPolygon

gamma(delta: float)Tuple[numpy.ndarray, numpy.ndarray][source]

Returns two nearest points on the domainn boundary for the given delta value or None if the given delta value is out of range.

Parameters

gamma (float) – Gamma value at which to find two nearest points on domain boundary.

Returns

  • gamma (np.ndarray vector of 2 floats) – Gamma coordinates of the nearest two points on the boundary of the domain.

  • delta (np.ndarray vector of 2 floats) – Delta coordinates of the nearest two points on the boundary of the domain.

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

Precalculate a scattering phase function domain boundary points/polygon and save the data to the given file.

Parameters
  • n (int) – Number of steps along the scattering phase function parameters. If None, a default value from NUM_POINTS static member variable is used.

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

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

save(filename: str)[source]

Save polygon data to a file. :param filename: Name of the file. Extension is not required. :type filename: str

show(marker='-', step=1, pfname='')[source]

Show the domain boundary using matlotlib.