def ion(self):
"""
Calculates the rate of ionizing photons in the SED.
>>> q=s.ion()
"""
import scipy.integrate
import scipy.stats
h=6.62607e-27 # Planck constant in CGS
# Performs interpolation before integrating. This is a precaution in
# case the user specify weird integration limits.
if not hasattr(self, 'nlnui'): self.interp()
# 13.6 eV - "infty"
xi, xf = 15.52, 22.
# Gets only the elements corresponding to ionizing frequencies
i=numpy.where((self.lognui>=xi) & (self.lognui<=xf))
x,y = self.lognui[i],self.lli[i] # easier notation
# Calculates ionizing rate using integration (trapezoidal rule)
q=scipy.integrate.trapz(self.nlnui[i]/self.nui[i]/(h*self.nui[i]), self.nui[i])
return q
评论列表
文章目录