Skip to content

Commit

Permalink
Check for masked values, fixed issue with wds_id
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasstolker committed Jun 4, 2024
1 parent 8a23b54 commit a5396f8
Showing 1 changed file with 36 additions and 22 deletions.
58 changes: 36 additions & 22 deletions calistar/calistar.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,19 @@ def target_star(
)

if "ruwe" in gaia_result.columns:
print(f"RUWE = {gaia_result['ruwe'][0]:.2f}")
if not np.ma.is_masked(gaia_result["ruwe"]):
print(f"RUWE = {gaia_result['ruwe'][0]:.2f}")

if "non_single_star" in gaia_result.columns:
print(f"Non single star = {gaia_result['non_single_star'][0]}")
if not np.ma.is_masked(gaia_result["non_single_star"]):
print(f"Non single star = {gaia_result['non_single_star'][0]}")

if "classprob_dsc_combmod_star" in gaia_result.columns:
print(
"Single star probability from DSC-Combmod = "
f"{gaia_result['classprob_dsc_combmod_star'][0]:.2f}"
)
if not np.ma.is_masked(gaia_result["classprob_dsc_combmod_star"]):
print(
"Single star probability from DSC-Combmod = "
f"{gaia_result['classprob_dsc_combmod_star'][0]:.2f}"
)

if "has_xp_continuous" in gaia_result.columns:
print(f"\nXP continuous = {gaia_result['has_xp_continuous'][0]}")
Expand Down Expand Up @@ -577,7 +580,8 @@ def target_star(
)

if np.ma.is_masked(vizier_2mass["e_Jmag"]):
print(f"\n2MASS J mag = >{vizier_2mass['Jmag']:.3f}")
if not np.ma.is_masked(vizier_2mass["Jmag"]):
print(f"\n2MASS J mag = >{vizier_2mass['Jmag']:.3f}")

else:
print(
Expand All @@ -591,7 +595,8 @@ def target_star(
)

if np.ma.is_masked(vizier_2mass["e_Hmag"]):
print(f"2MASS H mag = >{vizier_2mass['Hmag']:.3f}")
if not np.ma.is_masked(vizier_2mass["Hmag"]):
print(f"2MASS H mag = >{vizier_2mass['Hmag']:.3f}")

else:
print(
Expand All @@ -605,7 +610,8 @@ def target_star(
)

if np.ma.is_masked(vizier_2mass["e_Kmag"]):
print(f"2MASS Ks mag = >{vizier_2mass['Kmag']:.3f}")
if not np.ma.is_masked(vizier_2mass["Kmag"]):
print(f"2MASS Ks mag = >{vizier_2mass['Kmag']:.3f}")

else:
print(
Expand Down Expand Up @@ -642,7 +648,8 @@ def target_star(
)

if np.ma.is_masked(vizier_wise["e_W1mag"]):
print(f"\nWISE W1 mag = >{vizier_wise['W1mag']:.3f}")
if not np.ma.is_masked(vizier_wise["W1mag"]):
print(f"\nWISE W1 mag = >{vizier_wise['W1mag']:.3f}")

else:
print(
Expand All @@ -656,7 +663,8 @@ def target_star(
)

if np.ma.is_masked(vizier_wise["e_W2mag"]):
print(f"WISE W2 mag = >{vizier_wise['W2mag']:.3f}")
if not np.ma.is_masked(vizier_wise["W2mag"]):
print(f"WISE W2 mag = >{vizier_wise['W2mag']:.3f}")

else:
print(
Expand All @@ -670,7 +678,8 @@ def target_star(
)

if np.ma.is_masked(vizier_wise["e_W3mag"]):
print(f"WISE W3 mag = >{vizier_wise['W3mag']:.3f}")
if not np.ma.is_masked(vizier_wise["W3mag"]):
print(f"WISE W3 mag = >{vizier_wise['W3mag']:.3f}")

else:
print(
Expand All @@ -684,7 +693,8 @@ def target_star(
)

if np.ma.is_masked(vizier_wise["e_W4mag"]):
print(f"WISE W4 mag = >{vizier_wise['W4mag']:.3f}")
if not np.ma.is_masked(vizier_wise["W4mag"]):
print(f"WISE W4 mag = >{vizier_wise['W4mag']:.3f}")

else:
print(
Expand All @@ -700,22 +710,28 @@ def target_star(
else:
print("Target not found in WISE catalog")

# write_json = False

print("\n-> Querying Washington Double Star catalog...\n")

write_json = False
found_wds = False

if simbad_result is not None:
simbad_ids = simbad_result["IDS"].split("|")
wds_id = list(filter(lambda x: x.startswith("WDS"), simbad_ids))

if len(wds_id) == 1:
# There should be a single WDS identified per target on Simbad
wds_id = wds_id[0]

wds_table = Table.read(self.wds_file, path="wds_catalog")
# print(wds_table.columns)

id_crop = wds_id[0].split(" ")[-1][1:11]
# This will not always given the correct ID
# only for regular binary system IDs
id_crop = wds_id.split(" ")[-1][1:11]
id_idx = np.where(id_crop == wds_table["WDS"])[0]

target_dict["WDS ID"] = wds_id[0]
target_dict["WDS ID"] = wds_id

for wds_idx in range(len(id_idx)):
if wds_idx > 0:
Expand All @@ -736,12 +752,10 @@ def target_star(
print(f"Magnitude 1 = {wds_select['mag1']:.2f}")
print(f"Magnitude 2 = {wds_select['mag2']:.2f}")

# write_json = True
write_json = True
found_wds = True

if len(wds_id) == 0 or len(id_idx) == 0:
print("Target not found in WDS catalog")

else:
if not found_wds:
print("Target not found in WDS catalog")

if write_json:
Expand Down

0 comments on commit a5396f8

Please sign in to comment.