def test_eros_spk2_coverage(self): code = spice.bodn2c('EROS') cover = spice.stypes.SPICEDOUBLE_CELL(1000) spice.spkcov(self.near.SpkEros2, code, cover) result = [x for x in cover] expected_result = [-31334400.0, 81432000.0] np.testing.assert_array_almost_equal(result, expected_result)
def test_near_spk_orbit_coverage(self): code = spice.bodn2c('NEAR') cover = spice.stypes.SPICEDOUBLE_CELL(1000) spice.spkcov(self.near.SpkNearOrbit, code, cover) result = [x for x in cover] expected_result = [-43200.0, 35279120.0] np.testing.assert_array_almost_equal(result, expected_result)
def test_eros_spk1_coverage(self): spice.furnsh(self.near.metakernel) code = spice.bodn2c('EROS') cover = spice.stypes.SPICEDOUBLE_CELL(1000) spice.spkcov(self.near.SpkEros, code, cover) result = [x for x in cover] expected_result = [-126273600.0, 37886400.0] np.testing.assert_array_almost_equal(result, expected_result) spice.kclear()
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()
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()
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
def check_coverage(self): cover = spice.utils.support_types.SPICEDOUBLE_CELL(2000) if local == 0: spice.spkcov(auxdir + 'spk/MSGR_HGM008_INTGCB.bsp', -236, cover) else: spice.spkcov( '/home/sberton2/Works/NASA/Mercury_tides/spktst/MSGR_HGM008_INTGCB.bsp', -236, cover) twind = [spice.wnfetd(cover, i) for i in range(spice.wncard(cover))] epo_in = np.sort(self.ladata_df.ET_TX.values) self.ladata_df['in_spk'] = np.array( [np.sum([t[0] <= val <= t[1] for t in twind]) for val in epo_in]) > 0 if debug: print(len(self.ladata_df.loc[self.ladata_df['in_spk'] == False])) print("lensel", len(self.ladata_df), len(self.ladata_df.loc[self.ladata_df['in_spk']])) self.ladata_df = self.ladata_df.loc[self.ladata_df['in_spk']]
def coverage(self, body): """The coverage window for a specified `Body`.""" coverage = [t for t in spiceypy.spkcov(self._fname_str, body.id)] coverage = [spiceypy.et2datetime(t) for t in coverage] return coverage