Esempio n. 1
0
int main(int argc,char *argv[]) {
 
  struct CFitfp *fp=NULL;
  struct CFitdata cfit;
 
  int yr,mo,dy,hr,mt;
  double sc;

  fp=CFitOpen(argv[1]);

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

  while(CFitRead(fp,&cfit) !=-1) {
    CFitToRadarScan(&scn,&cfit);
    if (cfit.scan !=1) continue;
    TimeEpochToYMDHMS(scn.st_time,&yr,&mo,&dy,&hr,&mt,&sc);

    fprintf(stdout,"%d\n",scn.num);
    RadarScanReset(&scn);

  }

  CFitClose(fp);

  return 0;
}
Esempio n. 2
0
int SmrRadarScan(FILE *fp,int *state,
                 struct RadarScan *ptr,struct RadarParm *prm,
                 struct FitData *fit,int fbeam,
                 int tlen,
                 int lock,int chn) {

  int fstatus=0;
  int flg=0;
  int n=0;
  int r;
  struct RadarBeam *tmp;
  struct RadarBeam *bm;
  if (ptr==NULL) return -1;
  if (fit==NULL) return -1;
  if (fp==NULL) return -1;
  if (state==NULL) return -1;
  if (*state!=1) {
    if (chn==0) fstatus=SmrFread(fp,prm,fit,fbeam);
    else {
      do {
        fstatus=SmrFread(fp,prm,fit,fbeam); /* read first fit record */
        if (fstatus==-1) break;
      } while (prm->channel !=chn);
    }
    if (fstatus==-1) return -1;
  }
  if (*state !=2) {
    ptr->stid=prm->stid;
    ptr->version.major=1;
    ptr->version.minor=0;
    ptr->st_time=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 ((tlen !=0) && (lock !=0)) ptr->st_time=tlen*(int) (ptr->st_time/tlen);
    RadarScanReset(ptr);  
  }
  
  *state=1;
  do {

    n=ptr->num;
    if (ptr->bm==NULL) ptr->bm=malloc(sizeof(struct RadarBeam));
    else {
      tmp=realloc(ptr->bm,sizeof(struct RadarBeam)*(n+1));
      if (tmp==NULL) {
        flg=-1;        
        break;
      }
      ptr->bm=tmp;
    }
    
    bm=&ptr->bm[n];    
 
    bm->time=TimeYMDHMSToEpoch(prm->time.yr,
			       prm->time.mo,
			       prm->time.dy,
			       prm->time.hr,
			       prm->time.mt,
			       prm->time.sc+prm->time.us/1.0e6);
  
    bm->bm=prm->bmnum;
    bm->scan=prm->scan;
    bm->cpid=prm->cp;
    bm->intt.sc=prm->intt.sc;
    bm->intt.us=prm->intt.us;
    bm->frang=prm->frang;
    bm->rsep=prm->rsep;
    bm->rxrise=prm->rxrise;
    bm->freq=prm->tfreq;
    bm->noise=prm->noise.search;
    bm->atten=prm->atten;
    bm->channel=prm->channel;
    bm->nrang=prm->nrang;

    bm->sct=malloc(sizeof(char)*bm->nrang);
    bm->rng=malloc(sizeof(struct RadarCell)*bm->nrang);

    for (r=0;r<bm->nrang;r++) bm->sct[r]=0;
    for (r=0;r<bm->nrang;r++) {
      bm->sct[r]=(fit->rng[r].qflg==1);
      bm->rng[r].gsct=fit->rng[r].gsct;
      bm->rng[r].v=fit->rng[r].v;
      bm->rng[r].p_l=fit->rng[r].p_l;
      bm->rng[r].w_l=fit->rng[r].w_l;
      bm->rng[r].v_e=fit->rng[r].v_err;    
    }
    
    ptr->num++;
    ptr->ed_time=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 (ptr->num>100) {
      flg=-1;
      break;
    }
    if (chn==0) fstatus=SmrFread(fp,prm,fit,fbeam);
    else {
      do { 
        fstatus=SmrFread(fp,prm,fit,fbeam);
        if (fstatus==-1) break;
      } while (prm->channel !=chn);
    }
    if (fstatus==-1) flg=2;
    else {
      if (tlen==0) {
        if (prm->scan==1) flg=1;
      } else if (ptr->ed_time-ptr->st_time>=tlen) flg=1;
    }
  } while (flg==0);
  if (flg>0) flg--;
  if (flg==1) *state=2;
  return flg;
}
Esempio n. 3
0
int OldFitReadRadarScan(struct OldFitFp *fp,int *state,
                     struct RadarScan *ptr,
                     struct RadarParm *prm,struct FitData *fit,
                     int tlen,
                     int lock,int chn) {

  int fstatus=0;
  int flg=0;
  int n=0;
  int r;
  struct RadarBeam *tmp;
  struct RadarBeam *bm;
  if (ptr==NULL) return -1;
  if (fit==NULL) return -1;
  if (state==NULL) return -1;
  if (*state!=1) {
    if (chn==0) fstatus=OldFitRead(fp,prm,fit);
    else {
      do {
        fstatus=OldFitRead(fp,prm,fit); /* read first fit record */
        if (fstatus==-1) break;

        /* The logic below will handle mono/stereo mixed days.
         * If the channel is set to zero then the file is mono
         * and we should treat the data as channel A.
         */

           
        } while ( ((chn==2) && (prm->channel !=2)) || 
                ((chn==1) && (prm->channel ==2)));

    }
    if (fstatus==-1) return -1;
  }
  if (*state !=2) {
    ptr->stid=prm->stid;
    ptr->version.major=prm->revision.major;
    ptr->version.minor=prm->revision.minor;
    ptr->st_time=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 ((tlen !=0) && (lock !=0)) ptr->st_time=tlen*(int) (ptr->st_time/tlen);
    RadarScanReset(ptr);  
  }
  
  *state=1;
  do {

    n=ptr->num;
    if (ptr->bm==NULL) ptr->bm=malloc(sizeof(struct RadarBeam));
    else {
      tmp=realloc(ptr->bm,sizeof(struct RadarBeam)*(n+1));
      if (tmp==NULL) {
        flg=-1;        
        break;
      }
      ptr->bm=tmp;
    }
    
    bm=&ptr->bm[n];    
 
    bm->time=TimeYMDHMSToEpoch(prm->time.yr,prm->time.mo,
			      prm->time.dy,
			      prm->time.hr,prm->time.mt,
			      prm->time.sc+prm->time.us/1.0e6); 
 
    bm->scan=prm->scan;
    bm->bm=prm->bmnum;
    bm->cpid=prm->cp;
    bm->intt.sc=prm->intt.sc;
    bm->intt.us=prm->intt.us;
    bm->nave=prm->nave;
    bm->frang=prm->frang;
    bm->rsep=prm->rsep;
    bm->rxrise=prm->rxrise;
    bm->freq=prm->tfreq;
    bm->noise=prm->noise.search;
    bm->atten=prm->atten;
    bm->channel=prm->channel;
    bm->nrang=prm->nrang;

    for (r=0;r<MAX_RANGE;r++) bm->sct[r]=0;
    for (r=0;r<bm->nrang;r++) {
      bm->sct[r]=(fit->rng[r].qflg==1);
      bm->rng[r].gsct=fit->rng[r].gsct;
      bm->rng[r].p_0=fit->rng[r].p_0;
      bm->rng[r].p_0_e=0;
      bm->rng[r].v=fit->rng[r].v;
      bm->rng[r].p_l=fit->rng[r].p_l;
      bm->rng[r].w_l=fit->rng[r].w_l;
      bm->rng[r].v_e=fit->rng[r].v_err;    
    }
    
    ptr->num++;

    ptr->ed_time=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 (ptr->num>100) {
      flg=-1;
      break;
    }
    if (chn==0) fstatus=OldFitRead(fp,prm,fit);
    else {
      do { 
        fstatus=OldFitRead(fp,prm,fit);
        if (fstatus==-1) break;

        /* The logic below will handle mono/stereo mixed days.
         * If the channel is set to zero then the file is mono
         * and we should treat the data as channel A.
         */

           
        } while ( ((chn==2) && (prm->channel !=2)) || 
                ((chn==1) && (prm->channel ==2)));

    }
    if (fstatus==-1) flg=2;
    else {
      if (tlen==0) {
        if (prm->scan==1) flg=1;
      } else if (ptr->ed_time-ptr->st_time>=tlen) flg=1;
    }
  } while (flg==0);
  if (flg>0) flg--;
  if (flg==1) *state=2;
  return flg;
}
Esempio n. 4
0
void RadarScanFree(struct RadarScan *ptr) {
  if (ptr==NULL) return;
  RadarScanReset(ptr);
  free(ptr);
}