Skip to content

Commit

Permalink
Corrected suggestions + cleaned script
Browse files Browse the repository at this point in the history
  • Loading branch information
LishaRamon committed Dec 29, 2023
1 parent 7e8ed4b commit 23f0a21
Showing 1 changed file with 5 additions and 61 deletions.
66 changes: 5 additions & 61 deletions scripts/ingests/ingest_bard14_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from astropy.table import Table
from astropy.io import ascii
import astropy.units as u
from astropy.coordinates import Angle


SAVE_DB = False # True: save the data files(json) in addition to modifying the .db file
Expand Down Expand Up @@ -32,29 +31,6 @@
#print result table
print(bard14_table.info)


#Loop through data and update spectra
#def updating_spectra(db):
#for row in bard14_table[0:19]:

# Print spectra information
# print("Spectra Information:")

# for col_name in row.colnames:
# print(f"{col_name}: {row[col_name]}")

#Call spectra function
#updating_spectra(db)

#Ingest spectra loop 2

#def update_all_spectra(db):
#updating_spectra(db)
# with db.engine.begin() as conn:
# for entry in update_all_spectra:
# source_value = entry['Source']
# spectrum_value = entry['Spectrum']
# original_spectrum_value = entry['Original Spectrum']

#function to update all spectra in the database
def update_all_spectra(db):
Expand All @@ -66,56 +42,24 @@ def update_all_spectra(db):


#update data in loop
conn.execute(db.Spectra_table.update()\
.where(db.Spectra_table.c.source == source_value)\
.values(spectrum = spectrum_value))

conn.execute(db.Spectra_table.update()\
.where(db.Spectra_table.spectrum == spectrum_value)\
conn.execute(db.Spectra.update()\
.where(db.Spectra.c.source == source_value)\
.values(spectrum = spectrum_value))

conn.execute(db.Spectra_table.update()\
.where(db.Spectra_table.c.original_spectrum == source_value)\

conn.execute(db.Spectra.update()\
.where(db.Spectra.c.source == source_value)\
.values(original_spectrum = original_spectrum_value))


#Call spectra function
update_all_spectra(db)

#print(f"Updated entry with source '{source_value}' to spectrum value '{spectrum_value}'")

# Ingest SPECTRA, loop through data
#ingest_spectra(db,
# sources = "Source",
# spectrum= "Spectrum",
# original_spectrum= "Original Spectrum",
# regimes = "regime",
# telescope= "telescope",
# instrument= "instrument",
# mode= "mode",
# observation_date= "observation date",
# spectrum_comments= "spectrum comments",
# spectrum_reference= "spectrum reference",
# ra= "ra",
# dec= "dec",
# aperture= "aperture",
# raise_error=True,
# search_db= True,
#)
#DB Table has local spectrum, comments(spectrum comments on sheet), reference(spectrum reference on sheet)
#reference and other_references as categories not listed on sheet
#Sheet has ra, sec and aperture not in db




# Add a separator between rows for better readability
# print("-" * 50)

#Call spectral types function
#update_all_spectra(db)



# WRITE THE JSON FILES
if SAVE_DB:
Expand Down

0 comments on commit 23f0a21

Please sign in to comment.