Example #1
0
def get_color_curve(fp, given_band="B"):
    if given_band == "B":
        b_fp = fp
        r_fp = b_fp.replace(".B.mjd", ".R.mjd")
    else:
        r_fp = fp
        b_fp = r_fp.replace(".R.mjd", ".B.mjd")

    lc_b = eliminate_lc_noise(open_lightcurve(b_fp))
    lc_r = eliminate_lc_noise(open_lightcurve(r_fp))

    lc_join = pd.merge(lc_b, lc_r, left_index=True, right_index=True,
                       suffixes=('_b', '_r'))
    return pd.DataFrame(lc_join['mag_b'] - lc_join['mag_r'], columns=['mag'])
Example #2
0
def open_lightcurve(fp, dataset='macho'):
    """
    fp: Absolute file path of the lightcurve file
    """
    cols = ['mjd', 'mag', 'err']
    if dataset == 'macho':
        data = pd.read_table(fp, skiprows=[0, 1, 2], names=cols,
                             index_col='mjd', sep='\s+')
        data = eliminate_lc_noise(data)
    elif dataset == 'ogle':
        data = pd.read_table(fp, names=cols, index_col='mjd', sep='\s+')
    elif dataset == 'eros':
        cols = ['mjd', 'mag', 'err', 'mag2', 'err2']
        data = pd.read_table(fp, skiprows=[0, 1, 2, 3], names=cols,
                             index_col='mjd', sep='\s+')
        """
        EROS lcs come with some measurements that say 99.999 in both bands,
        which need to be removed before calculating any features
        """
        data = data[data['mag'] != 99.999]   # filter out the first band
        data = data[data['mag2'] != 99.999]  # filter out the second band
    return data