webbpsf_ext.spectra.source_spectrum
- class webbpsf_ext.spectra.source_spectrum(name, sptype, mag_val, bp, votable_input, Teff=None, metallicity=None, log_g=None, Av=None, **kwargs)[source]
Bases:
objectModel source spectrum
The class ingests spectral information of a given target and generates
s_ext.Spectrummodel fit to the known photometric SED. Two model routines can fit. The first is a very simple scale factor that is applied to the input spectrum, while the second takes the input spectrum and adds an IR excess modeled as a modified blackbody function.- Parameters:
name (string) – Source name.
sptype (string) – Assumed stellar spectral type. Not relevant if Teff, metallicity, and log_g are specified.
mag_val (float) – Magnitude of input bandpass for initial scaling of spectrum.
bp (
s_ext.Bandpass) – Bandpass to apply initial mag_val scaling.votable_input (string) – VOTable name that holds the source’s photometry. The user can find the relevant data at http://vizier.u-strasbg.fr/vizier/sed/ and click download data. Or astropy Table with column ‘sed_freq’, ‘sed_flux’, ‘sed_eflux’.
- Keyword Arguments:
Teff (float) – Effective temperature ranging from 3500K to 30000K.
metallicity (float) – Metallicity [Fe/H] value ranging from -2.5 to 0.5.
log_g (float) – Surface gravity (log g) from 0 to 5.
Av (float) – Add extinction to the stellar spectrum
catname (str) – Catalog name, including ‘bosz’, ‘ck04models’, and ‘phoenix’. Default is ‘bosz’, which comes from
BOSZ_spectrum().res (str) – Spectral resolution to use (200 or 2000 or 20000).
interpolate (bool) – Interpolate spectrum using a weighted average of grid points surrounding the desired input parameters. Default: True
radius (float) – Search radius in arcseconds for Vizier query. Default: 1 arcsec.
Example
Generate a source spectrum and fit photometric data
>>> import webbpsf_ext >>> from webbpsf_ext.spectra import source_spectrum >>> >>> name = 'HR8799' >>> vot = 'votables/{}.vot'.format(name) >>> bp_k = webbpsf_ext.bp_2mass('k') >>> >>> # Read in stellar spectrum model and normalize to Ks = 5.24 >>> src = source_spectrum(name, 'F0V', 5.24, bp_k, vot, >>> Teff=7430, metallicity=-0.47, log_g=4.35) >>> # Fit model to photometry from 0.1 - 30 microns >>> # Saves synphot spectral object at src.sp_model >>> src.fit_SED(wlim=[0.1,30]) >>> sp_sci = src.sp_model
- __init__(name, sptype, mag_val, bp, votable_input, Teff=None, metallicity=None, log_g=None, Av=None, **kwargs)[source]
Methods
__init__(name, sptype, mag_val, bp, ...[, ...])bb_jy(wave, T)Blackbody function (Jy)
fit_SED([x0, robust, use_err, IR_excess, ...])Fit a model function to photometry
func_resid(x[, IR_excess, wlim, use_err])Calculate model residuals
model_IRexcess(x[, sp])Model for stellar spectrum with IR excess
model_scale(x[, sp])Simple model to scale stellar spectrum
plot_SED([ax, return_figax, xr, yr, units])- bb_jy(wave, T)[source]
Blackbody function (Jy)
For a given wavelength set (in um) and a Temperature (K), return the blackbody curve in units of Jy.
- Parameters:
wave (array_like) – Wavelength array in microns
T (float) – Temperature of blackbody (K)
- fit_SED(x0=None, robust=True, use_err=True, IR_excess=False, wlim=[0.3, 10], verbose=True)[source]
Fit a model function to photometry
Use
scipy.optimize.least_squares()to find the best fit model to the observed photometric data. If no parameters passed, then defaults are set.- Keyword Arguments:
x0 (array_like) – Initial guess of independent variables.
robust (bool) – Perform an outlier-resistant fit.
use_err (bool) – Should we use the uncertainties in the SED photometry for weighting?
IR_excess (bool) – Include IR excess in model fit? This is a simple modified blackbody.
wlim (array_like) – Min and max limits for wavelengths to consider (microns).
verbose (bool) – Print out best-fit model parameters. Defalt is True.
- func_resid(x, IR_excess=False, wlim=[0.1, 30], use_err=True)[source]
Calculate model residuals
- Parameters:
x (array_like) – Model parameters for either model_scale or model_IRexcess. See these two functions for more details.
IR_excess (bool) – Include IR excess in model fit? This is a simple modified blackbody.
wlim (array_like) – Min and max limits for wavelengths to consider (microns).
use_err (bool) – Should we use the uncertainties in the SED photometry for weighting?