def nfw_cumulative(self,R):
'''
Cumulative radial NFW distribution
@param R: Radius
@return float: Probability of being within R
'''
R0 = self.__R0
norm = self.__norm
Rs = self.__Rs
Rcore = self.__Rcore
def integrate(z):
return quad(nfw,0,z,args=(norm,Rs,Rcore))[0]
if np.isscalar(R):
R = np.array([float(R)])
else:
R = R.astype(np.float)
res = np.piecewise(R, [R < 0.0, np.logical_and(R >= 0.0, R < R0), R >= R0],
[lambda z: z,
lambda z: np.fromiter(map(integrate,z),np.float),
lambda z: z/R0])
if len(res) == 1:
return res[0]
else:
return res
评论列表
文章目录