25 extern unsigned long mmap[16];
62 int rec_size,num_recs;
70 strcpy(
qual,
"VSFCQDA");
113 if(!strncmp(
pc,
"PPM",3))
134 int j,inum,
i,ier,ierr,qflow,len,jj;
136 char *
text,
buf[300],sbuf[150],hbuf[10];
142 XmString cancel,file_string,print_string;
158 Atom WM_DELETE_WINDOW;
165 file_string=XmStringCreateLocalized(
"file");
166 print_string=XmStringCreateLocalized(
"print");
167 cancel=XmStringCreateLocalized(
"quit");
191 if(!strncmp(pc,
"PPM",3))
217 if(inum == 0 || (inum > 0 && timnow-
stn_values[0].clock > 9*3600))
220 etim1.
hour=gm->tm_hour;
221 etim1.
day=gm->tm_mday;
222 etim1.
month=gm->tm_mon+1;
223 etim1.
year=gm->tm_year+1900;
231 etim1.
hour=gm->tm_hour;
232 etim1.
day=gm->tm_mday;
233 etim1.
month=gm->tm_mon+1;
234 etim1.
year=gm->tm_year+1900;
241 btim1.
hour=gm->tm_hour;
242 btim1.
day=gm->tm_mday;
243 btim1.
month=gm->tm_mon+1;
244 btim1.
year=gm->tm_year+1900;
302 XmDIALOG_OK_BUTTON));
304 XmDIALOG_HELP_BUTTON));
306 XmDIALOG_CANCEL_BUTTON));
308 XmDIALOG_SEPARATOR));
313 XtSetArg(
args[argcount],XmNbackground,0);argcount++;
320 XtSetArg(
args[argcount],XmNbackground,
mmap[1]);argcount++;
321 XtSetArg(
args[argcount],XmNforeground,
mmap[0]);argcount++;
328 XtSetArg(
args[argcount],XmNresizePolicy,XmRESIZE_ANY);argcount++;
329 XtSetArg(
args[argcount],XmNbackground,0);argcount++;
338 items[0].
label=
"Print";
343 items[1].
label=
"Quit";
345 items[1].
accel_text=XmStringCreateLocalized(
"Ctrl+Q");
346 items[1].
accel=
"Ctrl<Key>Q";
365 printf(
"rating table: %s %s %d\n",
id,pc,ier);
374 if(!strncasecmp(
sfile->
pc,
"PCI",3) ||
375 !strncasecmp(
sfile->
pc,
"PCH",3) )
378 items[jj].
label=
"Hourly rain";
386 items[jj].
accel=NULL;
394 items[jj].
label=
"6 hourly rain";
397 items[jj].
accel=NULL;
400 items[jj].
label=
"24 hourly rain";
408 items[jj].
accel=NULL;
416 items[jj].
label=
"rain bar off";
419 items[jj].
accel=NULL;
428 items[jj].
label=
"Linear stage";
436 items[jj].
accel_text=XmStringCreateLocalized(
"Ctrl+S");
437 items[jj].
accel=
"Ctrl<Key>S";
440 items[jj].
label=
"Linear flow";
448 items[jj].
accel_text=XmStringCreateLocalized(
"Ctrl+O");
449 items[jj].
accel=
"Ctrl<Key>O";
455 items[jj].
label=
"Scale to data";
463 items[jj].
accel_text=XmStringCreateLocalized(
"Ctrl+D");
464 items[jj].
accel=
"Ctrl<Key>D";
467 items[jj].
label=
"Scale to flood";
475 items[jj].
accel_text=XmStringCreateLocalized(
"Ctrl+F");
476 items[jj].
accel=
"Ctrl<Key>F";
482 items[jj].
label=NULL;
579 XmStringFree(file_string);
580 XmStringFree(print_string);
581 XmStringFree(cancel);
590 WM_DELETE_WINDOW=XmInternAtom(XtDisplay(
top_level),
591 "WM_DELETE_WINDOW",False);
593 XmAddWMProtocolCallback(shell,WM_DELETE_WINDOW,
quit_draw,(XtPointer)
j);
605 int xparm1,yparm1,xparm2,yparm2;
609 time_t lbtim,letim,
stim,otim;
610 char abuf[100],tbuf[100],next[10];
613 int deltat,
i,text_width,
j,h,qflag,ier;
615 float fxvalue,fyvalue,svalue,dxvalue;
616 int maxv,minv,smaxv,sminv,dvalue;
617 int xvalue,oday,yvalue,xvalue1,yvalue1,totlin,totdays,
hour,ierr,flow,ilinear;
619 char buf[200],ubuf[50],xbuf[50];
620 int inum,merr,ybegin,len;
622 double stage,wrn,fld,abs1,abs2;
624 int line_width,line_style,cap_style,join_style,lines;
655 dval=(float)idval/10;
663 dval=(float)idval/10;
671 dval=(float)idval/10;
677 line_style=LineSolid;
679 join_style=JoinRound;
681 XSetLineAttributes(
display,
gc1,line_width,line_style,
682 cap_style,join_style);
700 XSetClipRectangles(
display,
gc1,0,0,rect,1,Unsorted);
759 sprintf(abuf,
" (NEXT: %s)",next);
775 strcpy(
buf,
"NO DATA");
790 lbtim=
ouptime(tm.tm_year,tm.tm_mon,tm.tm_mday,tm.tm_hour,tm.tm_min,0);
799 letim=
ouptime(tm.tm_year,tm.tm_mon,tm.tm_mday,tm.tm_hour,tm.tm_min,0);
803 totlin=(lbtim-letim)/(24L*3600L)+1;
805 totyears=(lbtim-letim)/(24L*3600L*365L)+1;
811 if(tm.tm_hour > 0 && tm.tm_hour <=6)
813 else if(tm.tm_hour > 6 && tm.tm_hour <=12)
815 else if(tm.tm_hour > 12 && tm.tm_hour <=18)
817 else if(tm.tm_hour > 18)
826 maxtimes=(lbtim-letim)/(deltat*3600L);
827 totdays=(lbtim-letim)/(24L*3600L)+1;
828 totlin=totdays*24/deltat+4;
837 for(
i=0;
i<=totlin;
i++) {
839 stim=letim+((
i-4)*deltat*3600L) +
hour*3600L;
846 if(xvalue >
width-xparm1)
849 if(xvalue < xs+xparm1)
859 if(gm->tm_mday==1 && gm->tm_mon==0) {
865 sprintf(
buf,
"%d/%d",gm->tm_mon+1,gm->tm_year);
876 else if(gm->tm_mday==1 && totyears < 2) {
895 if(oday != gm->tm_mday) {
897 if(gm->tm_hour==0 || htflag==1) {
899 sprintf(
buf,
"%d/%d",gm->tm_mon+1,gm->tm_mday);
916 if(h==0 || h==2 || h==4 || h==6 || h==8 ||
917 h==10 || h==12 || h==14 || h==16 ||
918 h==18 || h==20 || h==22)
923 else if(deltat==3 && totdays <= 2) {
926 if(h==0 || h==3 || h==6 || h==9 || h==12 ||
927 h==15 || h==18 || h==21)
934 if(h==0 || h==6 || h==12 || h==18)
946 else if(deltat==24) {
982 if(ierr >= 0 && ierr <= 2)
1004 (
double)minv, &ierr);
1006 (
double)maxv,&merr);
1007 if(ierr < 0 || merr < 0)
1016 maxvalues=(maxv-minv)/(deltav);
1020 for(
i=0;
i<=maxvalues+2;
i++)
1022 svalue=(float)minv+(
i*deltav);
1024 (float)(svalue-minv);
1027 if(yvalue < ys+yparm1 || yvalue >
height-yparm2)
1039 width-xparm1,yvalue);
1041 if(ilinear==0 &&
save_rec[
k].parm[0]!=
'Q')
1045 xvalue=
width-xparm1+2;
1054 xvalue=xs+xparm1-text_width;
1073 xvalue=xs+xparm1-text_width;
1082 (
double)svalue,&ierr);
1090 if(ilinear==1 &&
save_rec[
k].parm[0]!=
'Q')
1093 xvalue=
width-xparm1+2;
1099 xvalue=xs+xparm1-text_width;
1113 line_style=LineOnOffDash;
1115 join_style=JoinRound;
1117 XSetLineAttributes(
display,
gc1,line_width,line_style,
1118 cap_style,join_style);
1131 fyvalue=
ymax-(float)(
ymin-
ymax)/(float)(minv-maxv)*(float)(fld-minv);
1136 if(yvalue > ys+yparm1 && yvalue <
height-yparm2)
1138 yvalue,
width-xparm1,yvalue);
1155 (float)(minv-maxv)*(float)(wrn-minv);
1161 line_style=LineOnOffDash;
1163 join_style=JoinRound;
1165 XSetLineAttributes(
display,
gc1,line_width,line_style,
1166 cap_style,join_style);
1168 if(yvalue > ys+yparm1 && yvalue <
height-yparm2)
1170 width-xparm1,yvalue);
1194 if(yvalue > ys+yparm1 && yvalue <
height-yparm2)
1196 width-xparm1,yvalue);
1200 line_style=LineSolid;
1202 join_style=JoinRound;
1204 XSetLineAttributes(
display,
gc1,line_width,line_style,
1205 cap_style,join_style);
1216 strcpy(ubuf,
"KAC-FT");
1230 yvalue,xbuf,strlen(xbuf));
1268 strcpy(ubuf,
"Inches");
1284 yvalue,xbuf,strlen(xbuf));
1291 (float)(letim-
stim);
1296 if(fxvalue >
xmax || fxvalue1 >
xmax)
1302 (float)(svalue-rminv);
1307 dxvalue=fxvalue-fxvalue1;
1331 else if(
ymax-yvalue==0)
1368 ix2,yvalue,
dx,
ymax-yvalue+1);
1387 tm.tm_mon=(
values[
i].
zdate-(tm.tm_year+1900)*10000)/100;
1388 tm.tm_mday=
values[
i].
zdate-(tm.tm_year+1900)*10000-tm.tm_mon*100;
1392 tm.tm_mon=tm.tm_mon;
1393 stim=
ouptime(tm.tm_year+1900,tm.tm_mon,tm.tm_mday,
1394 tm.tm_hour,tm.tm_min,0);
1397 (float)(letim-
stim);
1402 (float)(svalue-minv);
1407 dxvalue=-(float)(
xmax-
xmin)/(float)(letim-lbtim)*
1415 if(
ymax - yvalue == 0 &&
i > 0)
1434 xvalue-dvalue,yvalue,
1435 dvalue-1,
ymax-yvalue+1);
1448 tm.tm_mon=(
values[
i].
zdate-(tm.tm_year+1900)*10000)/100;
1449 tm.tm_mday=
values[
i].
zdate-(tm.tm_year+1900)*10000-tm.tm_mon*100;
1452 tm.tm_mon=tm.tm_mon;
1453 stim=
ouptime(tm.tm_year+1900,tm.tm_mon,tm.tm_mday,tm.tm_hour,tm.tm_min,0);
1455 (float)(letim-
stim);
1463 svalue=(double)flow;
1467 (float)(svalue-minv);
1487 if(otim-
stim < 7200L)
1490 line_style=LineSolid;
1492 join_style=JoinRound;
1494 XSetLineAttributes(
display,
gc1,line_width,line_style,
1495 cap_style,join_style);
1503 line_style=LineOnOffDash;
1505 join_style=JoinRound;
1507 XSetLineAttributes(
display,
gc1,line_width,line_style,
1508 cap_style,join_style);
1540 sprintf(abuf,
" %6.2f KAC-FT",((
float)flow+0.5)/1000.);
1544 sprintf(abuf,
" at %02d/%02d/%04d %02d:%02dZ",
1570 sprintf(abuf,
" %6.2f KAC-FT",((
float)flow+0.5)/1000.);
1574 sprintf(abuf,
" at %02d/%02d/%04d %02d:%02dZ",
1587 tm.tm_mon=(
values[
i].
zdate-(tm.tm_year+1900)*10000)/100;
1588 tm.tm_mday=
values[
i].
zdate-(tm.tm_year+1900)*10000-tm.tm_mon*100;
1602 (
double)svalue,&ierr);
1609 sprintf(abuf,
" %6.2f KAC-FT",((
float)flow+0.5)/1000.);
1613 sprintf(abuf,
" at %02d/%02d/%04d %02d:%02dZ",
1614 tm.tm_mon,tm.tm_mday,tm.tm_year+1900,tm.tm_hour,tm.tm_min);
1623 (float)(letim-
stim);
1627 if(xvalue >= xs+xparm1 && xvalue <=
width-xparm1) {
1630 line_style=LineOnOffDash;
1632 join_style=JoinRound;
1634 XSetLineAttributes(
display,
gc1,line_width,line_style,
1635 cap_style,join_style);
1654 int i,xdate,
xtime,ndate,ntime;
1660 for(
i=0;
i<inum;
i++) {
1742 hours=(lbtim-letim)/3600L;
1750 else if(hours < 144)
1753 else if(hours < 288)
1756 else if(hours < 576)
1759 else if(hours < 1152)
1762 else if(hours < 2304)
1765 else if(hours < 4608)
1805 else if(diff < 1000)
1808 else if(diff < 2000)
1811 else if(diff < 4000)
1814 else if(diff < 10000)
1817 else if(diff < 20000)
1820 else if(diff < 40000)
1823 else if(diff < 100000)
1826 else if(diff < 200000)
1829 else if(diff < 400000)
1832 else if(diff < 1000000)
1835 else if(diff < 2000000)
1838 else if(diff < 4000000)
1848 void options_draw(Widget w,XtPointer data,XmDrawingAreaCallbackStruct *call_data)
1865 XtSetArg(
args[0],XmNset,False);
1872 for(m=mstart;m<mstart+2;m++)
1875 XtSetArg(
args[0],XmNset,True);
1906 void options_rain(Widget w,XtPointer data,XmDrawingAreaCallbackStruct *call_data)
1917 if(strncmp(
save_rec[
j].parm,
"PCI",3)==0 ||
1921 XtSetArg(
args[0],XmNset,False);
1925 XtSetArg(
args[0],XmNset,True);
1952 void quit_draw(Widget w,XtPointer data,XmDrawingAreaCallbackStruct *call_data)
2032 hours=(lbtim-letim)/3600;
2037 tim2=lbtim-gm->tm_min*60;
2041 for(
i=0;
i<hours;
i++)
2044 for(
i=0;
i<hours;
i++) {
2054 for(m=0;m<hours;m++) {
2094 if(gm->tm_hour < 12)
2095 tim2=lbtim-(gm->tm_hour+12)*3600 - gm->tm_min*60;
2098 tim2=lbtim-(gm->tm_hour-12)*3600 - gm->tm_min*60;
2102 for(
i=0;
i<dhours;
i++)
2108 tim2=lbtim-(gm->tm_hour-(gm->tm_hour/6)*6) *3600 - gm->tm_min*60;
2110 for(
i=0;
i<shours;
i++)
2114 for(
i=0;
i<hours;
i++)
2122 for(
i=0;
i<dhours;
i++)
2130 for(
i=0;
i<shours;
i++)
2148 Widget Pulldown, button;
2155 XtSetArg(
args[argcount],XmNbackground,
mmap[1]);argcount++;
2156 XtSetArg(
args[argcount],XmNforeground,
mmap[0]);argcount++;
2157 Pulldown=XmCreatePulldownMenu(parent,
"pulldown",
args,argcount);
2159 for(
i=0;items[
i].
label!=NULL;
i++) {
2163 XtSetArg(
args[argcount],XmNbackground,
mmap[1]);argcount++;
2164 XtSetArg(
args[argcount],XmNforeground,
mmap[0]);argcount++;
2165 XtSetArg(
args[argcount],XmNselectColor,
mmap[4]);argcount++;
2168 XtSetArg(
args[argcount],XmNset,True);
2171 XtSetArg(
args[argcount],XmNset,False);
2175 mpbutton[
i]=XmCreateToggleButton(Pulldown,items[
i].label,
args,argcount);
2176 XtAddCallback(
mpbutton[
i],XmNvalueChangedCallback,items[
i].callback,items[
i].callback_data);
2190 Widget Pulldown, button;
2197 XtSetArg(
args[argcount],XmNbackground,
mmap[1]);argcount++;
2198 XtSetArg(
args[argcount],XmNforeground,
mmap[0]);argcount++;
2200 Pulldown=XmCreatePulldownMenu(parent,
"pulldown",
args,argcount);
2202 for(
i=0;items[
i].
label!=NULL;
i++) {
2206 XtSetArg(
args[argcount],XmNbackground,
mmap[1]);argcount++;
2207 XtSetArg(
args[argcount],XmNforeground,
mmap[0]);argcount++;
2209 if(items[
i].accel!=NULL) {
2211 XtSetArg(
args[argcount],XmNaccelerator,items[
i].accel);argcount++;
2212 XtSetArg(
args[argcount],XmNacceleratorText,items[
i].accel_text);argcount++;
2216 button=XmCreatePushButton(Pulldown,items[
i].label,
args,argcount);
2217 XtAddCallback(button,XmNactivateCallback,items[
i].callback,
2218 items[
i].callback_data);
2219 XtManageChild(button);
2228 void print_me(Widget w,XtPointer data,XmDrawingAreaCallbackStruct *call_data)
2250 sprintf(tbuf,
"/awips/hydroapps/rfc/local/apps/mapper/data/graph.%02d%02d%02d",
2251 gm->tm_hour,gm->tm_min,gm->tm_sec);
2257 sprintf(
cmd,
"/awips/hydroapps/rfc/local/apps/mapper/bin/print_graph %s &",tbuf);
int check_sens(char *stn_id, char *shef)
int get_fcst_values(char *stn_id, char *shef, time_t abeg, time_t aend, struct stn_values *stn_values)
float get_rain(struct stn_values *stn_values, char *pc, int inum, time_t etime, time_t btime, struct rainfall *r)
int get_sensor_info(char *stn_id, char *shef, struct sensor_file *sfile)
int get_stn_valuesM(char *stn_id, char *shef, time_t abeg, int maxmonths, struct stn_values *stn_values)
int get_stn_values(char *stn_id, char *shef, time_t abeg, time_t aend, struct stn_values *stn_values)
long ouptime(int year, int month, int day, int hour, int minute, int second)
Widget AttachToCascade(Widget, char *, Widget)
RatingTable getrc(char *, char, char, int, int *)
static RatingTable rate_table
sprintf(fbuf,"/usr/mapper/nexrad/ngrid.%02d-%02d-%02d-%02d", year, month, day, hour)
printf("fbuf is %s\n", fbuf)
void next_report(char *stn_id, char *shef, char *next, int debug)
double getstage(char *hb5, char *shef, int Flow, int *Warning)
int getflow(char *hb5, char *shef, double Stage, int *Warning)
struct stn_values stn_values[10000]
Widget BuildPulldownsubPushMenu(Widget parent, char *menu_title, char menu_mnemonic, struct MenuItem *items)
int get_delta_time(time_t lbtim, time_t letim)
XFontStruct * info_font[10]
struct sensor_rec * sensor_rec
struct max_min get_max_min(struct stn_values *stn_values, int inum)
struct stn_values * stn_values
void draw_area(int k, int m, int xs, int ys, int xz, int yz)
struct number_rec * number_rec
int future_time_series_days
struct stn_values values[10000]
int past_time_series_days
Widget BuildPulldownsubToggleMenu(Widget parent, char *menu_title, char menu_mnemonic, struct MenuItem *items)
struct sensor_type * stype
struct stn_values etn_values[5000]
struct sensor_file * sfile
float get_delta_valu(int diff)
void subdisplay(char *id, char *pc, int month, int day, int year, int hour, int min)
struct stn_values btn_values[5000]