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:
parent
f0de910ad6
commit
3dff433a13
|
@ -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)
|
Loading…
Reference in New Issue