Exemple #1
0
void findmins (SpiceDouble beg, SpiceDouble end) {

  SpiceInt i, count;

  // SPICEDOUBLE_CELLs are static, so must reinit them each time, sigh
  SPICEDOUBLE_CELL(result, 200);
  SPICEDOUBLE_CELL(cnfine,2);
  scard_c(0,&result);
  scard_c(0,&cnfine);

  // create interval
  wninsd_c(beg,end,&cnfine);

  // get results
  gfuds_c(gfq,gfdecrx,"LOCMIN",0.,0.,86400.,MAXWIN,&cnfine,&result);

  count = wncard_c(&result); 

  for (i=0; i<count; i++) {
    wnfetd_c(&result,i,&beg,&end);
    // becuase beg and end are equal, overwriting end with actual value
    gfq(beg,&end);
    printf("M %f %f %f\n",et2jd(beg),r2d(end),r2d(sunminangle(beg,planetcount,planets)));
  }
}
    void SpicePosition::getinterval(const std::vector<std::string> &kernels, BodyId body, EphemeridesInterval &interval) {
        SPICEDOUBLE_CELL        ( cover, 2000);

        bool first = true;

        for (std::vector<std::string>::const_iterator i = kernels.begin(); i != kernels.end(); i++) {
            scard_c(0, &cover);
            spkcov_c(i->c_str(), body, &cover);
            SpiceInt niv = wncard_c (&cover);

            for (SpiceInt j = 0; j < niv; j++) {
                SpiceDouble a, b;
                wnfetd_c(&cover, j, &a, &b);

                if (first) {
                    first = false;
                    interval.a = a;
                    interval.b = b;
                } else {
                    interval.a = std::min(interval.a, a);
                    interval.b = std::max(interval.b, b);
                }
            }
        }

        char timea[1000], timeb[1000];

        timout_c (interval.a, "YYYY ::TDB", sizeof(timea), timea);
        timout_c (interval.b, "YYYY ::TDB", sizeof(timeb), timeb);
    }
