Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
1,055 changes: 1,055 additions & 0 deletions scripts/ingests/sanghi23/FundamentalPropertiesbyAtmoModel.csv

Large diffs are not rendered by default.

1,055 changes: 1,055 additions & 0 deletions scripts/ingests/sanghi23/FundamentalPropertiesbyEvoModel.csv

Large diffs are not rendered by default.

45 changes: 45 additions & 0 deletions scripts/ingests/sanghi23/IngestAllNames.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# SIMPLE & Astrodb Packages
from astrodb_utils import load_astrodb, logger
from astrodb_utils.sources import ingest_source, find_source_in_db, ingest_name
from astrodb_utils.publications import ingest_publication
from simple.schema import *
from simple.schema import REFERENCE_TABLES
import pandas as pd
import os
# logger.setLevel("DEBUG")

# Load Database
recreate_db = False
save_db = True
db = load_astrodb("SIMPLE.sqlite", recreatedb=recreate_db, reference_tables=REFERENCE_TABLES)
path = "scripts/ingests/sanghi23/"


allsources = pd.read_csv(os.path.join(path, "Ultracool_Fundamental_Properties_Table.csv")) # Read entire table
for i, source in allsources.iterrows():
db_source = find_source_in_db(
db,
source['name'],
ra=source['ra_j2000_formula'],
dec=source['dec_j2000_formula'],
ra_col_name="ra",
dec_col_name="dec"
) or find_source_in_db(
db,
source['name_simbadable'],
ra=source['ra_j2000_formula'],
dec=source['dec_j2000_formula'],
ra_col_name="ra",
dec_col_name="dec"
)

if db_source:
alt_names = [source["name_simbadable"], source["name"]]
for name in alt_names:
if name != db_source[0] and name != "Null":
ingest_name(db, db_source[0], name.strip())


# Save to Database, Writes the JSON Files
if save_db:
db.save_database(directory="data/")
76 changes: 76 additions & 0 deletions scripts/ingests/sanghi23/Ingest_S23_Sources.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# SIMPLE & Astrodb Packages
from astrodb_utils import load_astrodb, logger
from astrodb_utils.sources import ingest_source, find_source_in_db, ingest_name
from astrodb_utils.publications import ingest_publication
from simple.schema import *
from simple.schema import REFERENCE_TABLES
import pandas as pd
import os
# logger.setLevel("DEBUG")

# Load Database
recreate_db = True
save_db = True
db = load_astrodb("SIMPLE.sqlite", recreatedb=recreate_db, reference_tables=REFERENCE_TABLES)
path = "scripts/ingests/sanghi23/"


# Workflow: Ingest pub, ingest sources, ingest parameters, ingest alt names functions ? ----

# Ingest Publications ---
ingest_publication(
db,
doi = "10.3847/1538-4357/accf9d"

)

# Ingest New Sources ---
# Expecting to ingest 43 new sources
n_added = 0
n_skipped = 0

newsources = pd.read_csv(os.path.join(path, "NewSources-23.csv")) # Read in new sources
for _, source in newsources.iterrows():
try:
ingest_source(
db,
source=source['name'],
ra=source['ra_j2000_formula'],
dec=source['dec_j2000_formula'],
reference=source['ref_discovery'],
epoch = None,
ra_col_name = "ra",
dec_col_name = "dec",
epoch_col_name="epoch"
)
print(f"Source {source['name']} ingested.")
n_added += 1
except Exception as e:
print(f"Error: {e}")
n_skipped += 1
continue

print(f"Total sources add: {n_added}/43")
print(f"Total sources skipped: {n_skipped}/43")

Comment on lines +62 to +64
Copy link

Copilot AI Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider changing 'Total sources add:' to 'Total sources added:' for correct grammar.

Suggested change
print(f"Total sources add: {n_added}/43")
print(f"Total sources skipped: {n_skipped}/43")
print(f"Total sources added: {n_added}/43")

Copilot uses AI. Check for mistakes.

# # Ingest Alternative Sources ---
print(f"Ingesting alternative names for {n_added} sources.")
for _, source in newsources.iterrows():
if source['name_simbadable'] != "Null":
Copy link

Copilot AI Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the string literal 'Null' for null checks may lead to errors if the data representation changes. Consider checking against None or an empty string for robustness.

Suggested change
if source['name_simbadable'] != "Null":
if source['name_simbadable'] is not None and source['name_simbadable'] != "":

Copilot uses AI. Check for mistakes.
try:
ingest_name(
db,
source=source['name'],
other_name=source['name_simbadable'],
)
print(f"Alternative name {source['name_simbadable']} ingested for existing source {source['name']}.")
except Exception as e:
print(f"Failed to ingest alternative name for {source['name']}: {e}")

