Skip to content

Commit ac2da07

Browse files
authored
Finish adding Radial Velocities table (#124)
* corrections to RV table * add template RV data and tests
1 parent 6c6bf0b commit ac2da07

File tree

6 files changed

+186
-21
lines changed

6 files changed

+186
-21
lines changed

data/reference/Publications.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,23 @@
8989
"doi": "10.1093/mnras/stad343",
9090
"description": "The TIME Table: rotation and ages of cool exoplanet host stars"
9191
},
92+
{
93+
"reference": "Liu_13",
94+
"bibcode": "2013ApJ...777L..20L",
95+
"doi": "10.1088/2041-8205/777/2/L20",
96+
"description": "The Extremely Red, Young L Dwarf PSO J318.5338-22.8603: A Free-floating Planetary-mass Analog to Directly Imaged Young Gas-giant Planets"
97+
},
98+
{
99+
"reference": "Alle16",
100+
"bibcode": "2016ApJ...819..133A",
101+
"doi": "10.3847/0004-637X/819/2/133",
102+
"description": "The Radial and Rotational Velocities of PSO J318.5338-22.8603, a Newly Confirmed Planetary-mass Member of the \u03b2 Pictoris Moving Group"
103+
},
92104
{
93105
"reference": "vanL07",
94106
"bibcode": "2007A&A...474..653V",
95107
"doi": "10.1051/0004-6361:20078357",
96108
"description": "Validation of the new Hipparcos reduction"
109+
97110
}
98111
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"Sources": [
3+
{
4+
"source": "2MASS J21140802-2251358",
5+
"ra_deg": 318.533,
6+
"dec_deg": -22.86,
7+
"epoch_year": 2000.0,
8+
"equinox": "J2000",
9+
"shortname": null,
10+
"reference": "Liu_13",
11+
"other_references": null,
12+
"comments": null
13+
}
14+
],
15+
"Names": [
16+
{
17+
"other_name": "2MASS J21140802-2251358"
18+
},
19+
{
20+
"other_name": "PSO J318.5-22"
21+
}
22+
],
23+
"RadialVelocities": [
24+
{
25+
"rv_kms": -6.0,
26+
"rv_error": 1.1,
27+
"adopted": true,
28+
"comments": "uncertainty reported as +0.8 and -1.1 km/s",
29+
"reference": "Alle16"
30+
}
31+
]
32+
}

schema/schema.yaml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ description: "Template database for use by the AstroDB Toolkit"
99
# - Comments length is 100 characters. ivoa:ucd: meta.note
1010
# - Reference is 30 characters
1111
# - Description is 100 characters. ivoa:ucd: meta.note
12+
# - Values are datatype: double
13+
# - Adopted: ivoa:ucd: meta.code
1214
######################################################
1315

1416
tables:
@@ -67,8 +69,9 @@ tables:
6769
- name: description
6870
"@id": "#Telescopes.description"
6971
datatype: string
70-
length: 1000
72+
length: 100
7173
description: Telescope description
74+
ivoa:ucd: meta.note
7275
- name: reference
7376
"@id": "#Telescopes.reference"
7477
datatype: string
@@ -117,8 +120,9 @@ tables:
117120
- name: description
118121
"@id": "#Instruments.description"
119122
datatype: string
120-
length: 1000
123+
length: 100
121124
description: Instrument description
125+
ivoa:ucd: meta.note
122126
- name: reference
123127
"@id": "#Instruments.reference"
124128
datatype: string
@@ -679,26 +683,27 @@ tables:
679683
- name: source
680684
"@id": "#RadialVelocities.source"
681685
datatype: string
682-
length: 100
686+
length: 50
683687
description: Main identifier for an object; links to Sources table
684688
ivoa:ucd: meta.id;meta.main
685689
nullable: false
686-
- name: radial_velocity_kms
687-
"@id": "#RadialVelocities.radial_velocity_kms"
690+
- name: rv_kms
691+
"@id": "#RadialVelocities.rv_kms"
688692
datatype: double
689693
description: Radial velocity value for this entry
690694
fits:tunit: km/s
691695
ivoa:ucd: spect.dopplerVeloc
692-
- name: radial_velocity_error_kms
693-
"@id": "#RadialVelocities.magnitude_error"
696+
- name: rv_error
697+
"@id": "#RadialVelocities.rv_error"
694698
datatype: double
695-
description: Uncertainty of this parallax value
696-
fits:tunit: mas
699+
description: Uncertainty of the radial velocity value
700+
fits:tunit: km/s
697701
ivoa:ucd: stat.error;spect.dopplerVeloc
698702
- name: adopted
699703
"@id": "#RadialVelocities.adopted"
700704
datatype: boolean
701705
description: Flag to indicate if this is the adopted entry
706+
ivoa:ucd: meta.code
702707
- name: comments
703708
"@id": "#RadialVelocities.comments"
704709
datatype: string
@@ -741,7 +746,7 @@ tables:
741746
"@type": Check
742747
"@id": "#check_radial_velocity_error"
743748
description: Validate radial velocity error
744-
expression: radial_velocity_error_kms >= 0
749+
expression: rv_error >= 0
745750

746751

747752
- name: CompanionRelationships

scripts/ingest_gl229b.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,17 @@
3434

3535

3636
def ingest_gl229b(db):
37-
# ingest_publication(db, doi="10.1038/378463a0")
37+
ingest_publication(db, doi="10.1038/378463a0")
3838
ingest_source(db, "Gl 229b", reference="Naka95")
3939

