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"
def test_tic_match(): """test tic match using query_tic_catalog & native vizier search TIC v8: https://vizier.u-strasbg.fr/viz-bin/VizieR-3?-source=IV/38/tic """ t = Target(toiid=837) tab = t.query_vizier() df = tab["IV/38/tic"].to_pandas() d1 = df.iloc[0] d2 = t.query_tic_catalog(return_nearest_xmatch=True) assert int(d1["TIC"]) == int(d2["ID"])
def test_toi_tic(): # toi t1 = Target(toiid=837) assert t1.toiid is not None coord1 = t1.target_coord assert coord1 is not None # tic t2 = Target(ticid=460205581) assert t2.ticid is not None coord2 = t2.target_coord assert coord2 is not None assert np.allclose( [coord1.ra.deg, coord1.dec.deg], [coord2.ra.deg, coord2.dec.deg], rtol=1e-2, )
def test_epic_name(): # epic t1 = Target(epicid=201270176) assert t1.epicid is not None coord1 = t1.target_coord assert coord1 is not None t2 = Target(name="EPIC 201270176") assert t2.target_name is not None # assert t2.epicid is not None coord2 = t2.target_coord assert coord2 is not None assert np.allclose( [coord1.ra.deg, coord1.dec.deg], [coord2.ra.deg, coord2.dec.deg], rtol=1e-2, )
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()
def test_query_tic(): t = Target(ticid=460205581) tic_params1 = t.query_tic_catalog(radius=60) assert isinstance(tic_params1, pd.DataFrame) tic_params2 = t.query_tic_catalog(return_nearest_xmatch=True) assert isinstance(tic_params2, pd.Series)
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)
def test_gaia(): # gaia t = Target(gaiaDR2id=5251470948229949568) assert t.gaiaid is not None coord = t.target_coord assert coord is not None
def test_radec(): # ra,dec t = Target(ra_deg=157.03729167, dec_deg=-64.50521111) coord = t.target_coord assert coord is not None
def test_name(): # name t = Target(name="Pi Mensae") assert t.target_name is not None coord = t.target_coord assert coord is not None
def test_vizier(): t = Target(ticid=410214986, verbose=False) tables = t.query_vizier() assert isinstance(tables, TableList) assert isinstance(tables[0], Table)
def test_simbad(): t = Target(ticid=410214986) df = t.query_simbad() assert isinstance(df, pd.DataFrame)
def test_specs_tfop(): t = Target(ticid=410214986) df = t.query_specs_from_tfop() assert isinstance(df, pd.DataFrame)
def test_harps(): t = Target(toiid=200) df = t.query_harps_bank_table() assert isinstance(df, pd.DataFrame)
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)