Пример #1
0
//FUNCTION : getBoundaries
int getBoundaries(char *et_0_str, SpiceDouble *et_0, char *et_end_str, SpiceDouble *et_end)
{
	SpiceInt n;

	str2et_c(et_0_str, et_0);
	str2et_c(et_end_str, et_end);
	n = (int)((*et_end-*et_0)/STEP);

	return n;
}
Пример #2
0
/*
  Function: Calculate the time at a given date.

  Parameters:

     date: Date for conversion
     outsys: Time system where it should be returned.

  Returns:

     t: Time in output system.
 */
int whatTimeIsIt(SpiceChar* date,double *t,SpiceChar* outsys="ET")
{
  SpiceDouble et;
  str2et_c(date,&et);
  *t=unitim_c(et,"ET",outsys);
  return 0;
}
Пример #3
0
static VALUE str2et(VALUE self, VALUE epoch) {
  double ephemeris_time;

  str2et_c(StringValuePtr(epoch), &ephemeris_time);
  
  if(spice_error(SPICE_ERROR_SHORT)) return Qnil;
  
  return DBL2NUM(ephemeris_time);
}
Пример #4
0
  /**
   * Changes the value of the iTime object.
   *
   * @param time A time string formatted in standard UTC or similar format.
   *             Example:"2000/12/31 23:59:01.6789" or "2000-12-31T23:59:01.6789"
   */
  void iTime::operator=(const QString &time) {
    LoadLeapSecondKernel();

    // Convert the time string to a double ephemeris time
    SpiceDouble et;
    str2et_c(time.toAscii().data(), &et);

    p_et = et;

    UnloadLeapSecondKernel();
  }
Пример #5
0
//FUNCTION : time2DDtime
int time2DDtime(double et_time, dd_time_t *DDtime)
{
	char *date_unix_zero = "1970-01-01T00:00:00";
	SpiceDouble et_unix_zero;

	str2et_c(date_unix_zero, &et_unix_zero);

	strcpy(*DDtime, Double2DD_Time(et_time-et_unix_zero));
	
	return 0;
} 
Пример #6
0
  // Overload of "=" with a c string
  void iTime::operator=(const char *time) {

    LoadLeapSecondKernel();

    // Convert the time string to a double ephemeris time
    SpiceDouble et;
    str2et_c(time, &et);

    p_et = et;

    UnloadLeapSecondKernel();
  }
Пример #7
0
 /** 
  * Constructs a iTime object and initializes it to the time from the argument.
  * 
  * @param time A time string formatted in standard UTC or similar format. 
  *             Example:"2000/12/31 23:59:01.6789" or "2000-12-31T23:59:01.6789"
  */
  iTime::iTime (const std::string &time) {
    LoadLeapSecondKernel ();
  
    // Convert the time string to a double ephemeris time
    SpiceDouble et;
    str2et_c (time.c_str(), &et);
  
    p_et = et;
    p_original = time;
  
    Extract ();
    UnloadLeapSecondKernel ();
  }
Пример #8
0
int main (int argc, char **argv) {

  SPICEDOUBLE_CELL(cnfine,2);
  SPICEDOUBLE_CELL(result,500000);
  SpiceDouble beg, end, et_start, et_end;
  char ftime[255];

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

  // and the limits of DE431
  str2et_c("13201 B.C. MAY 07 00:00:41.184", &et_start);
  str2et_c("17091 MAY 07 00:00:41.184", &et_end);

  // because I'm using large time intervals...
  gfstol_c(10.);

  // sun's x or y position (v[1] = y pos = 0 on equinox)
  void solarzed (SpiceDouble et, SpiceDouble *value) {
    SpiceDouble v[3], lt;

    spkezp_c(10,et,"EQEQDATE","CN+S",399,v,&lt);
    *value = v[0];
  }
Пример #9
0
//FUNCTION : getFilesName
int getFilesName(const char *bodyName, char startTime[], char ext[], char filename[])
{
	SpiceDouble et;
	dd_time_t time_struct;

	str2et_c(startTime, &et);
	time2DDtime(et, &time_struct);

	strcpy(filename, bodyName);
	strcat(filename, "_");
	strcat(filename, time_struct);
	strcat(filename, ext);

	return 0;
}
Пример #10
0
  HiresCamera::HiresCamera (Pvl &lab) : FramingCamera(lab) {

    // Get the camera characteristics
    iString filter = (string)(lab.FindGroup("BandBin", Pvl::Traverse))["FilterName"];
    filter = filter.UpCase();

    SetFocalLength ();
    SetPixelPitch ();

    // Get the start time in et
    PvlGroup inst = lab.FindGroup ("Instrument",Pvl::Traverse);
    string stime = inst["StartTime"];

    double time; 
    str2et_c(stime.c_str(),&time);



    // Do not correct time for center of the exposure duration. This is because
    // the kernels were built to accept the start times of the images. 
    // time += ((double)inst["ExposureDuration"] / 1000.0) / 2.0; // Add half
    // exposure duration in milliseconds

    // Setup detector map
    new CameraDetectorMap(this);

    // Setup focal plane map
    CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this,NaifIkCode());

    focalMap->SetDetectorOrigin (
                   Spice::GetDouble("INS" + (iString)(int)NaifIkCode() +
                                    "_BORESIGHT_SAMPLE"), 
                   Spice::GetDouble("INS" + (iString)(int)NaifIkCode() +
                                    "_BORESIGHT_LINE"));

    // Setup distortion map 
    new CameraDistortionMap(this);

    // Setup the ground and sky map
    new CameraGroundMap(this);
    new CameraSkyMap(this);

    SetEphemerisTime(time);
    LoadCache();
  }
