From 9f0aff0e784774554c0c9ac24c16c8db41bfb849 Mon Sep 17 00:00:00 2001 From: LishaRamon <149431682+LishaRamon@users.noreply.github.com> Date: Wed, 13 Dec 2023 11:46:47 -0500 Subject: [PATCH] Ingest wise_1810-1010 (#427) * First ingest wise_1810-1010 * Changed tests * Ingest of proper motions * modeled parameters ingested * Effective Temperature * updated temp, 1256, asymmetric uncertainty * json unit change * reverted 1256 json file to upstream/main version * Added t eff to json * Added new tests to modeled parameters --------- Co-authored-by: Kelle Cruz --- data/Publications.json | 12 +++ data/Versions.json | 12 ++- data/cwisep_j181006.00-101001.1.json | 85 ++++++++++++++++ scripts/ingests/ingest_wise_1810-1010.py | 120 +++++++++++++++++++++++ tests/test_data.py | 34 ++++++- 5 files changed, 258 insertions(+), 5 deletions(-) create mode 100644 data/cwisep_j181006.00-101001.1.json create mode 100644 scripts/ingests/ingest_wise_1810-1010.py diff --git a/data/Publications.json b/data/Publications.json index a673cefb0..6a6c12d3d 100644 --- a/data/Publications.json +++ b/data/Publications.json @@ -6928,5 +6928,17 @@ "bibcode": "2020ApJ...903L..33V", "doi": "10.3847/2041-8213/abc256", "description": "Direct Radio Discovery of a Cold Brown Dwarf" + }, + { + "reference": "Schn20", + "bibcode": "2020ApJ...898...77S", + "doi": "10.3847/1538-4357/ab9a40", + "description": "WISEA J041451.67-585456.7 and WISEA J181006.18-101000.5: The First Extreme T-type Subdwarfs?" + }, + { + "reference": "Lodi22", + "bibcode": "2022A&A...663A..84L", + "doi": "10.1051/0004-6361/202243516", + "description": "Physical properties and trigonometric distance of the peculiar dwarf WISE J181005.5\u2212101002.3" } ] \ No newline at end of file diff --git a/data/Versions.json b/data/Versions.json index 186743d38..9ad0796a2 100644 --- a/data/Versions.json +++ b/data/Versions.json @@ -48,9 +48,15 @@ "description": "Companions table, fixed IRS spectra" }, { - "version": "latest", + "version": "2023.4", "start_date": "2023-10-18", + "end_date": "2023-12-12", + "description": "Added two sources" + }, + { + "version": "latest", + "start_date": "2023-12-12", "end_date": null, - "description": "Version in development" + "description": "Version in development" } -] +] \ No newline at end of file diff --git a/data/cwisep_j181006.00-101001.1.json b/data/cwisep_j181006.00-101001.1.json new file mode 100644 index 000000000..386631124 --- /dev/null +++ b/data/cwisep_j181006.00-101001.1.json @@ -0,0 +1,85 @@ +{ + "Sources": [ + { + "source": "CWISEP J181006.00-101001.1", + "ra": 272.52574999999996, + "dec": -10.166805555555555, + "epoch": null, + "equinox": null, + "shortname": null, + "reference": "Schn20", + "other_references": null, + "comments": null + } + ], + "ModeledParameters": [ + { + "parameter": "T eff", + "value": 800.0, + "value_error": 100.0, + "unit": "K", + "comments": null, + "reference": "Lodi22" + }, + { + "parameter": "log g", + "value": 5.0, + "value_error": 0.25, + "unit": "dex", + "comments": null, + "reference": "Lodi22" + }, + { + "parameter": "mass", + "value": 17.0, + "value_error": null, + "unit": "M_jup", + "comments": "17[+56, -12]", + "reference": "Lodi22" + }, + { + "parameter": "metallicity", + "value": -1.5, + "value_error": 0.5, + "unit": "dex", + "comments": null, + "reference": "Lodi22" + }, + { + "parameter": "radius", + "value": 0.067, + "value_error": 0.032, + "unit": "R_sun", + "comments": null, + "reference": "Lodi22" + } + ], + "Names": [ + { + "other_name": "CWISEP J181006.00-101001.1" + }, + { + "other_name": "Wise 1810-1010" + } + ], + "Parallaxes": [ + { + "parallax": 112.5, + "parallax_error": 8.1, + "adopted": true, + "comments": null, + "reference": "Lodi22" + } + ], + "ProperMotions": [ + { + "mu_ra": -1027.0, + "mu_ra_error": 3.5, + "mu_dec": -246.4, + "mu_dec_error": 3.6, + "adopted": true, + "comments": null, + "reference": "Schn20" + } + ] +} \ No newline at end of file diff --git a/scripts/ingests/ingest_wise_1810-1010.py b/scripts/ingests/ingest_wise_1810-1010.py new file mode 100644 index 000000000..b91002dfa --- /dev/null +++ b/scripts/ingests/ingest_wise_1810-1010.py @@ -0,0 +1,120 @@ +# Script ingest first data into companion tables + +from scripts.ingests.ingest_utils import * +from scripts.ingests.utils import * +from astropy.table import Table +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) + + +# Ingest wise_1810-1010 and its reference +#doi- 10.3847/1538-4357/ab9a40 and 10.1051/0004-6361/202243516 +#bibcode of coordinates reference- 2020ApJ...898...77S and 2022A&A...663A..84L +def add_publication(db): + + ingest_publication(db, doi = "10.3847/1538-4357/ab9a40") + + ingest_publication(db, doi = "10.1051/0004-6361/202243516") + +def add_sources(db): + + ra_1810= Angle("18 10 06.18", u.hour).degree + dec_1010=Angle("-10 10 00.5", u.degree).degree + + ingest_sources(db, ["CWISEP J181006.00-101001.1"], references=["Schn20"], + ras= [ra_1810], + decs=[dec_1010], + search_db=False) + + + # Ingest other name for Wise 1810-1010 (one used in SIMBAD) + # code from deprecated utils does not work + ingest_names(db, 'CWISEP J181006.00-101001.1', 'Wise 1810-1010') + +def add_parallaxes(db): + ingest_parallaxes(db, + sources = ["CWISEP J181006.00-101001.1"], + plxs = [112.5], + plx_errs = [8.1], + plx_refs = "Lodi22", + comments=None) + +def add_proper_motions(db): + ingest_proper_motions(db, sources = ["CWISEP J181006.00-101001.1"], + pm_ras = [-1027], + pm_ra_errs = [3.5], + pm_decs = [-246.4], + pm_dec_errs = [3.6], + pm_references = "Schn20") + + +#Ingest Functions for Modeled Parameters (Gravity, Metallicity, Radius, Mass) +#Creating list of dictionaries for each value formatted for modeled parameters +def add_modeled_parameters_dict(db): + ingest_modeled_parameters = [{ + 'Gravity': + {'value': 5.0, + 'value_error': 0.25, + 'parameter': "log g", + 'unit': 'dex', + 'reference': "Lodi22"}, + + 'Metallicity': + {'value': -1.5, + 'value_error': 0.5, + 'parameter': "metallicity", + 'unit': 'dex', + 'reference': "Lodi22"}, + + 'Radius': + {'value': 0.067, + 'value_error': 0.032, #Highest value error was picked between +0.032 & -0.020 listed + 'parameter': "radius", + 'unit': 'R_jup', + 'reference': "Lodi22"}, + + 'Mass': + {'value': 17, + 'value_error': null, #Highest value error was picked between +56 & -12 listed + 'parameter': "mass", + 'unit': 'M_jup', + 'comments': "17[+56, -12]", + 'reference': "Lodi22"}, + + 'Effective temperature': + {'value': 800, + 'value_error': 100, + 'parameter': "T eff", + 'unit': 'K', + 'reference': "Lodi22"} + }] + + source = "CWISEP J181006.00-101001.1" + #value_types = ['Gravity', 'Metallicity', 'Radius', 'Mass', 'Effective temperature'] + value_types = ['Effective temperature'] + with db.engine.connect() as conn: + for row in ingest_modeled_parameters: + + for value_type in value_types: + if row[value_type]['value'] is not None: # Checking that there's a value + conn.execute(db.ModeledParameters.insert().values({'source': source, 'reference': 'Lodi22', **row[value_type]})) + + conn.commit() + +#Call functions/ Comment out when not needed +#add_publication(db) +#add_sources(db) +#add_parallaxes(db) +#add_proper_motions(db) +add_modeled_parameters_dict(db) +db.inventory('CWISEP J181006.00-101001.1', pretty_print=True) + +# WRITE THE JSON FILES +if SAVE_DB: + db.save_database(directory='data/') \ No newline at end of file diff --git a/tests/test_data.py b/tests/test_data.py index fc2b46a0e..f4976813e 100644 --- a/tests/test_data.py +++ b/tests/test_data.py @@ -183,7 +183,7 @@ def test_proper_motion_refs(db): def test_parallax_refs(db): # Test total odopted measuruments t = db.query(db.Parallaxes).filter(db.Parallaxes.c.adopted == 1).astropy() - assert len(t) == 1442, f'found {len(t)} adopted parallax measuruments.' + assert len(t) == 1443, f'found {len(t)} adopted parallax measuruments.' ref = 'GaiaDR3' t = db.query(db.Parallaxes).filter(db.Parallaxes.c.reference == ref).astropy() @@ -266,7 +266,7 @@ def test_missions(db): stm = except_(select(db.Names.c.source).where(db.Names.c.other_name.like("WISE%")), select(db.Photometry.c.source).where(db.Photometry.c.band.like("WISE%"))) s = db.session.scalars(stm).all() - assert len(s) == 479, f'found {len(s)} sources with WISE designation that have no WISE photometry' + assert len(s) == 480, f'found {len(s)} sources with WISE designation that have no WISE photometry' # If Wise photometry, Wise designation should be in Names stm = except_(select(db.Photometry.c.source).where(db.Photometry.c.band.like("WISE%")), @@ -557,6 +557,36 @@ def test_modeledparameters(db): t = db.query(db.ModeledParameters).filter(db.ModeledParameters.c.reference == ref).astropy() assert len(t) == 696, f'found {len(t)} modeled parameters with {ref} reference' + #Test to verify log g counts + param = 'log g' + t = db.query(db.ModeledParameters).filter(db.ModeledParameters.c.parameter == param).astropy() + assert len(t) == 175, f'found {len(t)} modeled parameters with {param} parameter' + + #Test to verify metallicity counts + param = 'metallicity' + t = db.query(db.ModeledParameters).filter(db.ModeledParameters.c.parameter == param).astropy() + assert len(t) == 1, f'found {len(t)} modeled parameters with {param} parameter' + + #Test to verify radius counts + param = 'radius' + t = db.query(db.ModeledParameters).filter(db.ModeledParameters.c.parameter == param).astropy() + assert len(t) == 175, f'found {len(t)} modeled parameters with {param} parameter' + + #Test to verify mass counts + param = 'mass' + t = db.query(db.ModeledParameters).filter(db.ModeledParameters.c.parameter == param).astropy() + assert len(t) == 175, f'found {len(t)} modeled parameters with {param} parameter' + + #Test to verify T eff counts + param = 'T eff' + t = db.query(db.ModeledParameters).filter(db.ModeledParameters.c.parameter == param).astropy() + assert len(t) == 175, f'found {len(t)} modeled parameters with {param} parameter' + + #Test to verify Lodi22 reference counts + ref = 'Lodi22' + t = db.query(db.ModeledParameters).filter(db.ModeledParameters.c.reference == ref).astropy() + assert len(t) == 5, f'found {len(t)} modeled parameters with {ref} reference' + def test_photometrymko_y(db): # Test for Y photometry entries added for references