Cassini SPICE kernels downloader


In [7]:
from planetarypy.spicekernels.cassini import *
from planetarypy.spicekernels.general import *
from astropy.time import Time

In [8]:
spk = CASSINI_KERNEL('spk')

In [9]:
spk.get_file('170417AP_SCPSE_17062_17116.bsp')

In [10]:
fnames = spk.filenames

In [11]:
tstr = '2017-03-27 14:30'

In [12]:
tstr2casdate(tstr)


Out[12]:
'17086'

In [33]:
spksearch??

In [13]:
spksearch(tstr, fnames)


Out[13]:
['090721AP_SCPSE_09198_17265.bsp',
 '090721AP_SK_09198_17265.bsp',
 '091005AP_SCPSE_09248_17265.bsp',
 '091005AP_SK_09248_17265.bsp',
 '110818AP_SCPSE_11175_17265.bsp',
 '110818AP_SK_11175_17265.bsp',
 '140114AP_SCPSE_13290_17265.bsp',
 '140114AP_SK_13290_17265.bsp',
 '150901AP_SCPSE_13290_17272.bsp',
 '150901AP_SK_13290_17272.bsp',
 '161202AP_SCPSE_16331_17116.bsp',
 '161202AP_SK_16331_17116.bsp',
 '161220AP_SCPSE_16357_17116.bsp',
 '161220AP_SK_16357_17116.bsp',
 '161230AP_SCPSE_16364_17116.bsp',
 '161230AP_SK_16364_17116.bsp',
 '170109AP_SCPSE_17007_17116.bsp',
 '170109AP_SK_17007_17116.bsp',
 '170123AP_SCPSE_17007_17116.bsp',
 '170123AP_SK_17007_17116.bsp',
 '170130AP_SCPSE_17027_17116.bsp',
 '170130AP_SK_17027_17116.bsp',
 '170213AP_SCPSE_17027_17116.bsp',
 '170213AP_SK_17027_17116.bsp',
 '170216AP_SCPSE_17046_17116.bsp',
 '170216AP_SK_17046_17116.bsp',
 '170227AP_SCPSE_17057_17116.bsp',
 '170227AP_SK_17057_17116.bsp',
 '170313AP_SCPSE_17062_17116.bsp',
 '170313AP_SK_17062_17116.bsp',
 '170327AP_SCPSE_17062_17116.bsp',
 '170327AP_SK_17062_17116.bsp',
 '170410AP_SCPSE_17062_17116.bsp',
 '170410AP_SK_17062_17116.bsp',
 '170417AP_SCPSE_17062_17116.bsp',
 '170417AP_SK_17062_17116.bsp']

In [21]:
spk = CASSINI_KERNEL('spk')

In [22]:
spk.get_file('170417AP_SCPSE_17062_17116.bsp')


---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-22-166d68f00cc9> in <module>()
----> 1 spk.get_file('170417AP_SCPSE_17062_17116.bsp')

/Users/klay6683/Dropbox/src/planetarypy/planetarypy/spicekernels/general.py in get_file(self, remote_name, local_name)
     32             local_name = remote_name
     33         local_path = str(self.local_dir / Path(self.kernel_dir) / local_name)
---> 34         self.ftp.retrbinary(f"RETR {remote_name}", open(f"{local_path}", "wb").write)

FileNotFoundError: [Errno 2] No such file or directory: '/Volumes/USB128II/spice/UVIS_data/kernels/spk/170417AP_SCPSE_17062_17116.bsp'

In [14]:
casfname = SPK_FNAME(spk.filenames[0])

In [15]:
casfname.fname


Out[15]:
'000202R_SK_LP0_V1P32.bsp'

In [16]:
casfname.delivery_date


Out[16]:
datetime.datetime(2000, 2, 2, 0, 0)

In [17]:
casfname.description


Out[17]:
'SK'

In [16]:
casfname.start_event


Out[16]:
['Launch', 'after swingby', '0 days']

In [17]:
casfname.end_event


Out[17]:
['Venus 1', 'after swingby', '32 days']

