import spiceypy as cspice import numpy as np import matplotlib.pyplot as plt def main(mk, utc0, utcf, steps, target, observer, frame): # load MK cspice.furnsh(mk) # define time stamp et0 = cspice.utc2et(utc0) etf = cspice.utc2et(utcf) times = np.linspace(et0, etf, steps) cartesian_juice = [] radec_juice = [] cartesian_juice_ecliptj2000 = [] source_ang_separation = [] for t in times: # compute target position r = cspice.spkpos(target, t, frame, 'NONE', observer)[0] cartesian_juice.append(r) # convert cartesian coordinates to Range [km], Right Ascension [rad] and Declination [rad] radec = cspice.recrad(r) radec_juice.append([radec[0], np.rad2deg(radec[1]), np.rad2deg(radec[2])]) # compute rotation matrix to transform from "frame" to "ECLIPTJ2000" (or any other ref frame) M_rot = cspice.pxform(frame, 'ECLIPJ2000', t) # multiply the rotation matrix by the position vector to transform it to the ECLIPJ2000 frame cartesian_juice_ecliptj2000.append(cspice.mxv(M_rot, r)) # transform Range [km], Right Ascension [rad] and Declination [rad] to Cartesian coordinates source_ra = np.deg2rad(30) source_dec = np.deg2rad(5) r_source = cspice.radrec(1, source_ra, source_dec) # compute angular separation between two vectors source_ang_separation.append(np.rad2deg(cspice.vsep(r, r_source))) cartesian_juice = np.asarray(cartesian_juice) plt.plot(cartesian_juice[:, 0], cartesian_juice[:, 1], color='green') plt.xlabel('X [km]') plt.ylabel('Y [km]') plt.grid() plt.show() cartesian_juice_ecliptj2000 = np.asarray(cartesian_juice_ecliptj2000) plt.plot(cartesian_juice_ecliptj2000[:, 0], cartesian_juice_ecliptj2000[:, 1], color='green') plt.xlabel('X [km]') plt.ylabel('Y [km]') plt.grid() plt.show() radec_juice = np.asarray(radec_juice) plt.plot(radec_juice[:, 1], radec_juice[:, 2], color='green') plt.xlabel('RA [deg]') plt.ylabel('Dec [deg]') plt.grid() plt.show() plt.plot(times, source_ang_separation, color='green') plt.xlabel('Times [s]') plt.ylabel('JUICE to source angular separation [deg]') plt.grid() plt.show() return main(mk='/Users/aescalante/spice/missions/juice/juice/kernels/mk/juice_crema_5_0_local.tm', utc0='2026-01-01', utcf='2026-01-07', steps=10000, target='JUICE', observer='EARTH', frame='J2000')