Add support for placeholder in kernels paths
Currently, the kernels
argument in TourConfig
support a kernel path string input or a list of kernels path strings, with explicit relative or absolute paths:
TourConfig(
kernels=[
'lsk/naif0012.tls',
'pck/pck00010.tpc',
...
],
)
Like for the metakernel, it should be possible to support placeholder in the path string, eg. '$KERNELS/lsk/naif0012.tls'
.
This value should be override by the kernels_dir
argument:
TourConfig(
kernels=[
'$KERNELS/lsk/naif0012.tls',
'$KERNELS/pck/pck00010.tpc',
...
],
kernels_dir='/data/JUICE/kernels',
)
Then, the kernels should be loaded as /data/JUICE/kernels/lsk/naif0012.tls
and /data/JUICE/kernels/pck/pck00010.tpc
.
It should also use the spacecraft
argument and the KERNELS_{SPACECRAFT_NAME}
environment variable (like in a .env
file) if kernels_dir=None
(default).
Going one step further
By default the $KERNELS
placeholder is the most frequent in metakernel files but any PATH_SYMBOLS
value could exists.
Replacing any placeholder in a metakernel is already possible with the Metakernel
object (see docs) but it is not possible directly in kernels_dir
(only the $KERNELS
placeholder is replaced at the moment).
It should be possible to provide a custom dict
with eventually, multiple placeholders, to replace custom PATH_SYMBOLS
:
TourConfig(
kernels=[
'$JUICE/spk/xxxx.bsp',
'$CLIPPER/spk/xxxx.bsp',
...
],
kernels_dir={'JUICE': '/data/JUICE/kernels', 'CLIPPER': '/data/EUROPA_CLIPPER/kernels'},
)
If theses values are present, they should override the default environment variables in both the metakernel and the kernels list.
In that case: kernels_dir='/data/JUICE/kernels'
is equivalent of kernels_dir={'KERNELS': '/data/JUICE/kernels'}
.
This could be extended to the .load_kernel()
as well (tour
and traj
):
new_traj = traj.add_kernel('$CUSTOM/new.ck', custom='/data/my-simulations/')
It will be recommended to use only $UPPERCASE_PATH_SYMBOLS
.
It should also be possible to provide the same kind of dict
to the remote_kernels
argument to point to different remote sources based on the placeholders names:
TourConfig(
kernels=[
'$JUICE/spk/xxxx.bsp',
'$CLIPPER/spk/xxxx.bsp',
...
],
remote_kernels={'JUICE': 'https://spiftp.esac.esa.int/...', 'CLIPPER': 'https://naif.jpl.nasa.gov/...'},
download_kernels=True,
)
In that case: remote_kernels='https://spiftp.esac.esa.int'
is equivalent of remote_kernels={'KERNELS': 'https://spiftp.esac.esa.int'}
.