void IDLCopyGridPrmToIDL(struct GridData *grd, struct GridIDLPrm *iprm) { int yr,mo,dy,hr,mt; double sc; iprm->stnum=grd->stnum; iprm->vcnum=grd->vcnum; iprm->xtd=grd->xtd; TimeEpochToYMDHMS(grd->st_time,&yr,&mo, &dy,&hr,&mt, &sc); iprm->start.yr=yr; iprm->start.mo=mo; iprm->start.dy=dy; iprm->start.hr=hr; iprm->start.mt=mt; iprm->start.sc=sc; TimeEpochToYMDHMS(grd->ed_time,&yr,&mo, &dy,&hr,&mt, &sc); iprm->end.yr=yr; iprm->end.mo=mo; iprm->end.dy=dy; iprm->end.hr=hr; iprm->end.mt=mt; iprm->end.sc=sc; }
int main (int argc,char *argv[]) { FILE *fp; int arg; unsigned char help=0; unsigned char option=0; unsigned char startstop=0; int st=0; double tme[2]; int32 inx; int yr,mo,dy,hr,mt; double sc; OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); OptionAdd(&opt,"xtd",'x',&startstop); arg=OptionProcess(1,argc,argv,&opt,NULL); if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (arg==argc) fp=stdin; else fp=fopen(argv[arg],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } do { st=ConvertFreadDouble(fp,&tme[0]); if (st !=0) break; if (startstop) { st=ConvertFreadDouble(fp,&tme[1]); if (st !=0) break; } st=ConvertFreadInt(fp,&inx); if (st !=0) break; TimeEpochToYMDHMS(tme[0],&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d %.2d %.2d %.2d %.2d %g ",yr,mo,dy,hr,mt,sc); if (startstop) { TimeEpochToYMDHMS(tme[1],&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d %.2d %.2d %.2d %.2d %g ",yr,mo,dy,hr,mt,sc); } fprintf(stdout,"%d\n",inx); } while (1); return 0; }
void plot_time(struct Plot *plot, float xoff,float yoff,float wdt,float hgt, double stime,double etime, unsigned int color,unsigned char mask, char *fontname,float fontsize, void *txtdata) { int i; char txt[256]; float txbox[3]; char *month[]={"Jan","Feb","Mar","Apr","May","Jun", "Jul","Aug","Sep","Oct","Nov","Dec",0}; char *tmeA="00:00:00 UT"; char *tmeB="00:00:00 - 00:00:00 UT"; char *tmeC="0"; float cwdt; float x,y; int yr,mo,dy,shr,smt,ssc,ehr,emt,esc; double sec; txtbox(fontname,fontsize,strlen(tmeC),tmeC,txbox,txtdata); cwdt=txbox[0]; TimeEpochToYMDHMS(etime,&yr,&mo,&dy,&ehr,&emt,&sec); esc=sec; TimeEpochToYMDHMS(stime,&yr,&mo,&dy,&shr,&smt,&sec); ssc=sec; sprintf(txt,"%.2d %s %d",dy,month[mo-1],yr); txtbox(fontname,fontsize,strlen(txt),txt,txbox,txtdata); x=xoff; y=yoff+txbox[2]; for (i=0;txt[i] !=0;i++) { txtbox(fontname,fontsize,1,txt+i,txbox,txtdata); PlotText(plot,NULL,fontname,fontsize,x, y,1,txt+i,color,mask,1); if (isdigit(txt[i])) x+=cwdt; else x+=txbox[0]; } if (stime==etime) sprintf(txt,"%.2d:%.2d:%.2d UT",shr,smt,ssc); else sprintf(txt,"%.2d:%.2d:%.2d - %.2d:%.2d:%.2d UT", shr,smt,ssc,ehr,emt,esc); if (stime==etime) txtbox(fontname,fontsize,strlen(tmeA),tmeA,txbox,txtdata); else txtbox(fontname,fontsize,strlen(tmeB),tmeB,txbox,txtdata); x=xoff+wdt-txbox[0]; y=yoff+txbox[2]; for (i=0;txt[i] !=0;i++) { txtbox(fontname,fontsize,1,txt+i,txbox,txtdata); PlotText(plot,NULL,fontname,fontsize,x, y,1,txt+i,color,mask,1); if (isdigit(txt[i])) x+=cwdt; else x+=txbox[0]; } }
int main(int argc,char *argv[]) { int ptr; int arg; FILE *fp; int yr,mo,dy,hr,mt; double sc; double tme[2]; void *tptr[2]; unsigned char help=0; unsigned char option=0; OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); arg=OptionProcess(1,argc,argv,&opt,NULL); if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (arg<argc) { fp=fopen(argv[arg],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } } else fp=stdin; tptr[0]=tme; ptr=ftell(fp); while (RfileRead(fp,0,NULL,tptr) !=-1) { TimeEpochToYMDHMS(tme[0],&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d %.2d %.2d %.2d %.2d %g ",yr,mo,dy,hr,mt,sc); TimeEpochToYMDHMS(tme[1],&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d %.2d %.2d %.2d %.2d %g ",yr,mo,dy,hr,mt,sc); fprintf(stdout,"%d\n",ptr); ptr=ftell(fp); } if (arg<argc) fclose(fp); return 0; }
int main(int argc,char *argv[]) { FILE *fp; RfileDecoder decode[2]; void *dptr[2]; int i; int yr,mo,dy,hr,mt; double sc; if (argc>1) { fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } } else fp=stdin; decode[0]=decode_blk1; decode[1]=decode_blk2; dptr[0]=&data.blk1; dptr[1]=&data.blk2; while (RfileRead(fp,2,decode,dptr) !=-1) { TimeEpochToYMDHMS(data.blk1.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%d-%d-%d %d:%d:%d to ",yr,mo,dy,hr,mt,(int) sc); TimeEpochToYMDHMS(data.blk1.ed_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%d-%d-%d %d:%d:%d\n",yr,mo,dy,hr,mt,(int) sc); fprintf(stdout,"Block 1\n"); fprintf(stdout,"pnt\tlat\tlon\thgt\tflg\n"); for (i=0;i<data.blk1.npnt;i++) { fprintf(stdout,"%d\t%g\t%g\t%g\t%d\n",i, data.blk1.lat[i],data.blk1.lon[i], data.blk1.hgt[i],data.blk1.flg[i]); } fprintf(stdout,"Block 2\n"); fprintf(stdout,"pnt\ta\tb\n"); for (i=0;i<data.blk2.npnt;i++) { fprintf(stdout,"%d\t%d\t%d\n",i, data.blk2.a[i],data.blk2.b[i]); } fprintf(stdout,"\n"); } if (fp !=stdin) fclose(fp); return 0; }
void print_schedule(struct scd_blk *ptr) {/* prints out the schedule */ int c; char txt[256]; if (ptr->num==0) { log_info(1,"No schedule file loaded"); return; } sprintf(txt,"Schedule file %s loaded",ptr->name); log_info(1,txt); sprintf(txt,"Command path -> %s",ptr->path); log_info(1,txt); if (ptr->entry[0].stime==-1) { sprintf(txt,"Default Program -> %s\n",ptr->entry[0].command); log_info(1,txt); } if ((ptr->cnt >0) && (ptr->cnt<ptr->num)) { int yr,mo,dy,hr,mt; double sc; log_info(1,"Pending programs :\n"); for (c=ptr->cnt;c<ptr->num;c++) { if (ptr->entry[c].stime==-1) continue; TimeEpochToYMDHMS(ptr->entry[c].stime,&yr,&mo,&dy,&hr,&mt,&sc); sprintf(txt,"%d : %d %d %d : %d %d -> %s",c,yr,mo,dy,hr,mt, ptr->entry[c].command); log_info(1,txt); } } else log_info(1,"There are no pending programs"); sprintf(txt,"\nCurrent program ->%s",ptr->command); log_info(1,txt); sprintf(txt,"Schedule reloaded every %d seconds",ptr->refresh); log_info(1,txt); }
int main(int argc,char *argv[]) { FILE *fp; int yr,mo,dy,hr,mt; double sc; fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } while(CnvMapFread(fp,&map,&grd) !=-1) { TimeEpochToYMDHMS(map.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,grd.vcnum); map.Bx=0.0; map.By=0.0; map.Bz=0.0; CnvMapFwrite(stdout,&map,&grd); } fclose(fp); return 0; }
double MLTConvertEpoch(double epoch,double mlon) { int yr,mo,dy,hr,mt; double sc; double mslon; TimeEpochToYMDHMS(epoch,&yr,&mo,&dy,&hr,&mt,&sc); return astmlt(yr,mo,dy,hr,mt,(int) sc,mlon,&mslon); }
int main(int argc,char *argv[]) { FILE *fp; int fd; int yr,mo,dy,hr,mt; double sc; fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } fd=fileno(fp); while(GridRead(fd,&grd) !=-1) { TimeEpochToYMDHMS(grd.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,grd.vcnum); GridWrite(fileno(stdout),&grd); } fclose(fp); return 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; }
double cfit_find(struct CFitfp *cfitfp,struct CFitdata *cfit,double sdate, double stime) { int status; int yr,mo,dy,hr,mt; double sc; double atime; do { status=CFitRead(cfitfp,cfit); if (status==-1) break; } while (status !=0); if (status==-1) return -1; atime=cfit->time; 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=CFitSeek(cfitfp,yr,mo,dy,hr,mt,sc,NULL); if (status==-1) return -1; do { status=CFitRead(cfitfp,cfit); if (status==-1) break; } while (status !=0); if (status==-1) return -1; return stime; }
void plot_title(struct Grplot *grplot,double stime,double etime, char *sat,char *plot,int mode, unsigned int color,float width,char *fontname, float fontsize) { char title[256]; char *motxt[]={"GSM","GSE",0}; int yr,mo,dy,hr,mt; int dayno; double sc; double yrsec; TimeEpochToYMDHMS(stime,&yr,&mo,&dy,&hr,&mt,&sc); yrsec=stime-TimeYMDHMSToEpoch(yr,1,1,0,0,0); dayno=1+yrsec/(24*3600); sprintf(title,"%s %s (%s) %s %.2d %.4d (Dayno=%.2d)", sat,plot,motxt[mode],mtxt[mo-1],dy,yr,dayno); GrplotXaxisTitle(grplot,0,0x02,strlen(title),title, fontname,fontsize,color,0x0f); }
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) { TimeEpochToYMDHMS(cfit.time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d bmnum=%d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,cfit.bmnum,cfit.num); } CFitClose(fp); return 0; }
int main(int argc,char *argv[]) { struct CFitfp *fp=NULL; struct CFitdata cfit; int yr=2004,mo=11,dy=10,hr=10,mt=0; double sc=0,atme; int s; fp=CFitOpen(argv[1]); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } s=CFitSeek(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(CFitRead(fp,&cfit) !=-1) { TimeEpochToYMDHMS(cfit.time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d bmnum=%d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,cfit.bmnum,cfit.num); } CFitClose(fp); return 0; }
struct PolygonData *make_fov(double tval,struct RadarNetwork *network, int id) { double rho,lat,lon; int i,rn,bm; float pnt[2]; int yr,mo,dy,hr,mt; double sc; int frang=180; int rsep=45; struct PolygonData *ptr=NULL; struct RadarSite *site=NULL; TimeEpochToYMDHMS(tval,&yr,&mo,&dy,&hr,&mt,&sc); ptr=PolygonMake(sizeof(float)*2,NULL); for (i=0;i<network->rnum;i++) { if (network->radar[i].status !=1) continue; if (network->radar[i].id==id) continue; site=RadarYMDHMSGetSite(&(network->radar[i]),yr,mo,dy,hr,mt,(int) sc); if (site==NULL) continue; PolygonAddPolygon(ptr,1); for (rn=0;rn<=site->maxrange;rn++) { RPosGeo(0,0,rn,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } for (bm=1;bm<=site->maxbeam;bm++) { RPosGeo(0,bm,site->maxrange,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } for (rn=site->maxrange-1;rn>=0;rn--) { RPosGeo(0,site->maxbeam,rn,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } for (bm=site->maxbeam-1;bm>0;bm--) { RPosGeo(0,bm,0,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } } return ptr; }
int main (int argc,char *argv[]) { int arg; unsigned char help=0; unsigned char option=0; unsigned char vb=0; FILE *fp; int yr,mo,dy,hr,mt; double sc; int s; grd=GridMake(); map=CnvMapMake(); OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); OptionAdd(&opt,"vb",'x',&vb); arg=OptionProcess(1,argc,argv,&opt,NULL); if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (arg==argc) fp=stdin; else fp=fopen(argv[arg],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } while (CnvMapFread(fp,map,grd) !=-1) { if (vb) { TimeEpochToYMDHMS(map->st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); } s=OldCnvMapFwrite(stdout,map,grd); } if (fp !=stdin) fclose(fp); return 0; }
int OldGridFwrite(FILE *fp,struct GridData *ptr) { int syr,smo,sdy,shr,smt,ssc; int eyr,emo,edy,ehr,emt,esc; double sec; int nfile,npnt; TimeEpochToYMDHMS(ptr->st_time,&syr,&smo,&sdy,&shr,&smt,&sec); ssc=(int) sec; TimeEpochToYMDHMS(ptr->ed_time,&eyr,&emo,&edy,&ehr,&emt,&sec); esc=(int) sec; fprintf(fp,"%d %d %d %d %d %d ",syr,smo,sdy,shr,smt,ssc); fprintf(fp,"%d %d %d %d %d %d\n",eyr,emo,edy,ehr,emt,esc); fprintf(fp,"%d\n",NBLOCKS); nfile=OldGridEncodeOne(fp,ptr); if (ptr->xtd) npnt=OldGridEncodeThree(fp,ptr); else npnt=OldGridEncodeTwo(fp,ptr); return 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; }
char *label_dte(double val,double min,double max,void *data) { int yr,mo,dy,hr,mt; double sc; char *txt=NULL; txt=malloc(32); /* if ((((int) (val/3600)) % 24) !=0) { sprintf(txt,""); return; } */ TimeEpochToYMDHMS(val,&yr,&mo,&dy,&hr,&mt,&sc); sprintf(txt,"%.2d %s %.4d",dy,mltxt[mo-1],yr); return txt; }
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; }
int GridWrite(int fid,struct GridData *ptr) { struct DataMap *data; int s; int32 stnum=0; int32 npnt=0; int16 syr,smo,sdy,shr,smt; double ssc; int16 eyr,emo,edy,ehr,emt; double esc; int yr,mo,dy,hr,mt; double sc; int16 *stid=NULL; int16 *chn=NULL; int16 *nvec=NULL; float *freq=NULL; int16 *major_rev=NULL; int16 *minor_rev=NULL; int16 *progid=NULL; float *noise_mean=NULL; float *noise_sd=NULL; int16 *gsct=NULL; float *v_min=NULL; float *v_max=NULL; float *p_min=NULL; float *p_max=NULL; float *w_min=NULL; float *w_max=NULL; float *ve_min=NULL; float *ve_max=NULL; float *gmlon=NULL; float *gmlat=NULL; float *kvect=NULL; int16 *vstid=NULL; int16 *vchn=NULL; int32 *index=NULL; float *vlos=NULL; float *vlos_sd=NULL; float *pwr=NULL; float *pwr_sd=NULL; float *wdt=NULL; float *wdt_sd=NULL; int size=0; unsigned char *buf=NULL; unsigned char *bptr=NULL; int xtd=0; int n,p; for (n=0;n<ptr->stnum;n++) if (ptr->sdata[n].st_id !=-1) stnum++; if (stnum==0) return 0; size=stnum*(11*sizeof(float)+7*sizeof(int16)); xtd=ptr->xtd; for (n=0;n<ptr->vcnum;n++) if (ptr->data[n].st_id !=-1) npnt++; size+=npnt*(3*sizeof(float)+sizeof(int32)+ 2*sizeof(int16)+(2+4*xtd)*sizeof(float)); if (size==0) return 0; buf=malloc(size); if (buf==NULL) return -1; bptr=buf; stid=(int16 *) bptr; bptr+=stnum*sizeof(int16); chn=(int16 *) bptr; bptr+=stnum*sizeof(int16); nvec=(int16 *) bptr; bptr+=stnum*sizeof(int16); freq=(float *) bptr; bptr+=stnum*sizeof(float); major_rev=(int16 *) bptr; bptr+=stnum*sizeof(int16); minor_rev=(int16 *) bptr; bptr+=stnum*sizeof(int16); progid=(int16 *) bptr; bptr+=stnum*sizeof(int16); noise_mean=(float *) bptr; bptr+=stnum*sizeof(float); noise_sd=(float *) bptr; bptr+=stnum*sizeof(float); gsct=(int16 *) bptr; bptr+=stnum*sizeof(int16); v_min=(float *) bptr; bptr+=stnum*sizeof(float); v_max=(float *) bptr; bptr+=stnum*sizeof(float); p_min=(float *) bptr; bptr+=stnum*sizeof(float); p_max=(float *) bptr; bptr+=stnum*sizeof(float); w_min=(float *) bptr; bptr+=stnum*sizeof(float); w_max=(float *) bptr; bptr+=stnum*sizeof(float); ve_min=(float *) bptr; bptr+=stnum*sizeof(float); ve_max=(float *) bptr; bptr+=stnum*sizeof(float); n=0; for (p=0;p<ptr->stnum;p++) if (ptr->sdata[p].st_id !=-1) { stid[n]=ptr->sdata[p].st_id; chn[n]=ptr->sdata[p].chn; nvec[n]=ptr->sdata[p].npnt; freq[n]=ptr->sdata[p].freq0; major_rev[n]=ptr->sdata[p].major_revision; minor_rev[n]=ptr->sdata[p].minor_revision; progid[n]=ptr->sdata[p].prog_id; noise_mean[n]=ptr->sdata[p].noise.mean; noise_sd[n]=ptr->sdata[p].noise.sd; gsct[n]=ptr->sdata[p].gsct; v_min[n]=ptr->sdata[p].vel.min; v_max[n]=ptr->sdata[p].vel.max; p_min[n]=ptr->sdata[p].pwr.min; p_max[n]=ptr->sdata[p].pwr.max; w_min[n]=ptr->sdata[p].wdt.min; w_max[n]=ptr->sdata[p].wdt.max; ve_min[n]=ptr->sdata[p].verr.min; ve_max[n]=ptr->sdata[p].verr.max; n++; } if (npnt !=0) { gmlon=(float *) bptr; bptr+=npnt*sizeof(float); gmlat=(float *) bptr; bptr+=npnt*sizeof(float); kvect=(float *) bptr; bptr+=npnt*sizeof(float); vstid=(int16 *) bptr; bptr+=npnt*sizeof(int16); vchn=(int16 *) bptr; bptr+=npnt*sizeof(int16); index=(int32 *) bptr; bptr+=npnt*sizeof(int32); vlos=(float *) bptr; bptr+=npnt*sizeof(float); vlos_sd=(float *) bptr; bptr+=npnt*sizeof(float); if (xtd) { pwr=(float *) bptr; bptr+=npnt*sizeof(float); pwr_sd=(float *) bptr; bptr+=npnt*sizeof(float); wdt=(float *) bptr; bptr+=npnt*sizeof(float); wdt_sd=(float *) bptr; bptr+=npnt*sizeof(float); } n=0; for (p=0;p<ptr->vcnum;p++) if (ptr->data[p].st_id !=-1) { gmlat[n]=ptr->data[p].mlat; gmlon[n]=ptr->data[p].mlon; kvect[n]=ptr->data[p].azm; vstid[n]=ptr->data[p].st_id; vchn[n]=ptr->data[p].chn; index[n]=ptr->data[p].index; vlos[n]=ptr->data[p].vel.median; vlos_sd[n]=ptr->data[p].vel.sd; if (xtd) { pwr[n]=ptr->data[p].pwr.median; pwr_sd[n]=ptr->data[p].pwr.sd; wdt[n]=ptr->data[p].wdt.median; wdt_sd[n]=ptr->data[p].wdt.sd; } n++; } } TimeEpochToYMDHMS(ptr->ed_time,&yr,&mo,&dy,&hr,&mt,&sc); eyr=yr; emo=mo; edy=dy; ehr=hr; emt=mt; esc=sc; TimeEpochToYMDHMS(ptr->st_time,&yr,&mo,&dy,&hr,&mt,&sc); syr=yr; smo=mo; sdy=dy; shr=hr; smt=mt; ssc=sc; data=DataMapMake(); DataMapAddScalar(data,"start.year",DATASHORT,&syr); DataMapAddScalar(data,"start.month",DATASHORT,&smo); DataMapAddScalar(data,"start.day",DATASHORT,&sdy); DataMapAddScalar(data,"start.hour",DATASHORT,&shr); DataMapAddScalar(data,"start.minute",DATASHORT,&smt); DataMapAddScalar(data,"start.second",DATADOUBLE,&ssc); DataMapAddScalar(data,"end.year",DATASHORT,&eyr); DataMapAddScalar(data,"end.month",DATASHORT,&emo); DataMapAddScalar(data,"end.day",DATASHORT,&edy); DataMapAddScalar(data,"end.hour",DATASHORT,&ehr); DataMapAddScalar(data,"end.minute",DATASHORT,&emt); DataMapAddScalar(data,"end.second",DATADOUBLE,&esc); DataMapAddArray(data,"stid",DATASHORT,1,&stnum,stid); DataMapAddArray(data,"channel",DATASHORT,1,&stnum,chn); DataMapAddArray(data,"nvec",DATASHORT,1,&stnum,nvec); DataMapAddArray(data,"freq",DATAFLOAT,1,&stnum,freq); DataMapAddArray(data,"major.revision",DATASHORT,1,&stnum,major_rev); DataMapAddArray(data,"minor.revision",DATASHORT,1,&stnum,minor_rev); DataMapAddArray(data,"program.id",DATASHORT,1,&stnum,progid ); DataMapAddArray(data,"noise.mean",DATAFLOAT,1,&stnum,noise_mean); DataMapAddArray(data,"noise.sd",DATAFLOAT,1,&stnum,noise_sd); DataMapAddArray(data,"gsct",DATASHORT,1,&stnum ,gsct); DataMapAddArray(data,"v.min",DATAFLOAT,1,&stnum,v_min); DataMapAddArray(data,"v.max",DATAFLOAT,1,&stnum,v_max); DataMapAddArray(data,"p.min",DATAFLOAT,1,&stnum,p_min); DataMapAddArray(data,"p.max",DATAFLOAT,1,&stnum,p_max); DataMapAddArray(data,"w.min",DATAFLOAT,1,&stnum,w_min); DataMapAddArray(data,"w.max",DATAFLOAT,1,&stnum,w_max); DataMapAddArray(data,"ve.min",DATAFLOAT,1,&stnum,ve_min); DataMapAddArray(data,"ve.max",DATAFLOAT,1,&stnum,ve_max); if (npnt !=0) { DataMapAddArray(data,"vector.mlat",DATAFLOAT,1,&npnt,gmlat); DataMapAddArray(data,"vector.mlon",DATAFLOAT,1,&npnt,gmlon); DataMapAddArray(data,"vector.kvect",DATAFLOAT,1,&npnt,kvect); DataMapAddArray(data,"vector.stid",DATASHORT,1,&npnt,vstid); DataMapAddArray(data,"vector.channel",DATASHORT,1,&npnt,vchn); DataMapAddArray(data,"vector.index",DATAINT,1,&npnt,index); DataMapAddArray(data,"vector.vel.median",DATAFLOAT,1,&npnt,vlos); DataMapAddArray(data,"vector.vel.sd",DATAFLOAT,1,&npnt,vlos_sd); if (xtd) { DataMapAddArray(data,"vector.pwr.median",DATAFLOAT,1,&npnt,pwr); DataMapAddArray(data,"vector.pwr.sd",DATAFLOAT,1,&npnt,pwr_sd); DataMapAddArray(data,"vector.wdt.median",DATAFLOAT,1,&npnt,wdt); DataMapAddArray(data,"vector.wdt.sd",DATAFLOAT,1,&npnt,wdt_sd); } } if (fid !=-1) s=DataMapWrite(fid,data); else s=DataMapSize(data); DataMapFree(data); free(buf); return s; }
int main(int argc,char *argv[]) { FILE *fp; int state=0; double min[4]={35,3,10,0}; double max[4]={2000,50,1000,200}; int yr,mo,dy,hr,mt; double sc; int index=0,num=0; int mode=0,nbox=3; int n,r; fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } while(FitFreadRadarScan(fp,&state,&src[index],&prm,&fit,0,0,0) !=-1) { TimeEpochToYMDHMS(src[index].st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); FilterBound(15,&src[index],min,max); if (num>2) { FilterRadarScan(mode,nbox,index,src,&dst,15); for (n=0;n<dst.num;n++) { cfit.stid=dst.stid; cfit.time=dst.bm[n].time; cfit.bmnum=dst.bm[n].bm; cfit.cp=dst.bm[n].cpid; cfit.intt.sc=dst.bm[n].intt.sc; cfit.intt.us=dst.bm[n].intt.us; cfit.nave=dst.bm[n].nave; cfit.frang=dst.bm[n].frang; cfit.rsep=dst.bm[n].rsep; cfit.rxrise=dst.bm[n].rxrise; cfit.tfreq=dst.bm[n].freq; cfit.noise=dst.bm[n].noise; cfit.atten=dst.bm[n].atten; cfit.channel=dst.bm[n].channel; cfit.nrang=MAX_RANGE; if (n==0) cfit.scan=1; else cfit.scan=0; cfit.num=0; for (r=0;r<MAX_RANGE;r++) { if (dst.bm[n].sct[r]==0) continue; cfit.rng[cfit.num]=r; cfit.data[cfit.num].gsct=dst.bm[n].rng[r].gsct; cfit.data[cfit.num].p_0=dst.bm[n].rng[r].p_0; cfit.data[cfit.num].p_0_e=dst.bm[n].rng[r].p_0_e; cfit.data[cfit.num].v=dst.bm[n].rng[r].v; cfit.data[cfit.num].v_e=dst.bm[n].rng[r].v_e; cfit.data[cfit.num].p_l=dst.bm[n].rng[r].p_l; cfit.data[cfit.num].p_l_e=dst.bm[n].rng[r].p_l_e; cfit.data[cfit.num].w_l=dst.bm[n].rng[r].w_l; cfit.data[cfit.num].w_l_e=dst.bm[n].rng[r].w_l_e; cfit.num++; } } CFitFwrite(stdout,&cfit); } index++; if (index>2) index=0; num++; } fclose(fp); return 0; }
int main(int argc,char *argv[]) { int arg=0,farg; int yr,mo,dy,hr,mt,isc,usc; double sc; int st=0; FILE *fp; char *envstr; char *tmetxt=NULL,*dtetxt=NULL; double tval=0,dval=0; char *nlab[2]= {"","name:"}; char *slab[2]= {"","status:"}; char *olab[2]= {"","operator:"}; char *clab[2]= {"","code:"}; char *ilab[2]= {"","id:"}; char *hlab[2]= {"","location:"}; char *plab[2]= {"","pole:"}; unsigned char nflg=0; unsigned char sflg=0; unsigned char oflg=0; unsigned char cflg=0; unsigned char iflg=0; unsigned char hflg=0; unsigned char pflg=0; unsigned char lflg=0; unsigned char aflg=0; unsigned char stflg=0; unsigned char edflg=0; unsigned char vb=0; unsigned char help=0; unsigned char option=0; int status,c; char *tmp=NULL; char ststr[1024]; int stid[256]; int stcnt=0; char *nldstr="\n"; char *tdstr="\t"; char *dstr=NULL; OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); OptionAdd(&opt,"vb",'x',&vb); OptionAdd(&opt,"n",'x',&nflg); OptionAdd(&opt,"s",'x',&sflg); OptionAdd(&opt,"o",'x',&oflg); OptionAdd(&opt,"c",'x',&cflg); OptionAdd(&opt,"i",'x',&iflg); OptionAdd(&opt,"h",'x',&hflg); OptionAdd(&opt,"p",'x',&pflg); OptionAdd(&opt,"st",'x',&stflg); OptionAdd(&opt,"ed",'x',&edflg); OptionAdd(&opt,"l",'x',&lflg); OptionAdd(&opt,"a",'x',&aflg); OptionAdd(&opt,"t",'t',&tmetxt); OptionAdd(&opt,"d",'t',&dtetxt); OptionAdd(&opt,"delim",'t',&dstr); farg=OptionProcess(1,argc,argv,&opt,NULL); if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (arg==argc) { OptionPrintInfo(stdout,errstr); exit(-1); } if (tmetxt !=NULL) tval=strtime(tmetxt); if (dtetxt !=NULL) dval=strdate(dtetxt); tval+=dval; if (tval !=0) TimeEpochToYMDHMS(tval,&yr,&mo,&dy,&hr,&mt,&sc); else { TimeReadClock(&yr,&mo,&dy,&hr,&mt,&isc,&usc); sc=isc; tval=TimeYMDHMSToEpoch(yr,mo,dy,hr,mt,sc); } if (dstr==NULL) { if (lflg) dstr=tdstr; else dstr=nldstr; } envstr=getenv("SD_RADAR"); if (envstr==NULL) { fprintf(stderr,"Environment variable 'SD_RADAR' must be defined.\n"); exit(-1); } fp=fopen(envstr,"r"); if (fp==NULL) { fprintf(stderr,"Could not locate radar information file.\n"); exit(-1); } network=RadarLoad(fp); fclose(fp); if (network==NULL) { fprintf(stderr,"Failed to read radar information.\n"); exit(-1); } envstr=getenv("SD_HDWPATH"); if (envstr==NULL) { fprintf(stderr,"Environment variable 'SD_HDWPATH' must be defined.\n"); exit(-1); } RadarLoadHardware(envstr,network); for (arg=farg; arg<argc; arg++) { strcpy(ststr,argv[arg]); tmp=strtok(ststr,","); do { if (isdigit(tmp[0])) stid[stcnt]=atoi(tmp); else stid[stcnt]=RadarGetID(network,tmp); if (stid[stcnt] !=-1) stcnt++; } while ((tmp=strtok(NULL,",")) !=NULL); } if (stcnt==0) { stcnt=network->rnum; for (st=0; st<stcnt; st++) stid[st]=network->radar[st].id; } for (st=0; st<stcnt; st++) { status=RadarGetStatus(network,stid[st]); /* if ((aflg) && (status !=1)) continue; */ radar=RadarGetRadar(network,stid[st]); if (radar==NULL) continue; if (aflg) { if (radar->st_time==-1) continue; if (tval<radar->st_time) continue; if ((radar->ed_time !=-1) && (tval>radar->ed_time)) continue; } if (iflg==1) fprintf(stdout,"%s%d%s",ilab[vb],stid[st],dstr); if (cflg==1) { fprintf(stdout,"%s",clab[vb]); for (c=0; (c<RadarGetCodeNum(network,stid[st])); c++) if (c !=0) fprintf(stdout,",%s",RadarGetCode(network,stid[st],c)); else fprintf(stdout,"%s",RadarGetCode(network,stid[st],c)); fprintf(stdout,"%s",dstr); } if (nflg==1) fprintf(stdout,"%s\"%s\"%s",nlab[vb],RadarGetName(network,stid[st]), dstr); if (sflg==1) { fprintf(stdout,"%s",slab[vb]); if (status==1) fprintf(stdout,"active"); else if (status==0) fprintf(stdout,"under construction"); else if (status==-1) fprintf(stdout,"defunct"); fprintf(stdout,"%s",dstr); } if (oflg==1) fprintf(stdout,"%s\"%s\"%s",olab[vb], RadarGetOperator(network,stid[st]),dstr); if (stflg) { if (radar->st_time !=-1) { TimeEpochToYMDHMS(radar->st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d%.2d%.2d%s",yr,mo,dy,dstr); } else fprintf(stdout,"-%s",dstr); } if (edflg) { if (radar->ed_time !=-1) { TimeEpochToYMDHMS(radar->ed_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d%.2d%.2d%s",yr,mo,dy,dstr); } else fprintf(stdout,"-%s",dstr); } TimeEpochToYMDHMS(tval,&yr,&mo,&dy,&hr,&mt,&sc); site=RadarYMDHMSGetSite(RadarGetRadar(network,stid[st]), yr,mo,dy,hr,mt,(int) sc); if (hflg) { if (site !=NULL) fprintf(stdout,"%s%g,%g,%g,%g%s",hlab[vb], site->geolat,site->geolon, site->alt, site->boresite,dstr); else fprintf(stdout,"unknown%s",dstr); } if (pflg) { if (site !=NULL) { if (site->geolat>0) fprintf(stdout,"%snorth",plab[vb]); else fprintf(stdout,"%ssouth",plab[vb]); } else if (radar->site !=NULL) { if (radar->site[0].geolat>0) fprintf(stdout,"%snorth",plab[vb]); else fprintf(stdout,"%ssouth",plab[vb]); } else fprintf(stdout,"unknown"); fprintf(stdout,"%s",dstr); } if (lflg) fprintf(stdout,"\n"); } return 0; }
int32 OldCnvMapIDLDecode(int argc,char *argv[]) { int n; int yr,mo,dy,hr,mt; double sc; unsigned char *ptr; struct CnvMapIDLPrm *prm; struct GridIDLStVec *stvec; struct GridIDLGVec *gvec; struct CnvMapData *map; struct GridData *grd; struct GridIDLGVec *mvec; double *coef; struct CnvMapIDLBnd *bnd; char tmp[257]; memset(tmp,0,257); ptr=((IDL_STRING *) argv[0])->s; grd=(struct GridData *) (ptr); ptr+=sizeof(struct GridData); grd->sdata=(struct GridSVec *) (ptr); ptr+=grd->stnum*sizeof(struct GridSVec); grd->data=(struct GridGVec *) (ptr); ptr+=grd->vcnum*sizeof(struct GridGVec); map=(struct CnvMapData *) (ptr); ptr+=sizeof(struct CnvMapData); map->model=(struct GridGVec *) (ptr); ptr+=map->num_model*sizeof(struct GridGVec); map->coef=(double *) (ptr); ptr+=map->num_coef*4*sizeof(double); map->bnd_lat=(double *) (ptr); ptr+=map->num_bnd*sizeof(double); map->bnd_lon=(double *) (ptr); prm=(struct CnvMapIDLPrm *) argv[1]; stvec=(struct GridIDLStVec *) argv[2]; gvec=(struct GridIDLGVec *) argv[3]; mvec=(struct GridIDLGVec *) argv[4]; coef=(double *) argv[5]; bnd=(struct CnvMapIDLBnd *) argv[6]; prm->stnum=grd->stnum; prm->vcnum=grd->vcnum; prm->xtd=grd->xtd; TimeEpochToYMDHMS(grd->st_time,&yr,&mo, &dy,&hr,&mt, &sc); prm->start.yr=yr; prm->start.mo=mo; prm->start.dy=dy; prm->start.hr=hr; prm->start.mt=mt; prm->start.sc=sc; TimeEpochToYMDHMS(grd->ed_time,&yr,&mo, &dy,&hr,&mt, &sc); prm->end.yr=yr; prm->end.mo=mo; prm->end.dy=dy; prm->end.hr=hr; prm->end.mt=mt; prm->end.sc=sc; prm->major_rev=map->major_rev; prm->minor_rev=map->minor_rev; IDL_StrDelete(&prm->source,1); if (map->source !=NULL) { strncpy(tmp,map->source,256); IDL_StrStore(&prm->source,tmp); } prm->modnum=map->num_model; prm->doping_level=map->doping_level; prm->model_wt=map->model_wt; prm->error_wt=map->error_wt; prm->imf_flag=map->imf_flag; prm->imf_delay=map->imf_delay; prm->Bx=map->Bx; prm->By=map->By; prm->Bz=map->Bz; IDL_StrDelete(&prm->model[0],1); if (map->imf_model[0] !=NULL) { strncpy(tmp,map->imf_model[0],64); IDL_StrStore(&prm->model[0],tmp); } IDL_StrDelete(&prm->model[1],1); if (map->imf_model[1] !=NULL) { strncpy(tmp,map->imf_model[1],64); IDL_StrStore(&prm->model[1],tmp); } prm->hemisphere=map->hemisphere; prm->fit_order=map->fit_order; prm->latmin=map->latmin; prm->coefnum=map->num_coef; prm->chi_sqr=map->chi_sqr; prm->chi_sqr_dat=map->chi_sqr_dat; prm->rms_err=map->rms_err; prm->lon_shft=map->lon_shft; prm->lat_shft=map->lat_shft; prm->mlt.st=map->mlt.start; prm->mlt.ed=map->mlt.end; prm->mlt.av=map->mlt.av; prm->pot_drop=map->pot_drop; prm->pot_drop_err=map->pot_drop_err; prm->pot_max=map->pot_max; prm->pot_max_err=map->pot_max_err; prm->pot_min=map->pot_min; prm->pot_min_err=map->pot_min_err; prm->bndnum=map->num_bnd; for (n=0;n<grd->stnum;n++) { stvec[n].stid=grd->sdata[n].st_id; stvec[n].chn=grd->sdata[n].chn; stvec[n].npnt=grd->sdata[n].npnt; stvec[n].freq=grd->sdata[n].freq0; stvec[n].major_revision=grd->sdata[n].major_revision; stvec[n].minor_revision=grd->sdata[n].minor_revision; stvec[n].prog_id=grd->sdata[n].prog_id; stvec[n].gsct=grd->sdata[n].gsct; stvec[n].noise.mean=grd->sdata[n].noise.mean; stvec[n].noise.sd=grd->sdata[n].noise.sd; stvec[n].vel.min=grd->sdata[n].vel.min; stvec[n].vel.max=grd->sdata[n].vel.max; stvec[n].pwr.min=grd->sdata[n].pwr.min; stvec[n].pwr.max=grd->sdata[n].pwr.max; stvec[n].wdt.min=grd->sdata[n].wdt.min; stvec[n].wdt.max=grd->sdata[n].wdt.max; stvec[n].verr.min=grd->sdata[n].verr.min; stvec[n].verr.max=grd->sdata[n].verr.max; } for (n=0;n<grd->vcnum;n++) { gvec[n].stid=grd->data[n].st_id; gvec[n].chn=grd->data[n].chn; gvec[n].index=grd->data[n].index; gvec[n].mlat=grd->data[n].mlat; gvec[n].mlon=grd->data[n].mlon; gvec[n].azm=grd->data[n].azm; gvec[n].vel.median=grd->data[n].vel.median; gvec[n].vel.sd=grd->data[n].vel.sd; if (grd->xtd !=0) { gvec[n].pwr.median=grd->data[n].pwr.median; gvec[n].pwr.sd=grd->data[n].pwr.sd; gvec[n].wdt.median=grd->data[n].wdt.median; gvec[n].wdt.sd=grd->data[n].wdt.sd; } } for (n=0;n<map->num_model;n++) { mvec[n].mlat=map->model[n].mlat; mvec[n].mlon=map->model[n].mlon; mvec[n].azm=map->model[n].azm; mvec[n].vel.median=map->model[n].vel.median; } for (n=0;n<map->num_coef;n++) { coef[n]=map->coef[4*n]; coef[map->num_coef+n]=map->coef[4*n+1]; coef[2*map->num_coef+n]=map->coef[4*n+2]; coef[3*map->num_coef+n]=map->coef[4*n+3]; } for (n=0;n<map->num_bnd;n++) { bnd[n].lat=map->bnd_lat[n]; bnd[n].lon=map->bnd_lon[n]; } return 0; }
int main(int argc,char *argv[]) { char *envstr; FILE *fp; int s; int state=0; int yr,mo,dy,hr,mt; double sc; int iflg=0; int avlen=120; unsigned char xtd=0; char wrtlog[256]; int pval=0; double min[4]={35,3,10,0}; double max[4]={2000,50,1000,200}; int tflg=0; double alt=300.0; grid.st_time=-1; grid.status=0; grid.pnt=NULL; grid.gsct=0; grid.chn=0; envstr=getenv("SD_RADAR"); if (envstr==NULL) { fprintf(stderr,"Environment variable 'SD_RADAR' must be defined.\n"); exit(-1); } fp=fopen(envstr,"r"); if (fp==NULL) { fprintf(stderr,"Could not locate radar information file.\n"); exit(-1); } network=RadarLoad(fp); fclose(fp); if (network==NULL) { fprintf(stderr,"Failed to read radar information.\n"); exit(-1); } envstr=getenv("SD_HDWPATH"); if (envstr==NULL) { fprintf(stderr,"Environment variable 'SD_HDWPATH' must be defined.\n"); exit(-1); } RadarLoadHardware(envstr,network); fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } while(FitFreadRadarScan(fp,&state,&scn,&prm,&fit,0,0,0) !=-1) { TimeEpochToYMDHMS(scn.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stderr,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d\n", yr,mo,dy,hr,mt,(int) sc); FilterBoundType(&scn,tflg); FilterBound(pval,&scn,min,max); if (site==NULL) { radar=RadarGetRadar(network,scn.stid); if (radar==NULL) { fprintf(stderr,"Failed to get radar information.\n"); exit(-1); } site=RadarYMDHMSGetSite(radar,prm.time.yr,prm.time.mo, prm.time.dy,prm.time.hr,prm.time.mt, prm.time.sc); } s=GridTableTest(&grid,&scn,avlen); if (s==1) { GridTableFwrite(stdout,&grid,wrtlog,xtd); } if (scn.num>=16) GridTableMap(&grid,&scn,site,avlen,iflg,alt); } fclose(fp); return 0; }
struct file_list *locate_files(char *fpath,char *prefix, double stime,double etime) { char filename[1024]; char tmp[256]; char dir[256]; char fname[256]; char ofname[256]; char *flist[4096]; int fcnt=0; int status; int dyval; struct dirent **dlist=NULL; int yr,mo,dy,hr,mt; double sc; int m; int state=0; int syr,eyr; int sdyval,edyval; struct file_list *ptr; ptr=malloc(sizeof(struct file_list)); ptr->cnt=0; ptr->fname=NULL; ofname[0]=0; /* The yearc check should look one month either side of the desired period to make sure that we catch all possible files that might contain the requested period, even if they span directories. */ TimeEpochToYMDHMS(stime-ONE_MONTH,&syr,&mo,&dy,&hr,&mt,&sc); TimeEpochToYMDHMS(etime+ONE_MONTH,&eyr,&mo,&dy,&hr,&mt,&sc); TimeEpochToYMDHMS(stime,&yr,&mo,&dy,&hr,&mt,&sc); sdyval=yr*10000+mo*100+dy; TimeEpochToYMDHMS(etime,&yr,&mo,&dy,&hr,&mt,&sc); edyval=yr*10000+mo*100+dy; for (yr=syr;yr<=eyr;yr++) { sprintf(dir,"%s/%.4d",fpath,yr); status=scandir(dir,&dlist,dsel,alphasort); if (status<=0) continue; /* now get only the most recent version numbers of the files */ fcnt=0; for (m=0;m<status;m++) { if ((prefix !=NULL) && (infname(dlist[m]->d_name,prefix) ==0)) continue; if (fcnt==0) { flist[fcnt]=dlist[m]->d_name; fcnt++; } else { strcpy(tmp,dlist[m]->d_name); strcpy(tmp+128,flist[fcnt-1]); tmp[18]=0; tmp[128+18]=0; if (strcmp(tmp,tmp+128)==0) flist[fcnt-1]=dlist[m]->d_name; else { flist[fcnt]=dlist[m]->d_name; fcnt++; } } } for (m=0;m<fcnt;m++) { strcpy(tmp,flist[m]); strcpy(fname,flist[m]); tmp[18]=0; dyval=atoi(tmp+10); if ((dyval>=sdyval) && (state==0)) { if (ofname[0] !=0) { sprintf(filename,"%s/%s",dir,ofname); status=test_file_epoch(filename,stime,etime); if (status==1) { if (ptr->fname==NULL) ptr->fname=malloc(sizeof(char *)); else ptr->fname=realloc(ptr->fname, (ptr->cnt+1)*sizeof(char *)); ptr->fname[ptr->cnt]=malloc(strlen(filename)+1); strcpy(ptr->fname[ptr->cnt],filename); ptr->cnt++; } } state=1; } if ((state==1) && (dyval<=edyval)) { sprintf(filename,"%s/%s",dir,fname); status=test_file_epoch(filename,stime,etime); if (status==1) { if (ptr->fname==NULL) ptr->fname=malloc(sizeof(char *)); else ptr->fname=realloc(ptr->fname, (ptr->cnt+1)*sizeof(char *)); ptr->fname[ptr->cnt]=malloc(strlen(filename)+1); strcpy(ptr->fname[ptr->cnt],filename); ptr->cnt++; } } else if (state==1) state=2; strcpy(ofname,fname); } } return ptr; }
int main (int argc,char *argv[]) { int arg=0; int status=0; double atime; char *stmestr=NULL; char *etmestr=NULL; char *sdtestr=NULL; char *edtestr=NULL; char *exstr=NULL; double stime=-1; double etime=-1; double extime=0; double sdate=-1; double edate=-1; int yr,mo,dy,hr,mt; double sc; unsigned char vb=0; unsigned char help=0; unsigned char option=0; FILE *fp=NULL; int n; prm=RadarParmMake(); iq=IQMake(); OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); OptionAdd(&opt,"vb",'x',&vb); OptionAdd(&opt,"st",'t',&stmestr); OptionAdd(&opt,"et",'t',&etmestr); OptionAdd(&opt,"sd",'t',&sdtestr); OptionAdd(&opt,"ed",'t',&edtestr); OptionAdd(&opt,"ex",'t',&exstr); arg=OptionProcess(1,argc,argv,&opt,NULL); if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (exstr !=NULL) extime=strtime(exstr); if (stmestr !=NULL) stime=strtime(stmestr); if (etmestr !=NULL) etime=strtime(etmestr); if (sdtestr !=NULL) sdate=strdate(sdtestr); if (edtestr !=NULL) edate=strdate(edtestr); if ((argc-arg)>1) { fp=fopen(argv[arg+1],"r"); if (fp==NULL) { fprintf(stderr,"Index not found.\n"); exit(-1); } inx=IQIndexFload(fp); fclose(fp); if (inx==NULL) { fprintf(stderr,"Error loading index.\n"); exit(-1); } } if (arg==argc) fp=stdin; else fp=fopen(argv[arg],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } if (IQFread(fp,prm,iq,&badtr,&samples)==-1) { fprintf(stderr,"Error reading file\n"); exit(-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); /* skip here */ if ((stime !=-1) || (sdate !=-1)) { /* we must skip the start of the files */ int yr,mo,dy,hr,mt; double sc; 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); status=IQFseek(fp,yr,mo,dy,hr,mt,sc,NULL,inx); if (status ==-1) { fprintf(stderr,"File does not contain the requested interval.\n"); exit(-1); } if (IQFread(fp,prm,iq,&badtr,&samples)==-1) { fprintf(stderr,"Error reading file\n"); exit(-1); } } else stime=atime; if (etime !=-1) { if (edate==-1) etime+=atime - ( (int) atime % (24*3600)); else etime+=edate; } if (extime !=0) etime=stime+extime; do { fprintf(stderr,"%s\n",prm->origin.time); fprintf(stderr,"%s\n",prm->origin.command); fprintf(stderr,"%s\n",prm->combf); fprintf(stderr,"%d:",prm->mppul); for (n=0;n<prm->mppul;n++) fprintf(stderr,"%d ",prm->pulse[n]); fprintf(stderr,"\n"); fprintf(stderr,"%d\n",prm->mplgs); for (n=0;n<=prm->mplgs;n++) fprintf(stderr,"%d,%d ", prm->lag[0][n],prm->lag[1][n]); fprintf(stderr,"\n"); IQFwrite(stdout,prm,iq,badtr,samples); 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); TimeEpochToYMDHMS(atime,&yr,&mo,&dy,&hr,&mt,&sc); if (vb==1) fprintf(stderr,"%d-%d-%d %d:%d:%d\n",yr,mo,dy,hr,mt,(int) sc); if ((etime !=-1) && (atime>=etime)) break; status=IQFread(fp,prm,iq,&badtr,&samples); } while (status !=-1); if (fp !=stdin) fclose(fp); return 0; }
int main(int argc,char *argv[]) { FILE *fp; struct RfileIndex *inx=NULL; int yr=2005,mo=3,dy=31,hr=10,mt=30; double sc=0,atme; int s; if (argc>2) { fp=fopen(argv[2],"r"); if (fp==NULL) { fprintf(stderr,"Index not found.\n"); exit(-1); } inx=RfileLoadIndex(fp); fclose(fp); if (inx==NULL) { fprintf(stderr,"Error loading index.\n"); exit(-1); } } fp=fopen(argv[1],"r"); if (fp==NULL) { fprintf(stderr,"File not found.\n"); exit(-1); } s=OldCnvMapFseek(fp,yr,mo,dy,hr,mt,(int) sc,inx,&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(OldCnvMapFread(fp,&map,&grd) !=-1) { TimeEpochToYMDHMS(map.st_time,&yr,&mo,&dy,&hr,&mt,&sc); fprintf(stdout,"%.4d-%.2d-%.2d %.2d:%.2d:%.2d pnts=%d\n", yr,mo,dy,hr,mt,(int) sc,grd.vcnum); } fclose(fp); return 0; }
int main(int argc,char *argv[]) { #ifdef _XLIB_ int xdf=0; int xd=0; struct XwinDisplay *dp; struct XwinWindow *win; char *display_name=NULL; char *wname="fov_plot"; int xdoff=-1; int ydoff=-1; #endif struct FrameBuffer *img=NULL; struct PostScript *psdata=NULL; FILE *fontfp=NULL; char *fntdbfname=NULL; struct FrameBufferFontDB *fontdb=NULL; unsigned int bgcol; unsigned int txtcol; int arg; char *envstr=NULL; char *cfname=NULL; FILE *fp; float wdt=540,hgt=540; float pad=0; char *fontname=NULL; float fontsize=10.0; char *dfontname="Helvetica"; float width=0.5; struct Plot *plot=NULL; struct Splot *splot=NULL; float xpoff=40,ypoff=40; unsigned char psflg=0; unsigned char xmlflg=0; unsigned char ppmflg=0; unsigned char ppmxflg=0; unsigned char pngflg=0; unsigned char gflg=0; unsigned char pflg=0; unsigned char help=0; unsigned char option=0; char *bgcol_txt=NULL; char *txtcol_txt=NULL; unsigned char sqflg=0; MapTFunction tfunc; unsigned char flip=0; unsigned char gvp=0; unsigned char ortho=0; unsigned char stereo=0; unsigned char cylind=0; float lat=90,lon=0; float latmin=50.0; float sf=1.0; float alt=0.0; unsigned char magflg=0; unsigned char rotflg=0; unsigned char mapflg=0; unsigned char fmapflg=0; unsigned char bndflg=0; unsigned char grdflg=0; unsigned char tmkflg=0; unsigned char tlblflg=0; unsigned char ofovflg=0; unsigned char fofovflg=0; unsigned char cfovflg=0; unsigned char fcfovflg=0; unsigned char fovflg=0; unsigned char ffovflg=0; unsigned char grdontop=0; unsigned char dotflg=0; int tmtick=3; unsigned char lstflg=0; unsigned char trmflg=0; unsigned char ftrmflg=0; char *grdcol_txt=NULL; char *cstcol_txt=NULL; char *bndcol_txt=NULL; char *lndcol_txt=NULL; char *seacol_txt=NULL; char *trmcol_txt=NULL; char *ftrmcol_txt=NULL; char *tmkcol_txt=NULL; char *ofovcol_txt=NULL; char *fofovcol_txt=NULL; char *fovcol_txt=NULL; char *ffovcol_txt=NULL; char *cfovcol_txt=NULL; char *fcfovcol_txt=NULL; unsigned int grdcol; unsigned int cstcol; unsigned int bndcol; unsigned int lndcol; unsigned int seacol; unsigned int trmcol; unsigned int ftrmcol; unsigned int tmkcol; unsigned int ofovcol; unsigned int fofovcol; unsigned int fovcol; unsigned int ffovcol; unsigned int cfovcol; unsigned int fcfovcol; FILE *mapfp; float marg[4]; int i; char *tmetxt=NULL; char *dtetxt=NULL; double tval=-1; double dval=-1; int yr,mo,dy,hr,mt; double sc; int yrsec; float tme_shft; double LsoT,LT,Hangle,dec,eqt; float dotr=2; int stid=-1; char *ststr=NULL; int stnum=0; char tsfx[16]; envstr=getenv("MAPDATA"); mapfp=fopen(envstr,"r"); map=MapFread(mapfp); fclose(mapfp); envstr=getenv("BNDDATA"); mapfp=fopen(envstr,"r"); bnd=MapBndFread(mapfp); fclose(mapfp); envstr=getenv("SD_RADAR"); if (envstr==NULL) { fprintf(stderr,"Environment variable 'SD_RADAR' must be defined.\n"); exit(-1); } fp=fopen(envstr,"r"); if (fp==NULL) { fprintf(stderr,"Could not locate radar information file.\n"); exit(-1); } network=RadarLoad(fp); fclose(fp); if (network==NULL) { fprintf(stderr,"Failed to read radar information.\n"); exit(-1); } envstr=getenv("SD_HDWPATH"); if (envstr==NULL) { fprintf(stderr,"Environment variable 'SD_HDWPATH' must be defined.\n"); exit(-1); } RadarLoadHardware(envstr,network); bgcol=PlotColor(0xff,0xff,0xff,0xff); txtcol=PlotColor(0x00,0x00,0x00,0xff); grdcol=PlotColor(0x20,0x40,0x60,0xff); cstcol=PlotColor(0xa0,0xa0,0xa0,0xff); bndcol=PlotColor(0x80,0x80,0x80,0xff); lndcol=PlotColor(0xff,0xff,0xf0,0xff); seacol=PlotColor(0xe0,0xf0,0xff,0xff); tmkcol=PlotColor(0x00,0x00,0x00,0xff); ofovcol=PlotColor(0x00,0x00,0x00,0xff); fofovcol=PlotColor(0xff,0xff,0xff,0xff); fovcol=PlotColor(0x00,0x00,0x00,0xff); ffovcol=PlotColor(0xc0,0x00,0x00,0xff); trmcol=PlotColor(0x80,0x80,0x80,0xff); ftrmcol=PlotColor(0x80,0x80,0x80,0xff); cfovcol=PlotColor(0x00,0x00,0x00,0xff); fcfovcol=PlotColor(0xff,0xff,0xff,0xff); OptionAdd(&opt,"-help",'x',&help); OptionAdd(&opt,"-option",'x',&option); OptionAdd(&opt,"cf",'t',&cfname); #ifdef _XLIB_ OptionAdd(&opt,"x",'x',&xd); OptionAdd(&opt,"display",'t',&display_name); OptionAdd(&opt,"xoff",'i',&xdoff); OptionAdd(&opt,"yoff",'i',&ydoff); #endif OptionAdd(&opt,"ppm",'x',&ppmflg); OptionAdd(&opt,"ppmx",'x',&ppmxflg); OptionAdd(&opt,"xml",'x',&xmlflg); OptionAdd(&opt,"png",'x',&pngflg); OptionAdd(&opt,"ps",'x',&psflg); OptionAdd(&opt,"xp",'f',&xpoff); OptionAdd(&opt,"yp",'f',&ypoff); OptionAdd(&opt,"wdt",'f',&wdt); OptionAdd(&opt,"hgt",'f',&hgt); OptionAdd(&opt,"pad",'f',&pad); OptionAdd(&opt,"bgcol",'t',&bgcol_txt); OptionAdd(&opt,"txtcol",'t',&txtcol_txt); OptionAdd(&opt,"square",'x',&sqflg); OptionAdd(&opt,"ortho",'x',&ortho); OptionAdd(&opt,"stereo",'x',&stereo); OptionAdd(&opt,"gvp",'x',&gvp); OptionAdd(&opt,"lat",'f',&lat); OptionAdd(&opt,"lon",'f',&lon); OptionAdd(&opt,"latmin",'f',&latmin); OptionAdd(&opt,"sf",'f',&sf); OptionAdd(&opt,"mag",'x',&magflg); OptionAdd(&opt,"rotate",'x',&rotflg); OptionAdd(&opt,"alt",'f',&alt); OptionAdd(&opt,"flip",'x',&flip); OptionAdd(&opt,"coast",'x',&mapflg); OptionAdd(&opt,"fcoast",'x',&fmapflg); OptionAdd(&opt,"bnd",'x',&bndflg); OptionAdd(&opt,"grd",'x',&grdflg); OptionAdd(&opt,"tmk",'x',&tmkflg); OptionAdd(&opt,"grdontop",'x',&grdontop); OptionAdd(&opt,"fov",'x',&fovflg); OptionAdd(&opt,"ffov",'x',&ffovflg); OptionAdd(&opt,"ofov",'x',&ofovflg); OptionAdd(&opt,"fofov",'x',&fofovflg); OptionAdd(&opt,"cfov",'x',&cfovflg); OptionAdd(&opt,"fcfov",'x',&fcfovflg); OptionAdd(&opt,"tmtick",'i',&tmtick); OptionAdd(&opt,"lst",'x',&lstflg); OptionAdd(&opt,"term",'x',&trmflg); OptionAdd(&opt,"fterm",'x',&ftrmflg); OptionAdd(&opt,"grdcol",'t',&grdcol_txt); OptionAdd(&opt,"cstcol",'t',&cstcol_txt); OptionAdd(&opt,"bndcol",'t',&bndcol_txt); OptionAdd(&opt,"lndcol",'t',&lndcol_txt); OptionAdd(&opt,"seacol",'t',&seacol_txt); OptionAdd(&opt,"trmcol",'t',&trmcol_txt); OptionAdd(&opt,"tmkcol",'t',&tmkcol_txt); OptionAdd(&opt,"fovcol",'t',&fovcol_txt); OptionAdd(&opt,"ffovcol",'t',&ffovcol_txt); OptionAdd(&opt,"ofovcol",'t',&ofovcol_txt); OptionAdd(&opt,"fofovcol",'t',&fofovcol_txt); OptionAdd(&opt,"cfovcol",'t',&cfovcol_txt); OptionAdd(&opt,"fcfovcol",'t',&fcfovcol_txt); OptionAdd(&opt,"st",'t',&ststr); OptionAdd(&opt,"t",'t',&tmetxt); OptionAdd(&opt,"d",'t',&dtetxt); OptionAdd(&opt,"tmlbl",'x',&tlblflg); OptionAdd(&opt,"fontname",'t',&fontname); OptionAdd(&opt,"fontsize",'f',&fontsize); OptionAdd(&opt,"lnewdt",'f',&width); OptionAdd(&opt,"dotr",'f',&dotr); OptionAdd(&opt,"dot",'x',&dotflg); arg=OptionProcess(1,argc,argv,&opt,NULL); if (cfname !=NULL) { /* load the configuration file */ int farg; do { fp=fopen(cfname,"r"); if (fp==NULL) break; free(cfname); cfname=NULL; optf=OptionProcessFile(fp); if (optf !=NULL) { farg=OptionProcess(0,optf->argc,optf->argv,&opt,NULL); OptionFreeFile(optf); } fclose(fp); } while (cfname !=NULL); } if (help==1) { OptionPrintInfo(stdout,hlpstr); exit(0); } if (option==1) { OptionDump(stdout,&opt); exit(0); } if (tmetxt !=NULL) tval=strtime(tmetxt); if (dtetxt !=NULL) dval=strdate(dtetxt); tval+=dval; TimeEpochToYMDHMS(tval,&yr,&mo,&dy,&hr,&mt,&sc); yrsec=TimeYMDHMSToYrsec(yr,mo,dy,hr,mt,sc); if (magflg) { MapModify(map,AACGMtransform,NULL); MapModify(bnd,AACGMtransform,NULL); } fov=make_fov(tval,network,alt); if (magflg) MapModify(fov,AACGMtransform,NULL); if (tmtick<1) tmtick=1; if (tmtick>6) tmtick=6; if ((ortho==0) && (stereo==0)) cylind=1; if (grdflg) grd=make_grid(15,10,cylind); if (tmkflg) tmk=make_grid(30*tmtick,10,cylind); if ((lat<0) && (latmin>0)) latmin=-latmin; if ((lat>0) && (latmin<0)) latmin=-latmin; if (trmflg || ftrmflg) { if ((cylind) || (ortho) | (gvp)) trm=SZATerminator(yr,mo,dy,hr,mt,sc,0,magflg, 1.0,90.0); else if (lat>0) trm=SZATerminator(yr,mo,dy,hr,mt,sc,1,magflg, 1.0,90.0); else trm=SZATerminator(yr,mo,dy,hr,mt,sc,-1,magflg,1.0,90.0); } marg[0]=lat; marg[1]=lon; tfunc=MapCylindrical; if (ortho) tfunc=MapOrthographic; if (stereo) tfunc=MapStereographic; if (gvp) tfunc=MapGeneralVerticalPerspective; if ((ortho) || (gvp)) marg[2]=sf; else if (stereo) marg[2]=1.25*0.5*sf*90.0/(90-fabs(latmin)); else marg[2]=1; marg[3]=flip; strcpy(tsfx,"LT"); if (magflg) strcpy(tsfx,"MLT"); else if (lstflg) strcpy(tsfx,"LST"); dec=SZASolarDec(yr,mo,dy,hr,mt,sc); eqt=SZAEqOfTime(yr,mo,dy,hr,mt,sc); if (magflg) tme_shft=-MLTConvertYrsec(yr,yrsec,0.0)*15.0; else { if (lstflg) { LsoT=(hr*3600+mt*60+sc)+eqt; Hangle=15*(LsoT/3600); tme_shft=-Hangle; } else { LT=(hr*3600+mt*60+sc); Hangle=15*(LT/3600); tme_shft=-Hangle; } } if (lat<0) tme_shft+=180.0; if (rotflg) marg[1]=lon+tme_shft; if ((cylind) || (sqflg)) clip=MapSquareClip(); else clip=MapCircleClip(10); if (mapflg || fmapflg) { nmap=MapTransform(map,2*sizeof(float),PolygonXYbbox, tfunc,marg); if (cylind) nmap=wrap(nmap); pmap=PolygonClip(clip,nmap); } if (bndflg) { nbnd=MapTransform(bnd,2*sizeof(float),PolygonXYbbox, tfunc,marg); if (cylind) nbnd=wrap(nbnd); pbnd=PolygonClip(clip,nbnd); } if (grdflg) { ngrd=MapTransform(grd,2*sizeof(float),PolygonXYbbox, tfunc,marg); if (cylind) ngrd=wrap(ngrd); pgrd=PolygonClip(clip,ngrd); } if (trmflg || ftrmflg) { ntrm=MapTransform(trm,2*sizeof(float),PolygonXYbbox, tfunc,marg); if (cylind) ntrm=wrap(ntrm); ptrm=PolygonClip(clip,ntrm); } nfov=MapTransform(fov,2*sizeof(float),PolygonXYbbox, tfunc,marg); if (cylind) nfov=wrap(nfov); pfov=PolygonClip(clip,nfov); if (tmkflg) { float tmp; tmp=marg[1]; if (rotflg) marg[1]=0; else marg[1]=lon-tme_shft; ntmk=MapTransform(tmk,2*sizeof(float),PolygonXYbbox, tfunc,marg); ptmk=PolygonClip(clip,ntmk); marg[1]=tmp; } if (bgcol_txt !=NULL) bgcol=PlotColorStringRGBA(bgcol_txt); if (txtcol_txt !=NULL) txtcol=PlotColorStringRGBA(txtcol_txt); if (grdcol_txt !=NULL) grdcol=PlotColorStringRGBA(grdcol_txt); if (cstcol_txt !=NULL) cstcol=PlotColorStringRGBA(cstcol_txt); if (bndcol_txt !=NULL) bndcol=PlotColorStringRGBA(bndcol_txt); if (lndcol_txt !=NULL) lndcol=PlotColorStringRGBA(lndcol_txt); if (seacol_txt !=NULL) seacol=PlotColorStringRGBA(seacol_txt); if (trmcol_txt !=NULL) trmcol=PlotColorStringRGBA(trmcol_txt); if (ftrmcol_txt !=NULL) ftrmcol=PlotColorStringRGBA(ftrmcol_txt); if (tmkcol_txt !=NULL) tmkcol=PlotColorStringRGBA(tmkcol_txt); if (fovcol_txt !=NULL) fovcol=PlotColorStringRGBA(fovcol_txt); if (ofovcol_txt !=NULL) ofovcol=PlotColorStringRGBA(ofovcol_txt); if (cfovcol_txt !=NULL) cfovcol=PlotColorStringRGBA(cfovcol_txt); if (ffovcol_txt !=NULL) ffovcol=PlotColorStringRGBA(ffovcol_txt); if (fofovcol_txt !=NULL) fofovcol=PlotColorStringRGBA(fofovcol_txt); if (fcfovcol_txt !=NULL) fcfovcol=PlotColorStringRGBA(fcfovcol_txt); if ((wdt==0) || (hgt==0)) { fprintf(stderr,"invalid plot size.\n"); exit(-1); } if (tlblflg) pad=10+fontsize; if (fontname==NULL) fontname=dfontname; fntdbfname=getenv("FONTDB"); fontfp=fopen(fntdbfname,"r"); if (fontfp !=NULL) { fontdb=FrameBufferFontDBLoad(fontfp); fclose(fontfp); } if (fontdb==NULL) { fprintf(stderr,"Could not load fonts.\n"); exit(-1); } if (ststr !=NULL) stid=RadarGetID(network,ststr); for (stnum=0;stnum<network->rnum;stnum++) if (stid==network->radar[stnum].id) break; if (stnum==network->rnum) stnum=0; /* now determine our output type */ if (psflg) pflg=1; if (xmlflg) gflg=1; if (ppmflg) gflg=1; if (ppmxflg) gflg=1; if (pngflg) gflg=1; #ifdef _XLIB_ if (xd !=0) { pflg=0; gflg=1; } #endif if (pflg) gflg=0; if ((!gflg) && (!pflg)) pflg=1; plot=PlotMake(); splot=SplotMake(); SplotSetPlot(plot,splot); if (gflg) SplotSetFrameBuffer(splot,&img,fontdb,NULL,NULL); if (pflg) { psdata=PostScriptMake(); PostScriptSetText(psdata,stream,stdout); SplotSetPostScript(splot,psdata,0,xpoff,ypoff); } PlotDocumentStart(plot,"fov_plot",NULL,wdt,hgt,24); PlotPlotStart(plot,"fov_plot",wdt,hgt,24); PlotRectangle(plot,NULL,0,0,wdt,hgt,1,bgcol,0x0f,0,NULL); if (fmapflg) { if ((cylind) || (sqflg)) PlotRectangle(plot,NULL,pad,pad, wdt-2*pad,hgt-2*pad, 1,seacol,0x0f,0,NULL); PlotEllipse(plot,NULL,wdt/2,hgt/2,wdt/2-pad,hgt/2-pad, 1,seacol,0x0f,0,NULL); } if ((grdflg) && (!grdontop)) { MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,0, grdcol,0x0f,width,NULL, pgrd,1); } if (fmapflg) { MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,1, lndcol,0x0f,0,NULL,pmap,1); MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,1, lndcol,0x0f,0,NULL,pmap,3); MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,1, seacol,0x0f,0,NULL,pmap,0); } if (ftrmflg) MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad, 1,ftrmcol,0x0f,0,NULL,ptrm,1); if (fofovflg) { for (i=0;i<network->rnum;i++) { if (network->radar[i].id==stid) continue; if (network->radar[i].status !=1) continue; MapPlotPolygon(plot,NULL,pad,pad, wdt-2*pad,hgt-2*pad,1,fofovcol,0x0f,0,NULL,pfov,i); } } if (fcfovflg) { for (i=0;i<network->rnum;i++) { if (network->radar[i].id==stid) continue; if (network->radar[i].status!=0) continue; MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,1, fcfovcol,0x0f,0,NULL,pfov,i); } } if (ffovflg) { MapPlotPolygon(plot,NULL,pad,pad, wdt-2*pad,hgt-2*pad,1,ffovcol,0x0f,0,NULL,pfov,stnum); } if (mapflg) { MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,0,cstcol,0x0f, width,NULL, pmap,1); MapPlotOpenPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,cstcol,0x0f, width,NULL, pmap,2); MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,0,cstcol,0x0f, width,NULL, pmap,0); } if (ofovflg) { for (i=0;i<network->rnum;i++) { if (network->radar[i].id==stid) continue; if (network->radar[i].status !=1) continue; MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,0, ofovcol,0x0f,width,NULL, pfov,i); } } if (cfovflg) { for (i=0;i<network->rnum;i++) { if (network->radar[i].id==stid) continue; if (network->radar[i].status !=0) continue; MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,0, cfovcol,0x0f,width,NULL, pfov,i); } } if (dotflg) { int s=0; struct RadarSite *site; float pnt[2]; if (cfovflg | fcfovflg) { for (i=0;i<network->rnum;i++) { if (network->radar[i].id==stid) continue; if (network->radar[i].status !=0) continue; site=RadarYMDHMSGetSite(&(network->radar[i]),yr,mo,dy,hr,mt,sc); pnt[0]=site->geolat; pnt[1]=site->geolon; s=(*tfunc)(sizeof(float)*2,pnt,2*sizeof(float),pnt,marg); if (s==0) PlotEllipse(plot,NULL,pad+pnt[0]*(wdt-2*pad), pad+pnt[1]*(hgt-2*pad),dotr,dotr, 1,fcfovcol,0x0f,0,NULL); } } if (ofovflg | fofovflg) { for (i=0;i<network->rnum;i++) { if (network->radar[i].id==stid) continue; if (network->radar[i].status !=1) continue; site=RadarYMDHMSGetSite(&(network->radar[i]),yr,mo,dy,hr,mt,sc); pnt[0]=site->geolat; pnt[1]=site->geolon; s=(*tfunc)(sizeof(float)*2,pnt,2*sizeof(float),pnt,marg); if (s==0) PlotEllipse(plot,NULL,pad+pnt[0]*(wdt-2*pad), pad+pnt[1]*(hgt-2*pad),dotr,dotr, 1,fofovcol,0x0f,0,NULL); } } if (fovflg) { site=RadarYMDHMSGetSite(&(network->radar[stnum]),yr,mo,dy,hr,mt,sc); pnt[0]=site->geolat; pnt[1]=site->geolon; s=(*tfunc)(sizeof(float)*2,pnt,2*sizeof(float),pnt,marg); if (s==0) PlotEllipse(plot,NULL,pad+pnt[0]*(wdt-2*pad), pad+pnt[1]*(hgt-2*pad),dotr,dotr, 1,ffovcol,0x0f,0,NULL); } } if (fovflg) MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,0, fovcol,0x0f,width,NULL, pfov,stnum); if (bndflg) MapPlotOpenPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad, bndcol,0x0f,width,NULL, pbnd,-1); if (trmflg) MapPlotOpenPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad, trmcol,0x0f,width,NULL, ptrm,1); if (tmkflg) MapPlotPolygon(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad,0, tmkcol,0x0f,width,NULL, ptmk,1); if ((grdflg) && (grdontop)) { MapPlotPolygon(plot,NULL,0,0,wdt-2*pad,hgt-2*pad,0, grdcol,0x0f,width,NULL, pgrd,1); } if ((cylind) || (sqflg)) PlotRectangle(plot,NULL,pad,pad,wdt-2*pad,hgt-2*pad, 0,grdcol,0x0f,width,NULL); else PlotEllipse(plot,NULL,wdt/2,hgt/2,wdt/2-pad,hgt/2-pad, 0,grdcol,0x0f,width,NULL); if (tlblflg){ if (lat>0) plot_time_label(plot,pad,pad,wdt-2*pad,hgt-2*pad, 90,flip,tsfx, lon-tme_shft*(! rotflg), (wdt/2)-pad,6, txtcol,0x0f,fontname,fontsize,fontdb); else plot_time_label(plot,pad,pad,wdt-2*pad,hgt-2*pad, -90,flip,tsfx, lon-tme_shft*(! rotflg), (wdt/2)-pad,6, txtcol,0x0f,fontname,fontsize,fontdb); } PlotPlotEnd(plot); PlotDocumentEnd(plot); if (!gflg) exit(0); if (img==NULL) { fprintf(stderr,"Nothing to plot.\n"); exit(-1); } #ifdef _XLIB_ if (xd !=0) { dp=XwinOpenDisplay(display_name,&xdf); if (dp==NULL) { fprintf(stderr,"Could not open display.\n"); exit(-1); } if (xdoff==-1) xdoff=(dp->wdt-img->wdt)/2; if (ydoff==-1) ydoff=(dp->hgt-img->hgt)/2; win=XwinMakeWindow(xdoff,ydoff,img->wdt,img->hgt,0, dp,wname, wname,argv[0],wname,argc,argv,&xdf); if (win==NULL) { fprintf(stderr,"Could not create window.\n"); exit(-1); } XwinFrameBufferWindow(img,win); XwinShowWindow(win); XwinDisplayEvent(dp,1,&win,1,NULL); XwinFreeWindow(win); XwinCloseDisplay(dp); } else { if (xmlflg==1) FrameBufferSaveXML(img,stream,stdout); else if (ppmflg==1) FrameBufferSavePPM(img,stdout); else if (ppmxflg==1) FrameBufferSavePPMX(img,stdout); else FrameBufferSavePNG(img,stdout); } #else if (xmlflg==1) FrameBufferSaveXML(img,stream,stdout); else if (ppmflg==1) FrameBufferSavePPM(img,stdout); else if (ppmxflg==1) FrameBufferSavePPMX(img,stdout); else FrameBufferSavePNG(img,stdout); #endif return 0; }
int GridTableAddBeam(struct GridTable *ptr, struct RadarSite *pos,double alt, double tval,struct RadarBeam *bm) { int yr,mo,dy,hr,mt; double sc; double lat,lon,azm,geoazm,elv,lspc,velco; float grdlat,grdlon; int ref; int r=0,inx; void *tmp=NULL; struct GridBm *b=NULL; struct GridPnt *p=NULL; if (ptr==NULL) return -1; if (pos==NULL) return -1; if (bm==NULL) return -1; velco=(2*PI/86400.0)*6356.779*1000*cos(PI*pos->geolat/180.0); if (ptr->bm==NULL) tmp=malloc(sizeof(struct GridBm)); else tmp=realloc(ptr->bm,sizeof(struct GridBm)*(ptr->bnum+1)); if (tmp==NULL) return -1; ptr->bm=tmp; b=&ptr->bm[ptr->bnum]; ptr->bnum++; b->bm=bm->bm; b->frang=bm->frang; b->rsep=bm->rsep; b->rxrise=bm->rxrise; b->nrang=bm->nrang; b->azm=malloc(sizeof(double)*b->nrang); if (b->azm==NULL) return -1; b->ival=malloc(sizeof(double)*b->nrang); if (b->ival==NULL) return -1; b->inx=malloc(sizeof(int)*b->nrang); if (b->inx==NULL) return -1; TimeEpochToYMDHMS(tval,&yr,&mo,&dy,&hr,&mt,&sc); for (r=0;r<b->nrang;r++) { RPosRngBmAzmElv(b->bm,r,yr,pos, b->frang,b->rsep,b->rxrise, alt,&geoazm,&elv); RPosInvMag(b->bm,r,yr,pos, b->frang,b->rsep,b->rxrise, alt,&lat,&lon,&azm); if (azm<0.) azm+=360.; if (lon<0) lon+=360; if ((lat>0) && (lat<50)) lat=50; if ((lat<0) && (lat>-50)) lat=-50; if (lat>0) grdlat=(int) (lat)+0.5; else grdlat=(int) (lat)-0.5; lspc=((int) (360*cos(fabs(grdlat)*PI/180)+0.5))/(360.0); grdlon=((int) (lon*lspc)+0.5)/lspc; if (lat>0) ref=1000*( (int) lat-50)+( (int) (lon*lspc) ); else ref=-1000*( (int) -lat-50)-( (int) (lon*lspc) ); inx=GridTableFindPoint(ptr,ref); if (inx==-1) inx=GridTableAddPoint(ptr); p=&ptr->pnt[inx]; p->ref=ref; p->max++; p->mlat=grdlat; p->mlon=grdlon; b->inx[r]=inx; b->azm[r]=azm; b->ival[r]=velco*cos(PI*(90+geoazm)/180.0); } return ptr->bnum-1; }