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.
Since it is expensive to do calculations with astropy units, these classes are not used during the MCMC routine. Values are converted to simple floats for fitting.
Bound
class Bound(lower, upper)
A bounded region with units.
Parameters
lower: astropy.units.QuantityThe lower bound with units equal to those of
upper.
upper: astropy.units.QuantityThe upper bound with units equal to those of
lower.
Attributes
value: tupleThe tuple of (
lower,upper).
Properties
center: astropy.units.QuantityThe average of
lowerandupper.
width: astropy.units.QuantityThe 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.QuantityThe value to check.
inclusive: bool, optional, default =TrueIf
True, does an inclusive check, else exclusive.
Returns
boolDo 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
frequencyorwavelengthmust be provided. Ifwavelengthis provided instead, the frequency is calculated using the speed of light and stored with units ofHz.
wavelength: astropy.units.Quantity['length']The average band wavelength. Either
frequencyorwavelengthmust be provided. Iffrequencyis provided instead, the wavelength is calculated using the speed of light and stored with units ofum.
band: str, optional, default = NoneThe name of the observed band. Useful for plotting routines.
Attributes
uncertainty: BoundThe uncertainty bounds.
Parameters
avg_uncertainty: astropy.units.Quantity['spectral flux density']Returns
self.uncertainty.center. I.e., the average oflowerandupper.
Methods
SpectralFlux.from_csv_row(row)
Parses a NamedTuple from a Pandas.DataFrame row and returns a SpectralFlux.
See ?? for the schema.
Parameters
row: NamedTupleSee ?? for the schema.
Returns
SpectralFlux
Raises
IOErrorCatches any error while parsing and redirects into an
IOErrorcontaining 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 = NoneThe name of the observed band. Useful for plotting routines.
Attributes
uncertainty: BoundThe uncertainty bounds.
int_range: BoundThe 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
lowerandupper. I.e.,self.uncertainty.center.
int_type: strThe 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: NamedTupleSee ?? for the schema.
IntegratedFlux.to_spectral(unit='mJy')
Converts self to a SpectralFlux and returns it.
Parameters
unit: str or astropy.units.Unit], default = mJyThe spectral flux density unit to convert to.
Returns
SpectralFluxThe
SpectralFluxequivalent.
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: BoundThe uncertainty bounds.
int_range: BoundThe integration limits.
Parameters
avg_uncertainty: astropy.units.Quantity['spectral flux density']The average of
lowerandupper. I.e.,self.uncertainty.center.
int_type: strThe 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: NamedTupleSee ?? for the schema.
Last updated