Skip to content
Draft
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
130 changes: 130 additions & 0 deletions scripts/ingests/xshyne/ingest_xshyne_spectra
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import sys
import logging
sys.path.append(".")
from astropy.io import ascii
from simple import REFERENCE_TABLES
from astrodb_utils import load_astrodb

from astrodb_utils.spectra import (
ingest_spectrum,
)
from astrodb_utils.sources import (
logger,
find_source_in_db,
ingest_name
)
from astrodb_utils.publications import ingest_publication

astrodb_utils_logger = logging.getLogger("astrodb_utils")
logger.setLevel(logging.DEBUG) # Set logger to INFO/DEBUG/WARNING/ERROR/CRITICAL level
astrodb_utils_logger.setLevel(logging.DEBUG)

SAVE_DB = False # save the data files in addition to modifying the .db file
RECREATE_DB = True # recreates the .db file from the data files
SCHEMA_PATH = "simple/schema.yaml"
db = load_astrodb(
"SIMPLE.sqlite",
recreatedb=RECREATE_DB,
reference_tables=REFERENCE_TABLES,
felis_schema=SCHEMA_PATH,
)

file = (
""
)

link = "scripts/ingests/xshyne/xshyne_data.csv"

xshyne_table = ascii.read(
link,
format="csv",
data_start=1,
header_start=0,
guess=False,
fast_reader=False,
delimiter=",",
)

spectra_ingested = 0
source_ingested = 0
source_already_exist = 0
names_ingested = 0

ingest_publication( db =db,
doi = "10.48550/arXiv.2507.16899",
bibcode = "2025arXiv250716899P",
reference = "Petr25")

for row in xshyne_table:
source = row["Source"]
ra = row["Ra"]
dec = row["Dec"]
date = row["Date"]
short_name = row["Short Name"]

multiple_dates = row["Start Date"] is not row["End Date"]

short_name_result = find_source_in_db(db=db, source = short_name)

if len(short_name_result) == 0:
ingest_name(db=db, source = source, other_name=short_name)
names_ingested+=1

#ingest each spectra twice, once for nir and once for optical regime
#add comment if spectra has multiple observation dates
if multiple_dates:
ingest_spectrum(
db=db,
source = source,
regime = "optical",
spectrum = file,
telescope="ESO VLT",
instrument="VLT/X-Shooter",
mode = "Echelle",
obs_date=date,
reference = "Petr25",
comments="Spectrum is a combination of multiple observation dates"
)
spectra_ingested+=1
ingest_spectrum(
db=db,
source = source,
regime = "nir",
spectrum = file,
telescope="ESO VLT",
instrument="VLT/X-Shooter",
mode = "Echelle",
obs_date=date,
reference = "Petr25",
comments="Spectrum is a combination of multiple observation dates"
)
spectra_ingested+=1
else:
ingest_spectrum(
db=db,
source = source,
regime = "optical",
spectrum = file,
telescope="ESO VLT",
instrument="VLT/X-Shooter",
mode = "Echelle",
obs_date=date,
reference = "Petr25",
)
spectra_ingested+=1
ingest_spectrum(
db=db,
source = source,
regime = "nir",
spectrum = file,
telescope="ESO VLT",
instrument="VLT/X-Shooter",
mode = "Echelle",
obs_date=date,
reference = "Petr25",
)

logger.info(f"Spectra ingested: {spectra_ingested}") # spectra ingested
logger.info(f"Names ingested: {names_ingested}") # names ingested
if SAVE_DB:
db.save_database(directory="data/")
44 changes: 44 additions & 0 deletions scripts/ingests/xshyne/xshyne_data.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Short Name,Source,Start Date,End Date,Date,Ra,Dec
2MASS0030,2MASSW J0030300-145033,2018-07-28,2018-08-16,2018-07-28,7.6255,-14.842611
2MASS0045,2MASS J00452143+1634446,2018-10-09,2018-10-17,2018-10-09,11.3393,16.579094
2MASS0046,2MASS J00464841+0715177,2019-07-15,2019-07-15,2019-07-15,11.7018,7.254933
2MASS0103,2MASSI J0103320+193536,2019-10-10,2019-10-11,2019-10-10,15.8835,19.593383
2MASS0153,2MASS J01531463-6744181,2018-10-08,2018-10-18,2018-10-08,28.3110,-67.738389
2MASS0219b,2MASS J02192210-3925225b,2018-10-21,2018-10-21,2018-10-21,34.8421,-39.422928
2MASS0249c,2MASS J02495436-0558015,2019-10-10,2019-10-11,2019-10-10,42.4765,-5.967106
2MASS0326,2MASS J03264225-2102057,2018-10-21,2018-10-21,2018-10-21,51.6761,-21.034936
2MASS0342,2MASSI J0342162-681732,2018-10-08,2018-10-08,2018-10-08,55.5675,-68.292256
2MASS0355,2MASS J03552337+1133437,2019-09-10,2019-09-10,2019-09-10,58.8474,11.562167
2MASS0508,2MASS J05081657-1413479,2020-01-14,2020-01-14,2020-01-14,77.0691,-14.230011
2MASS0512,2MASSI J0512063-294954,2018-10-31,2018-10-31,2018-10-31,78.0265,-29.831669
2MASS0518,2MASSI J0518461-275645,2018-11-27,2018-11-27,2018-11-27,79.6924,-27.946031
2MASS0616,2MASS J06165623-2543557,2019-11-17,2019-11-17,2019-11-17,94.2343,-25.732153
2MASS0723,2MASS J07235265-3309446,2020-02-06,2020-02-06,2020-02-06,110.9694,-33.162372
2MASS1021,2MASS J10212570-2830427,2018-04-28,2018-05-04,2018-04-28,155.3571,-28.511878
2MASS1119,TWA 42,2019-04-15,2019-04-15,2019-04-15,169.8856,-11.629639
2MASS1147,TWA 41,2018-06-16,2018-06-16,2018-06-16,176.8509,-20.672344
2MASS1148,2MASS J11480096-2836488,2018-04-29,2018-04-29,2018-04-29,177.0040,-28.613583
2MASS1207,TWA 40,2018-04-28,2018-04-28,2018-04-28,181.9515,-39.001244
2MASS1213,2MASS J12130336-0432437,2019-04-15,2019-04-15,2019-04-15,183.2639,-4.545486
2MASS1425,2MASS J14252798-3650229,2018-06-19,2018-06-19,2018-06-19,216.3666,-36.839792
2MASS1521,2MASS J15210327+0131426,2023-04-10,2023-05-02,2023-04-10,230.2636,1.528525
2MASS1826,2MASS J18264679-4602234,2019-04-18,2019-04-30,2019-04-18,276.6950,-46.0399
2MASS2104,2MASS J21043128-0939217,2019-05-03,2019-07-12,2019-05-03,316.1304,-9.656061
2MASS2139,CFBDS J213926+022023,2023-06-06,2023-06-06,2023-06-06,324.8615,2.339639
2MASS2206,2MASSW J2206450-421721,2018-06-01,2018-06-01,2018-06-01,331.6875,-42.289206
2MASS2244,2MASS J22443167+2043433,2018-07-23,2018-07-23,2018-07-23,341.1320,20.728694
2MASS2322,2MASS J23225299-6151275,2018-06-26,2018-06-26,2018-06-26,350.7209,-61.857647
2MASS2354,PSO J358.5527+22.1393,2019-10-11,2019-10-11,2019-10-11,358.5524,22.139606
PSO057,PSO J057.2893+15.2433,2018-10-17,2018-10-30,2018-10-17,57.2893,15.243333
PSO071,2MASS J04473039-1216155,2018-10-30,2018-10-31,2018-10-30,71.8767,-12.270983
PSO318,2MASS J21140802-2251358,2018-06-20,2018-06-27,2018-06-20,318.5335,-22.859956
PSO319,2MASS J21171431-2940034,2018-05-30,2018-05-30,2018-05-30,319.3096,-29.667617
SDSS1110,2MASS J11101001+0116130,2018-04-29,2018-05-28,2018-04-29,167.5417 ,1.270303
SIMP0136,SIMP J013656.5+093347.3,2018-11-16,2018-11-16,2018-11-16,24.2357,9.563142
ULAS0047,ULAS J004757.40+154641.4,2023-08-01,2023-08-01,2023-08-01,11.9888,15.778211
ULAS1316,ULAS J131610.13+031205.5,2023-03-30,2023-04-11,2023-04-11,199.0422,3.201544
VHS1256b,SIPS J1256-1257B,2018-05-28,2018-05-28,2018-05-28,194.0076,-12.957692
WISE0241,WISE J024124.73-365328.0,2022-12-30,2023-02-03,2022-12-30,40.3531,-36.891136
WISE0528,WISE J052857.68+090104.4,2018-10-22,2018-10-26,2018-10-22,82.2404,9.017889
WISE0819,2MASS J08195820-0335266,2022-12-16,2022-12-16,2022-12-16,124.9925,-3.590736
WISE2216,PSO J334.1193+19.8800,2019-06-05,2019-07-15,2019-06-05,334.1193,19.880028
Loading