Skip to content

Commit

Permalink
fixed script
Browse files Browse the repository at this point in the history
  • Loading branch information
Exu-112 committed Jul 15, 2024
1 parent 902893d commit 064232f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 10 additions & 4 deletions scripts/ingests/ultracool_sheet/Ingest_YJHK_MKO_Photometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ def ingest_Photometry_Evan(
multiple_sources = 0
ingested = 0
already_exists = 0
bad_reference = 0
no_data = 0
names_ingested = 0

Expand Down Expand Up @@ -197,6 +198,8 @@ def ingest_Photometry_Evan(
msg = "ingest failed with error: " + str(e)
if "The measurement may be a duplicate" in str(e):
already_exists += 1
elif "Reference match failed due to bad publication" in str(e):
bad_reference += 1
else:
logger.warning(msg)
raise AstroDBError(msg) from e
Expand All @@ -210,17 +213,20 @@ def ingest_Photometry_Evan(
logger.error(msg)
raise AstroDBError(msg)

logger.info(f"ingested:{ingested}") # 7936
logger.info(f"ingested:{ingested}") # 6692
logger.info(f"already exists:{already_exists}") # 801
logger.info(f"no sources:{no_sources}") # 1403
logger.info(f"multiple sources:{multiple_sources}") # 8
logger.info(f"bad references:{bad_reference}") # 1244
logger.info(f"no data: {no_data}") # 5412
logger.info(
f"data points tracked:{ingested+already_exists+no_sources+multiple_sources}"
f"data points tracked:{ingested+already_exists+no_sources+multiple_sources+bad_reference}"
) # 10148
total = ingested + already_exists + no_sources + multiple_sources + no_data
total = (
ingested + already_exists + no_sources + multiple_sources + no_data + bad_reference
)
logger.info(f"total: {total}") # 15560
logger.info(f"names ingested: {names_ingested}") # 2215
logger.info(f"names ingested: {names_ingested}") # 155

if total != len(uc_sheet_table) * 4:
msg = "data points tracked inconsistent with UC sheet"
Expand Down
10 changes: 8 additions & 2 deletions scripts/ingests/ultracool_sheet/references.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from astrodb_utils import ingest_publication
from astrodb_utils import ingest_publication, AstroDBError
from astropy.io import ascii


Expand Down Expand Up @@ -29,6 +29,9 @@
def uc_ref_to_simple_ref(db, ref):
if ref == "Harr15": # Reference with no ADS.
return ref
if uc_ref_to_ADS[ref][0:5] == "noADS":
msg = "Reference match failed due to bad publication"
raise AstroDBError(msg)
t = (
db.query(db.Publications)
.filter(db.Publications.c.bibcode == uc_ref_to_ADS[ref])
Expand All @@ -37,5 +40,8 @@ def uc_ref_to_simple_ref(db, ref):
if len(t) == 0:
ingest_publication(db, bibcode=uc_ref_to_ADS[ref], reference=ref)
return ref
else:
elif len(t) == 1:
return t["reference"][0]
else:
msg = "Multiple reference match"
raise AstroDBError(msg)

0 comments on commit 064232f

Please sign in to comment.