def zindex(self,z):
"""
redshift index lookup
parameters
----------
z: array of floats
returns
-------
indices: array of integers
redshift indices
"""
# return the z index/indices with rounding.
zind = np.searchsorted(self.zinteger,np.round(np.atleast_1d(z)*self.zbinscale).astype(np.int64))
if (zind.size == 1):
return np.asscalar(zind)
else:
return zind
# and check for top overflows. Minimum is always 0
#test,=np.where(zind == self.z.size)
#if (test.size > 0): zind[test] = self.z.size-1
评论列表
文章目录