Пример #11
0
  IssWACamera::IssWACamera (Pvl &lab) : FramingCamera(lab) {
    PvlGroup bandBin = lab.FindGroup ("BandBin",Pvl::Traverse);
    // Get the camera characteristics
    iString key = string("INS"+(iString)(int)NaifIkCode()+"_")+ (string)bandBin["FilterName"] + "_FOCAL_LENGTH";
    key = key.Convert("/",'_');
    double focalLength = Spice::GetDouble(key);
    
    SetFocalLength (focalLength);
    SetPixelPitch ();
    InstrumentRotation()->SetFrame(Spice::GetInteger("INS_"+(iString)(int)NaifIkCode()+"_FRAME_ID"));


    // Get the start time in et
    PvlGroup inst = lab.FindGroup ("Instrument",Pvl::Traverse);
    string stime = inst["StartTime"];
    double et; 
    str2et_c(stime.c_str(),&et);
    double exposureDuration = (double)inst["ExposureDuration"] /1000.0;
    et += exposureDuration / 2.0;

    // Setup detector map
    int summingMode = inst["SummingMode"];
    CameraDetectorMap *detectorMap = new CameraDetectorMap(this);
    detectorMap->SetDetectorLineSumming(summingMode);
    detectorMap->SetDetectorSampleSumming(summingMode);

    // Setup focal plane map
    CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this,NaifIkCode());

    focalMap->SetDetectorOrigin (Spice::GetDouble("INS" + (iString)(int)NaifIkCode() + "_BORESIGHT_SAMPLE"), 
                                 Spice::GetDouble("INS" + (iString)(int)NaifIkCode() + "_BORESIGHT_LINE"));

    // Setup distortion map
    double k1 = Spice::GetDouble("INS" + (iString)(int)NaifIkCode() + "_K1");
    new RadialDistortionMap(this, k1);

    // Setup the ground and sky map
    new CameraGroundMap(this);
    new CameraSkyMap(this);
  
    SetEphemerisTime(et);
    LoadCache();
  }
Пример #12
0
int main() {

  SpiceDouble et, lt, pos[6];

  furnsh_c("/home/barrycarter/BCGIT/ASTRO/000157.html");
  furnsh_c("/home/barrycarter/BCGIT/ASTRO/eqeqdate.tf");
  furnsh_c("/home/barrycarter/SPICE/KERNELS/de431_part-1.bsp");
  furnsh_c("/home/barrycarter/SPICE/KERNELS/naif0011.tls");
  str2et_c("BC 9998-06-06 00:00:00", &et);

  //  spkgeo_c(10, et, "ECLIPDATE", 399, pos, &lt);
  //  spkezp_c(10, et, "ECLIPDATE", "NONE", 399, pos, &lt);
  //  spkezp_c(10, et, "EQEQDATE", "NONE", 399, pos, &lt);
  spkgeo_c(10, et, "EQEQDATE", "NONE", 399, pos, &lt);

  printf("ET: %f, POS: %f %f %f\n", et, pos[0], pos[1], pos[2]);

  return 0;
}
Пример #13
0
    // constructors
    LoHighCamera::LoHighCamera (Pvl &lab) : FramingCamera(lab) {
      // Get the Instrument label information needed to define the camera for this frame
      PvlGroup inst = lab.FindGroup ("Instrument",Pvl::Traverse);
      iString spacecraft = (string)inst["SpacecraftName"];
      iString instId = (string)inst["InstrumentId"];

      // Turn off the aberration corrections for the instrument position object
        InstrumentPosition()->SetAberrationCorrection("NONE");

        // Get the camera characteristics
      SetFocalLength ();
      SetPixelPitch ();

      // Get the start time in et
      string stime = inst["StartTime"];
      double time; 
      str2et_c(stime.c_str(),&time);

      // Setup focal plane map

      LoCameraFiducialMap fid( inst, NaifIkCode());

      // Setup detector map
      new CameraDetectorMap(this);

      // Setup focalplane map
      CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this,NaifIkCode());
      // Try (0.,0.)
      focalMap->SetDetectorOrigin(0.0,0.0);

      // Setup distortion map
      LoHighDistortionMap *distortionMap = new LoHighDistortionMap(this);
      distortionMap->SetDistortion(NaifIkCode());
      // Setup the ground and sky map
      new CameraGroundMap(this);
      new CameraSkyMap(this);

      SetEphemerisTime(time);
      LoadCache();
    }
