Last active
June 13, 2023 19:52
-
-
Save kelle/6ba958606ca820c096adf0e4ce0b3180 to your computer and use it in GitHub Desktop.
Ingest Photometry Psuedo-script
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
from scripts.ingests.ingest_utils import * | |
from astropy.utils.exceptions import AstropyWarning | |
warnings.simplefilter('ignore', category=AstropyWarning) | |
SAVE_DB = True # save the data files in addition to modifying the .db file | |
RECREATE_DB = True # recreates the .db file from the data files | |
db = load_simpledb('SIMPLE.db', recreatedb=RECREATE_DB) | |
logger.setLevel(logging.INFO) # Can also set to debug | |
# You may want to add the UKIDSS names | |
# https://github.com/SIMPLE-AstroDB/SIMPLE-db/blob/main/documentation/Names.md | |
def add_ukidss_names(db): | |
other_name_data = [{'source': source, 'other_name': 'VHS 1256-1257b'}] | |
db.Names.insert().execute(other_name_data) | |
wise_name = [{'source': source, 'other_name': 'WISEA J125601.66-125728.7'}] | |
db.Names.insert().execute(wise_name) | |
# You may need to add publications. You can use the ingest_publication function | |
# https://github.com/SIMPLE-AstroDB/SIMPLE-db/blob/main/documentation/Publications.md | |
def ingest_pubs(db): | |
ingest_publication(db, bibcode='2020ApJ...895..145B') | |
# You may need to add filters to the Photometry Filters table | |
# https://github.com/SIMPLE-AstroDB/SIMPLE-db/blob/main/documentation/PhotometryFilters.md | |
def add_filters(db): | |
# ingest WHT/ACAM SDSS i and z photometry | |
acam_instrument = [{'name': 'ACAM', | |
'reference': 'ACAM'}] | |
db.Instruments.insert().execute(acam_instrument) | |
wht_telescope = [{'name': 'WHT'}] | |
db.Telescopes.insert().execute(wht_telescope) | |
wht_i = [{'band': 'ACAM.i', | |
'effective_wavelength': '7458', | |
'instrument': 'ACAM', | |
'telescope': 'WHT', | |
'width': '1103'}] | |
db.PhotometryFilters.insert().execute(wht_i) | |
# Read in your data however you want | |
# Use the ingest_photometry function to ingest to the Photometry table | |
# https://github.com/SIMPLE-AstroDB/SIMPLE-db/blob/main/documentation/Photometry.md | |
def ingest_phot(db): | |
# ingest WISE photometry: WISEA J125601.66-125728.7 | |
wise_bands = ['WISE.W1', 'WISE.W2'] | |
wise_mags = [13.6, 12.8] | |
wise_mag_errors = [0.5, 0.5] | |
ingest_photometry(db, sources, wise_bands, wise_mags, wise_mag_errors, 'Gauz15', | |
telescope='WISE') | |
# Execute the ingests! | |
add_ukidss_names(db) | |
ingest_pubs(db) | |
add_filters(db) | |
ingest_phot(db) | |
# WRITE THE JSON FILES | |
if SAVE_DB: | |
db.save_database(directory='data/') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment