示例#1
0
 def test_earth_spk_coverage(self):
     spice.furnsh(self.near.metakernel)
     spkids = spice.spkobj(self.near.SpkPlanet)
     cover = spice.stypes.SPICEDOUBLE_CELL(1000)
     spice.spkcov(self.near.SpkPlanet, 399, cover)
     result = [x for x in cover]
     expected_result = [-633873600.0, 347630400.0] 
     np.testing.assert_array_almost_equal(result, expected_result)
     spice.kclear()
示例#2
0
    def info(self):
        """Read and Output info about the loaded kernels
        """
        spice.kclear()

        spice.furnsh(self.metakernel)

        self.spkList = [
            self.SpkPlanet, self.SpkEros, self.SpkEros2, self.SpkMath,
            self.SpkNearLanded, self.SpkNearOrbit, self.SpkStations
        ]

        self.ckList = [self.Ck]
        self.pckList = [self.PckEros1, self.PckEros2]

        # check SPK coverage
        self.bodies = {}
        self.bodies_coverage = {}
        for spk in self.spkList:
            idcell = spice.spkobj(spk)
            for code in idcell:
                cover = spice.stypes.SPICEDOUBLE_CELL(1000)
                spice.spkcov(spk, code, cover)
                self.bodies[str(code)] = spice.bodc2n(code)
                self.bodies[spice.bodc2n(code)] = code
                self.bodies_coverage[str(code)] = [x for x in cover]
                self.bodies_coverage[spice.bodc2n(code)] = [x for x in cover]

        # check CK coverage
        self.ckframes = {}
        self.ckframes_coverage = {}
        for ck in self.ckList:
            idcell = spice.ckobj(ck)
            for code in idcell:
                cover = spice.ckcov(ck, code, True, 'SEGMENT', 0.0, 'TDB')
                self.ckframes[str(code)] = spice.frmnam(code)
                self.ckframes[spice.frmnam(code)] = code
                self.ckframes_coverage[str(code)] = [x for x in cover]
                self.ckframes_coverage[spice.frmnam(code)] = [x for x in cover]

        # check pck coverage
        self.pckframes = {}
        for pck in self.pckList:
            ids = spice.stypes.SPICEINT_CELL(1000)
            spice.pckfrm(pck, ids)
            for code in ids:
                self.pckframes[str(code)] = spice.frmnam(code)
                self.pckframes[spice.frmnam(code)] = code

        spice.kclear()
示例#3
0
    def __get_spice_range__(self, filename):
        """
        Function to calculate the range of coverage of a spice file given by filename
        :param filename: String, full path to spice file.
        :return dates_min: Astropy time object giving start of period spanned by spice file
        :return dates_max: Astropy time object giving end of period spanned by spice file
        :return craft_ids: List of craft ids represented by the spice file
        """

        # Ephemeris files:
        if filename.endswith('bsp'):
            # Get craft id's
            craft_ids = spice.spkobj(filename)
            times = []
            for s in craft_ids:
                cover = spice.utils.support_types.SPICEDOUBLE_CELL(2000)
                spice.spkcov(filename, s, cover)
                times.append([c for c in cover])
        # Pointing files
        elif filename.endswith('bc'):
            # Get craft id's
            craft_ids = spice.ckobj(filename)
            times = []
            for s in craft_ids:
                cover = spice.utils.support_types.SPICEDOUBLE_CELL(2000)
                try:
                    print('spice.ckcov: compute segment')
                    spice.ckcov(filename, s, False, 'segment', 0.0, 'TDB',
                                cover)
                except Exception:
                    print('spice.ckcov: compute interval')
                    spice.ckcov(filename, s, False, 'interval', 0.0, 'TDB',
                                cover)

                times.append([c for c in cover])
        else:
            print('Unrecognized file extension : ' + filename.split('.')[-1])
            dates_min = np.NaN
            dates_max = np.NaN
            craft_ids = np.NaN
            return dates_min, dates_max, craft_ids

        # Format the dates.
        min_time = min([min(t) for t in times])
        dates_min = Time(spice.et2utc(min_time, 'ISOC', 3))
        max_time = max([max(t) for t in times])
        dates_max = Time(spice.et2utc(max_time, 'ISOC', 3))
        return dates_min, dates_max, craft_ids
示例#4
0
def search_solar_objects(obsinfo):
    solar_objects = []
    count = spice.ktotal("spk")
    for which in range(count):
        filename, _filetype, _source, _handle = spice.kdata(which, "spk")
        ids = spice.spkobj(filename)
        for i in range(spice.card(ids)):
            obj = ids[i]
            target = spice.bodc2n(obj)
            if is_target_in_fov(
                    obsinfo.inst,
                    target,
                    obsinfo.et,
                    obsinfo.abcorr,
                    obsinfo.obsrvr,
            ):
                solar_objects.append(get_solar_object(obsinfo, obj, target))
    return solar_objects
示例#5
0
 def bodies(self):
     """List of the bodies stored within the kernel."""
     ids = [int(i) for i in spiceypy.spkobj(self._fname_str)]
     return [Body(i) for i in ids]