
PDL::NAIF -- a PDL interface to JPL's NAIF toolkit

This package implements an interface to JPL's NAIF toolkit. The NAIF toolkit is a collection of routines extensively used to plan for and analyze data from NASA missions. (More information about the NAIF toolkit is available at http://pds.jpl.nasa.gov/naif.html and the software itself at ftp://naif.jpl.nasa.gov/pub/naif/toolkit.) Information is provided to the NAIF routines via a series of "kernels" of various types. (Various kernels are also available at the ftp site.) These contain information such as the positions and velocities of various bodies, including spacecraft, planets and their satellites, the orientation of spacecraft at various times during their missions, etc. Toolkit routines are used to query the kernels for various quantities of interest.
The NAIF toolkit now comes in both ANSI C and FORTRAN 77, so it's feasible to construct a Perl interface using the C version. I had originally intended to create a NAIF module similar to the PGPLOT module, usable using standard Perl lists and scalars. However, too many NAIF routines use multidimensional arrays, and I don't know enough about XS to write the interface routines to create a multidimensional Perl array from a C array and vice versa. When installing PDL on my new Powerbook G4, I realized that PDL knows how to handle "real" arrays (i.e. arrays as continuous blocks of data of the same C type), because that's what it was designed for. I started looking through the docs, discovered PDL::PP, and quickly had a working interface.
This is very preliminary. I haven't yet implemented all the NAIF toolkit routines. So far I've combed through my own programs and have implemented every NAIF routine I've used in my own code, including some things that don't really need to be done considering that PDL is also available (mxv, for example, can just as easily be done in PDL). There are some quirks. Many NAIF routines use character strings as switches, so PDL::Char must be used to construct these strings. PDL::Char seems to store strings with single quotes on each side of the content. This doesn't seem to cause problems on input, but output routines expecting particular strings will have to both deal with the single quotes and the whitespace that the f2c string routines put inside the single quotes. (NAIF uses f2c extensively.) Some routines expect fixed size arrays to be fed to them, so naturally these have to be predeclared in PDL:
$et = <some time>;
$frame = PDL::Char->new("CASSINI_XBAND");
$reference_frame = PDL::Char->new("J2000");
$xform = zeroes(6,6);
PDL::NAIF::sxform($frame,$reference_frame,$et,$xform);
Individual functions aren't documented here. For details on usage of specific subroutines, consult the documentation that comes with the NAIF toolkit. Differences between the routines here (mostly passing sizes, since PDL objects know their own sizes and so we can obtain them directly from the object rather than passing them) are documented in the short notes above for each routine.

Paul J. Schinder
NASA Goddard Space Flight Center, Code 693
schinder@leprss.gsfc.nasa.gov
This code is licensed under the same terms as Perl itself.