else:
print(f"Source {source['name']} does not have an alternative name.")

# Save to Database, Writes the JSON Files
if save_db:
db.save_database(directory="data/")
44 changes: 44 additions & 0 deletions scripts/ingests/sanghi23/NewSources-23.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name,name_simbadable,ref_discovery,ra_j2000_formula,dec_j2000_formula
PSO J000.2794+16.6237,Gaia DR2 2772504778021649152,Alle16.PhDT,0.2792,16.6241
PSO J002.0878+52.0687,Null,Sang23,2.0877,52.0697
PSO J009.8334+58.5781,2MASS J00391959+5834426,Alle16.PhDT,9.8318,58.5785
PSO J013.7740+38.2804,Null,Sang23,13.7724,38.2802
SIMP J01205253+1518277,2MASS J01205253+1518277,Robe16,20.2191,15.3076
PSO J028.0715-15.5717,Null,Sang23,28.0714,-15.5714
PSO J032.2211+67.4179,Null,Alle16.PhDT,32.2202,67.4181
PSO J033.2936+20.4493,Null,Sang23,33.2934,20.4497
PSO J037.4616+17.2761,Null,Alle16.PhDT,37.4614,17.2764
PSO J042.8405+35.3726,Null,Alle16.PhDT,42.8401,35.3729
YU-29133_55877,Gaia DR3 231029348869153664,Alle16.PhDT,58.0036,41.7957
PSO J063.1519-02.8904,Null,Sang23,63.1516,-2.8903
PSO J069.4987+19.6346,Gaia DR3 3410602846507601920,Alle16.PhDT,69.4987,19.6348
PSO J075.4182-17.8327,Null,Alle16.PhDT,75.4182,-17.8327
PSO J080.3940+23.0999,Gaia DR3 3416336838301404672,Alle16.PhDT,80.394,23.1003
2MASS J05445741+3705039,2MASS J05445741+3705039,Hurt23,86.2392,37.0845
PSO J098.2822-23.2845,Null,Sang23,98.2823,-23.2848
PSO J138.1887-06.9862,Null,Alle16.PhDT,138.189,-6.986
PSO J139.5493+39.0380,2MASS J09181190+3902168,Sang23,139.5495,39.0379
PSO J153.7969-11.3631,Null,Alle16.PhDT,153.7971,-11.363
PSO J154.9622+04.8279,2MASS J10195117+0449444,Sang23,154.9631,4.829
PSO J162.0614+13.9756,2MASS J10481476+1358341,Sang23,162.0614,13.976
PSO J178.1434-23.8603,Null,Alle16.PhDT,178.1435,-23.8603
PSO J179.2489+41.5121,Null,Sang23,179.2496,41.5121
PSO J210.6211-26.9300,Gaia DR2 6273537856003401728,Alle16.PhDT,210.6215,-26.9297
PSO J216.4707-06.2849,Null,Sang23,216.4702,-6.2845
PSO J227.1576-07.9608,Null,Sang23,227.1577,-7.9605
PSO J235.3149+61.5071,Null,Alle16.PhDT,235.3153,61.5071
PSO J255.0913+10.3263,Null,Sang23,255.0914,10.3264
PSO J260.1789+15.3091,Gaia DR2 4543541311397087872,Alle16.PhDT,260.179,15.3093
PSO J271.8353+46.9326,LSPM J1807+4655,Alle16.PhDT,271.8357,46.9331
PSO J277.3873+26.0116,2MASS J18293277+2600424,Sang23,277.3865,26.0118
PSO J279.6187+11.6036,Null,Alle16.PhDT,279.6186,11.6041
PSO J281.4296+04.2296,Null,Sang23,281.4295,4.2296
PSO J299.5032+55.0722,Gaia DR2 2233867878549277312,Alle16.PhDT,299.5027,55.0722
PSO J307.7981-06.6854,Null,Alle16.PhDT,307.798,-6.6852
PSO J313.1067+32.9117,Null,Alle16.PhDT,313.1064,32.9119
YU2-644_102045,2MASS J21043128-0939217,Alle16.PhDT,316.1304,-9.6561
PSO J319.7576-13.0982,Null,Sang23,319.7571,-13.0982
PSO J323.4300-07.5353,Gaia DR3 6894984160189465472,Alle16.PhDT,323.4299,-7.5351
PSO J345.2949+07.7665,2MASS J23011072+0746002,Alle16.PhDT,345.2946,7.7667
PSO J348.5125+69.6598,2MASS J23140244+6939368,Alle16.PhDT,348.51,69.6603
PSO J349.3359+32.0532,Null,Sang23,349.3358,32.0534
Loading