Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Substitui magnitudes normalizadas Praia por originais Gaia #870

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/tno/prediction_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def upcoming_events_to_create_maps(
"position_angle": obj.position_angle,
"velocity": obj.velocity,
"delta": obj.delta,
"g": obj.g,
"g": obj.g_star,
"long": obj.long,
"filepath": str(obj.get_map_filepath()),
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import os
from datetime import datetime as dt
from datetime import timezone
from pathlib import Path
Expand Down Expand Up @@ -98,6 +99,13 @@ def run_occultation_path_coeff(predict_table_path: Path, obj_data: dict):
df.loc[df["h_star"] == 50, "h_star"] = None
df.loc[df["k_star"] == 50, "k_star"] = None

# Le o source_id, ra, dec e g magnitude do catalogo gaia csv
df_gaia_csv = pd.read_csv(
os.path.join(obj_data["path"], "gaia_catalog.csv"),
usecols=(0, 1, 3, 13),
delimiter=";",
)

# -------------------------------------------------
# Coeff paths e calculo de outros grandezas
# -------------------------------------------------
Expand All @@ -107,6 +115,8 @@ def run_occultation_path_coeff(predict_table_path: Path, obj_data: dict):
for row in df.to_dict(orient="records"):

new_row = {
"gaia_source_id": None,
"gaia_g_mag": None,
"apparent_magnitude": None,
"magnitude_drop": None,
"aparent_diameter": None,
Expand All @@ -119,6 +129,19 @@ def run_occultation_path_coeff(predict_table_path: Path, obj_data: dict):
"occ_path_coeff": {},
}

# Obtem a magnitude da estrela do catalogo gaia (a magnitude retornada
# pelo praia esta corrigida por padrão por velocidade da sombra, por isso é substituída)
minimum_distance = np.sqrt(
(df_gaia_csv["ra"] - row["ra_star_deg"]) ** 2
+ (df_gaia_csv["dec"] - row["dec_star_deg"]) ** 2
)
star_index = np.argmin(minimum_distance)
source_id, gaia_g_mag = (
df_gaia_csv["source_id"][star_index],
df_gaia_csv["phot_g_mean_mag"][star_index],
)
new_row.update({"gaia_source_id": source_id, "gaia_g_mag": gaia_g_mag})

# ------------------------------------------------------------------------
# Calcula a magnitude visual do asteroide no instante da ocultação
# Alerta: os arquivos bsp estão na memoria global por alguma razão,
Expand Down Expand Up @@ -220,6 +243,8 @@ def run_occultation_path_coeff(predict_table_path: Path, obj_data: dict):
if len(coeff_paths) > 0:
df_coeff = pd.DataFrame.from_dict(coeff_paths)

df["gaia_source_id"] = df_coeff["gaia_source_id"]
df["g_star"] = df_coeff["gaia_g_mag"]
df["apparent_magnitude"] = df_coeff["apparent_magnitude"]
df["magnitude_drop"] = df_coeff["magnitude_drop"]
df["aparent_diameter"] = df_coeff["aparent_diameter"]
Expand All @@ -234,6 +259,8 @@ def run_occultation_path_coeff(predict_table_path: Path, obj_data: dict):

del df_coeff
else:
df["gaia_source_id"] = None
df["g_star"] = None
df["apparent_magnitude"] = None
df["magnitude_drop"] = None
df["aparent_diameter"] = None
Expand Down
Loading