Classes
- 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 photospheric 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
- 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
Photospheric parameter axis labels.
- Type
list
- property axis_x_min
Photospheric parameter axis minima.
- Type
dict
- property axis_x_max
Photospheric 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_usage
Current memory usage of grid cache (MB).
- Type
int
- property cache_limit
Maximum memory usage of grid cache (MB).
- Type
int
- flush_cache()
Flush the grid cache
- intensity(x, mu, lam, deriv=None)
Evaluate the spectroscopic intensity.
- Parameters
x (dict) – Photospheric 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 photospheric 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
- 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) – Photospheric 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 photospheric 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
- 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) – Photospheric 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 photospheric 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
- 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) – Photospheric 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 photospheric 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
- 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.
- class pymsg.PhotGrid(file_name, passband_file_name=None)
The PhotGrid class represents a grid of photometric intensity data.
This grid may be used to interpolate the intensity (or related quantities) for a set of photospheric parameter values.
- __init__(file_name, passband_file_name=None)
- PhotGrid constructor (via loading data from a photgrid file, or
from a specgrid file together with a passband file).
- Parameters
file_name (string) – Name of grid file.
passband_file_name (string) – Name of passband file (if file_name corresponds to a specgrid file)
- Returns
Constructed object.
- Return type
- Raises
FileNotFound – If either file cannot be found.
TypeError – If either file contains an incorrect datatype.
- property rank
Number of dimensions in grid.
- Type
int
- property axis_labels
Photospheric parameter axis labels.
- Type
list
- property axis_x_min
Photospheric parameter axis minima.
- Type
dict
- property axis_x_max
Photospheric parameter axis maxima.
- Type
dict
- property cache_usage
Current memory usage of grid cache (MB).
- Type
int
- property cache_limit
Maximum memory usage of grid cache (MB).
- Type
int
- flush_cache()
Flush the grid cache
- intensity(x, mu, deriv=None)
Evaluate the photometric intensity, normalized to the zero- point flux.
- Parameters
x (dict) – Photospheric parameters; keys must match axis_labels property, values must be double.
mu (double) – Cosine of angle of emergence relative to surface normal.
deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each photospheric parameter; keys must match the axis_labels property, values must be boolean.
- Returns
photometric intensity (/sr).
- Return type
double
- Raises
KeyError – If x does not define all keys appearing in the axis_labels property.
ValueError – If x or mu falls outside the bounds of the grid.
LookupError – If x falls in a grid void.
- E_moment(x, k, deriv=None)
Evaluate the photometric intensity E-moment, normalized to the zero-point flux.
- Parameters
x (dict) – Photospheric parameters; keys must match axis_labels property, values must be double.
k (int) – Degree of moment.
deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each photospheric parameter; keys must match the axis_labels property, values must be boolean.
- Returns
photometric intensity E-moment.
- Return type
double
- Raises
KeyError – If x does not define all keys appearing in the axis_labels property.
ValueError – If x or k falls outside the bounds of the grid.
LookupError – If x falls in a grid void.
- D_moment(x, l, deriv=None)
Evaluate the photometric intensity D-moment, normalized to the zero-point flux.
- Parameters
x (dict) – Photospheric parameters; keys must match axis_labels property, values must be double.
l (int) – Harmonic degree of moment.
deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each photospheric parameter; keys must match the axis_labels property, values must be boolean.
- Returns
photometric intensity D-moment.
- Return type
double
- Raises
KeyError – If x does not define all keys appearing in the axis_labels property.
ValueError – If x or l falls outside the bounds of the grid.
LookupError – If x falls in a grid void.
- flux(x, deriv=None)
Evaluate the photometric flux, normalized to the zero-point flux.
- Parameters
x (dict) – Photospheric parameters; keys must match axis_labels property, values must be double.
deriv (dict, optional) – Flags indicating whether to evaluate derivative with respect to each photospheric parameter; keys must match the axis_labels property, values must be boolean.
- Returns
photometric flux.
- Return type
double
- Raises
KeyError – If x does not define all keys appearing in the axis_labels property.
ValueError – If x or l falls outside the bounds of the grid.
LookupError – If x falls in a grid void.