;; ;; Load kernels ;; PRO ies_example ;; ;; Load kernels. ;; metakernel = "ies_example.furnsh" cspice_furnsh, metakernel ;; ;; Retrieve IES/Ion geometric parameters from the kernel pool. ;; ;; First, get the number of sectors in-plane (variable "iipnum") and ;; out-of-plane (variable "iopnum"). These numbers are provided in ;; the IK keyword INS-226521_NUMBER_OF_SECTORS. ;; cspice_gipool, "INS-226521_NUMBER_OF_SECTORS", 0, 2, tmpbuff, found if (found) then begin iipnum = tmpbuff[0] iopnum = tmpbuff[1] endif else begin print, "Failed to find INS-226521_NUMBER_OF_SECTORS in the kernel pool." cspice_unload, metakernel return endelse ;; ;; Then, fetch the IES/Ion sector view directions provided in the IK ;; keyword INS-226522_SECTOR_DIRECTION and format them as ;; [3,iipnum,iopnum] array (variable ivdir). ;; cspice_gdpool, "INS-226522_SECTOR_DIRECTIONS", 0, 3*iipnum*iopnum, $ tmpbuff, found if (found) then begin ivdir = reform( tmpbuff, 3, iipnum, iopnum ) endif else begin print, "Failed to find INS-226522_SECTOR_DIRECTIONS in the kernel pool." cspice_unload, metakernel return endelse ;; ;; Finally, fetch the name of the frame (variable iframe), in which ;; these directions are defined; this name is provided in the IK ;; keyword INS-226522_FRAME. ;; cspice_gcpool, "INS-226522_FRAME", 0, 1, 32, iframe, found if (found) then begin iframe = iframe[0] endif else begin print, "Failed to find INS-226522_FRAME in the kernel pool." cspice_unload, metakernel return endelse ;; ;; Verify that Rosetta s/c orientation is available in the loaded CK ;; files. For that, call ckgp with Rosetta s/c CK id -226000 and ;; reference frame J2000. The tolerance should be zero because ;; we need find out if there is attitude at this exact time so we ;; could call spkpos with this time as input later. ;; ;; The SCLK string below is from the first data line of the ;; RPCIES050305T0000_ION_2C0.TAB file. ;; sclkstr = '68601642' ;; ;; Convert SCLK string to encoded SCLK ticks and call ckgp. ;; cspice_scencd, -226, sclkstr, sclkdp cspice_ckgp, -226000, sclkdp, 0.0, "J2000", cmat, clkout, found if (found) then begin ;; ;; CK provides orientation for Rosetta s/c at the time of interest ;; meaning that we can proceed with calling high level SPICE ;; routines that may rely on it. ;; ;; Compute direction to the Sun as seen from Rosetta in the ;; instrument frame the name of which was obtained from the IK. ;; cspice_scs2e, -226, sclkstr, et cspice_spkpos, "SUN", et, iframe, "LT+S", "ROSETTA", sunpos, ltime ;; ;; Compute angular separation between each of the view vectors ;; and direction to the Sun and buffer them. ;; sunang = findgen(iipnum,iopnum) for j = 0, iopnum-1 do begin for i = 0, iipnum-1 do begin sunang[i,j] = cspice_vsep( sunpos, ivdir[*,i,j] ) * cspice_dpr() endfor endfor ;; ;; Find index of the sector with the smallest angular separation ;; and report it. ;; minsunang = min( sunang, minsunangidx ) minsunangidxs = array_indices( sunang, minsunangidx ) print, " " print, "Sector closest to the Sun direction:" print, " in-plane index:", minsunangidxs[0] print, " out-of-plane index:", minsunangidxs[1] print, " " print, "Angle between sector view direction and Sun direction:" print, " ", minsunang, " degrees" print, " " ;; ;; Plot a contour plot of the Sun angle with 10 degrees contour ;; lines filled with bright for zero angle to dark for 180 angle. ;; contour, sunang, $ /FILL, $ LEVELS = FINDGEN(18)*10, $ C_COLORS = FINDGEN(18)*(-10)+200, $ XTITLE = "in-plane index", $ YTITLE = "out-of-plane index" endif else begin print, "No s/c orientation is available at specified time." cspice_unload, metakernel return endelse ;; ;; Unload all loaded kernels to ensure lean start for the future ;; ICY-based run in this IDL session. ;; cspice_unload, metakernel END