pro nis_c_spice,spectra,spice, sourcedir, verbose ; SUB-PROGRAM of nis_proc ; ; ABSTRACT ; Takes the NIS spectra MET data and uses the best available spice kernel to get ; appropriate spacecraft and target parameters. ; ; INPUTS ; spectra - sequence of spectra from nis_c_dark ; sourcedir - source directory for NISCAL programs and data ; verbose - Toggle description of events std output. ; ; OUTPUTS ; spice - extracted spice data ; ; USES ; spice.so - c routine written by Wen-Jong Shyong at APL for extracting ; spice information. Contains subroutine spice queries for ; tie conversion, position info, and attitude data. ; kernel - list of kernels referenced. Can be added to or changed. ; ; HISTORY ; Created 11/24/97 by N. R. Izenberg ; Modified 12/30/95 (NRI) V1.1 directory structure ; 1/19/98 (NRI) V1.2 directory structure ; NOTES ; From NIS sequence data: ; column 3 = Spectra MET high word (A) ; column 4 = Spectra MET low word (B) ; REAL MET = A*2^16+b ; column 15 = shutter in/out (0 = in) ; columns 46-77 = 32 Ge detectors ; columns 78-109 = 32 InGas detectors ; sun position should always be 0,0,0 and velocity 0,0,0 ;------------------------------------------------------------------------------ ; Main sz=size(spectra) num=fix(sz(2)) cal_dir=sourcedir ;Steps ;1 Load Kernels ;2 Convert MET for Each spectrum into ET ;3 Get Ephemeris ;4 Get Attitude ;5 Derive needed values (distances, angles) ;6 put all in a nice array and return. ;1 Load Kernels ;----------------------------------------------------- s=call_external(cal_dir+'spice.so', 'ispiceinit', cal_dir+'kernels'); near = -93L ; neari = -93000L ; moon = 301L ; earth = 399L ; sun = 10L ; eros = 2000433L ; mathilde = 2000253L ; ;2 Convert MET for Each spectrum into ET ;--------------------------------------- hinum=double(spectra(2,*)) lonum=double(spectra(3,*)) MET=reform(hinum*(2.^16)+lonum) ET = make_array(1,num,/double) s=call_external(cal_dir+'spice.so','inmetet',near,met,num,et) ;3 Get Ephemeris for all targets ;------------------------------- st_near=dblarr(6,num) st_moon=dblarr(6,num) st_earth=dblarr(6,num) st_sun=dblarr(6,num) st_eros=dblarr(6,num) s = call_external(cal_dir+'spice.so', 'inposvel', near, et, num, st_near) s = call_external(cal_dir+'spice.so', 'inposvel', moon, et, num, st_moon) s = call_external(cal_dir+'spice.so', 'inposvel', earth, et, num, st_earth) s = call_external(cal_dir+'spice.so', 'inposvel', sun, et, num, st_sun) s = call_external(cal_dir+'spice.so', 'inposvel', eros, et, num, st_eros) ;4 Get Attitude of NEAR ;---------------------- quats=dblarr(4,num) avs=dblarr(3,num) tol=1.0D0 s = call_external(cal_dir+'spice.so', 'inmetquat', neari, met, num, tol, quats, avs) ;5 Derive needed values (distances, angles) ;------------------------------------------ ;Distances - Angles - ; Sun-Earth NEAR-Off sun pointing ; Sun-Moon Incidence angle ; Sun-Eros Emission angle ; Sun-NEAR Phase angle ; NEAR-Moon ; NEAR-Earth ; NEAR-Eros sun_home=sqrt(st_earth(0,*)^2 + st_earth(1,*)^2 + st_earth(2,*)^2) sun_moon=sqrt(st_moon(0,*)^2 + st_moon(1,*)^2 + st_moon(2,*)^2) sun_eros=sqrt(st_eros(0,*)^2 + st_eros(1,*)^2 + st_eros(2,*)^2) sun_near=sqrt(st_near(0,*)^2 + st_near(1,*)^2 + st_near(2,*)^2) near_home=sqrt( (st_near(0,*)-st_earth(0,*))^2 + $ (st_near(1,*)-st_earth(1,*))^2 + $ (st_near(2,*)-st_earth(2,*))^2 ) near_moon=sqrt( (st_near(0,*)-st_moon(0,*))^2 + $ (st_near(1,*)-st_moon(1,*))^2 + $ (st_near(2,*)-st_moon(2,*))^2 ) near_eros=sqrt( (st_near(0,*)-st_eros(0,*))^2 + $ (st_near(1,*)-st_eros(1,*))^2 + $ (st_near(2,*)-st_eros(2,*))^2 ) off_sun=fltarr(num) ; Placeholder for further development. inc=fltarr(num) ; None of these data are needed by the current versions emi=fltarr(num) ; of niscal phz=fltarr(num) ;6 put all in a nice array and return. ;------------------------------------- spice =dblarr(11,num) spice(0,*)=sun_home spice(1,*)=sun_moon spice(2,*)=sun_eros spice(3,*)=sun_near spice(4,*)=near_home spice(5,*)=near_moon spice(6,*)=near_eros spice(7,*)=off_sun spice(8,*)=inc spice(9,*)=emi spice(10,*)=phz if verbose eq 1 then print,' STEP 4: SPICE data retrieved' return end