def furnsh_kernels(): spice.tkvrsn('TOOLKIT') path = r'C:/Spice_Kernels/' spice.furnsh(path + r'de430.bsp') spice.furnsh(path + r'naif0009.tls') spice.furnsh(path + r'sat425.bsp') spice.furnsh(path + r'cpck05Mar2004.tpc') spice.furnsh(path + r'020514_SE_SAT105.bsp') spice.furnsh(path + r'981005_PLTEPH-DE405S.bsp') spice.furnsh(path + r'030201AP_SK_SM546_T45.bsp') spice.furnsh(path + r'04135_04171pc_psiv2.bc') spice.furnsh(path + r'sat425.inp') spice.furnsh(path + r'sat425.cmt')
def furnsh_kernels(): ''' Furnshes the kernels needed for a Saturn mission ''' spice.tkvrsn('TOOLKIT') path = r'C:\Senior_Design\Spice_Kernels' spice.furnsh(path + r'de430.bsp') spice.furnsh(path + r'naif0009.tls') spice.furnsh(path + r'sat425.bsp') spice.furnsh(path + r'cpck05Mar2004.tpc') spice.furnsh(path + r'020514_SE_SAT105.bsp') spice.furnsh(path + r'981005_PLTEPH-DE405S.bsp') spice.furnsh(path + r'030201AP_SK_SM546_T45.bsp') spice.furnsh(path + r'04135_04171pc_psiv2.bc') spice.furnsh(path + r'sat425.inp') spice.furnsh(path + r'sat425.cmt')
def get_sun_sizes(utc_start, utc_end, step_size): """get sun angular size and time steps given start and end times""" #spice constants abcorr = "None" #tolerance = "1" #method = "Intercept: ellipsoid" #prec = 3 #shape = "Ellipsoid" #load spiceypy kernels os.chdir(KERNEL_DIRECTORY) sp.furnsh(KERNEL_DIRECTORY + os.sep + METAKERNEL_NAME) print(sp.tkvrsn("toolkit")) os.chdir(BASE_DIRECTORY) utctimestart = sp.str2et(utc_start) utctimeend = sp.str2et(utc_end) durationseconds = utctimeend - utctimestart nsteps = int(np.floor(durationseconds / step_size)) timesteps = np.arange(nsteps) * step_size + utctimestart ref = "J2000" observer = "-143" target = "SUN" #get TGO-SUN pos tgo2sunpos = [ sp.spkpos(target, time, ref, abcorr, observer)[0] for time in timesteps ] sunaxes = sp.bodvrd("SUN", "RADII", 3)[1][0] #get mars axis values return ([np.arctan((sunaxes*2.0)/np.linalg.norm(tgo2sunVector))*sp.dpr()*60.0 \ for tgo2sunVector in tgo2sunpos], timesteps)
def __init__(self): super(SpiceBase, self).__init__() # Set SpiceyPy version number being used self.versions = dict( SpiceyPy=pkg_resources.get_distribution("spiceypy").version, NAIF=spice.tkvrsn('TOOLKIT'))
def cspice_utc2et(kernelfile, ctime): spice_ver = spice.tkvrsn('TOOLKIT') spice.furnsh(kernelfile) kernels_loaded = spice.ktotal("ALL") #print(kernels_loaded) ntime = spice.utc2et(ctime.value) #print(spice_ver) return ntime
def load_spice_kernels(planning=False): os.chdir(paths["KERNEL_DIRECTORY"]) if planning: sp.furnsh(os.path.join(paths["KERNEL_DIRECTORY"], "em16_plan.tm")) else: sp.furnsh(os.path.join(paths["KERNEL_DIRECTORY"], "em16_ops.tm")) print(sp.tkvrsn("toolkit")) os.chdir(paths["BASE_DIRECTORY"])
def interval(): print("which kernels would you like to load?") meta = input() KERNELS_TO_LOAD = ('meta.tm') print(spice.tkvrsn('TOOLKIT')) #help(spice.furnsh) spice.furnsh(KERNELS_TO_LOAD) print("Load successful") pass
def test(): print("which kernels would you like to load?") meta = input() KERNELS_TO_LOAD = ('meta.tm') print(spice.tkvrsn('TOOLKIT')) #help(spice.furnsh) spice.furnsh(KERNELS_TO_LOAD) print("Load successful") print("Enter time:") time = input() et = spice.str2et(time) #et=spice.str2et( '2012-12-03T12:23:52' ) #help(spice.spkcpo) target0 = 'DAWN' frame0 = 'DAWN_SPACECRAFT' corrtn0 = 'NONE' observ0 = 'DAWN' state0 = [6] state0, ltime0 = spice.spkezr(target0, et, frame0, corrtn0, observ0) print("target:" + target0) print("positions:" + "\nx: " + str(state0[0])) print("y: " + str(state0[1])) print("z: " + str(state0[2])) target1 = 'VESTA' frame1 = 'DAWN_SPACECRAFT' corrtn1 = 'NONE' observ1 = 'DAWN' state1, ltime1 = spice.spkezr(target1, et, frame1, corrtn1, observ1) print("target:" + target1) print("positions:" + "\nx: " + str(state1[0])) print("y: " + str(state1[1])) print("z: " + str(state1[2])) mat = spice.pxform('DAWN_SPACECRAFT', 'IAU_VESTA', et) print("orientation") print(mat) fig = plt.figure(figsize=(9, 9)) ax = fig.add_subplot(111, projection='3d') ax.text(state0[0], state0[1], state0[2], target0) ax.text(state1[0], state1[1], state1[2], target1) ax.set_xlabel('X axis') ax.set_ylabel('Y axis') ax.set_zlabel('Z axis') plt.show()
def cspice_utc2et(kernelfile, stimes, ttimes): global ets, etx nt = len(stimes) ets = np.zeros(nt) etx = np.zeros(nt) spice_ver = spice.tkvrsn('TOOLKIT') spice.furnsh(kernelfile) kernels_loaded = spice.ktotal("ALL") #print(kernels_loaded) for i in range(0, nt): sstr = stimes[i][:23] tstr = ttimes[i][:23] et1 = spice.utc2et(sstr) et2 = spice.utc2et(tstr) ets[i] = 0.5 * (et1 + et2) for i in range(0, nt): etx[i] = ets[i] - ets[0]
data[p]['rotz'][r[0]:r[1] + 1] += ad ad -= 360 with open('../js/ikuchi-pregenerated.js', 'w') as fh: fh.write( '// All data and functions in this file are auto-generated. Do not modify.\n' ) fh.write('// Build date: {}\n'.format(datetime.datetime.now().__str__())) fh.write('// Build platform: {} {}\n'.format(platform.platform(), platform.processor())) fh.write('// Build Python version: {}\n'.format(platform.python_version())) fh.write('// Build NumPy version: {}\n'.format(np.__version__)) fh.write('// Build SciPy version: {}\n'.format(scipy.__version__)) fh.write('// Build Matplotlib version: {}\n'.format( matplotlib.__version__)) fh.write('// Build SPICE version: {}\n'.format(spiceypy.tkvrsn('toolkit'))) fh.write('// SPICE Kernels used:\n') for i in range(spiceypy.ktotal('ALL')): [file, type, source, handle] = spiceypy.kdata(i, 'ALL') fh.write('// {} ({})\n'.format(file, type)) fh.write('\n\n\n') # Output default planet rotation angle functions. fh.write('//Fits for Default Planet\n') fh.write('function rotzDefault(t){\n\treturn(0.0);\n}\n\n') fh.write('function rotyDefault(t){\n\treturn(0.0);\n}\n\n\n') # We have full time series of the two rotation angles we need, so now we # do fits and write the results of the fits to javascript functions we # need in the main web app. print('[ikuchi-build] Fitting and generating Javascript functions')
import spiceypy as spice import numpy as np import scipy.special as scs import datetime as dt import matplotlib.pyplot as plt from numpy import pi, sin, cos from mpl_toolkits.mplot3d import Axes3D # Print toolkit version numbers print spice.tkvrsn('TOOLKIT') # Load kernels. The kernel files listed in meta_kernel.txt were downloaded # from "https://naif.jpl.nasa.gov/pub/naif/generic_kernels/suffix", where # the string "suffix" matches the directory structure inside the directory # "spiceypy/kernels". spice.furnsh("/data5/glwagner/Software/spiceypy/meta_kernel.txt") def lon_lat_r(body, time): """ Use SPICE software to get - longitude and latitude of <body>'s subsolar point, or the coordinates at which <body> is in zenith (or point 'Q' in Munk and Cartwright 1966's figure 13), and - the distance between the barycenters of Earth and <body> at a specified <time> (in UTC). The input <body> is a string like "SUN" or "MOON", and <time> is a datestring with format 'yyyy-mm-dd hh:mm:ss'
import spiceypy as sp import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D if os.path.exists(os.path.normcase(r"C:\Users\ithom\Dropbox\NOMAD\Python")): BASE_DIRECTORY = os.path.normcase(r"C:\Users\ithom\Dropbox\NOMAD\Python") KERNEL_DIRECTORY = os.path.normcase(r"D:\kernels\kernels\mk") FIG_X = 18 FIG_Y = 9 """load spiceypy kernels""" METAKERNEL_NAME = r"em16_ops_win.tm" os.chdir(KERNEL_DIRECTORY) sp.furnsh(KERNEL_DIRECTORY + os.sep + METAKERNEL_NAME) print(sp.tkvrsn("toolkit")) os.chdir(BASE_DIRECTORY) origin = np.asfarray([0.0, 0.0, 0.0]) #vectorOffsetX = 3.0**(-1/2) #vectorOffsetY = 3.0**(-1/2) vectorOffsetX = np.arcsin(1.9992 / sp.dpr()) #2 degrees vectorOffsetY = np.arcsin(15.0 * 88 / 90 / sp.dpr()) #15 vectorOffsetZ = np.sqrt(1.0 - vectorOffsetX**2 - vectorOffsetY**2) vector = np.asfarray([vectorOffsetX, vectorOffsetY, vectorOffsetZ]) vectorMagnitude = sp.vnorm(vector) #should be 1 vector2 = np.asfarray([0.0, 0.0, 1.0])
if TestCase == 1: # Import required packages import math import numpy as np import spiceypy as spice import pygmo # Part(Problem) 1 of Basics-I assignment S_bar = np.array([ 8751268.4691, -7041314.6869, 4846546.9938, 332.2601039, -2977.0815768, -4869.8462227 ]) # Extracting mu from SPICE kernels print(spice.tkvrsn('TOOLKIT')) spice.furnsh("./External_files/Spice_kernels/kernel_load.txt") muE = spice.bodvrd('EARTH', 'GM', 1) #mu = 398600.441E9 # Gravitational parameter for Earth [m^3/s^2] mu = muE[1][0] * 1e9 spice.kclear CovertedKep = convertCartesianToKepler( S_bar, mu, True, True) # Position arguments are passed # Part(Problem) 2 of Basics-I assignment a = 12158817.9615 # Semi-major axis[m]
def test_spiceypy_installation_correct(): spice_version = 'CSPICE_N0066' np.testing.assert_equal(spice.tkvrsn('TOOLKIT'),spice_version)
def test_import_spiceypy(self): import spiceypy self.assertTrue(spiceypy.tkvrsn('TOOLKIT') >= "CSPICE_N0066")
def print_ver(): """Prints the TOOLKIT version """ print(spiceypy.tkvrsn('TOOLKIT'))
import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import spiceypy as spice print("Toolkit Version: " + spice.tkvrsn("TOOLKIT")) #prints version of toolkit spice.furnsh("./cassMetaK.txt") step = 4000 utc = ['Jun 20, 2004', 'Dec 1, 2005'] #Get positions between these two dates etOne = spice.str2et(utc[0]) #get et values one... etTwo = spice.str2et(utc[1]) #...and two, we could vectorize str2et print("ET One: {}, ET Two: {}".format(etOne, etTwo)) times = [x * (etTwo - etOne) / step + etOne for x in range(step)] # get times print(times[0:3]) #prints the first few times: #Runs spkpos as a vectorized function positions, lightTimes = spice.spkpos('Cassini', times, 'J2000', 'NONE', 'SATURN BARYCENTER') # Positions is a 3xN vector of XYZ positions print("Positions: ") print(positions[0]) # Light times is a N vector of time
import numpy as np import spiceypy as spice print(spice.tkvrsn("TOOLKIT")) path = '/home/uzumochi/eigenjuno/stitching/kernels/' KERNEL_LIST = [ path + "naif0012.tls", # basic functionality i think path + "de430.bsp", # basic solar system info path + "juno_v12.tf", # juno reference frame description path + "jup310.bsp", # jupiter information path + "jno_sclkscet_00094.tsc", # clock information i think path + "perijove_15.bsp", path + "pck00010.tpc", path + "perijove_15.bc" ] spice.furnsh(KERNEL_LIST) # loading these kernels JUPITER_EQUATORIAL_RADIUS = 71492 # km JUPITER_POLAR_RADIUS = 66854 # km STRIPE_LENGTH = 1648 # px STRIPE_HEIGHT = 128 # px STANDARD_IMAGE_START_TIME_OFFSET = 0.06188 # secs PHOTOACTIVE_PIXELS = np.ones((STRIPE_LENGTH, STRIPE_HEIGHT), dtype=np.int) PHOTOACTIVE_PIXELS[:23 + 1, :] = 0 PHOTOACTIVE_PIXELS[1631 - 1:, :] = 0 MIN_SURFACE_ANGLE = 10 * np.pi / 180 MIN_SUN_ANGLE = 5 * np.pi / 180
from pipeline_config_v03 import BASE_DIRECTORY, KERNEL_DIRECTORY, figx, figy from pipeline_mappings_v03 import METAKERNEL_NAME import spiceypy as sp import os abcorr = "None" tolerance = "1" method = "Intercept: ellipsoid" formatstr = "C" prec = 3 shape = "Ellipsoid" os.chdir(KERNEL_DIRECTORY) sp.furnsh(KERNEL_DIRECTORY + os.sep + METAKERNEL_NAME) print sp.tkvrsn("toolkit") os.chdir(BASE_DIRECTORY) ref = "MARSIAU" observer = "MARS" target = "-143" utcstring_start = "2018NOV30-09:30:00 UTC" #normal and then long grazing occultations utcstring_end = "2018DEC01-09:00:00 UTC" step = 10 #time delta (s) utctime_start = sp.str2et(utcstring_start) utctime_end = sp.str2et(utcstring_end) total_seconds = utctime_end - utctime_start nsteps = int(np.floor(total_seconds / step))