In [18]:
casfname.fname


Out[18]:
'000202R_SK_LP0_V1P32.bsp'

In [19]:
casfname.long_description


Out[19]:
'orbiter S/C trajectory'

In [ ]:


In [ ]:


In [20]:
fk = CASSINI_KERNEL('fk')

In [11]:
fnames = ckftp.filenames

In [14]:
casdate2dt(17086)


Out[14]:
datetime.datetime(2017, 3, 27, 0, 0)

In [15]:


In [16]:
tstr2casdate(tstr)


Out[16]:
'17086'

In [28]:
for ktype in ['ck','spk','fk','ik','lsk',' pck', 'sclk']:
    print(ktype)
    kernel = CASSINI_KERNEL(ktype)
    fnames = kernel.filenames
    search = CKSEARCH(tstr, fnames)
    hits = search.search_target()
    to_DL = find_highest_version(hits)
    kernel.get_file(to_DL)


ck
spk
---------------------------------------------------------------------------
IsADirectoryError                         Traceback (most recent call last)
<ipython-input-28-60eea792325f> in <module>()
      6     hits = search.search_target()
      7     to_DL = find_highest_version(hits)
----> 8     kernel.get_file(to_DL)

~/Dropbox/src/planetarypy/planetarypy/spicekernels/general.py in get_file(self, remote_name, local_name)
     32             local_name = remote_name
     33         local_path = str(self.local_dir / Path(self.kernel_dir) / local_name)
---> 34         self.ftp.retrbinary(f"RETR {remote_name}", open(f"{local_path}", "wb").write)

IsADirectoryError: [Errno 21] Is a directory: '/Volumes/USB128II/spice/UVIS_data/kernels/spk'

In [29]:
spk = CASSINI_KERNEL('spk')
ck = CASSINI_KERNEL('ck')

In [30]:
search = CKSEARCH(tstr, ck.filenames)

In [31]:



Out[31]:
<planetarypy.spicekernels.cassini.CKSEARCH at 0x10dcce2e8>

In [20]:
fnames = spk.filenames

In [21]:
[i for i in fnames if i.startswith('17')]


