Esempio n. 1
0
def test_find_cluster():
    t = Target(toiid=837)
    _ = t.query_gaia_dr2_catalog(return_nearest_xmatch=True)
    nearest_cluster_member = t.get_nearest_cluster_member(
        catalog_name="CantatGaudin2020", match_id=True)
    assert isinstance(nearest_cluster_member, pd.Series)
    assert t.nearest_cluster_name == "IC_2602"
Esempio n. 2
0
def test_target_xmatch():
    t = Target(toiid=837)
    _ = t.query_gaia_dr2_catalog(return_nearest_xmatch=True)
    _ = t.query_tic_catalog(return_nearest_xmatch=True)
    assert t.validate_gaia_tic_xmatch()
Esempio n. 3
0
def test_query_gaia():
    t = Target(gaiaDR2id=5251470948229949568)
    gaia_params1 = t.query_gaia_dr2_catalog(radius=60)
    assert isinstance(gaia_params1, pd.DataFrame)
    gaia_params2 = t.query_gaia_dr2_catalog(return_nearest_xmatch=True)
    assert isinstance(gaia_params2, pd.Series)
Esempio n. 4
0
def plot_cluster_kinematics(
    ticid=None,
    toiid=None,
    cluster_name=None,
    frac_err=0.5,
    rv=None,
    savefig=False,
):
    """
    """
    assert (ticid is not None) | (toiid is not None)

    t = Target(toiid=toiid, ticid=ticid)
    if cluster_name is None:
        cluster, idxs = t.get_cluster_membership(
            catalog_name="CantatGaudin2020",
            return_idxs=True,
            frac_err=frac_err,
            sigma=5,
        )
        cluster_name = cluster.Cluster

    c = Cluster(cluster_name=cluster_name)
    df_target = t.query_gaia_dr2_catalog(return_nearest_xmatch=True)

    if rv is not None:
        df_target.radial_velocity = rv
    else:
        if np.isnan(df_target.radial_velocity):
            rv = np.nanmean(list(t.query_vizier_param("RV").values()))
            if not np.isnan(rv):
                df_target.radial_velocity = rv
    try:
        fig1 = c.plot_xyz_uvw(target_gaiaid=t.gaiaid,
                              df_target=df_target,
                              match_id=False)
        fig1.suptitle(f"{t.target_name} in {c.cluster_name}")
        if savefig:
            fp1 = f"{t.target_name}_galactocentric.png"
            fig1.savefig(fp1, bbox_inches="tight")
    except Exception as e:
        print("Error: ", e)
    # ==============
    try:
        log10age = c.get_cluster_age()
        fig2 = c.plot_rdp_pmrv(target_gaiaid=t.gaiaid,
                               df_target=df_target,
                               match_id=False)
        fig2.suptitle(f"{t.target_name} in {c.cluster_name}")
        if savefig:
            fp2 = f"{t.target_name}_kinematics.png"
            fig2.savefig(fp2, bbox_inches="tight")
    except Exception as e:
        print("Error: ", e)
    # ==============
    try:
        # TODO: AG50 doesn't yield G consistent with cmd
        # if str(df_target.a_g_val) == "nan":
        #     vq = t.query_vizier_param("AG50")
        #     if "I/349/starhorse" in vq:
        #         df_target.a_g_val = vq["I/349/starhorse"]
        #         print("Using AG from starhorse.")
        log10age = c.get_cluster_age()
        ax = c.plot_cmd(
            target_gaiaid=t.gaiaid,
            df_target=df_target,
            match_id=False,
            log_age=log10age,
        )
        ax.set_title(f"{t.target_name} in {c.cluster_name}")
        if savefig:
            fp3 = f"{t.target_name}_cmd.png"
            ax.figure.savefig(fp3, bbox_inches="tight")
    except Exception as e:
        print("Error: ", e)

    try:
        ax = c.plot_hrd(
            target_gaiaid=t.gaiaid,
            df_target=df_target,
            match_id=False,
            log_age=log10age,
        )
        ax.set_title(f"{t.target_name} in {c.cluster_name}")
        if savefig:
            fp4 = f"{t.target_name}_hrd.png"
            ax.figure.savefig(fp4, bbox_inches="tight")
    except Exception as e:
        print("Error: ", e)