コード例 #1
0
void ceos_init_alos_stVec(const char *fName, ceos_description *ceos, 
			  meta_parameters *meta)
{
  struct pos_data_rec ppdr;

  // Read platform position record
  get_ppdr(fName,&ppdr);

  // Initialize state vector
  int vector_count=3;
  double data_int = meta->sar->original_line_count / 2
    * fabs(meta->sar->azimuth_time_per_pixel);
  while (fabs(data_int) > 15.0) {
    data_int /= 2;
    vector_count = vector_count*2-1;
  }
  meta->state_vectors = meta_state_vectors_init(vector_count);
  meta->state_vectors->vector_count = vector_count;

  // Determine image start time
  ymd_date imgDate;
  julian_date imgJD;
  hms_time imgTime;
  date_dssr2date(ceos->dssr.inp_sctim, &imgDate, &imgTime);
  date_ymd2jd(&imgDate, &imgJD);
  double imgSec = date2sec(&imgJD, &imgTime);
  imgSec -= ceos->dssr.sc_lin*fabs(meta->sar->azimuth_time_per_pixel);
  
  sec2date(imgSec, &imgJD, &imgTime);
  meta->state_vectors->year   = (int) imgJD.year;
  meta->state_vectors->julDay = (int) imgJD.jd;
  meta->state_vectors->second = date_hms2sec(&imgTime);

  // Assign position and velocity for center of image
  int n = (vector_count - 1)/2;
  double timeStart = get_timeDelta(ceos, &ppdr, meta);
  double time = timeStart + n*data_int;
  stateVector st;
  st.pos.x = ppdr.orbit_ele[0];
  st.pos.y = ppdr.orbit_ele[1];
  st.pos.z = ppdr.orbit_ele[2];
  st.vel.x = ppdr.orbit_ele[3];
  st.vel.y = ppdr.orbit_ele[4];
  st.vel.z = ppdr.orbit_ele[5];
  meta->state_vectors->vecs[n].vec = st;
  meta->state_vectors->vecs[n].time = time - timeStart;

  int ii;
  double newTime;
  for (ii=0; ii<n; ii++) {
    newTime = time - (n - ii)*data_int;
    meta->state_vectors->vecs[ii].time = newTime - timeStart;
    meta->state_vectors->vecs[ii].vec = propagate(st, time, newTime);
  }
  for (ii=n+1; ii<vector_count; ii++) {
    newTime = time + (vector_count - n - 1)*data_int;
    meta->state_vectors->vecs[ii].time = newTime - timeStart;
    meta->state_vectors->vecs[ii].vec = propagate(st, time, newTime);
  }
}
コード例 #2
0
/***************************************************************
 * Get_timeDelta:
 * Return the time difference, in seconds, between the start
 * of the state vectors (in the PPDR) and the start of the image
 * (as described in the DSSR).  Write this time to the given
 * meta_parameters->state_vectors structure.*/