Пример #14
0
Date::Date(std::string str)
{
	CSPICE_ASSERT(str2et_c(str.c_str(), &etTime));
}
Пример #15
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);
}
Пример #16
0
int main (int argc, char **argv) {

  SpiceDouble et, mat[3][3], mat2[3][3], jac[3][3], nut, obq, dboq;
  SpiceDouble pos[3], newpos[3];
  SpiceDouble lt;
  SpiceInt planets[6], i;
  SPICEDOUBLE_CELL (range, 2);
  SpiceDouble beg,end,stime,etime,*array;
  char test2[2000];

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

  exit(-1);

  for (i=-20000; i<=20000; i++) {
    timout_c(year2et(i), "ERAYYYY##-MON-DD HR:MN:SC.############# ::MCAL", 50, test2);
    printf("TIME: %d %s\n", i, test2);
  }

  exit(-1);

  spkcov_c("/home/barrycarter/SPICE/KERNELS/de431_part-1.bsp", 399, &range);
  wnfetd_c (&range, 0, &stime, &end);
  spkcov_c("/home/barrycarter/SPICE/KERNELS/de431_part-2.bsp", 399, &range);
  wnfetd_c(&range, 0, &beg, &etime);

  printf("TIMES: %f %f\n", beg, etime);



  str2et_c("2017-10-17 07:59", &et);
  printf("ET: %f\n", et);
  spkezp_c(1, et, "EQEQDATE", "CN+S", 399, pos, &lt);
  printf("ET: %f\n", et);
  printf("POS: %f %f %f %f %f\n", et, pos[0], pos[1], pos[2], lt);

  //  eqeq2eclip(et, mat, jac);

  mxv_c(mat, pos, newpos);

  printf("NEWPOS: %f %f %f\n", newpos[0], newpos[1], newpos[2]);

  exit(0);

  zzwahr_(&et, &nut);
  zzmobliq_(&et, &obq, &dboq);

  printf("NUTATION: %f\n", nut);
  printf("OBLIQUITY: %f\n", obq);

  pxform_c("EQEQDATE", "ECLIPDATE", et, mat);

  for (i=0; i<=2; i++) {
    printf("ALPHA: %d %f %f %f\n", i, mat[i][0], mat[i][1], mat[i][2]);
  }

  eqeq2eclip(et, mat2);

  printf("ALPHATEST\n");

  for (i=0; i<=2; i++) {
    printf("BETA: %d %f %f %f\n", i, mat2[i][0], mat2[i][1], mat2[i][2]);
  }


  exit(0);

  str2et_c("10400-FEB-28 00:00:00", &et);
  printf("ET: %f\n", et);
  str2et_c("10400-MAR-01 00:00:00", &et);
  printf("ET: %f\n", et);


  exit(0);



  timout_c(0, "ERAYYYY##-MON-DD HR:MN:SC.############# ::MCAL", 41, test2);

  printf("%s\n", test2);

  exit(0);

  long long test = -pow(2,63);

  printf("TEST: %lld\n",test);

  exit(0);


  if (!strcmp(argv[1],"posxyz")) {
    double time = atof(argv[2]);
    int planet = atoi(argv[3]);
    posxyz(time,planet,pos);
    printf("%f -> %f %f %f\n",time,pos[0],pos[1],pos[2]);
  };

  if (!strcmp(argv[1],"earthvector")) {
    double time = atof(argv[2]);
    int planet = atoi(argv[3]);
    earthvector(time,planet,pos);
    printf("%f -> %f %f %f\n",time,pos[0],pos[1],pos[2]);
  };

  if (!strcmp(argv[1],"earthangle")) {
    double time = atof(argv[2]);
    int p1 = atoi(argv[3]);
    int p2 = atoi(argv[4]);
    SpiceDouble sep = earthangle(time,p1,p2);
    printf("%f -> %f\n",time,sep);
  };

  if (!strcmp(argv[1],"earthmaxangle")) {
    double time = atof(argv[2]);
    for (i=3; i<argc; i++) {planets[i-3] = atoi(argv[i]);}
    SpiceDouble sep = earthmaxangle(time,argc-3,planets);
    printf("%f -> %f\n",time,sep);
  };

}