Skip to content

Commit 5554d9b

Browse files
committed
Add a parser function
1 parent 8fdb402 commit 5554d9b

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

sbpy/data/utils/dastcom5.py

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import astropy.units as u
88
import numpy as np
99
from astropy.time import Time
10-
from astropy.table import Table, vstack
10+
from astropy.table import Table, vstack, QTable
1111
import astropy.units as u
1212

1313
AST_DTYPE = np.dtype(
@@ -335,6 +335,34 @@ def orbit_from_name(name):
335335
return tbl
336336

337337

338+
def orbit_parser(name):
339+
"""Return :py:class:`~astropy.table.QTable` given a name.
340+
341+
Retrieve info with proper units from JPL DASTCOM5 database.
342+
343+
Parameters
344+
----------
345+
name : str
346+
NEO name.
347+
348+
Returns
349+
-------
350+
QTable : ~astropy.table.QTable
351+
Near Earth Asteroid/Comet orbit parameters, all stacked.
352+
353+
"""
354+
orb = orbit_from_name(name)
355+
record = [int(orb[1][0][0]),]
356+
a = [float(orb[1][0][1]),] * u.au
357+
ecc = [float(orb[1][0][2]),] * u.one
358+
inc = [float(orb[1][0][3]),] * u.deg
359+
raan = [float(orb[1][0][4]),] * u.deg
360+
argp = [float(orb[1][0][5]),] * u.deg
361+
m = [float(orb[1][0][6]),] * u.deg
362+
epoch = [orb[1][0][7],]
363+
tab = QTable([record, a, ecc, inc, raan, argp, m, epoch], names=("record", "a", "ecc", "inc", "raan", "argp", "m", "EPOCH"))
364+
return tab
365+
338366
def orbit_from_record(record):
339367
"""Return :py:class:`~astropy.table.Table` given a record.
340368
@@ -359,8 +387,8 @@ def orbit_from_record(record):
359387
argp = body_data["W"].item()
360388
m = body_data["MA"].item()
361389
epoch = Time(body_data["EPOCH"].item(), format="jd", scale="tdb")
362-
column2 = (record, a, ecc, inc, raan, argp, m, epoch)
363-
column1 = ("record", "a", "ecc", "inc", "raan", "argp", "m", "EPOCH")
390+
column2 = [record, a, ecc, inc, raan, argp, m, epoch]
391+
column1 = ["record", "a", "ecc", "inc", "raan", "argp", "m", "EPOCH"]
364392
data = Table(rows=[column1, column2])
365393

366394
return data

0 commit comments

Comments
 (0)