SpecGrid

class pymsg.SpecGrid(file_name)

The SpecGrid class represents a grid of spectroscopic intensity data.

This grid may be used to interpolate the intensity (or related quantities) across a wavelength abscissa and for a set of atmosphere parameter values.

__init__(file_name)

SpecGrid constructor (via loading data from a specgrid file).

Parameters

file_name (string) – Name of the file

Returns

Constructed object.

Return type

pymsg.SpecGrid

Raises
  • FileNotFound – If the the file cannot be found.

  • TypeError – If the file contains an incorrect datatype.

property rank

Number of dimensions in grid.

Type

int

property axis_labels

Atmosphere parameter axis labels.

Type

list

property axis_x_min

Atmosphere parameter axis minima.

Type

dict

property axis_x_max

Atmosphere parameter axis maxima.

Type

dict

property lam_min

Minimum wavelength of grid.

Type

double

property lam_max

Maximum wavelength of grid.

Type

double

property cache_lam_min

Minimum wavelength of grid cache.

Type

double

property cache_lam_max

Maximum wavelength of grid cache.

Type

double

property cache_count

Number of nodes currently held in grid cache.

Type

int

property cache_limit

Maximum number of nodes to hold in grid cache. Set to 0 to disable caching.

Type

double

intensity(x, mu, lam, deriv=None)

Evaluate the spectroscopic intensity.

Parameters
  • x (dict) – Atmosphere parameters; keys must match axis_labels property, values must be double.b

  • mu (double) – Cosine of angle of emergence relative to surface normal.

  • lam (numpy.ndarray) – Wavelength abscissa (Å).

  • deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each atmosphere parameter; keys must match the axis_labels property, values must be boolean.

Returns

Spectroscopic intensity (erg/cm^2/s/Å/sr) in bins delineated by lam; length len(lam)-1.

Return type

numpy.ndarray

Raises
  • KeyError – If x does not define all keys appearing in the axis_labels property.

  • ValueError – If x, mu, or any part of the wavelength abscissa falls outside the bounds of the grid.

  • LookupError – If x falls in a grid void.

E_moment(x, k, lam, deriv=None)

Evaluate the spectroscopic intensity E-moment.

Parameters
  • x (dict) – Atmosphere parameters; keys must match axis_labels property, values must be double.

  • k (int) – Degree of moment.

  • lam (numpy.ndarray) – Wavelength abscissa (Å).

  • deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each atmosphere parameter; keys must match the axis_labels property, values must be boolean.

Returns

Spectroscopic intensity E-moment (erg/cm^2/s/Å) in bins delineated by lam; length len(lam)-1.

Return type

numpy.ndarray

Raises
  • KeyError – If x does not define all keys appearing in the axis_labels property.

  • ValueError – If x, k, or any part of the wavelength abscissa falls outside the bounds of the grid.

  • LookupError – If x falls in a grid void.

D_moment(x, l, lam, deriv=None)

Evaluate the spectroscopic intensity D-moment.

Parameters
  • x (dict) – Atmosphere parameters; keys must match axis_labels property, values must be double.

  • l (int) – Harmonic degree of moment.

  • lam (numpy.ndarray) – Wavelength abscissa (Å).

  • deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each atmosphere parameter; keys must match the axis_labels property, values must be boolean.

Returns

Spectroscopic intensity D-moment (erg/cm^2/s/Å) in bins delineated by lam; length len(lam)-1.

Return type

numpy.ndarray

Raises
  • KeyError – If x does not define all keys appearing in the axis_labels property.

  • ValueError – If x, l, or any part of the wavelength abscissa falls outside the bounds of the grid.

  • LookupError – If x falls in a grid void.

flux(x, lam, deriv=None)

Evaluate the spectroscopic flux.

Parameters
  • x (dict) – Atmosphere parameters; keys must match axis_labels property, values must be double.

  • lam (numpy.ndarray) – Wavelength abscissa (Å)

  • deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each atmosphere parameter; keys must match the axis_labels property, values must be boolean.

Returns

Spectroscopic flux (erg/cm^2/s/Å) in bins delineated by lam; length len(lam)-1.

Return type

numpy.ndarray

Raises
  • KeyError – If x does not define all keys appearing in the axis_labels property.

  • ValueError – If x or any part of the wavelength abscissa falls outside the bounds of the grid.

  • LookupError – If x falls in a grid void.