def sum(seds):
"""
Given a list of SEDs previously interpolated in the same binning,
sums their luminosities and returns a SED object with the sum.
>>> ss=sum([s,s1,s2])
returns the SED ss <- [lognu, s+s1+s2],
where s+s1+s2 -> log10[nuLnu(s)+nuLnu(s1)+nuLnu(s2)], lognu being the common
units of frequency for the SEDs after interpolation.
The method is designed to automatically call the interp method for each SED
if needed.
"""
# Precaution in case the user did not use the interp method
seds[0].interp(seds)
sums=numpy.zeros_like(seds[0].lognui) # initializes the sum
for sed in seds:
sums=sums+sed.nlnui
return SED(lognu=seds[0].lognui, ll=numpy.log10(sums), logfmt=1)
评论列表
文章目录