double get_timeDelta(ceos_description *ceos,struct pos_data_rec *ppdr,meta_parameters *meta)
{
    ymd_date imgDate;
    julian_date imgJD,stJD;
    hms_time imgTime,stTime;
    double imgSec,stSec;/*Seconds since 1900 for start of image and start of state vectors*/

/*Read time of *start* of state vectors*/
    stJD.year = (int) ppdr->year;
    stJD.jd = (int) ppdr->gmt_day;
    date_sec2hms(ppdr->gmt_sec,&stTime);
    stSec=date2sec(&stJD,&stTime);

/*Compute the *scene* start time from the CEOS DSSR: */
    /* begin with scene center time */
    if (ceos->facility == BEIJING)
      date_dssr2time(ceos->dssr.inp_sctim,&imgDate,&imgTime);
    else
      date_dssr2date(ceos->dssr.inp_sctim,&imgDate,&imgTime);
    date_ymd2jd(&imgDate,&imgJD);
    imgSec=date2sec(&imgJD,&imgTime);

    if (ceos->processor==FOCUS && ceos->product==CCSD) {
        /* do nothing-- dssr "inp_sctim" already gives scene start time */
    }
    else if (0!=strcmp(ceos->dssr.az_time_first,""))
    { /* e.g., ESA data.  "az_time_first" field gives start of image */
        date_dssr2time(ceos->dssr.az_time_first,&imgDate,&imgTime);
        imgSec=date2sec(&imgJD,&imgTime);
    }
    else if (ceos->facility==EOC)
    {
        imgSec-=ceos->dssr.sc_lin*fabs(meta->sar->azimuth_time_per_pixel);
    }
    else {/*Convert scene center time to scene *start* time, by
       subtracting off the center line # * the time/line */
        imgSec-=ceos->dssr.sc_lin*fabs(meta->sar->azimuth_time_per_pixel);
    }
    /*
    // Complex ALOS data have an additional 1 sec shift
    // Still under investigation: Need word from DQ on this
    if (ceos->facility==EOC && ceos->product==SLC)
      imgSec -= 1.0;
    */

    /*Convert scene center # of seconds back to date/time*/
    sec2date(imgSec,&imgJD,&imgTime);

/*Write image time to meta->state_vectors structure*/
    meta->state_vectors->year   = (int) imgJD.year;
    meta->state_vectors->julDay = (int) imgJD.jd;
    meta->state_vectors->second = date_hms2sec(&imgTime);

/*Return the time between state vector start and image start*/
    return stSec-imgSec;
}
コード例 #3
0
ファイル: dateUtil.c プロジェクト: thisissmithj/ASF_MapReady
// input is seconds since midnight Jan 1, 1900
// output is a string of the form "MM/DD HH:MM"
const char *date_str(double s)
{
  julian_date jd;
  hms_time t;
  ymd_date d;
  static char buf[64];

  sec2date(s, &jd, &t);
  date_jd2ymd(&jd, &d);

  sprintf(buf, "%02d/%02d %02d:%02d", d.month, d.day, t.hour, t.min);
  return buf;
}
コード例 #4
0
ファイル: 格林时间.c プロジェクト: aspenstarss/leason1
main()
{
 long sec;
 date d;

 puts("请输入日期(格式为2008-08-08 08:08:08):");
 scanf("%d-%d-%d %d:%d:%d",&d.year,&d.month,&d.day,&d.hour,&d.min,&d.sec);
 sec=date2sec(d);
 printf("到格林时间%d秒!\n",sec);
 puts("请到格林时间的秒数:");
 scanf("%d",&sec);
 d=sec2date(sec);
 printf("日期为:%d-%d-%d %d:%d:%d\n",d.year,d.month,d.day,d.hour,d.min,d.sec);
}
コード例 #5
0
ファイル: dateUtil.c プロジェクト: thisissmithj/ASF_MapReady
// input is seconds since midnight Jan 1, 1900
// output is a string of the form "DD-MON-YYYY HH:MM"
const char *date_str_long(double s)
{
  char mon[][5]= 
    {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
  julian_date jd;
  hms_time t;
  ymd_date d;
  static char buf[64];

  sec2date(s, &jd, &t);
  date_jd2ymd(&jd, &d);

  sprintf(buf, "%02d-%s-%4d, %02d:%02d:%02d", d.day, mon[d.month], d.year,
          t.hour, t.min, (int)(t.sec+.5));
  return buf;
}
コード例 #6
0
ファイル: dateUtil.c プロジェクト: thisissmithj/ASF_MapReady
/*
   Compute the average ymd_date date and hms_time time
  -----------------------------------------------------*/
void average_ymdTimes(ymd_date *date1, ymd_date *date2,
                      hms_time *time1, hms_time *time2,
                      ymd_date *ave_date, hms_time *ave_time)
{
    double secs1, secs2, ave_secs;
    julian_date jd_1, jd_2, ave_jd;

    date_ymd2jd(date1, &jd_1); // Julian date contains year and day number within that year
    date_ymd2jd(date2, &jd_2);

    secs1 = date2sec(&jd_1, time1); // Seconds from midnight, Jan 1, 1900 to julian date plus seconds into that day
    secs2 = date2sec(&jd_2, time2);
    ave_secs = (secs1 + secs2) / 2.0;

    sec2date(ave_secs, &ave_jd, ave_time);
    date_jd2ymd(&ave_jd, ave_date);
}