Out[21]:
['170109AP_PE_17007_17116.bsp',
 '170109AP_PE_17007_17116.bsp.lbl',
 '170109AP_SCPSE_17007_17116.bsp',
 '170109AP_SCPSE_17007_17116.bsp.lbl',
 '170109AP_SE_17007_17116.bsp',
 '170109AP_SE_17007_17116.bsp.lbl',
 '170109AP_SK_17007_17116.bsp',
 '170109AP_SK_17007_17116.bsp.lbl',
 '170123AP_PE_17007_17116.bsp',
 '170123AP_PE_17007_17116.bsp.lbl',
 '170123AP_SCPSE_17007_17116.bsp',
 '170123AP_SCPSE_17007_17116.bsp.lbl',
 '170123AP_SE_17007_17116.bsp',
 '170123AP_SE_17007_17116.bsp.lbl',
 '170123AP_SK_17007_17116.bsp',
 '170123AP_SK_17007_17116.bsp.lbl',
 '170130AP_PE_17027_17116.bsp',
 '170130AP_PE_17027_17116.bsp.lbl',
 '170130AP_SCPSE_17027_17116.bsp',
 '170130AP_SCPSE_17027_17116.bsp.lbl',
 '170130AP_SE_17027_17116.bsp',
 '170130AP_SE_17027_17116.bsp.lbl',
 '170130AP_SK_17027_17116.bsp',
 '170130AP_SK_17027_17116.bsp.lbl',
 '170213AP_PE_17027_17116.bsp',
 '170213AP_PE_17027_17116.bsp.lbl',
 '170213AP_SCPSE_17027_17116.bsp',
 '170213AP_SCPSE_17027_17116.bsp.lbl',
 '170213AP_SE_17027_17116.bsp',
 '170213AP_SE_17027_17116.bsp.lbl',
 '170213AP_SK_17027_17116.bsp',
 '170213AP_SK_17027_17116.bsp.lbl',
 '170216AP_PE_17046_17116.bsp',
 '170216AP_PE_17046_17116.bsp.lbl',
 '170216AP_SCPSE_17046_17116.bsp',
 '170216AP_SCPSE_17046_17116.bsp.lbl',
 '170216AP_SE_17046_17116.bsp',
 '170216AP_SE_17046_17116.bsp.lbl',
 '170216AP_SK_17046_17116.bsp',
 '170216AP_SK_17046_17116.bsp.lbl',
 '170227AP_PE_17057_17116.bsp',
 '170227AP_PE_17057_17116.bsp.lbl',
 '170227AP_SCPSE_17057_17116.bsp',
 '170227AP_SCPSE_17057_17116.bsp.lbl',
 '170227AP_SE_17057_17116.bsp',
 '170227AP_SE_17057_17116.bsp.lbl',
 '170227AP_SK_17057_17116.bsp',
 '170227AP_SK_17057_17116.bsp.lbl',
 '170228R_SCPSE_16262_16282.bsp',
 '170228R_SCPSE_16262_16282.bsp.lbl',
 '170301R_SCPSE_16282_16310.bsp',
 '170301R_SCPSE_16282_16310.bsp.lbl',
 '170313AP_PE_17062_17116.bsp',
 '170313AP_PE_17062_17116.bsp.lbl',
 '170313AP_SCPSE_17062_17116.bsp',
 '170313AP_SCPSE_17062_17116.bsp.lbl',
 '170313AP_SE_17062_17116.bsp',
 '170313AP_SE_17062_17116.bsp.lbl',
 '170313AP_SK_17062_17116.bsp',
 '170313AP_SK_17062_17116.bsp.lbl',
 '170315R_SCPSE_16310_16329.bsp',
 '170315R_SCPSE_16310_16329.bsp.lbl',
 '170323R_SCPSE_16329_16363.bsp',
 '170323R_SCPSE_16329_16363.bsp.lbl',
 '170327AP_PE_17062_17116.bsp',
 '170327AP_PE_17062_17116.bsp.lbl',
 '170327AP_SCPSE_17062_17116.bsp',
 '170327AP_SCPSE_17062_17116.bsp.lbl',
 '170327AP_SE_17062_17116.bsp',
 '170327AP_SE_17062_17116.bsp.lbl',
 '170327AP_SK_17062_17116.bsp',
 '170327AP_SK_17062_17116.bsp.lbl',
 '170410AP_PE_17062_17116.bsp',
 '170410AP_PE_17062_17116.bsp.lbl',
 '170410AP_SCPSE_17062_17116.bsp',
 '170410AP_SCPSE_17062_17116.bsp.lbl',
 '170410AP_SE_17062_17116.bsp',
 '170410AP_SE_17062_17116.bsp.lbl',
 '170410AP_SK_17062_17116.bsp',
 '170410AP_SK_17062_17116.bsp.lbl',
 '170417AP_PE_17062_17116.bsp',
 '170417AP_PE_17062_17116.bsp.lbl',
 '170417AP_SCPSE_17062_17116.bsp',
 '170417AP_SCPSE_17062_17116.bsp.lbl',
 '170417AP_SE_17062_17116.bsp',
 '170417AP_SE_17062_17116.bsp.lbl',
 '170417AP_SK_17062_17116.bsp',
 '170417AP_SK_17062_17116.bsp.lbl',
 '170423AP_PE_17108_17258.bsp',
 '170423AP_PE_17108_17258.bsp.lbl',
 '170423AP_SCPSE_17108_17258.bsp',
 '170423AP_SCPSE_17108_17258.bsp.lbl',
 '170423AP_SE_17108_17258.bsp',
 '170423AP_SE_17108_17258.bsp.lbl',
 '170423AP_SK_17108_17258.bsp',
 '170423AP_SK_17108_17258.bsp.lbl',
 '170502AP_PE_17108_17135.bsp',
 '170502AP_PE_17108_17135.bsp.lbl',
 '170502AP_SCPSE_17108_17135.bsp',
 '170502AP_SCPSE_17108_17135.bsp.lbl',
 '170502AP_SE_17108_17135.bsp',
 '170502AP_SE_17108_17135.bsp.lbl',
 '170502AP_SK_17108_17135.bsp',
 '170502AP_SK_17108_17135.bsp.lbl',
 '170509AP_PE_17118_17258.bsp',
 '170509AP_PE_17118_17258.bsp.lbl',
 '170509AP_SCPSE_17118_17258.bsp',
 '170509AP_SCPSE_17118_17258.bsp.lbl',
 '170509AP_SE_17118_17258.bsp',
 '170509AP_SE_17118_17258.bsp.lbl',
 '170509AP_SK_17118_17258.bsp',
 '170509AP_SK_17118_17258.bsp.lbl',
 '170509R_SCPSE_16363_17061.bsp',
 '170509R_SCPSE_16363_17061.bsp.lbl',
 '170518AP_PE_17131_17258.bsp',
 '170518AP_PE_17131_17258.bsp.lbl',
 '170518AP_SCPSE_17131_17258.bsp',
 '170518AP_SCPSE_17131_17258.bsp.lbl',
 '170518AP_SE_17131_17258.bsp',
 '170518AP_SE_17131_17258.bsp.lbl',
 '170518AP_SK_17131_17258.bsp',
 '170518AP_SK_17131_17258.bsp.lbl',
 '170612AP_PE_17152_17258.bsp',
 '170612AP_PE_17152_17258.bsp.lbl',
 '170612AP_SCPSE_17152_17258.bsp',
 '170612AP_SCPSE_17152_17258.bsp.lbl',
 '170612AP_SE_17152_17258.bsp',
 '170612AP_SE_17152_17258.bsp.lbl',
 '170612AP_SK_17152_17258.bsp',
 '170612AP_SK_17152_17258.bsp.lbl',
 '170619AP_PE_17166_17258.bsp',
 '170619AP_PE_17166_17258.bsp.lbl',
 '170619AP_SCPSE_17166_17258.bsp',
 '170619AP_SCPSE_17166_17258.bsp.lbl',
 '170619AP_SE_17166_17258.bsp',
 '170619AP_SE_17166_17258.bsp.lbl',
 '170619AP_SK_17166_17258.bsp',
 '170619AP_SK_17166_17258.bsp.lbl',
 '170626AP_PE_17166_17258.bsp',
 '170626AP_PE_17166_17258.bsp.lbl',
 '170626AP_SCPSE_17166_17258.bsp',
 '170626AP_SCPSE_17166_17258.bsp.lbl',
 '170626AP_SE_17166_17258.bsp',
 '170626AP_SE_17166_17258.bsp.lbl',
 '170626AP_SK_17166_17258.bsp',
 '170626AP_SK_17166_17258.bsp.lbl']

In [22]:
hits = search.search_target()

In [23]:
hits


Out[23]:
[]

In [22]:
CAS_CK_FNAME(hits[-1]).type


Out[22]:
'r'

In [24]:
find_highest_version(hits)


Out[24]:
''

In [3]:
ckftp.get_file('17082_17087ra.bc', '17082_17087ra.bc')

In [54]:



total 13896
-rw-r--r--@ 1 klay6683  2260  6920192 May 15 12:11 17082_17087ra.bc
-rw-r--r--@ 1 klay6683  2260    14937 May 15 12:10 cassini_spice_kernels.ipynb
-rw-r--r--@ 1 klay6683  2260    44105 May  9 23:33 downloading_index_files.ipynb
-rw-r--r--@ 1 klay6683  2260    52641 May  8  2016 parse_roses_calendar.ipynb
-rw-r--r--@ 1 klay6683  2260    33954 Jan 19 16:55 planet4_hirise_index_parsing.ipynb
-rw-r--r--@ 1 klay6683  2260     2294 Dec 20 13:36 planet4_metadata.csv
-rw-r--r--@ 1 klay6683  2260    34880 Apr 20  2015 planetary constants.ipynb

In [ ]: