Values

Classes for measured values.

These values are convenient for I/O, plotting, and conversions since they make use of astropy units. The flexibility of these classes allow for input photometry to be defined using whatever units are intuitive and convenient for the user.

For example, AMPy uses flux units of mJy and erg cm-2 s-1 internally, but the input photometry can be defined in any spectral flux density and energy flux units. The values are converted at read in so that the user doesn't have to deal with any of it.

Users can even define their inputs using spectrally equivalent units. For example, AMPy uses Hz internally for all integration ranges, but Swift XRT reports their integration range using eV. The user can input the range using eV and AMPy will convert to Hz using h at read in.

circle-exclamation

Bound

class Bound(lower, upper)

A bounded region with units.

Parameters

lower: astropy.units.Quantity

The lower bound with units equal to those of upper.

upper: astropy.units.Quantity

The upper bound with units equal to those of lower.

Attributes

value: tuple

The tuple of (lower, upper).

Properties

center: astropy.units.Quantity

The average of lower and upper.

width : astropy.units.Quantity

The difference of upper - lower.

Methods

Bound.encompasses(v, inclusive=True)

Checks if v is between lower and upper. If v is dimensionless Quantity or a simple float, assumes that v has units equal to that of lower and upper.

Parameters

v: float or astropy.units.Quantity

The value to check.

inclusive : bool, optional, default = True

If True, does an inclusive check, else exclusive.

Returns

bool

Do the bounds encompass the value?


Examples


SpectralFlux

class SpectralFlux(value, lower, upper, time, frequency=N, wavelength=None, band=None)

A spectral flux (flux density) measurement.

Parameters

value: astropy.units.Quantity['spectral flux density']

The flux value.

lower: astropy.units.Quantity['spectral flux density']

The lower uncertainty.

upper: astropy.units.Quantity['spectral flux density']

The upper uncertainty.

time : astropy.units.Quantity['time']

The time of the flux measurement.

frequency : astropy.units.Quantity['frequency']

The average band frequency. Either frequency or wavelength must be provided. If wavelength is provided instead, the frequency is calculated using the speed of light and stored with units of Hz.

wavelength : astropy.units.Quantity['length']

The average band wavelength. Either frequency or wavelength must be provided. If frequency is provided instead, the wavelength is calculated using the speed of light and stored with units of um.

band : str, optional, default = None

The name of the observed band. Useful for plotting routines.

Attributes

uncertainty : Bound

The uncertainty bounds.

Parameters

avg_uncertainty : astropy.units.Quantity['spectral flux density']

Returns self.uncertainty.center. I.e., the average of lower and upper.

Methods

SpectralFlux.from_csv_row(row)

Parses a NamedTuple from a Pandas.DataFrame row and returns a SpectralFlux.

See ?? for the schema.

Parameters

row: NamedTuple

See ?? for the schema.

Returns

SpectralFlux

Raises

IOError

Catches any error while parsing and redirects into an IOError containing the offending row number.


IntegratedFlux

class IntegratedFlux(value, lower, upper, time, int_lower=None, int_upper=None, band=None)

An integrated flux measurement.

Parameters

value: astropy.units.Quantity['energy flux']

The integrated flux value.

lower: astropy.units.Quantity['energy flux']

The lower uncertainty.

upper: astropy.units.Quantity['energy flux']

The upper uncertainty.

time : astropy.units.Quantity['time']

The time of the flux measurement.

int_lower : astropy.units.Quantity['frequency']

The lower bound of the integration range.

int_upper : astropy.units.Quantity['frequency']

The upper bound of the integration range.

band : str, optional, default = None

The name of the observed band. Useful for plotting routines.

Attributes

uncertainty : Bound

The uncertainty bounds.

int_range : Bound

The integration limits.

Parameters

frequency : astropy.units.Quantity['frequency']

The log average of the integration limits.

avg_uncertainty : astropy.units.Quantity['spectral flux density']

The average of lower and upper. I.e., self.uncertainty.center.

int_type : str

The physical type of the integration limits (e.g., frequency).

Methods

IntegratedFlux.from_csv_row(row)

Parses a NamedTuple from a Pandas.DataFrame row and returns an IntegratedFlux.

See ?? for the schema.

Parameters

row: NamedTuple

See ?? for the schema.


IntegratedFlux.to_spectral(unit='mJy')

Converts self to a SpectralFlux and returns it.

Parameters

unit: str or astropy.units.Unit], default = mJy

The spectral flux density unit to convert to.

Returns

SpectralFlux

The SpectralFlux equivalent.


SpectralIndex

class SpectralIndex(value, lower, upper, time, int_lower=None, int_upper=None)

A spectral index measurement.

Parameters

value: astropy.units.Quantity['energy flux']

The integrated flux value.

lower: astropy.units.Quantity['energy flux']

The lower uncertainty.

upper: astropy.units.Quantity['energy flux']

The upper uncertainty.

time : astropy.units.Quantity['time']

The time of the flux measurement.

int_lower : astropy.units.Quantity['frequency']

The lower bound of the integration range.

int_upper : astropy.units.Quantity['frequency']

The upper bound of the integration range.

Attributes

uncertainty : Bound

The uncertainty bounds.

int_range : Bound

The integration limits.

Parameters

avg_uncertainty : astropy.units.Quantity['spectral flux density']

The average of lower and upper. I.e., self.uncertainty.center.

int_type : str

The physical type of the integration limits (e.g., frequency).

Methods

SpectralIndex.from_csv_row(row)

Parses a NamedTuple from a Pandas.DataFrame row and returns a SpectralIndex.

See ?? for the schema.

Parameters

row: NamedTuple

See ?? for the schema.


Last updated