Esempio n. 1
0
def scatter_res_raw(t, m, e, lomb_model):
    """ From arXiv 1101_2406v1 Dubath 20110112 paper.

    Scatter: res/raw
    Median absolute deviation (MAD) of the residuals (obtained by subtracting
    model values from the raw light curve) divided by the MAD of the raw
    light-curve values around the median.
    """
    lomb_resid = lomb_model["freq_fits"][-1]["resid"]
    return cf.median_absolute_deviation(lomb_resid) / cf.median_absolute_deviation(m)
Esempio n. 2
0
def p2p_model(x, y, frequency):
    """
    Compute features that compare the residuals of data folded by estimated
    period from Lomb-Scargle model with residuals folded by twice the estimated
    period.
    """

    sumsqr_diff_unfold = np.sum((np.diff(y)**2))
    median_diff = np.median(np.abs(np.diff(y)))
    mad = cf.median_absolute_deviation(y)
    x = x.copy()
    x = x - min(x)

    t_2per_fold = np.array(x % (2. / frequency))
    t_2per_sort_inds = np.argsort(t_2per_fold)
    t_2per_fold = t_2per_fold[t_2per_sort_inds]
    y_2per_fold = np.array(y)[t_2per_sort_inds]
    sumsqr_diff_2per_fold = np.sum(np.diff(y_2per_fold)**2)

    ### eta feature from arXiv 1101.3316 Kim QSO paper:
    t_1per_fold = np.array(x % (1. / frequency))
    t_1per_sort_inds = np.argsort(t_1per_fold)
    t_1per_fold = t_1per_fold[t_1per_sort_inds]
    y_1per_fold = np.array(y)[t_1per_sort_inds]
    median_1per_fold_diff = np.median(np.abs(np.diff(y_1per_fold)))

    out_dict = {}
    out_dict['scatter_2praw'] = sumsqr_diff_2per_fold / sumsqr_diff_unfold
    out_dict['scatter_over_mad'] = median_diff / mad
    out_dict['ssqr_diff_over_var'] = sumsqr_diff_unfold / ((len(y) - 1) 
            * np.var(y))
    out_dict['scatter_pfold_over_mad'] = median_1per_fold_diff / mad
    return out_dict