appspice.spice_id2name
¶
List body ID in the know kernel
Usage¶
Usage: irfpy-spice-bspbody kernels …
For example,
irfpy-spice-id2name
list all the ID that SPICE knows without loading any kernels.
The range to search for ID can be specified by –max and –min arguments.
irfpy-spice-id2name --max 1000 --min "-50"
(Note the quote is likely needed not to give negative number as argument.)
You can specify the kernel files as
irfpy-spice-id2name ik/VEX_ASPERA4_V02.TI fk/RSSD0002.TF
Maybe you want to use meta kernel (*.TM) to load multiple kernels.
Advanced use¶
If you want to run python command before searching ID, one can use “preload” option. For example:
irfpy-spice-id2name --preload "from irfpy.vexpvat import vexspice; vexspice.init()"
Note to run this command, one should install irfpy.aspera package.
The vexspice module create the meta file (TM) upon execution of init() function. Therefore, to understand what ID is known by the vexspice module, preload funcitonality is needed, instead of giving all the kernel files.
""" List body ID in the know kernel
Usage
-----
Usage: irfpy-spice-bspbody kernels ...
For example,
.. code-block:: sh
irfpy-spice-id2name
list all the ID that SPICE knows without loading any kernels.
The range to search for ID can be specified by --max and --min arguments.
.. code-block:: sh
irfpy-spice-id2name --max 1000 --min "-50"
(Note the quote is likely needed not to give negative number as argument.)
You can specify the kernel files as
.. code-block:: sh
irfpy-spice-id2name ik/VEX_ASPERA4_V02.TI fk/RSSD0002.TF
Maybe you want to use meta kernel (*.TM) to load multiple kernels.
Advanced use
------------
If you want to run python command before searching ID, one can use
"preload" option. For example:
.. code-block:: sh
irfpy-spice-id2name --preload "from irfpy.vexpvat import vexspice; vexspice.init()"
Note to run this command, one should install irfpy.aspera package.
The vexspice module create the meta file (TM) upon execution of init() function.
Therefore, to understand what ID is known by the vexspice module, preload funcitonality is needed, instead of giving all the kernel files.
"""
import sys
from argparse import ArgumentParser
import logging
from irfpy.spice import spice
from irfpy.spice import spicetools
logging.basicConfig()
logger = logging.getLogger(__name__)
DEFAULT_MIN = -1000000
DEFAULT_MAX = 3000000
def main(kernels, start=DEFAULT_MIN, stop=DEFAULT_MAX):
spicetools.set_error_action('report')
for k in kernels:
logger.debug('Loading {}'.format(k))
try:
spice.furnsh(k)
except KeyboardInterrupt:
raise
except:
logger.warning("Error while loading the kernel: {}".format(k))
logger.warning("... continue without loading the corresponding kernel")
for index in range(start, stop):
try:
body_name = spice.bodc2n(index, 64)
print(index, '\t', body_name)
except KeyboardInterrupt:
raise
except:
pass
try:
frame_name = spice.frmnam(index)
if len(frame_name) != 0:
print(index, '\t\t*', frame_name)
except KeyboardInterrupt:
raise
except:
pass
def argmain():
parser = ArgumentParser()
parser.add_argument('-v', dest='verbose', action='store_true', default=False,
help='Verbose mode (for debugging)')
parser.add_argument('--min', type=int, default=DEFAULT_MIN, dest='min',
help='Minimum number to start searching')
parser.add_argument('kernel', nargs='*', help="Kernel files to be furnished.")
parser.add_argument('--max', type=int, default=DEFAULT_MAX, dest='max',
help='Maximum number to stop searching')
parser.add_argument('--preload', dest='preload', help="Command that runs before searching ID.")
args = parser.parse_args()
if args.verbose:
logger.setLevel(logging.DEBUG)
logger.debug(args)
if args.preload:
logger.info(args.preload)
exec(args.preload)
main(args.kernel, start=args.min, stop=args.max)
if __name__ == '__main__':
argmain()