heliopython / heliopy

Python for heliospheric and planetary physics
http://docs.heliopy.org/en/stable/
GNU General Public License v3.0
66 stars 44 forks source link

heliopy.spice LSK has to be explicitly loaded? #895

Closed STBadman closed 4 years ago

STBadman commented 4 years ago

I just upgraded to v 0.11 and I noticed my scripts broke everywhere I was using heliopy.spice, with the spice error that leap seconds were not loaded. Things work again when I do

>>> spice.setup_spice()

or

>>> spice.furnish(spicedata.get_kernel('lsk'))

Was there a change where setup_spice() used to be called automatically?

This also seems to unfortunately break the RTD spice example :

 >>> import heliopy.data.spice as spicedata 
 >>> import heliopy.spice 
 >>> from datetime import datetime, timedelta 
 >>> heliopy.__version__
'0.11.0'
>>> kernels = spicedata.get_kernel('psp')
>>> kernels += spicedata.get_kernel('psp_pred')
>>> heliopy.spice.furnish(kernels)
>>> psp = heliopy.spice.Trajectory('SPP')
>>> psp.generate_positions([datetime(2018,11,6)], 'Sun', 'ECLIPJ2000')
SpiceyError: 
================================================================================

Toolkit version: N0066

SPICE(NOLEAPSECONDS) --

The variable that points to the leapseconds (DELTET/DELTA_AT) could not be located in the kernel pool.  It is likely that the leapseconds kernel has not been loaded via the routine FURNSH.

str2et_c --> STR2ET --> TTRANS

================================================================================

(I also verified the example ran after manually running setup_spice and found a new error where no ephemeris data is loaded for PSP for october 3 6am-12am. It seems in the newest spice kernel the trajectory is not defined in this time interval which corresponds to PSP's first venus gravity assist. If we change the cadence of the list of datatimes or pop those time stamps that should fix that)

dstansby commented 4 years ago

Having to use setup_spice is a deliberate change made to solve some circular import problems between heliopy.spice and heliopy.data.spice. It is documented, but the documentation builds are currently failing...

For the second issue, that's odd, I'm guessing there just isn't any ephemeris data in the kernel for the gravity assist?

dstansby commented 4 years ago

I think I found a way round circular imports in #899. Do you think the PSP ephemeris issue is something wrong with HelioPy, or just a problem with the kernel?

STBadman commented 4 years ago

I pulled this commit and both issues went away. I tested the 2nd issue in the current master branch and found that it went away when I explicitly loaded the planet_trajectories kernel or ran setup_spice - I think that means the PSP trajectory requires Venus ephemerides during the gravity assist.

Either way, by having setup_spice happen implicity I think you've solved it