Ejemplo n.º 1
0
int32 OldFitIDLSeek(int argc,char *argv[]) {

  struct OldFitIDLFp *idlfitfp;
  struct OldFitFp fitfp;

  IDL_FILE_STAT stat;
  FILE *ffp=NULL,*ifp=NULL;
  int s;

  int32 yr,mo,dy,hr,mt;
  double sc;
  double *atme;

  idlfitfp=(struct OldFitIDLFp *) argv[0];
  
  IDL_FileStat(idlfitfp->fitunit,&stat);
 
  /* Find the file pointer */

  ffp=stat.fptr; 
  
  if (ffp==NULL) return -1;

  fflush(ffp);

  if (idlfitfp->inxunit !=-1) {
    IDL_FileStat(idlfitfp->inxunit,&stat);
    ifp=stat.fptr;
  }

  if (ifp !=NULL) fflush(ifp);

  fitfp.fitfp=fileno(ffp);
  if (ifp !=NULL) fitfp.inxfp=fileno(ifp);
  else fitfp.inxfp=-1;
 
  yr=*( (int32 *) argv[1]);
  mo=*( (int32 *) argv[2]);
  dy=*( (int32 *) argv[3]);
  hr=*( (int32 *) argv[4]);
  mt=*( (int32 *) argv[5]);
  sc=*( (double *) argv[6]);
  atme=(double *) argv[7];
 
  OldFitIDLToFitFp(idlfitfp,&fitfp);

  s=OldFitSeek(&fitfp,yr,mo,dy,hr,mt,sc,atme);

  OldFitFitFpToIDL(&fitfp,idlfitfp);

  return s;
}
Ejemplo n.º 2
0
int main(int argc,char *argv[]) {
 
  struct RadarParm prm;
  struct FitData fit;

  struct OldFitFp *fp;

   int yr=2004,mo=11,dy=10,hr=12,mt=0;
  double sc=0,atme;

  int s;


  if (argc==2) fp=OldFitOpen(argv[1],NULL);
  else fp=OldFitOpen(argv[1],argv[2]);

  if (fp==NULL) {
    fprintf(stderr,"File not found.\n");
    exit(-1);
  }


  s=OldFitSeek(fp,yr,mo,dy,hr,mt,(int) sc,&atme);
  if (s==-1) {
    fprintf(stderr,"file does not contain that interval.\n");
    exit(-1);
  }

  fprintf(stdout,"Requested:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n",
            yr,mo,dy,hr,mt,(int) sc);

  TimeEpochToYMDHMS(atme,&yr,&mo,&dy,&hr,&mt,&sc);
  fprintf(stdout,"Found:%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n",
            yr,mo,dy,hr,mt,(int) sc);

  while(OldFitRead(fp,&prm,&fit) !=-1) {
    fprintf(stdout,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n",
             prm.time.yr,prm.time.mo,prm.time.dy,
             prm.time.hr,prm.time.mt,prm.time.sc);
  }
 
  OldFitClose(fp);

  return 0;
}
Ejemplo n.º 3
0
double oldfit_find(struct OldFitFp *fitfp,struct RadarParm *prm,
                struct FitData *fit,double sdate,
                double stime) {
  int status;
  int yr,mo,dy,hr,mt;
  double sc;
  double atime;
  if (OldFitRead(fitfp,prm,fit)==-1) return -1;
  atime=TimeYMDHMSToEpoch(prm->time.yr,prm->time.mo,prm->time.dy,
                          prm->time.hr,prm->time.mt,
                          prm->time.sc+prm->time.us/1.0e6);
       	                 

  if ((stime==-1) && (sdate==-1)) return atime;
  if (stime==-1) stime= ( (int) atime % (24*3600));
  if (sdate==-1) stime+=atime - ( (int) atime % (24*3600));
  else stime+=sdate;
  TimeEpochToYMDHMS(stime,&yr,&mo,&dy,&hr,&mt,&sc);
  if (atime>=stime) return stime;
  status=OldFitSeek(fitfp,yr,mo,dy,hr,mt,sc,NULL);
  if (status==-1) return -1;
  if (OldFitRead(fitfp,prm,fit)==-1) return -1;
  return stime;
}