本文整理汇总了Python中lsst.sims.photUtils.Sed.calcErgs方法的典型用法代码示例。如果您正苦于以下问题:Python Sed.calcErgs方法的具体用法?Python Sed.calcErgs怎么用?Python Sed.calcErgs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lsst.sims.photUtils.Sed
的用法示例。
在下文中一共展示了Sed.calcErgs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_calcErgs
# 需要导入模块: from lsst.sims.photUtils import Sed [as 别名]
# 或者: from lsst.sims.photUtils.Sed import calcErgs [as 别名]
def test_calcErgs(self):
"""
Test that calcErgs actually calculates the flux of a source in
ergs/s/cm^2 by running it on black bodies with flat bandpasses
and comparing to the Stefan-Boltzmann law.
"""
boltzmann_k = 1.3807e-16 # in ergs/Kelvin
planck_h = 6.6261e-27 # in cm^2*g/s
speed_of_light = 2.9979e10 # in cm/s
stefan_boltzmann_sigma = 5.6705e-5 # in ergs/cm^2/s/Kelvin
wavelen_arr = np.arange(10.0, 200000.0, 10.0) # in nm
bp = Bandpass(wavelen=wavelen_arr, sb=np.ones(len(wavelen_arr)))
log10_bb_factor = np.log10(2.0) + np.log10(planck_h)
log10_bb_factor += 2.0*np.log10(speed_of_light)
log10_bb_factor -= 5.0*(np.log10(wavelen_arr) - 7.0) # convert wavelen to cm
for temp in np.arange(5000.0, 7000.0, 250.0):
log10_exp_arg = np.log10(planck_h) + np.log10(speed_of_light)
log10_exp_arg -= (np.log10(wavelen_arr) - 7.0)
log10_exp_arg -= (np.log10(boltzmann_k) + np.log10(temp))
exp_arg = np.power(10.0, log10_exp_arg)
log10_bose_factor = -1.0*np.log10(np.exp(exp_arg)-1.0)
# the -7.0 below is because, otherwise, flambda will be in
# ergs/s/cm^2/cm and we want ergs/s/cm^2/nm
#
# the np.pi comes from the integral in the 'Stefan-Boltzmann'
# section of
# https://en.wikipedia.org/wiki/Planck%27s_law#Stefan.E2.80.93Boltzmann_law
#
bb_flambda = np.pi*np.power(10.0, log10_bb_factor+log10_bose_factor-7.0)
sed = Sed(wavelen=wavelen_arr, flambda=bb_flambda)
ergs = sed.calcErgs(bp)
log10_ergs = np.log10(stefan_boltzmann_sigma) + 4.0*np.log10(temp)
ergs_truth = np.power(10.0, log10_ergs)
msg = '\ntemp:%e\nergs: %e\nergs_truth: %e' % (temp, ergs, ergs_truth)
self.assertAlmostEqual(ergs/ergs_truth, 1.0, 3, msg=msg)
# Now test it on a bandpass with throughput=0.25 and an wavelength
# array that is not the same as the SED
wavelen_arr = np.arange(10.0, 100000.0, 146.0) # in nm
bp = Bandpass(wavelen=wavelen_arr, sb=0.25*np.ones(len(wavelen_arr)))
wavelen_arr = np.arange(5.0, 200000.0, 17.0)
log10_bb_factor = np.log10(2.0) + np.log10(planck_h)
log10_bb_factor += 2.0*np.log10(speed_of_light)
log10_bb_factor -= 5.0*(np.log10(wavelen_arr) - 7.0) # convert wavelen to cm
for temp in np.arange(5000.0, 7000.0, 250.0):
log10_exp_arg = np.log10(planck_h) + np.log10(speed_of_light)
log10_exp_arg -= (np.log10(wavelen_arr) - 7.0)
log10_exp_arg -= (np.log10(boltzmann_k) + np.log10(temp))
exp_arg = np.power(10.0, log10_exp_arg)
log10_bose_factor = -1.0*np.log10(np.exp(exp_arg)-1.0)
# the -7.0 below is because, otherwise, flambda will be in
# ergs/s/cm^2/cm and we want ergs/s/cm^2/nm
#
# the np.pi comes from the integral in the 'Stefan-Boltzmann'
# section of
# https://en.wikipedia.org/wiki/Planck%27s_law#Stefan.E2.80.93Boltzmann_law
#
bb_flambda = np.pi*np.power(10.0, log10_bb_factor+log10_bose_factor-7.0)
sed = Sed(wavelen=wavelen_arr, flambda=bb_flambda)
ergs = sed.calcErgs(bp)
log10_ergs = np.log10(stefan_boltzmann_sigma) + 4.0*np.log10(temp)
ergs_truth = np.power(10.0, log10_ergs)
msg = '\ntemp: %e\nergs: %e\nergs_truth: %e' % (temp,ergs, ergs_truth)
self.assertAlmostEqual(ergs/ergs_truth, 0.25, 3, msg=msg)