Exemple #3
0
int main (int argc, char **argv) {

  SPICEDOUBLE_CELL (result, 2*MAXWIN);
  SPICEDOUBLE_CELL (cnfine, 2);
  // various formats
  SpiceChar begstr[TIMLEN], classic[100], terse[100];
  SpiceDouble beg,end,*array;
  SpiceInt count,i,j,house;

  furnsh_c("/home/barrycarter/BCGIT/ASTRO/standard.tm");

  // 1 second tolerance (serious overkill, but 1e-6 is default, worse!)
  gfstol_c(1.);
  
  // 1 year window
  wninsd_c(year2et(atof(argv[1])), year2et(atof(argv[2])), &cnfine);

  // TODO: figure out how to compute sizeof(iplanets) properly, this is hack
  for (j=0; j<sizeof(iplanets)/4; j++) {

    gplanet = iplanets[j];

    gfuds_c (gfq, gfdecrx, "=", 0., 0., 86400., MAXWIN, &cnfine, &result);
    count = wncard_c(&result);
    
    for (i=0; i<count; i++) {

      // find the time of event (beg == end in this case)
      wnfetd_c (&result, i, &beg, &end);

      // find ecliptic longitude (and if its increasing/decreasing)
      array = geom_info(gplanet, beg, FRAME, 399);

      // pretty print the time
      timout_c (beg, TIMFMT, TIMLEN, begstr);

      house = rint(array[11]*dpr_c()/30);
      if (array[17] < 0) {house--;}
      house = (house+12)%12;

      // the classic form
      sprintf(classic, "%s %s ENTERS %s %s",  begstr,  
	      planet2str(gplanet, ""), houses[house], 
	      array[17]<0?"RETROGRADE":"PROGRADE");

      sprintf(terse, "%lld %s%s%s", (long long) floor(beg+0.5), 
	      planet2str(gplanet, "TERSE"), house2str(house, "TERSE"),
	      array[17]<0?"-":"+");

      printf("%s %s\n", classic, terse);
    }
  }
  return(0);
}
// Extract the temporal coverages for a given object in an SPK kernel
std::vector< std::vector<double> > spkcoverage(std::string kernel, int obj) {
    SPICEDOUBLE_CELL(cover,2000);
    scard_c(0,&cover);
    spkcov_c(kernel.c_str(),obj,&cover);
    int niv = wncard_c(&cover);
    std::vector< std::vector<double> > ret(niv,std::vector<double>(2,0.0));
    for(int j=0; j<niv; j++) {
        double b,e; wnfetd_c(&cover,j,&b,&e);
        ret[j][0] = b; ret[j][1] = e;
    }
    return ret;
}
Exemple #5
0
void show_results (char *prefix, SpiceCell result, 
		   void(* udfuns)(SpiceDouble et,SpiceDouble * value)) {

  SpiceInt i;
  SpiceInt nres = wncard_c(&result);
  SpiceDouble beg, end, vbeg, vend;

  for (i=0; i<nres; i++) {
    wnfetd_c(&result,i,&beg,&end);
    udfuns(beg,&vbeg);
    udfuns(end,&vend);
    printf("%s %f %f %f %f '%s'\n",prefix,et2jd(beg),et2jd(end),vbeg,vend,s);
  }
}
int main( int argc, char **argv ) {

  SpiceInt i,count,j;
  SPICEDOUBLE_CELL(result, 2*MAXWIN);
  SPICEDOUBLE_CELL(cnfine,2);
  char stime[255];
  SpiceDouble beg, end, ang;

  // fill the static planets array
  for (i=1; i<argc; i++) {planets[i] = atoi(argv[i]);}
  planetcount = argc-1;

  // 1 second tolerance (serious overkill, but 1e-6 is default, worse!)
  gfstol_c(1.);

  furnsh_c("/home/barrycarter/BCGIT/ASTRO/standard.tm");

  // DE431 limits
  wninsd_c (-479695089600.+86400*468, 479386728000., &cnfine);

  // 1970 to 2038 (all "Unix time") for testing
  //  wninsd_c(unix2et(0),unix2et(2147483647),&cnfine);

  gfuds_c(gfq,gfdecrx,"LOCMIN",0.,0.,86400.,MAXWIN,&cnfine,&result);
  count = wncard_c(&result); 

  for (i=0; i<count; i++) {
    // we don't use 'end' but need to pass it
    wnfetd_c(&result,i,&beg,&end);
    // find the angle at this time
    gfq(beg,&ang);
    // format time nicely
    timout_c(beg, "ERA YYYY##-MM-DD HR:MN:SC ::MCAL",255,stime);

    // print et and separation as degree
    printf("%f %f",beg,ang*dpr_c());
    // print out the planets involved (redundant, but useful)
    for (j=1; j<argc; j++) {printf(" %s",argv[j]);}
    printf(" %s\n",stime);



  }
  return 0;
}
Exemple #7
0
int main (int argc, char **argv) {

  SpiceInt i, nres;
  SPICEDOUBLE_CELL(cnfine,2);
  SPICEDOUBLE_CELL(result,2*MAXWIN);
  SpiceDouble beg,end;

  furnsh_c("/home/barrycarter/BCGIT/ASTRO/standard.tm");

  // this will represent the stars position
  planets[0] = -1;

  // convert ra and dec to starpos
  radrec_c(1,atof(argv[1]),atof(argv[2]),starpos);

  // planets array and count
  for (i=1; i<argc-2; i++) {planets[i] = atoi(argv[i+2]);}
  planetcount = argc-2;

  printf("CONJUNCTIONS FOR %f degrees, planets: %s %s %d %d %d %d %d %d\n",r2d(MAXSEP),argv[1],argv[2],(int)planets[1],(int)planets[2],(int)planets[3],(int)planets[4],(int)planets[5],(int)planets[6]);

  // TODO: this is for testing only
  // wninsd_c(unix2et(0),unix2et(2147483647),&cnfine);
  wninsd_c (-479695089600.+86400*468, 479386728000., &cnfine);

  // 1 second tolerance (serious overkill, but 1e-6 is default, worse!)
  gfstol_c(1.);

  // find under MAXSEP degrees...
  // TODO: The 90 days below is just for testing, not accurate!!!!
  gfuds_c(gfq,gfdecrx,"<",MAXSEP,0.,86400.*90,MAXWIN,&cnfine,&result);

  nres = wncard_c(&result);

  for (i=0; i<nres; i++) {
    wnfetd_c(&result,i,&beg,&end);
    // R = range, M = min
    printf("R %f %f\n",et2jd(beg),et2jd(end));
    findmins(beg,end);
  }

  //  printf("There are %d results\n",wncard_c(&result));

  return 0;
}
Exemple #8
0
std::vector<Interval> Window::GetIntervals() const
{
	SpiceCell cellCopy = cell;

	std::vector<Interval> intervals;

	long count = wncard_c(&cellCopy);
	for(long i = 0; i < count; i++)
	{
		double start, end;

		wnfetd_c(&cellCopy, i, &start, &end);

		intervals.push_back(Interval(start, end));
	}

	return intervals;
}
    spkezp_c(-125544,et,"EQEQDATE","CN+S",399,iss,&lt);
    spkezp_c(301,et,"EQEQDATE","CN+S",399,moon,&lt);
    //    printf("%f -> %f\n", et, vsep_c(iss,moon)*dpr_c());
    *value = vsep_c(iss,moon);
  }

  void gfdecrx (void(* udfuns)(SpiceDouble et,SpiceDouble * value),
                SpiceDouble et, SpiceBoolean * isdecr ) {
    uddc_c( udfuns, et, 10., isdecr );
  }

  // using two day window, but not accurate for those buffer times
  // wninsd_c(et_start+86400.*2, et_end-86400.*2, &cnfine);

  // test
  wninsd_c(et_start+86400.*2, et_start+86400.*4, &cnfine);

  gfuds_c(issmoon,gfdecrx,"LOCMIN",0,0,10.,500000,&cnfine,&result);

  int count = wncard_c( &result );

  for (int i=0; i<count; i++) {
    wnfetd_c (&result, i, &beg, &end);
    // below is completely hideous/improper use of end variable
    issmoon(beg, &end);
    spkezp_c(-125544,beg,"J2000","CN+S",399,iss,&lt);
    timout_c(beg, "YYYY-MM-DD HR:MN:SC ::MCAL",255,stime);
    printf("CLOSEST %s %f %f\n", stime, end*dpr_c(), vnorm_c(iss));
  }
}
Exemple #10
0
int main() {

#define TIMFMT "YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND"
#define MAXVAL 10000
#define STRSIZ 41
#define LNSIZE 81
#define MAXPAR 10

  SpiceBoolean bail;
  SpiceBoolean rpt;

  SpiceChar begstr [LNSIZE] = "2001 jan 01 00:00:00.000";
  SpiceChar endstr [LNSIZE] = "2001 dec 31 00:00:00.000";
  SpiceChar event [] = "DISTANCE";
  SpiceChar relate [] = "LOCMAX";

 
  SpiceChar qpnams[SPICE_GFEVNT_MAXPAR][LNSIZE]={"TARGET","OBSERVER","ABCORR"};
  SpiceChar qcpars[SPICE_GFEVNT_MAXPAR][LNSIZE] = {"MOON","EARTH","LT+S"};
  SpiceDouble qdpars[SPICE_GFEVNT_MAXPAR];
  SpiceInt qipars[SPICE_GFEVNT_MAXPAR];
  SpiceBoolean qlpars[SPICE_GFEVNT_MAXPAR];
 

  SPICEDOUBLE_CELL ( cnfine, MAXVAL );
  SPICEDOUBLE_CELL ( result, MAXVAL );

  SpiceDouble begtim,endtim,step,refval,adjust,tol,beg,end;
  SpiceInt lenvals,nintvls,count,qnpars,i;

 furnsh_c ( "standard.tm" );

 str2et_c ( begstr, &begtim );
 str2et_c ( endstr, &endtim );
 wninsd_c ( begtim, endtim, &cnfine );
 count = wncard_c( &cnfine );
 printf( "Found %ld intervals in cnfine\n", count );

 
 step = 0.001 * spd_c();
 gfsstp_c ( step );


 bail = SPICETRUE;
 rpt = SPICETRUE;
 
 lenvals= LNSIZE;
 qnpars = 3;
 tol = SPICE_GF_CNVTOL;
 refval = 0.;
 adjust = 0.;
 nintvls= MAXVAL;

 gfevnt_c ( gfstep_c, gfrefn_c, event, qnpars, lenvals, qpnams,
 qcpars, qdpars, qipars, qlpars, relate, refval, tol, adjust, rpt,
 &gfrepi_c, gfrepu_c, gfrepf_c, nintvls, bail, gfbail_c, &cnfine,
 &result );

 if ( gfbail_c() ) {
   
   gfclrh_c();
 
   printf ( "\nSearch was interrupted.\n\nThis message "
	    "was written after an interrupt signal\n"
	    "was trapped. By default, the program "
	    "would have terminated \nbefore this message "
	    "could be written.\n\n" );
 }
 else
   {
     count = wncard_c( &result);
     printf( "Found %ld intervals in result\n", count );
     
     for( i=0; i<count; i++ )
       {
	 wnfetd_c( &result, i, &beg, &end );
	 
	 timout_c ( beg, TIMFMT, LNSIZE, begstr );
	 timout_c ( end, TIMFMT, LNSIZE, endstr );
	 
	 printf( "Interval %ld\n", i );
	 printf( "Beginning TDB %s\n", begstr );
	 printf( "Ending TDB %s\n", endstr );
       }
   }
 return (0);
}
Exemple #11
0
int main( int argc, char **argv )
{

  SPICEDOUBLE_CELL(result,2*MAXWIN );
  SPICEDOUBLE_CELL(resultr,2*MAXWIN );

  // TODO: these windows can hold at most one interval????? 
  SPICEDOUBLE_CELL(cnfine,2);
  SPICEDOUBLE_CELL(cnfiner,2);
  SpiceInt i,j;

  // which ephermis's to use
  furnsh_c( "/home/barrycarter/BCGIT/ASTRO/standard.tm" );

  // TOL too small otherwise; this is one second
  gfstol_c(1.);

  // SPICE window for all DE431
  wninsd_c (-479695089600.+86400*468, 479386728000., &cnfine);

  // FOR TESTING PURPOSES ONLY!!!!
  // wninsd_c (-946684800., 2147483647.+946684800., &cnfine);
    
  // I send these as: observer b1 b2, thus the odd argv order below
  // 0.10471975511965977462 radians = 6 degrees

  gfsep_c(argv[2],"POINT","J2000",argv[3],"POINT","J2000","NONE",argv[1],
	  "<", 0.10471975511965977462,0,86400.,MAXWIN,&cnfine,&result);

  SpiceInt count = wncard_c(&result);
  SpiceDouble begtim, endtim, mintim1, mintim2;

  for (i=0; i<count; i++) {

    // find the ith result and print it
    wnfetd_c(&result,i,&begtim,&endtim);
    printf("%s %s %s 6deg %f %f\n",argv[1],argv[2],argv[3],et2jd(begtim),et2jd(endtim));

    // find min separation in this interval
    
    // TODO: this is hideous coding (append/remove, must be a better way)
    appndd_c(begtim,&cnfiner);
    appndd_c(endtim,&cnfiner);
    wnvald_c(2,2,&cnfiner);
  
    // TODO: use of ABSMIN missed conjunctions, changed to LOCMIN
    gfsep_c(argv[2],"POINT","J2000",argv[3],"POINT","J2000","NONE",argv[1], "LOCMIN", 0,0,86400.,MAXWIN,&cnfiner,&resultr);

    SpiceInt count2 = wncard_c(&resultr);

    for (j=0; j<count2; j++) {
      wnfetd_c(&resultr,j,&mintim1,&mintim2);
      // mintim1 and mintim2 should be identical, printing them both anyway
      printf("%s %s %s min %f %f\n",argv[1],argv[2],argv[3],et2jd(mintim1),et2jd(mintim2));
    }

    removd_c(endtim,&cnfiner);
    removd_c(begtim,&cnfiner);

  }
}
Exemple #12
0
//------------------------------------------------------------------------------
void  SpiceAttitudeKernelReader::GetCoverageStartAndEnd(StringArray       &kernels,
                                                        Integer           forNaifId,
                                                        Real              &start,
                                                        Real              &end,
                                                        bool              needAngVel)
{
   // first check to see if a kernel specified is not loaded; if not,
   // try to load it
   for (unsigned int ii = 0; ii < kernels.size(); ii++)
      if (!IsLoaded(kernels.at(ii)))   LoadKernel(kernels.at(ii));

   SpiceInt         idSpice     = forNaifId;
   SpiceInt         arclen      = 4;
   SpiceInt         typlen      = 5;
   bool             firstInt    = true;
   bool             idOnKernel  = false;
   char             kStr[5]     = "    ";
   char             aStr[4]     = "   ";
   char             levelStr[8] = "SEGMENT";
   char             timeStr[4]  = "TDB";
   SpiceBoolean     needAv      = needAngVel;
   ConstSpiceChar   *kernelName = NULL;
   ConstSpiceChar   *level      = levelStr;
   ConstSpiceChar   *timeSys    = timeStr;
   SpiceDouble      tol         = 0.0;
   SpiceInt         objId       = 0;
   SpiceInt         numInt      = 0;
   SpiceChar        *kernelType;
   SpiceChar        *arch;
   SpiceDouble      b;
   SpiceDouble      e;
   Real             bA1;
   Real             eA1;
   SPICEINT_CELL(ids, 200);
   SPICEDOUBLE_CELL(cover, 200000);

   // look through each kernel
   for (unsigned int ii = 0; ii < kernels.size(); ii++)
   {
      #ifdef DEBUG_CK_COVERAGE
         MessageInterface::ShowMessage(wxT("Checking coverage for ID %d on kernel %s\n"),
               forNaifId, (kernels.at(ii)).c_str());
      #endif
      kernelName = kernels[ii].char_str();
      // check the type of kernel
      arch        = aStr;
      kernelType  = kStr;
      getfat_c(kernelName, arclen, typlen, arch, kernelType);
      if (failed_c())
      {
         ConstSpiceChar option[] = "LONG";
         SpiceInt       numChar  = MAX_LONG_MESSAGE_VALUE;
         SpiceChar      err[MAX_LONG_MESSAGE_VALUE];
         getmsg_c(option, numChar, err);
         wxString errStr(wxString::FromAscii( err));
         wxString errmsg = wxT("Error determining type of kernel \"");
         errmsg += kernels.at(ii) + wxT("\".  Message received from CSPICE is: ");
         errmsg += errStr + wxT("\n");
         reset_c();
         throw UtilityException(errmsg);
      }
      #ifdef DEBUG_CK_COVERAGE
         MessageInterface::ShowMessage(wxT("Kernel is of type %s\n"),
               kernelType);
      #endif
      // only deal with CK kernels
      if (eqstr_c(kernelType, "ck") || eqstr_c(kernelType, "CK"))
      {
         ckobj_c(kernelName, &ids);
         // get the list of objects (IDs) for which data exists in the CK kernel
         for (SpiceInt jj = 0;  jj < card_c(&ids);  jj++)
         {
            objId = SPICE_CELL_ELEM_I(&ids,jj);
            #ifdef DEBUG_CK_COVERAGE
               MessageInterface::ShowMessage(wxT("Kernel contains data for object %d\n"),
                     (Integer) objId);
            #endif
            // look to see if this kernel contains data for the object we're interested in
            if (objId == idSpice)
            {
               idOnKernel = true;
               break;
            }
//            if (objId == (idSpice * 1000))
//            {
//               idSpice     = idSpice * 1000;
//               naifIDSPICE = idSpice; // not the way to do this - should pass it back
//               idOnKernel  = true;
//               break;
//            }
         }
         // only deal with kernels containing data for the object we're interested in
         if (idOnKernel)
         {
            #ifdef DEBUG_CK_COVERAGE
               MessageInterface::ShowMessage(wxT("Checking kernel %s for data for object %d\n"),
                     (kernels.at(ii)).c_str(), (Integer) objId);
            #endif
            scard_c(0, &cover);   // reset the coverage cell
            ckcov_c (kernelName, idSpice, needAv, level, tol, timeSys, &cover);
            if (failed_c())
            {
               ConstSpiceChar option[] = "LONG";
               SpiceInt       numChar  = MAX_LONG_MESSAGE_VALUE;
               SpiceChar      err[MAX_LONG_MESSAGE_VALUE];
               getmsg_c(option, numChar, err);
               wxString errStr(wxString::FromAscii(err));
               wxString errmsg = wxT("Error determining coverage for CK kernel \"");
               errmsg += kernels.at(ii) + wxT("\".  Message received from CSPICE is: ");
               errmsg += errStr + wxT("\n");
               reset_c();
               throw UtilityException(errmsg);
            }
            numInt = wncard_c(&cover);
            #ifdef DEBUG_CK_COVERAGE
               MessageInterface::ShowMessage(wxT("Number of intervals found =  %d\n"),
                     (Integer) numInt);
            #endif
            if ((firstInt) && (numInt > 0))
            {
               wnfetd_c(&cover, 0, &b, &e);
               if (failed_c())
               {
                  ConstSpiceChar option[] = "LONG";
                  SpiceInt       numChar  = MAX_LONG_MESSAGE_VALUE;
                  SpiceChar      err[MAX_LONG_MESSAGE_VALUE];
                  getmsg_c(option, numChar, err);
                  wxString errStr(wxString::FromAscii(err));
                  wxString errmsg = wxT("Error getting interval times for CK kernel \"");
                  errmsg += kernels.at(ii) + wxT("\".  Message received from CSPICE is: ");
                  errmsg += errStr + wxT("\n");
                  reset_c();
                  throw UtilityException(errmsg);
               }
               start    = SpiceTimeToA1(b);
               end      = SpiceTimeToA1(e);
               firstInt = false;
            }
            for (SpiceInt jj = 0; jj < numInt; jj++)
            {
               wnfetd_c(&cover, jj, &b, &e);
               bA1 = SpiceTimeToA1(b);
               eA1 = SpiceTimeToA1(e);
               if (bA1 < start)  start = bA1;
               if (eA1 > end)    end   = eA1;
            }
         }

      }
   }
   if (firstInt)
   {
      char           itsName[256];
      SpiceChar      *itsNameSPICE = itsName;
      SpiceBoolean   found2;
      bodc2n_c(naifIDSPICE, 256, itsNameSPICE, &found2);
      if (found2 == SPICEFALSE)
      {
         wxString errmsg = wxT("Error - unable to find name for body in SPICE kernel pool");
         throw UtilityException(errmsg);
      }
      else
      {
         wxString nameStr = wxString::FromAscii(itsNameSPICE);
         wxString errmsg = wxT("Error - no data available for body ");
         errmsg += nameStr + wxT(" on specified CK kernels");
         throw UtilityException(errmsg);
      }
   }
}
Exemple #13
0
//------------------------------------------------------------------------------
void  SpiceOrbitKernelReader::GetCoverageStartAndEnd(StringArray       &kernels,
                                                     Integer           forNaifId,
                                                     Real              &start,
                                                     Real              &end)
{
   // first check to see if a kernel specified is not loaded; if not,
   // try to load it
   for (unsigned int ii = 0; ii < kernels.size(); ii++)
      if (!IsLoaded(kernels.at(ii)))   LoadKernel(kernels.at(ii));

   SpiceInt         idSpice     = forNaifId;
   SpiceInt         arclen      = 4;
   SpiceInt         typlen      = 5;
   bool             firstInt    = true;
   bool             idOnKernel  = false;
   ConstSpiceChar   *kernelName = NULL;
   SpiceInt         objId       = 0;
   SpiceInt         numInt      = 0;
   SpiceChar        *kernelType;
   SpiceChar        *arch;
   SpiceDouble      b;
   SpiceDouble      e;
   Real             bA1;
   Real             eA1;
   SPICEINT_CELL(ids, 200);
   SPICEDOUBLE_CELL(cover, 200000);
   char             kStr[5] = "    ";
   char             aStr[4] = "   ";

   // look through each kernel
   for (unsigned int ii = 0; ii < kernels.size(); ii++)
   {
      #ifdef DEBUG_SPK_COVERAGE
         MessageInterface::ShowMessage(wxT("Checking coverage for ID %d on kernel %s\n"),
               forNaifId, (kernels.at(ii)).c_str());
      #endif
      kernelName = kernels[ii].char_str();
      // check the type of kernel
      arch        = aStr;
      kernelType  = kStr;
      getfat_c(kernelName, arclen, typlen, arch, kernelType);
      if (failed_c())
      {
         ConstSpiceChar option[] = "LONG";
         SpiceInt       numChar  = MAX_LONG_MESSAGE_VALUE;
         //SpiceChar      err[MAX_LONG_MESSAGE_VALUE];
         SpiceChar      *err = new SpiceChar[MAX_LONG_MESSAGE_VALUE];
         getmsg_c(option, numChar, err);
         wxString errStr(wxString::FromAscii(err));
         wxString errmsg = wxT("Error determining type of kernel \"");
         errmsg += kernels.at(ii) + wxT("\".  Message received from CSPICE is: ");
         errmsg += errStr + wxT("\n");
         reset_c();
         delete [] err;
         throw UtilityException(errmsg);
      }
      #ifdef DEBUG_SPK_COVERAGE
         MessageInterface::ShowMessage(wxT("Kernel is of type %s\n"),
               kernelType);
      #endif
      // only deal with SPK kernels
      if (eqstr_c( kernelType, "spk" ))
      {
         spkobj_c(kernelName, &ids);
         // get the list of objects (IDs) for which data exists in the SPK kernel
         for (SpiceInt jj = 0;  jj < card_c(&ids);  jj++)
         {
            objId = SPICE_CELL_ELEM_I(&ids,jj);
            #ifdef DEBUG_SPK_COVERAGE
               MessageInterface::ShowMessage(wxT("Kernel contains data for object %d\n"),
                     (Integer) objId);
            #endif
            // look to see if this kernel contains data for the object we're interested in
            if (objId == idSpice)
            {
               idOnKernel = true;
               break;
            }
         }
         // only deal with kernels containing data for the object we're interested in
         if (idOnKernel)
         {
            #ifdef DEBUG_SPK_COVERAGE
               MessageInterface::ShowMessage(wxT("Checking kernel %s for data for object %d\n"),
                     (kernels.at(ii)).c_str(), (Integer) objId);
            #endif
            scard_c(0, &cover);   // reset the coverage cell
            spkcov_c (kernelName, idSpice, &cover);
            if (failed_c())
            {
               ConstSpiceChar option[] = "LONG";
               SpiceInt       numChar  = MAX_LONG_MESSAGE_VALUE;
               //SpiceChar      err[MAX_LONG_MESSAGE_VALUE];
               SpiceChar      *err = new SpiceChar[MAX_LONG_MESSAGE_VALUE];
               getmsg_c(option, numChar, err);
               wxString errStr(wxString::FromAscii(err));
               wxString errmsg = wxT("Error determining coverage for SPK kernel \"");
               errmsg += kernels.at(ii) + wxT("\".  Message received from CSPICE is: ");
               errmsg += errStr + wxT("\n");
               reset_c();
               delete [] err;
               throw UtilityException(errmsg);
            }
            numInt = wncard_c(&cover);
            #ifdef DEBUG_SPK_COVERAGE
               MessageInterface::ShowMessage(wxT("Number of intervals found =  %d\n"),
                     (Integer) numInt);
            #endif
            if ((firstInt) && (numInt > 0))
            {
               wnfetd_c(&cover, 0, &b, &e);
               if (failed_c())
               {
                  ConstSpiceChar option[] = "LONG";
                  SpiceInt       numChar  = MAX_LONG_MESSAGE_VALUE;
                  //SpiceChar      err[MAX_LONG_MESSAGE_VALUE];
                  SpiceChar      *err = new SpiceChar[MAX_LONG_MESSAGE_VALUE];
                  getmsg_c(option, numChar, err);
                  wxString errStr(wxString::FromAscii(err));
                  wxString errmsg = wxT("Error getting interval times for SPK kernel \"");
                  errmsg += kernels.at(ii) + wxT("\".  Message received from CSPICE is: ");
                  errmsg += errStr + wxT("\n");
                  reset_c();
                  delete [] err;
                  throw UtilityException(errmsg);
               }
               start    = SpiceTimeToA1(b);
               end      = SpiceTimeToA1(e);
               firstInt = false;
            }
            for (SpiceInt jj = 0; jj < numInt; jj++)
            {
               wnfetd_c(&cover, jj, &b, &e);
               bA1 = SpiceTimeToA1(b);
               eA1 = SpiceTimeToA1(e);
               if (bA1 < start)  start = bA1;
               if (eA1 > end)    end   = eA1;
            }
         }

      }
   }
   if (firstInt)
   {
      wxString errmsg(wxT(""));
      errmsg << wxT("Error - no data available for body with NAIF ID ") << forNaifId << wxT(" on specified SPK kernels\n");
      throw UtilityException(errmsg);
   }
}