WDmodel.WDmodel module¶
DA White Dwarf Atmosphere Models and SED generator.
Model grid originally from J. Holberg using I. Hubeny’s Tlusty code (v200) and custom Synspec routines, repackaged into HDF5 by G. Narayan.
-
class
WDmodel.WDmodel.WDmodel(grid_file=None, grid_name=None, rvmodel=u'f99')[source]¶ Bases:
objectDA White Dwarf Atmosphere Model and SED generator
Base class defines the routines to generate and work with DA White Dwarf model spectra. Requires a grid file of DA White Dwarf atmospheres. This grid file is included along with the package -
TlustyGrids.hdf5- and is the default.Parameters: - grid_file (str, optional) – Filename of the HDF5 grid file to read. See
WDmodel.io.read_model_grid()for format of the grid file. Default isTlustyGrids.hdf5, included with theWDmodelpackage. - grid_name (str, optional) – Name of the HDF5 group containing the white dwarf model atmosphere
grids in
grid_file. Default isdefault - rvmodel (
{'ccm89','od94','f99','custom'}, optional) –Specify parametrization of the reddening law. Default is
'f99'.rvmodel parametrization 'ccm89'Cardelli, Clayton and Mathis (1989, ApJ, 345, 245) 'od94'O’Donnell (1994, ApJ, 422, 158) 'f99'Fitzpatrick (1999, PASP, 111, 63) 'custom'Custom law from Jay Holberg (email, 20180424)
-
_lines¶ dictionary mapping Hydrogen Balmer series line names to line number, central wavelength in Angstrom, approximate line width and continuum region width around line. Used to extract Balmer lines from spectra for visualization.
Type: dict
-
_wave¶ Array of model grid wavelengths in Angstroms, sorted in ascending order
Type: array-like
-
_ggrid¶ Array of model grid surface gravity values in dex, sorted in ascending order
Type: array-like
-
_tgrid¶ Array of model grid temperature values in Kelvin, sorted in ascending order
Type: array-like
-
_flux¶ Array of model grid fluxes, shape
(_nwave, _ntemp, _ngrav)Type: array-like
-
_lwave¶ Array of model grid
log10wavelengths for interpolationType: array-like
-
_lflux¶ Array of model grid
log10fluxes for interpolation, shape(_ntemp, _ngrav, _nwave)Type: array-like
-
_law¶ Type: extinction function corresponding to rvmodel
Returns: out Return type: WDmodel.WDmodel.WDmodelinstanceRaises: ValueError– If the supplied rvmodel is unknownNotes
Virtually none of the attributes should be used directly since it is trivially possible to break the model by redefining them. Access to them is best through the functions connected to the models.
A custom user-specified grid file can be specified. See
WDmodel.io.read_model_grid()for the format of the grid file.Uses
scipy.interpolate.RegularGridInterpolatorto interpolate the models.The class contains various convenience methods that begin with an underscore (_) that will not be imported by default. These are intended for internal use, and do not have the sanity checking and associated overhead of the public methods.
-
_WDmodel__init__rvmodel(rvmodel=u'f99')¶
-
_WDmodel__init__tlusty(grid_file=None, grid_name=None)¶
-
__call__(teff, logg, wave=None, log=False, strict=True)¶ Returns the model flux given
teffandloggat wavelengthswaveWraps
WDmodel.WDmodel.WDmodel._get_model()adding checking of inputs.Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- wave (array-like, optional) – Desired wavelengths at which to compute the model atmosphere flux. If not supplied, the full model wavelength grid is returned.
- log (bool, optional) – Return the log10 flux, rather than the flux
- strict (bool, optional) – If strict,
teffandloggout of model grid range raise aValueError, otherwise raise aRuntimeWarningand setteff,loggto the nearest grid value.
Returns: - wave (array-like) – Valid output wavelengths
- flux (array-like) – Interpolated model flux at
teff,loggand wavelengthswave
Raises: ValueError– Iftefforloggare out of range of model grid andstrictis True or if there are any invalid wavelengths, or the requested wavelengths to do not overlap with the model gridNotes
Unlike the corresponding private methods, the public methods implement checking of the inputs and returns the wavelengths in addition to the flux. Internally, we only use the private methods as the inputs only need to be checked once, and their state is not altered anywhere after.
-
__init__(grid_file=None, grid_name=None, rvmodel=u'f99')[source]¶ x.__init__(…) initializes x; see help(type(x)) for signature
-
_custom_extinction(wave, av, rv=3.1, unit=u'aa')[source]¶ Return the extinction for
av,rvat wavelengthswavefor the custom reddening law defined by J. HolbergMimics the interface provided by
WDmodel.WDmodel.WDmodel._lawto calculate the extinction as a function of wavelength (in Angstroms), \(A_{\lambda}\).Parameters: Returns: out – Extinction at wavelengths
waveforavandrvReturn type: array-like
Notes
avshould be >= 0.
-
_extract_from_indices(w, f, ZE, df=None)[source]¶ Extracts slices of multiple arrays for the same set of indices.
Convenience function to extract elements of wavelength
w, fluxfand optionally flux uncertaintydfusing indicesZEParameters: - w (array-like) – Wavelength array from which to extract indices
ZE - f (array-like) – Flux array from which to extract indices
ZE - ZE (array-like) – indices to extract
- df (None or array-like, optional) – If array-like, extracted elements of this array are also returned
Returns: - w (array-like) – elements of input wavelength array at indices
ZE - f (array-like) – elements of input flux array at indices
ZE - [df] (array-like) – elements of input flux uncertainty array at indices
ZEif optional inputdfis supplied
- w (array-like) – Wavelength array from which to extract indices
-
_extract_spectral_line(w, f, line, df=None)[source]¶ Extracts slices of multiple arrays corresponding to a hydrogen Balmer line
Convenience function to extract elements of wavelength
w, fluxfand optionally flux uncertaintydffor a hydrogen Balmerline. WrapsWDmodel.WDmodel.WDmodel._get_line_indices()andWDmodel.WDmodel.WDmodel._extract_from_indices(), both of which have their own reasons for existence as well.Parameters: - w (array-like) – Wavelength array from which to extract elements corresponding to
hydrogen Balmer
line - f (array-like) – Flux array from which to extract elements corresponding to hydrogen
Balmer
line - line (
{'alpha', 'beta', 'gamma', 'delta', 'zeta', 'eta'}) – Name of hydrogen Balmer line to extract. Properties are pre-defined inWDmodel.WDmodel.WDmodel._lines - df (None or array-like, optional) – If array-like, extracted elements of this array are also returned
Returns: - w (array-like) – elements of input wavelength array for hydrogen Balmer feature
line - f (array-like) – elements of input flux array for hydrogen Balmer feature
line - [df] (array-like) – elements of input flux uncertainty array for hydrogen Balmer
feature
lineif optional inputdfis supplied
Notes
Same as
WDmodel.WDmodel.WDmodel.extract_spectral_line()without checking of inputs and therefore corresponding overhead. Used internally.- w (array-like) – Wavelength array from which to extract elements corresponding to
hydrogen Balmer
-
_get_full_obs_model(teff, logg, av, fwhm, wave, rv=3.1, log=False, pixel_scale=1.0)[source]¶ Returns the observed model flux given
teff,logg,av,rv,fwhm(for Gaussian instrumental broadening) at wavelengths,waveas well as the full SED.Convenience function that does the same thing as
WDmodel.WDmodel.WDmodel._get_obs_model(), but also returns the full SED without any instrumental broadening applied, appropriate for synthetic photometry.Uses
WDmodel.WDmodel.WDmodel._get_model()to get the unreddened model, and reddens it withWDmodel.WDmodel.WDmodel.reddening()and convolves it with a Gaussian kernel usingscipy.ndimage.filters.gaussian_filter1d()Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- av (float) – Extinction in the V band, \(A_V\)
- fwhm (float) – Instrumental FWHM in Angstrom
- wave (array-like) – Desired wavelengths at which to compute the model atmosphere flux.
- rv (float, optional) – The reddening law parameter, \(R_V\), the ration of the V band
extinction \(A_V\) to the reddening between the B and V bands,
\(E(B-V)\). Default is
3.1, appropriate for stellar SEDs in the Milky Way. - log (bool, optional) – Return the log10 flux, rather than the flux (what’s actually interpolated)
- pixel_scale (float, optional) – Jacobian of the transformation between wavelength in Angstrom and
pixels. In principle, this should be a vector, but virtually all
spectral reduction packages resample the spectrum onto a uniform
wavelength scale that is close to the native pixel scale of the
spectrograph. Default is
1.
Returns: - flux (array-like) – Interpolated model flux at
teff,loggwith reddening parametrized byav,rvand broadened by a Gaussian kernel defined byfwhmat wavelengthswave - mod (
numpy.recarraywithdtype=[('wave', '<f8'), ('flux', '<f8')]) – Full model SED atteff,loggwith reddening parametrized byav,rv
Notes
fwhmandpixel_scalemust be > 0
-
classmethod
_get_indices_in_range(wave, WA, WB, W0=None)[source]¶ Returns indices of wavelength between blue and red wavelength limits and the central wavelength
Parameters: - wave (array-like) – Wavelengths array from which to extract indices
- WA (float) – blue limit of wavelengths to extract
- WB (float) – red limit of wavelenghts to extract
- W0 (float or None, optional) –
Noneor a central wavelength of range[WA, WB]to return. IfNone, the central wavelength is computed, else the input is simply returned.
Returns: - W0 (float) – central wavelength of range
[WA, WB] - ZE (array-like) – indices of
wavein range[WA, WB]
-
_get_line_indices(wave, line)[source]¶ Returns the central wavelength and indices of wavelength corresponding to a hydrogen Balmer line
Parameters: - wave (array-like) – Wavelengths array from which to extract indices
- line (
{'alpha', 'beta', 'gamma', 'delta', 'zeta', 'eta'}) – Name of hydrogen Balmer line to extract. Properties are pre-defined inWDmodel.WDmodel.WDmodel._lines
Returns: - W0 (float) – central wavelength of line
- ZE (array-like) – indices of wave of line
Notes
No checking of input - will throw
KeyErrorif line is not accepted value
-
_get_model(teff, logg, wave=None, log=False)[source]¶ Returns the model flux given
teffandloggat wavelengthswaveSimple 3-D interpolation of model grid. Computes unreddened, unnormalized, unconvolved, interpolated model flux. Uses
scipy.interpolate.RegularGridInterpolatorto generate the interpolated model. This output has been tested againstWDmodel.WDmodel.WDmodel._get_model_nosp().Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- wave (array-like, optional) – Desired wavelengths at which to compute the model atmosphere flux. If not supplied, the full model wavelength grid is returned.
- log (bool, optional) – Return the log10 flux rather than the flux.
Returns: flux – Interpolated model flux at
teff,loggand wavelengthswave.Return type: array-like
Notes
Inputs
teff,loggandwavemust be within the bounds of the grid. SeeWDmodel.WDmodel.WDmodel._wave,WDmodel.WDmodel.WDmodel._ggrid,WDmodel.WDmodel.WDmodel._tgrid, for grid locations and limits.
-
_get_model_nosp(teff, logg, wave=None, log=False)[source]¶ Returns the model flux given
teffandloggat wavelengthswaveSimple 3-D interpolation of model grid. Computes unreddened, unnormalized, unconvolved, interpolated model flux. Not used, but serves as check of output of interpolation of
scipy.interpolate.RegularGridInterpolatoroutput.Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- wave (array-like, optional) – Desired wavelengths at which to compute the model atmosphere flux. If not supplied, the full model wavelength grid is returned.
- log (bool, optional) – Return the log10 flux, rather than the flux.
Returns: flux – Interpolated model flux at
teff,loggand wavelengthswaveReturn type: array-like
Notes
Inputs
teff,loggandwavemust be within the bounds of the grid. SeeWDmodel.WDmodel.WDmodel._wave,WDmodel.WDmodel.WDmodel._ggrid,WDmodel.WDmodel.WDmodel._tgrid, for grid locations and limits.This restriction is not imposed here for performance reasons, but is implicitly set by routines that call this method. The user is expected to verify this condition if this method is used outside the context of the
WDmodelpackage. Caveat emptor.
-
_get_obs_model(teff, logg, av, fwhm, wave, rv=3.1, log=False, pixel_scale=1.0)[source]¶ Returns the observed model flux given
teff,logg,av,rv,fwhm(for Gaussian instrumental broadening) and wavelengthswaveUses
WDmodel.WDmodel.WDmodel._get_model()to get the unreddened model, and reddens it withWDmodel.WDmodel.WDmodel.reddening()and convolves it with a Gaussian kernel usingscipy.ndimage.filters.gaussian_filter1d()Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- av (float) – Extinction in the V band, \(A_V\)
- fwhm (float) – Instrumental FWHM in Angstrom
- wave (array-like) – Desired wavelengths at which to compute the model atmosphere flux.
- rv (float, optional) – The reddening law parameter, \(R_V\), the ration of the V band extinction \(A_V\) to the reddening between the B and V bands, \(E(B-V)\). Default is 3.1, appropriate for stellar SEDs in the Milky Way.
- log (bool, optional) – Return the log10 flux, rather than the flux (what’s actually interpolated)
- pixel_scale (float, optional) – Jacobian of the transformation between wavelength in Angstrom and
pixels. In principle, this should be a vector, but virtually all
spectral reduction packages resample the spectrum onto a uniform
wavelength scale that is close to the native pixel scale of the
spectrograph. Default is
1.
Returns: flux – Interpolated model flux at
teff,loggwith reddening parametrized byav,rvand broadened by a Gaussian kernel defined byfwhmat wavelengthswaveReturn type: array-like
Notes
fwhmandpixel_scalemust be > 0
-
_get_red_model(teff, logg, av, wave, rv=3.1, log=False)[source]¶ Returns the reddened model flux given
teff,logg,av,rvat wavelengthswaveUses
WDmodel.WDmodel.WDmodel._get_model()to get the unreddened model, and reddens it withWDmodel.WDmodel.WDmodel.reddening()Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- av (float) – Extinction in the V band, \(A_V\)
- wave (array-like) – Desired wavelengths at which to compute the model atmosphere flux.
- rv (float, optional) – The reddening law parameter, \(R_V\), the ration of the V band extinction \(A_V\) to the reddening between the B and V bands, \(E(B-V)\). Default is 3.1, appropriate for stellar SEDs in the Milky Way.
- log (bool, optional) – Return the log10 flux, rather than the flux (what’s actually interpolated)
Returns: flux – Interpolated model flux at
teff,loggwith reddening parametrized byav,rvat wavelengthswaveReturn type: array-like
-
classmethod
_wave_test(wave)[source]¶ Raises an error if wavelengths are not valid
Parameters: wave (array-like) – Array of wavelengths to test for validity Raises: ValueError– If wavelength array is empty, has negative values, or is not monotonic
-
extinction(wave, av, rv=3.1)[source]¶ Return the extinction for
av,rvat wavelengthswaveUses the extinction function corresponding to the
rvmodelparametrization set asWDmodel.WDmodel.WDmodel._lawto calculate the extinction as a function of wavelength (in Angstroms), \(A_{\lambda}\).Parameters: - wave (array-like) – Array of wavelengths in Angstrom at which to compute extinction, sorted in ascending order
- av (float) – Extinction in the V band, \(A_V\)
- rv (float, optional) – The reddening law parameter, \(R_V\), the ration of the V band
extinction \(A_V\) to the reddening between the B and V bands,
\(E(B-V)\). Default is
3.1, appropriate for stellar SEDs in the Milky Way.
Returns: out – Extinction at wavelengths
waveforavandrvReturn type: array-like
Notes
avshould be >= 0.
-
extract_spectral_line(w, f, line, df=None)[source]¶ Extracts slices of multiple arrays corresponding to a hydrogen Balmer line
Convenience function to extract elements of wavelength
w, fluxfand optionally flux uncertaintydffor a hydrogen Balmer line. WrapsWDmodel.WDmodel.WDmodel._extract_spectral_line()adding checking of inputs.Parameters: - w (array-like) – Wavelength array from which to extract elements corresponding to
hydrogen Balmer
line - f (array-like) – Flux array from which to extract elements corresponding to hydrogen
Balmer
line - line (
{'alpha', 'beta', 'gamma', 'delta', 'zeta', 'eta'}) – Name of hydrogen Balmer line to extract. Properties are pre-defined inWDmodel.WDmodel.WDmodel._lines - df (None or array-like, optional) – If array-like, extracted elements of this array are also returned
Returns: - w (array-like) – elements of input wavelength array for hydrogen Balmer feature
line - f (array-like) – elements of input flux array for hydrogen Balmer feature
line - [df] (array-like) – elements of input flux uncertainty array for hydrogen Balmer
feature
lineif optional inputdfis supplied
Raises: ValueError– Iflineis not one of the first six of the Balmer series or If wavelengths are invalid of If there’s a difference in shape of any of the arrays- w (array-like) – Wavelength array from which to extract elements corresponding to
hydrogen Balmer
-
get_model(teff, logg, wave=None, log=False, strict=True)[source]¶ Returns the model flux given
teffandloggat wavelengthswaveWraps
WDmodel.WDmodel.WDmodel._get_model()adding checking of inputs.Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- wave (array-like, optional) – Desired wavelengths at which to compute the model atmosphere flux. If not supplied, the full model wavelength grid is returned.
- log (bool, optional) – Return the log10 flux, rather than the flux
- strict (bool, optional) – If strict,
teffandloggout of model grid range raise aValueError, otherwise raise aRuntimeWarningand setteff,loggto the nearest grid value.
Returns: - wave (array-like) – Valid output wavelengths
- flux (array-like) – Interpolated model flux at
teff,loggand wavelengthswave
Raises: ValueError– Iftefforloggare out of range of model grid andstrictis True or if there are any invalid wavelengths, or the requested wavelengths to do not overlap with the model gridNotes
Unlike the corresponding private methods, the public methods implement checking of the inputs and returns the wavelengths in addition to the flux. Internally, we only use the private methods as the inputs only need to be checked once, and their state is not altered anywhere after.
-
get_obs_model(teff, logg, av, fwhm, rv=3.1, wave=None, log=False, strict=True, pixel_scale=1.0)[source]¶ Returns the observed model flux given
teff,logg,av,rv,fwhm(for Gaussian instrumental broadening) and wavelengthswaveUses
WDmodel.WDmodel.WDmodel.get_red_model()to get the reddened model and convolves it with a Gaussian kernel usingscipy.ndimage.filters.gaussian_filter1d()Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- av (float) – Extinction in the V band, \(A_V\)
- fwhm (float) – Instrumental FWHM in Angstrom
- rv (float, optional) – The reddening law parameter, \(R_V\), the ration of the V band
extinction \(A_V\) to the reddening between the B and V bands,
\(E(B-V)\). Default is
3.1, appropriate for stellar SEDs in the Milky Way. - wave (array-like, optional) – Desired wavelengths at which to compute the model atmosphere flux. If not supplied, the full model wavelength grid is returned.
- log (bool, optional) – Return the log10 flux, rather than the flux (what’s actually interpolated)
- strict (bool, optional) – If strict,
teffandloggout of model grid range raise aValueError, otherwise raise aRuntimeWarningand setteff,loggto the nearest grid value. - pixel_scale (float, optional) – Jacobian of the transformation between wavelength in Angstrom and
pixels. In principle, this should be a vector, but virtually all
spectral reduction packages resample the spectrum onto a uniform
wavelength scale that is close to the native pixel scale of the
spectrograph. Default is
1.
Returns: - wave (array-like) – Valid output wavelengths
- flux (array-like) – Interpolated model flux at
teff,loggwith reddening parametrized byav,rvbroadened by a Gaussian kernel defined byfwhmat wavelengthswave
Notes
fwhmandpixel_scalemust be> 0
-
get_red_model(teff, logg, av, rv=3.1, wave=None, log=False, strict=True)[source]¶ Returns the reddened model flux given
teff,logg,av,rvat wavelengthswaveUses
WDmodel.WDmodel.WDmodel.get_model()to get the unreddened model, and reddens it withWDmodel.WDmodel.WDmodel.reddening()Parameters: - teff (float) – Desired model white dwarf atmosphere temperature (in Kelvin)
- logg (float) – Desired model white dwarf atmosphere surface gravity (in dex)
- av (float) – Extinction in the V band, \(A_V\)
- rv (float, optional) – The reddening law parameter, \(R_V\), the ration of the V band
extinction \(A_V\) to the reddening between the B and V bands,
\(E(B-V)\). Default is
3.1, appropriate for stellar SEDs in the Milky Way. - wave (array-like, optional) – Desired wavelengths at which to compute the model atmosphere flux. If not supplied, the full model wavelength grid is returned.
- log (bool, optional) – Return the log10 flux, rather than the flux (what’s actually interpolated)
- strict (bool, optional) – If strict,
teffandloggout of model grid range raise aValueError, otherwise raise aRuntimeWarningand setteff,loggto the nearest grid value.
Returns: - wave (array-like) – Valid output wavelengths
- flux (array-like) – Interpolated model flux at
teff,loggwith reddening parametrized byav,rvat wavelengthswave
Raises: ValueError– Ifav < 0orrvnot in[1.7, 5.1]
-
reddening(wave, flux, av, rv=3.1)[source]¶ Redden a 1-D spectrum with extinction
Uses the extinction function corresponding to the
rvmodelparametrization set inWDmodel.WDmodel.WDmodel._WDmodel__init__rvmodel()to calculate the extinction as a function of wavelength (in Angstroms), \(A_{\lambda}\).Parameters: - wave (array-like) – Array of wavelengths in Angstrom at which to compute extinction, sorted in ascending order
- flux (array-like) – Array of fluxes at
waveat which to apply extinction - av (float) – Extinction in the V band, \(A_V\)
- rv (float, optional) – The reddening law parameter, \(R_V\), the ration of the V band
extinction \(A_V\) to the reddening between the B and V bands,
\(E(B-V)\). Default is
3.1, appropriate for stellar SEDs in the Milky Way.
Returns: out – The reddened spectrum
Return type: array-like
Notes
avandfluxshould be >= 0.
- grid_file (str, optional) – Filename of the HDF5 grid file to read. See