struct PolygonData *make_fov(double tval,struct RadarNetwork *network) { 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; 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++) { RPosMag(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++) { RPosMag(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--) { RPosMag(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--) { RPosMag(0,bm,0,site,frang,rsep, site->recrise,0,&rho,&lat,&lon); pnt[0]=lat; pnt[1]=lon; PolygonAdd(ptr,pnt); } } return ptr; }
static PyObject * PosMag(PyRPosObject *self, PyObject *args, PyObject *kwds) { PyObject *list=NULL, *timetuple=NULL; char *radarcode; struct RadarNetwork *network; struct Radar *radar; struct RadarSite *site; int center, bcrd, rcrd; int frang,rsep,rxrise,height; int yr,mo,dy,hr,mt; double sc; int stid; double rho,lat,lng; char *envstr=NULL; FILE *fp; int r,c; static char *kwlist[] = {"center","bcrd","rcrd","frang","rsep","rxrise","height", "radarcode","radarid","time",NULL}; PyDateTime_IMPORT; center=0; bcrd=1; rcrd=15; frang=1200; rxrise=0; rsep=100; height=300; radarcode="kod"; stid=-1; yr=2008; mo=7; dy=12; hr=12; mt=0; sc=0; if (! PyArg_ParseTupleAndKeywords(args, kwds, "|iiiiiiisiO", kwlist, ¢er,&bcrd,&rcrd,&frang,&rsep,&rxrise,&height,&radarcode,&stid,&timetuple)) return NULL; if ( timetuple != NULL) { if (PyDateTime_Check(timetuple)) { yr=PyDateTime_GET_YEAR(timetuple); mo=PyDateTime_GET_MONTH(timetuple); dy=PyDateTime_GET_DAY(timetuple); hr=PyDateTime_DATE_GET_HOUR(timetuple); mt=PyDateTime_DATE_GET_MINUTE(timetuple); sc=PyDateTime_DATE_GET_SECOND(timetuple); } } 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); if (stid==-1) { stid=RadarGetID(network,radarcode); } radar=RadarGetRadar(network,stid); site=RadarYMDHMSGetSite(radar,yr,mo,dy,hr,mt,(int) sc); RPosMag(center,bcrd,rcrd,site,frang,rsep,rxrise,height,&rho,&lat,&lng); radar=NULL; site=NULL; for (r=0;r<network->rnum;r++) { for (c=0;c<network->radar[r].cnum;c++) { if (network->radar[r].code[c] !=NULL) free(network->radar[r].code[c]); } if (network->radar[r].code !=NULL) free(network->radar[r].code); if (network->radar[r].name !=NULL) free(network->radar[r].name); if (network->radar[r].operator !=NULL) free(network->radar[r].operator); if (network->radar[r].hdwfname !=NULL) free(network->radar[r].hdwfname); if (network->radar[r].site !=NULL) free(network->radar[r].site); } free(network->radar); free(network); list = PyList_New(0); PyList_Append(list,Py_BuildValue("d",rho)); PyList_Append(list,Py_BuildValue("d",lat)); PyList_Append(list,Py_BuildValue("d",lng)); return list; }