本文整理匯總了Python中lsst.sims.photUtils.Sed.Sed.addCCMDust方法的典型用法代碼示例。如果您正苦於以下問題:Python Sed.addCCMDust方法的具體用法?Python Sed.addCCMDust怎麽用?Python Sed.addCCMDust使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lsst.sims.photUtils.Sed.Sed
的用法示例。
在下文中一共展示了Sed.addCCMDust方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: SNObjectSED
# 需要導入模塊: from lsst.sims.photUtils.Sed import Sed [as 別名]
# 或者: from lsst.sims.photUtils.Sed.Sed import addCCMDust [as 別名]
#.........這裏部分代碼省略.........
requested time and wavelengths with or without extinction from MW
according to the SED extinction methods. The wavelengths may be
obtained from a `lsst.sims.Bandpass` object or a `lsst.sims.BandpassDict`
object instead. (Currently, these have the same wavelengths). See notes
for details on handling of exceptions.
If the sed is requested at times outside the validity range of the
model, the flux density is returned as 0. If the time is within the
range of validity of the model, but the wavelength range requested
is outside the range, then the returned fluxes are np.nan outside
the range, and the model fluxes inside
Parameters
----------
time: float
time of observation
wavelen: `np.ndarray` of floats, optional, defaults to None
array containing wavelengths in nm
bandpass: `lsst.sims.photUtils.Bandpass` object or
`lsst.sims.photUtils.BandpassDict`, optional, defaults to `None`.
Using the dict assumes that the wavelength sampling and range
is the same for all elements of the dict.
if provided, overrides wavelen input and the SED is
obtained at the wavelength values native to bandpass
object.
Returns
-------
`sims_photutils.sed` object containing the wavelengths and SED
values from the SN at time time in units of ergs/cm^2/sec/nm
.. note: If both wavelen and bandpassobject are `None` then exception,
will be raised.
Examples
--------
>>> sed = SN.SNObjectSED(time=0., wavelen=wavenm)
'''
if wavelen is None and bandpass is None:
raise ValueError('A non None input to either wavelen or\
bandpassobject must be provided')
# if bandpassobject present, it overrides wavelen
if bandpass is not None:
if isinstance(bandpass, BandpassDict):
firstfilter = bandpass.keys()[0]
bp = bandpass[firstfilter]
else:
bp = bandpass
# remember this is in nm
wavelen = bp.wavelen
flambda = np.zeros(len(wavelen))
# self.mintime() and self.maxtime() are properties describing
# the ranges of SNCosmo.Model in time.
# Set SED to 0 beyond the model phase range, will change this if
# SNCosmo includes a more sensible decay later.
if (time > self.mintime()) & (time < self.maxtime()):
# If SNCosmo is requested a SED value beyond the model range
# it will crash. Try to prevent that by returning np.nan for
# such wavelengths. This will still not help band flux calculations
# but helps us get past this stage.
flambda = flambda * np.nan
# Convert to Ang
wave = wavelen * 10.0
mask1 = wave > self.minwave()
mask2 = wave < self.maxwave()
mask = mask1 & mask2
wave = wave[mask]
# flux density dE/dlambda returned from SNCosmo in
# ergs/cm^2/sec/Ang, convert to ergs/cm^2/sec/nm
flambda[mask] = self.flux(time=time, wave=wave)
flambda[mask] = flambda[mask] * 10.0
SEDfromSNcosmo = Sed(wavelen=wavelen, flambda=flambda)
if not applyExtinction:
return SEDfromSNcosmo
# Apply LSST extinction
ax, bx = SEDfromSNcosmo.setupCCMab()
if self.ebvofMW is None:
raise ValueError('ebvofMW attribute cannot be None Type and must'
' be set by hand using set_MWebv before this'
'stage, or by using setcoords followed by'
'mwEBVfromMaps\n')
SEDfromSNcosmo.addCCMDust(a_x=ax, b_x=bx, ebv=self.ebvofMW)
return SEDfromSNcosmo