Vega

class sbpy.calib.Vega(source, description=None, bibcode=None)[source] [edit on github]

Bases: SpectralStandard

Vega spectrum.

Parameters:
waveQuantity

Spectral wavelengths.

fluxdQuantity

Spectral flux density.

descriptionstr, optional

Brief description of the source spectrum.

bibcodestr, optional

Bibliography code for sbpy.bib.register.

metadict, optional

Any additional meta data, passed on to SourceSpectrum.

Attributes:
wave - Wavelengths of the source spectrum.
fluxd - Source spectrum.
description - Brief description of the source spectrum.
meta - Meta data.

Examples

Get the default Vega spectrum: >>> vega = Vega.from_default() # doctest: +IGNORE_OUTPUT

Create Vega from a file: >>> vega = Vega.from_file(‘filename’) # doctest: +SKIP

Evaluate Vega at 1 μm (interpolation): >>> print(vega(1 * u.um)) # doctest: +FLOAT_CMP 6.326492514857613e-09 W / (um m2)

Observe Vega through as if through a spectrometer: >>> import numpy as np >>> wave = np.linspace(0.4, 0.6) * u.um >>> spec = vega.observe(wave)

Observe Vega through a filter: >>> from sbpy.photometry import bandpass >>> V = bandpass(‘Johnson V’) >>> fluxd = vega.observe(V)

User provided calibration: >>> from sbpy.calib import vega_fluxd >>> vega = Vega(None) >>> with vega_fluxd.set({‘V’: 3674 * u.Jy, … ‘V(lambda pivot)’: 5511 * u.AA}): … print(vega.observe(‘V’, unit=’Jy’)) 3674.0 Jy

Attributes Summary

description

Description of the source spectrum.

fluxd

The source spectrum.

meta

source

wave

Wavelengths of the source spectrum.

Methods Summary

__call__(wave_or_freq[, unit])

Evaluate/interpolate the source spectrum.

color_index(wfb, unit)

Color index (magnitudes) and effective wavelengths.

from_array(wave, fluxd[, meta])

Create standard from arrays.

from_builtin(name)

Spectrum from a built-in sbpy source.

from_default()

Initialize new spectral standard from current default.

from_file(filename[, wave_unit, flux_unit, ...])

Load the source spectrum from a file.

observe(wfb[, unit, interpolate])

Observe as through filters or spectrometer.

observe_bandpass(bp[, unit])

Observe through a bandpass.

observe_filter_name(filt[, unit])

Flux density through this filter.

observe_spectrum(wave_or_freq[, unit])

Observe source as through a spectrometer.

redden(S)

Redden the spectrum.

show_builtin([print])

List built-in spectra.

Attributes Documentation

description

Description of the source spectrum.

fluxd

The source spectrum.

meta
source
wave

Wavelengths of the source spectrum.

Methods Documentation

__call__(wave_or_freq, unit=None) [edit on github]

Evaluate/interpolate the source spectrum.

Parameters:
wave_or_freqQuantity

Requested wavelengths or frequencies of the resulting spectrum.

unitstr, Unit, optional

Spectral units of the output (flux density). If None, the default depends on wave_or_freq: W/(m2 μm) for wavelengths, Jy for frequencies.

Returns:
fluxdQuantity

The spectrum evaluated/interpolated to the requested wavelengths or frequencies.

color_index(wfb, unit) [edit on github]

Color index (magnitudes) and effective wavelengths.

Parameters:
wfbQuantity, or tuple/list of SectralElement, str

Two wavelengths, frequencies, or bandpasses.

unitstr or MagUnit

Units for the calculation, e.g., astropy.units.ABmag or sbpy.units.VEGAmag.

Returns:
eff_waveQuantity

Effective wavelengths for each wfb.

ciQuantity

Color index, m_0 - m_1, where 0 and 1 are element indexes for wfb.

classmethod from_array(wave, fluxd, meta=None, **kwargs) [edit on github]

Create standard from arrays.

Parameters:
waveQuantity

The spectral wavelengths.

fluxdQuantity