40-
41-
# ingest_publication(
42-
# db,
43-
# doi="10.1093/mnras/stad343",
44-
# bibcode="2023MNRAS.520.5283G",
45-
# reference="Gaid23",
46-
# description="The TIME Table: rotation and ages of cool exoplanet host stars",
47-
# ignore_ads=True,
48-
# )
40+
ingest_publication(
41+
db,
42+
doi="10.1093/mnras/stad343",
43+
bibcode="2023MNRAS.520.5283G",
44+
reference="Gaid23",
45+
description="The TIME Table: rotation and ages of cool exoplanet host stars",
46+
ignore_ads=True,
47+
)
4948

5049

5150
def ingest_companion(db):

scripts/ingest_pso0318

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
from astrodb_utils import load_astrodb
2+
from astrodb_utils.sources import ingest_source, ingest_names
3+
from astrodb_utils.publications import ingest_publication
4+
5+
# Load the database
6+
db_file = "tests/astrodb_template_tests.sqlite"
7+
felis_schema = "schema/schema.yaml"
8+
9+
reference_tables = [
10+
"Publications",
11+
"Telescopes",
12+
"Instruments",
13+
"Versions",
14+
"PhotometryFilters",
15+
"Regimes",
16+
"AssociationList",
17+
"ParameterList",
18+
"CompanionList",
19+
"SourceTypeList",
20+
]
21+
22+
db = load_astrodb(
23+
db_file,
24+
recreatedb=True,
25+
felis_schema=felis_schema,
26+
reference_tables=reference_tables,
27+
)
28+
29+
def ingest_PSO_J318(db):
30+
ingest_publication(
31+
db,
32+
doi="10.1088/2041-8205/777/2/L20",
33+
bibcode="2013ApJ...777L..20L",
34+
description="The Extremely Red, Young L Dwarf PSO J318.5338-22.8603: A Free-floating Planetary-mass Analog to Directly Imaged Young Gas-giant Planets",
35+
reference="Liu_13",
36+
ignore_ads=True,
37+
)
38+
39+
ingest_source(db, "2MASS J21140802-2251358", reference="Liu_13")
40+
41+
ingest_names(db, "2MASS J21140802-2251358", "PSO J318.5-22")
42+
43+
def ingest_radial_velocity(db):
44+
# Add radial velocity data for PSO J318.5
45+
ingest_publication(db, doi="10.3847/0004-637X/819/2/133")
46+
47+
rv_data = [
48+
{
49+
"source": "2MASS J21140802-2251358",
50+
"rv_kms": -6.0,
51+
"rv_error": 1.1,
52+
"adopted": True,
53+
"comments": "uncertainty reported as +0.8 and -1.1 km/s",
54+
"reference": "Alle16",
55+
}
56+
]
57+
with db.engine.connect() as conn:
58+
conn.execute(db.RadialVelocities.insert().values(rv_data))
59+
conn.commit()
60+
61+
62+
DB_SAVE = True
63+
64+
ingest_PSO_J318(db)
65+
ingest_radial_velocity(db)
66+
67+
if DB_SAVE:
68+
db.save_database("data/")

tests/test_database.py

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
Functions to test the database and example files
33
"""
44

5-
from astrodbkit.astrodb import or_
65
from sqlalchemy.ext.automap import automap_base
6+
from sqlalchemy import func, or_
77

88

99
def test_setup_db(db):
@@ -242,3 +242,51 @@ def test_companion_relationships(db):
242242
), f"Found {len(t)} entries in the Companion Relationships table, expected {n_companion_relationships}"
243243

244244

245+
def test_radial_velocities(db):
246+
# Test that Radial Velocities has expected number of entries
247+
t = db.query(db.RadialVelocities.c.rv_kms).astropy()
248+
249+
n_radial_velocities = 1
250+
assert (
251+
len(t) == n_radial_velocities
252+
), f"Found {len(t)} entries in the Radial Velocities table, expected {n_radial_velocities}"
253+
254+
# Test that there is one adopted radial velocity measurement per source
255+
t = (
256+
db.query(
257+
db.RadialVelocities.c.source,
258+
func.sum(db.RadialVelocities.c.adopted).label("adopted_counts"),
259+
)
260+
.group_by(db.RadialVelocities.c.source)
261+
.having(func.sum(db.RadialVelocities.c.adopted) != 1)
262+
.astropy()
263+
)
264+
265+
assert (
266+
len(t) == 0
267+
), f"Found {len(t)} radial velocity measurements with incorrect 'adopted' labels"
268+
269+
270+
def test_proper_motions(db):
271+
# Test that Radial Velocities has expected number of entries
272+
t = db.query(db.ProperMotions.c.pm_ra).astropy()
273+
274+
n_proper_motions = 1
275+
assert (
276+
len(t) == n_proper_motions
277+
), f"Found {len(t)} entries in the Proper Motions table, expected {n_proper_motions}"
278+
279+
# Test that there is one adopted proper motion measurement per source
280+
t = (
281+
db.query(
282+
db.ProperMotions.c.source,
283+
func.sum(db.ProperMotions.c.adopted).label("adopted_counts"),
284+
)
285+
.group_by(db.ProperMotions.c.source)
286+
.having(func.sum(db.ProperMotions.c.adopted) != 1)
287+
.astropy()
288+
)
289+
290+
assert (
291+
len(t) == 0
292+
), f"Found {len(t)} proper motion measurements with incorrect 'adopted' labels"

0 commit comments

Comments
 (0)