For the future: dedicated module for NAIF names

Since this cache of dictionaries will be needed by users both of
`jpllib.py` and of `planetarylib.py`, it should have its own home.
Tests and documentation?  Someday!
This commit is contained in:
Brandon Rhodes 2019-12-17 10:59:03 -05:00
parent f0de910ad6
commit 3dff433a13
1 changed files with 16 additions and 0 deletions

16
skyfield/naifcodes.py Normal file
View File

@ -0,0 +1,16 @@
from jplephem.names import (
target_name_pairs as code_name_pairs,
target_names as code_names
)
name_codes = dict((name, code) for code, name in code_name_pairs)
def numbered_name_of(code):
"""Given a code, return a string giving both the code and name.
>>> numbered_name_of(301)
'301 Moon'
"""
name = code_names.get(code, '(Unnamed)')
return '{0} {1}'.format(code, name)