Ejemplo n.º 1
0
    flags[f5] = 0

    # Add alerts caught by ZTF already from MPC
    if ssdistnr is not None:
        # alerts should be at max 5'' away from MPC object
        f_distance1 = ssdistnr >= 0.0
        f_distance2 = ssdistnr < 5.0

        # Distance to Panstarrs object should be bigger than distance to MPC object
        f_relative_distance = (abs(distpsnr1) - ssdistnr) > 0.0

        # Not seen many times with the same objectId
        f_ndethist = ndethist <= 2

        mask_roid = f_distance1 & f_distance2 & f_relative_distance & f_ndethist
        flags[mask_roid] = 3

    return pd.Series(flags)


if __name__ == "__main__":
    """ Execute the test suite """

    globs = globals()
    path = os.path.dirname(__file__)
    ztf_alert_sample = 'file://{}/data/alerts/datatest'.format(path)
    globs["ztf_alert_sample"] = ztf_alert_sample

    # Run the test suite
    spark_unit_tests(globs)
Ejemplo n.º 2
0
        np.array(catalog_matches, dtype=np.int64),
        'match':
        True
    })
    pdf_merge = pd.merge(pdf, pdf_matches, how='left', on='candid')

    m = pdf_merge['match'].apply(lambda x: x is True)

    # Now get types for these
    catalog_ztf_merge = SkyCoord(
        ra=np.array(pdf_merge.loc[m, 'ra'].values, dtype=np.float) * u.degree,
        dec=np.array(pdf_merge.loc[m, 'dec'].values, dtype=np.float) *
        u.degree)

    # cross-match
    idx2, d2d2, d3d2 = catalog_ztf_merge.match_to_catalog_sky(catalog_other)

    pdf_merge['Type'] = 'Unknown'
    pdf_merge.loc[m, 'Type'] = [
        str(i).strip() for i in type2.astype(str).values[idx2]
    ]

    return pdf_merge['Type']


if __name__ == "__main__":
    """ Execute the test suite """

    # Run the test suite
    spark_unit_tests(globals())