The spectral flux densities.

metadict, optional

Meta data.

**kwargsdict

Passed to object initialization.

classmethod from_builtin(name) [edit on github]

Spectrum from a built-in sbpy source.

Parameters:
namestr

The name of the spectrum. See show_builtin() for available sources.

classmethod from_default() [edit on github]

Initialize new spectral standard from current default.

The spectrum will be None if synphot is not available.

classmethod from_file(filename, wave_unit=None, flux_unit=None, cache=True, **kwargs) [edit on github]

Load the source spectrum from a file.

NaNs are dropped.

Parameters:
filenamestr

The name of the file. See from_file for details.

wave_unit, flux_unitstr or Unit, optional

Wavelength and flux units in the file.

cachebool, optional

If True, cache the contents of URLs.

**kwargsdict

Passed to object initialization.

observe(wfb, unit=None, interpolate=False, **kwargs) [edit on github]

Observe as through filters or spectrometer.

Calls observe_bandpass, observe_spectrum, or self(), as appropriate.

Parameters:
wfbQuantity, SpectralElement, str

Wavelengths, frequencies, or bandpasses. Bandpasses may be a filter name (string). May also be a list of SpectralElement or strings.

unitstr, Unit, optional

Units of the output (spectral flux density).

interpolatebool, optional

For wavelengths/frequencies, set to True for interpolation instead of rebinning. Use this when the spectral resolution of the source is close to that of the requested wavelengths.

**kwargsdict

Additional keyword arguments for Observation, e.g., force.

Returns:
fluxdQuantity
observe_bandpass(bp, unit=None, **kwargs) [edit on github]

Observe through a bandpass.

Parameters:
bpSpectralElement, list, or tuple

Bandpass.

unitstr, Unit, optional

Spectral flux density units for the output. The default is W/(m2 μm).

**kwargsdict

Additional keyword arguments for Observation, e.g., force.

Returns:
lambda_effQuantity

Effective wavelength(s) of the observation(s).

fluxdQuantity

The spectrum rebinned.

observe_filter_name(filt, unit=None) [edit on github]

Flux density through this filter.

Does not use the spectrum, but instead the flux density calibration manager. If the name of the filter is BP, then the expected keys are:

BP : flux density BP(lambda eff) : effective wavelength, optional BP(lambda pivot) : pivot wavelength, optional

Parameters:
filtstr

Name of the filter.

unitstr, Unit, optional

Spectral flux density units for the output.

Returns:
lambda_eff: Quantity

Effective wavelength. None if it is not provided.

lambda_pivot: Quantity

Pivot wavelength. None if it is not provided.

fluxdQuantity

Spectral flux density.

Raises:
FilterLookupError if the filter is not defined.
observe_spectrum(wave_or_freq, unit=None, **kwargs) [edit on github]

Observe source as through a spectrometer.

Important

This method works best when the requested spectral resolution is lower than the spectral resolution of the internal data. If the requested wavelengths/frequencies are exactly the same as the internal spectrum, then the internal spectrum will be returned without binning. This special case does not work for subsets of the wavelengths.

Parameters:
wave_or_freqQuantity

Wavelengths or frequencies of the spectrum. Spectral bins will be centered at these values. The length must be larger than 1.

unitstr, Unit, optional

Spectral flux density units for the output. If None, the default is W/(m2 μm) for wavelengths, Jy for frequencies.

**kwargsdict

Additional keyword arguments for Observation, e.g., force.

Returns:
fluxdQuantity

The spectrum rebinned.

Raises:
SinglePointSpectrumError - If requested wavelengths or

frequencies has only one value.

Notes

Method for spectra adapted from AstroBetter post by Jessica Lu: https://www.astrobetter.com/blog/2013/08/12/python-tip-re-sampling-spectra-with-pysynphot/

redden(S) [edit on github]

Redden the spectrum.

Parameters:
SSpectralGradient

The spectral gradient to redden.

Returns:
specSpectralSource

Reddened spectrum

classmethod show_builtin(print=True) [edit on github]

List built-in spectra.