def stetsonK(mag, magerr):
"""The variability index K was first suggested by Peter B. Stetson and serves as a
measure of the kurtosis of the magnitude distribution.
See: (P. B. Stetson, Publications of the Astronomical Society of the Pacific 108, 851 (1996)).
:param mag: the time-varying intensity of the object. Must be an array.
:param magerr: photometric error for the intensity. Must be an array.
:rtype: float
"""
mag, magerr = remove_bad(mag, magerr)
n = np.float(len(mag))
#mean = meanMag(mag, magerr)
mean = np.median(mag)
delta = np.sqrt((n/(n-1.)))*((mag - mean)/magerr)
stetsonK = ((1./n)*sum(abs(delta)))/(np.sqrt((1./n)*sum(delta**2)))
return np.nan_to_num(stetsonK)
评论列表
文章目录