예제 #1
0
 def test_single_position(self):
     with SPK(NAIF_DAF(open('de405.bsp', 'rb'))) as kernel:
         x, y, z = kernel[0, 4].compute(2457061.5)
         # Expect rough agreement with a DE430 position from our README:
         self.assertAlmostEqual(x, 2.05700211e+08, delta=2.0)
         self.assertAlmostEqual(y, 4.25141646e+07, delta=2.0)
         self.assertAlmostEqual(z, 1.39379183e+07, delta=2.0)
예제 #2
0
def bsp_expiration(fileobj):
    """
    Return the expiration date for a .bsp file.
    """
    daf_object = DAF(fileobj)
    spk_object = SPK(daf_object)
    dates = [segment.end_jd for segment in spk_object.segments]
    # We take the closest end date, to expire the file as soon as it's obsolete
    end_jd = min(dates)
    return calendar_date(end_jd)
예제 #3
0
 def __init__(self, file):
     if isinstance(file, str):
         file = open(file, 'rb')
     self.spk = SPK(file)
     segments = [Segment(s.center, s.target, _build_compute(s))
                 for s in self.spk.segments]
     codes = set(s.center for s in segments).union(
                 s.target for s in segments)
     for code in codes:
         body = Body(code, segments)
         self[code] = body
         raw_name = target_names.get(code, None)
         if raw_name is None:
             continue
         name = raw_name.lower().replace(' ', '_')
         setattr(self, name, body)
예제 #4
0
def get_summary(url, spk=True):
    ''' simple function to retrieve the header of a BSP file and return SPK object'''
    # connect to file at URL
    bspurl = urllib2.urlopen(url)
    # retrieve the "tip" of a file at URL
    bsptip = bspurl.read(10**5)  # first 100kB
    # save data in fake file object (in-memory)
    bspstr = StringIO(bsptip)
    # load into DAF object
    daf = DAF(bspstr)
    # return either SPK or DAF object
    if spk:
        # make a SPK object
        spk = SPK(daf)
        # return representation
        return spk
    else:
        # return representation
        return daf