From 0ccc09a912ddab3f7a458057f78d53e787cb12d3 Mon Sep 17 00:00:00 2001 From: Evan <93949832+Exu-112@users.noreply.github.com> Date: Fri, 12 Jul 2024 15:19:10 -0400 Subject: [PATCH] made script ingest names --- .../Ingest_YJHK_MKO_Photometry.py | 32 ++++++++++++++----- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/scripts/ingests/ultracool_sheet/Ingest_YJHK_MKO_Photometry.py b/scripts/ingests/ultracool_sheet/Ingest_YJHK_MKO_Photometry.py index de9004567..44038f1f0 100644 --- a/scripts/ingests/ultracool_sheet/Ingest_YJHK_MKO_Photometry.py +++ b/scripts/ingests/ultracool_sheet/Ingest_YJHK_MKO_Photometry.py @@ -1,8 +1,4 @@ -from astrodb_utils import ( - load_astrodb, - find_source_in_db, - AstroDBError, -) +from astrodb_utils import load_astrodb, find_source_in_db, AstroDBError, ingest_names from astrodb_utils.photometry import ingest_photometry import sys @@ -105,20 +101,22 @@ def ingest_Photometry_Evan( ingested = 0 already_exists = 0 no_data = 0 +names_ingested = 0 # Ingest loop for source in uc_sheet_table: comment_filter = "" - if len(source["designation_MKO"]) == 0: + MKO_name = source["designation_MKO"] + if len(MKO_name) == 0: # instrument = "WFCAM" telescope = "UKIRT" filter_name = "WFCAM" comment_filter = "WFCAM filter is a guess. Check reference for actual filter and telescope used. " - elif source["designation_MKO"][0] == "U": + elif MKO_name[0] == "U": # instrument = "WFCAM" telescope = "UKIRT" filter_name = "WFCAM" - elif source["designation_MKO"][0] == "V": + elif MKO_name[0] == "V": # instrument = "VIRCAM" telescope = "VISTA" filter_name = "VISTA" @@ -127,7 +125,24 @@ def ingest_Photometry_Evan( telescope = "UKIRT" filter_name = "WFCAM" comment_filter = "WFCAM filter is a guess. Check reference for actual filter and telescope used. " + match = None + if len(MKO_name) > 0: + match = find_source_in_db( + db, + source["name"], + ra=source["ra_j2000_formula"], + dec=source["dec_j2000_formula"], + ) + if len(match) == 1: + try: + ingest_names( + db, match[0], MKO_name + ) # ingest new names while were at it + names_ingested += 1 + except AstroDBError as e: + None # only error is if there is a preexisting name anyways. + for band in ["Y", "J", "H", "K"]: measurement = source[f"{band}_MKO"] error = source[f"{band}err_MKO"] @@ -205,6 +220,7 @@ def ingest_Photometry_Evan( ) # 10148 total = ingested + already_exists + no_sources + multiple_sources + no_data logger.info(f"total: {total}") # 15560 +logger.info(f"names ingested: {names_ingested}") # 2215 if total != len(uc_sheet_table) * 4: msg = "data points tracked inconsistent with UC sheet"