Skip to content

Commit 5de6c70

Browse files
committed
Add a wrapper around dastcom5
1 parent 68b9bc8 commit 5de6c70

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

sbpy/data/orbit.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from .. import bib
1919
from . import conf, DataClass
20+
from .. import utils
2021

2122
__all__ = ['Orbit']
2223

@@ -133,6 +134,33 @@ def from_horizons(cls, targetids, id_type='smallbody',
133134

134135
return cls.from_table(all_elem)
135136

137+
@classmethod
138+
def from_dastcom5(cls, name):
139+
"""Load orbital elements from the DASTCOM5 Database
140+
(ftp://ssd.jpl.nasa.gov/pub/ssd/dastcom5.zip).
141+
142+
Parameters
143+
----------
144+
name: str, mandatory
145+
Name of NEO
146+
147+
Returns
148+
-------
149+
`~Orbit` object
150+
151+
Examples
152+
--------
153+
>>> from sbpy.data import Orbit
154+
>>> orb = Orbit.from_dastcom5('atira')
155+
156+
"""
157+
dastcom5_dir = os.path.join(utils.dastcom5.SBPY_LOCAL_PATH, "dastcom5")
158+
if not os.path.isdir(dastcom5_dir):
159+
utils.dastcom5.download_dastcom5()
160+
161+
tb = utils.dastcom5.orbit_from_name(name=name)
162+
return cls.from_table(tb)
163+
136164
@classmethod
137165
def from_mpc(cls, targetid):
138166
"""Load orbital elements from the Minor Planet Center

sbpy/utils/dastcom5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def orbit_from_name(name):
330330
331331
"""
332332
records = record_from_name(name)
333-
orbits = [self.orbit_from_record(rec) for rec in records]
333+
orbits = [orbit_from_record(rec) for rec in records]
334334
tbl = Table(orbits)
335335
return tbl
336336

0 commit comments

Comments
 (0)