pro naifinit, forcedef = forcedef, rw=rw, ro=ro, kernelFile=kernelFile ;+ ; NAME: ; naifinit ; PURPOSE: (one line) ; prepare tnaif library and collect some constants into a system variable ; DESCRIPTION: ; see /usr/local/icy/doc/html/req/icy.html for ICY info ; ; CATEGORY: ; Astronomy ; CALLING SEQUENCE: ; naifinit ; INPUTS: ; none ; OPTIONAL INPUT PARAMETERS: ; forcedef - define !naif even if it is defined ; rw - allow !naif to be read-write ; kernelFile - the kernels to load. This can take two different ; forms, either a single string which is the ; full path name of one kernel file (tls or bsp for ; example), or a metakernel file with the ; names of the kernels to load. If this optional ; argument is not defined, the file ; "kernels.tm" is used. This file is located ; in the same directory as naifinit.pro. ; ; Note: under OSX, the cpsice_furnsh function expects the master ; kernel file to have lines delimited ; by line feeds instead of carriage returns. ; ; KEYWORD INPUT PARAMETERS: ; none ; KEYWORD OUTPUT PARAMETERS: ; none ; OUTPUTS: ; None. ; COMMON BLOCKS: ; None. ; SIDE EFFECTS: ; Defines the system variable !eph using defsysv ; RESTRICTIONS: ; PROCEDURE: ; MODIFICATION HISTORY: ; Written 2004 May, by Leslie Young, SwRI ; Modified 2004 Dec 7, by Cathy Olkin, SwRI ; 1. Moved "help, 'icy',/dlm" to be after package is ; loaded to remove error message. ; 2. Added a kernel file ; 3. Call cspice_furnsh on the kernel file ; 4. Made a standard kernels.tm file and added an ; optional argument to override the ; standard kernel file. ; To do: 1. Add to !naif the string passed to cspice_furnsh ; 2005 Mar 3 Leslie Young. Moved to $idl/layoung/naif ; Changed call to getdir to call to findpro, ; Added more error checking ; 2005 Apr 26 Leslie Young. Added readonly to structure ; 2005 Nov 16.Default to read-write; default TextMetakernel -> kernels.tm ;- on_error, 2 debug = 0 ; Don't add it if it already exists. DEFSYSV, '!naif', EXISTS = i IF i EQ 1 and not keyword_set(forcedef) THEN return ; check that icy.dlm is loadable findpro, 'cspice_tkvrsn', dirlist=dirlist, /noprint if dirlist[0] ne 'INTRINSIC' then begin message, 'cspice_tkvrsn not defined. '+string(10B)+$ 'Check the location of icy.dlm' end version= cspice_tkvrsn( 'TOOLKIT' ) if debug then print, version help, 'icy',/dlm IF not keyword_set(kernelFile) THEN BEGIN ; print, "dir for kernel file = ", kernelDir ; kernelFile=kernelDir+dirsep+'kernels.txt' findpro, 'naifinit', dirlist=dirlist, /noprint if dirlist[0] eq '' then begin kernelFile = 'kernels.tm' endif else begin kernelFile = filepath('kernels.tm',root=dirlist[0]) endelse ENDIF if not isfile(kernelFile) then begin message, 'kernel file '+kernelFile + ' not found' end cspice_furnsh, kernelFile IF debug THEN BEGIN ; Count the number of loaded kernel files. cspice_ktotal, 'ALL', count print, 'The number of loaded kernel files = ', count ; Loop over the count, outputting file information as we loop. ; The loop tells us all files loaded via cspice_furnsh, their ; type, and how they were loaded. for i = 0, (count-1) do begin cspice_kdata, i, 'ALL', file, type, source, handle, found if ( found ) then begin print, 'Index : ' + string(i) print, 'File : ' + file print, 'Type : ' + type print, 'Source: ' + source print endif else begin print, 'No kernel found with index: ' + string(i) endelse endfor endif readonly = 0 ; default is read-write if (keyword_set(rw)) and (keyword_set(ro)) then begin message, 'Set only one of rw and ro' end if keyword_set(rw) then readonly=0 if keyword_set(ro) then readonly=1 defsysv, '!naif', $ { $ kernelFile : kernelFile, $ version : version, $ readonly : readonly $ }, readonly message, $ 'NAIF variable (!naif) has been added', /inf ;print, "target # -98 is New Horizons" end