-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bard14 Spectra #439
Merged
Merged
Bard14 Spectra #439
Changes from 5 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
0f1d08c
test
LishaRamon 1988469
first publish
LishaRamon bc790e5
First spectra type ingest attempt
LishaRamon 9dfb0af
Rewritten bard14 ingest script
LishaRamon 064743b
Fixed to read in first line of sheet
LishaRamon 1715f3d
Data loop attempt
LishaRamon 5af3823
suggestions update
LishaRamon 7e8ed4b
spectra loop update
LishaRamon 23f0a21
Corrected suggestions + cleaned script
LishaRamon ee4f7a9
Completed script, saved jsons, updated versions
LishaRamon a28d951
Request response attempt 2
LishaRamon 4543370
response 3 attempt
LishaRamon 5ae5c7a
Merge branch 'main' into bard14-spectra
kelle 00f3bdd
request response attempt
LishaRamon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
test | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
from scripts.ingests.ingest_utils import * | ||
from scripts.ingests.utils import * | ||
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 | ||
RECREATE_DB = True # recreates the .db file from the data files | ||
# LOAD THE DATABASE | ||
db = load_simpledb('SIMPLE.db', recreatedb=RECREATE_DB) | ||
|
||
#bard14 url : https://docs.google.com/spreadsheets/d/11o5NRGA7jSbHKaTNK7SJnu_DTECjsyZ6rY3rcznYsJk/edit#gid=0 | ||
|
||
SHEET_ID = '11o5NRGA7jSbHKaTNK7SJnu_DTECjsyZ6rY3rcznYsJk' | ||
SHEET_NAME = 'bard14' | ||
full = 'all' | ||
|
||
url = f'https://docs.google.com/spreadsheets/d/{SHEET_ID}/gviz/tq?tqx=out:csv&sheet={full}' | ||
|
||
bard14_table = ascii.read( | ||
url, | ||
format="csv", | ||
data_start=1, | ||
header_start=0, | ||
guess=False, | ||
fast_reader=False, | ||
delimiter=",", | ||
) | ||
|
||
#print result table | ||
print(bard14_table.info) | ||
|
||
|
||
#Loop through data and ingest spectra | ||
def ingest_all_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]}") | ||
|
||
|
||
# Ingest SPECTRAL TYPES, 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 | ||
ingest_all_spectra(db) | ||
|
||
|
||
|
||
# WRITE THE JSON FILES | ||
if SAVE_DB: | ||
db.save_database(directory="data/") |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this particular case, since we are updating the spectra entries and not adding entirely new ones, we can't use this function.