11 #include <sys/types.h>
13 #include <sys/ioctl.h>
32 #define DEFINE_COLORS_STRINGS
42 #define LAST_IMAGE_INFO 1
43 #define LAST_FLUX_INFO 2
44 #define LAST_ACCUM_RESULTS 3
45 #define LAST_FLUX_HISTORY 4
46 #define LAST_CONTINUUM_PLAIN 5
47 #define LAST_CONTINUUM_SPTIP 6
48 #define LAST_OBJECT_HISTORY 7
49 #define LAST_FFT_INFO 8
50 #define LAST_HISTO_INFO 9
51 #define LAST_TSYS_INFO 10
52 #define LAST_SSS_INFO 11
53 #define LAST_FOCUS_HISTORY 12
61 #define SAVE_DEM_FILE 1
71 char *
sideband[] = {
"LSB",
"USB",
"LSB",
"USB" };
76 char *
mouse_str =
"print \"MOUSE: \", MOUSE_X, \" \", MOUSE_X2, \" \", MOUSE_Y, \" \", MOUSE_Y2";
77 char *
map_ang_str =
"print \"MAP_ANGLE: \", GPVAL_VIEW_ROT_X, \" \", GPVAL_VIEW_ROT_Z";
78 char *
get_range_str =
"print \"PLOT_RANGE: \", GPVAL_X_MIN, \" \", GPVAL_X_MAX, \" \", GPVAL_Y_MIN, \" \", GPVAL_Y_MAX";
110 #define MAX_BUF_SIZE (sizeof(last_image)+256)
126 static float sinEl[] = {2.6, 2.3, 2.0, 1.7, 1.4, 1.1, 1.4, 1.7, 2.0, 2.3, 2.6};
148 #define MAX_GNUPLOT_INITS 13
175 char pbuf[256], sysbuf[256];
176 char *string, line[256], *cp;
191 cp = getenv(
"LINUXPOPS_GNUPLOT");
194 sprintf(pbuf,
"%s -title GNUPLOT_%s", cp,
session);
198 sprintf(pbuf,
"gnuplot -title GNUPLOT_%s",
session);
201 if((
gpout = popen(pbuf,
"w")) == NULL)
211 fprintf(
gpout,
"set mouse; set print \"%s\"\n",
gpfifo);
214 fprintf(
gpout,
"set terminal %s enhanced font \"%s\"\n", term,
fsize);
237 "/bin/ps auxww | /bin/grep -i 'GNUPLOT_%s' | /bin/grep 'gnuplot ' | /bin/grep -v grep | /bin/awk '{print $2}'",
240 if((fp = popen(sysbuf,
"r")) == NULL)
249 while((
string = fgets(line,
sizeof(line), fp)) != NULL)
262 log_msg(
"# FIFO open for reading.");
293 log_msg(
"> Sending to gnuplot: %s", buf);
295 fprintf(
gpout,
"%s\n", buf);
300 log_msg(
"Sleeping for %.3f seconds", (
double)delay / 1.0e6);
313 char inBuf[1024], *cp;
316 cp = fgets(inBuf,
sizeof(inBuf),
gpin);
320 log_msg(
"Nothing returned from fscanf()");
325 log_msg(
"Runaway detected; Exiting");
342 log_msg(
"< Got from gnuplot: %s", inBuf);
361 if(image->badChans[i] == bad)
373 double year,
mon, day;
375 static char tbuf[256];
402 sprintf(tbuf,
"%02.0f-%02.0f-%4.0f", mon, day, year);
413 static char tbuf[256];
416 fr = fabs(freqres * 1e3);
420 sprintf(tbuf,
"FR=%4.2f", fr);
424 sprintf(tbuf,
"FR=%4.0f", fr);
436 char tbuf[256], raStr[80], decStr[80], timeStr[80], scanStr[80],
dateStr[256];
445 if(image->ainfo.bscan != 0.0 && image->ainfo.escan != 0.0)
447 sprintf(scanStr,
"(%3d) Scans: %7.2f-%7.2f",
448 image->ainfo.scanct, image->ainfo.bscan, image->ainfo.escan);
452 sprintf(scanStr,
"%7.2f ", h->
scan);
457 sprintf(tbuf,
"%16.16s %s INT=%s DATE: %s\\n", h->
object, scanStr, timeStr, dateStr);
463 sprintf(tbuf,
"%8.8s %s %s CAL= %6.1f TS=%6.1f\\n",
469 sprintf(tbuf,
"FREQ= %9.2f SYN= %8.6f VEL= %8.1f DV= %5.2f %s SB=%d",
485 char tbuf[256], raStr[80], decStr[80], timeStr[80], scanStr[80],
dateStr[256];
494 sprintf(scanStr,
"%7.2f ", h->
scan);
498 sprintf(tbuf,
"%12.12s %s INT=%s DATE: %s\\n", h->
object, scanStr, timeStr, dateStr);
504 sprintf(tbuf,
"%8.8s %s %s CAL= %6.1f TS= %5.0f\\n",
512 sprintf(tbuf,
"FREQ= %9.2f SYN= %8.6f VEL= %8.1f DV= %5.2f %s SB=%d",
527 char tbuf[256], raStr[80], decStr[80], timeStr[80], scanStr[80],
dateStr[256];
536 sprintf(scanStr,
"%7.2f ", h->
scan);
540 sprintf(tbuf,
"%12.12s %s INT=%s DATE: %s\\n", h->
object, scanStr, timeStr, dateStr);
546 sprintf(tbuf,
"%8.8s %s %s CAL= %6.1f TS= %5.0f\\n",
553 sprintf(tbuf,
"FREQ= %9.2f SYN= %8.6f VEL= %8.1f DV= %5.2f %s SB=%d",
568 char tbuf[256], raStr[80], decStr[80], timeStr[80], scanStr[80],
dateStr[256];
577 sprintf(scanStr,
"%7.2f ", h->
scan);
581 sprintf(tbuf,
"%12.12s %s INT=%s DATE: %s\\n", h->
object, scanStr, timeStr, dateStr);
587 sprintf(tbuf,
"%8.8s %s %s CAL= %6.1f TS= %5.0f\\n",
594 sprintf(tbuf,
"FREQ= %9.2f SYN= %8.6f VEL= %8.1f DV= %5.2f %s SB=%d",
609 char tbuf[256], raStr[80], decStr[80], timeStr[80], scanStr[80],
dateStr[256];
626 sprintf(scanStr,
"(%3d) Scans: %7.2f-%7.2f", a->
scanct, a->
bscan, a->
escan);
630 sprintf(scanStr,
"%7.2f ", h->scan);
633 strcpy(dateStr,
makeDate(h->utdate));
635 sprintf(tbuf,
"%12.12s %s INT=%s DATE: %s\\n", h->object, scanStr, timeStr, dateStr);
640 sprintf(tbuf,
"%8.8s %s %s CAL= %6.1f TS= %5.0f\\n",
641 h->coordcd, raStr, decStr, h->tcal, h->stsys);
645 sprintf(tbuf,
"FREQ= %9.2f SYN= %10.8f VEL= %8.1f SB=%d",
646 h->obsfreq, h->synfreq/1000.0, h->velocity, (
int)h->sideband);
660 char datName[256], demName[256],
661 sname[256], headBuf[512], gpBuf[256];
664 sprintf(datName,
"/tmp/%s/scan.dat",
session);
666 if((fp = fopen(datName,
"w")) == NULL)
668 log_msg(
"Unable to open %s for writting", datName);
674 for(i=0;i<fft->num;i++)
676 fprintf(fp,
"%e %e\n", fft->xdata[i], fabs(fft->ydata[i]));
682 sprintf(demName,
"/tmp/%s/scan.dem",
session);
684 if((fp = fopen(demName,
"w")) == NULL)
686 log_msg(
"Unable to open %s for writting", demName);
691 strncpy(sname, fft->head.object, 16);
696 fprintf(fp,
"reset\n");
697 fprintf(fp,
"set size 1.0, 1.0\n");
699 fprintf(fp,
"set title \"%s\" font \"%s\" noenhanced\n", headBuf,
fsize);
701 fprintf(fp,
"set xlabel \"Inverse Frequency (MHz^{-1})\" tc rgb \"red\"\n");
702 fprintf(fp,
"set ylabel \" \" tc rgb \"red\"\n");
706 fprintf(fp,
"set xrange [%e:%e]\n", fft->xb, fft->xe);
709 fprintf(fp,
"set grid\n");
711 fprintf(fp,
"set key off\n");
713 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", fft->plotwin,
fsize,
startx, fft->plotwin*10);
715 fprintf(fp,
"plot '%s' with histeps lc rgb \"red\" \n", datName);
719 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
735 char datName[256], demName[256], gname[256],
736 sname[256], headBuf[512], gpBuf[256];
739 sprintf(datName,
"/tmp/%s/scan.dat",
session);
741 if((fp = fopen(datName,
"w")) == NULL)
743 log_msg(
"Unable to open %s for writting", datName);
749 for(i=0;i<histo->num;i++)
751 fprintf(fp,
"%e %e\n", histo->xdata[i], histo->ydata[i]);
759 sprintf(gname,
"/tmp/%s/gauss.dat",
session);
761 if((fp = fopen(gname,
"w")) == NULL)
763 log_msg(
"Unable to open %s for writting", gname);
769 for(i=0;i<histo->num;i++)
771 fprintf(fp,
"%e %e\n", histo->xdata[i], histo->gdata[i]);
778 sprintf(demName,
"/tmp/%s/scan.dem",
session);
780 if((fp = fopen(demName,
"w")) == NULL)
782 log_msg(
"Unable to open %s for writting", demName);
787 strncpy(sname, histo->head.object, 16);
792 fprintf(fp,
"reset\n");
793 fprintf(fp,
"set size 1.0, 1.0\n");
795 fprintf(fp,
"set title \"%s\" font \"%s\" noenhanced\n", headBuf,
fsize);
797 fprintf(fp,
"set xlabel \"Intensity\" tc rgb \"red\"\n");
798 fprintf(fp,
"set ylabel \" Quantity\" tc rgb \"red\"\n");
800 fprintf(fp,
"set grid\n");
802 fprintf(fp,
"set key off\n");
804 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", histo->plotwin,
fsize,
startx, histo->plotwin*10);
806 fprintf(fp,
"plot '%s' with histeps lc rgb \"red\" ", datName);
810 fprintf(fp,
", '%s' with lines lc rgb \"dark-magenta\"", gname);
817 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
830 char bstr[4096], tbuf[256];
833 log_msg(
"# struct LP_IMAGE_INFO image");
835 log_msg(
"# Magic = %s", image->magic);
836 log_msg(
"# Name = %s", image->name);
837 log_msg(
"# Mode = %d", image->mode);
838 log_msg(
"# Peak = %d", image->peakChan);
839 log_msg(
"# Plotwin = %d", image->plotwin);
840 log_msg(
"# NArray = %d", image->narray);
841 log_msg(
"# nSize = %d", image->nsize);
842 log_msg(
"# Datamin = %f", image->datamin);
843 log_msg(
"# Datamax = %f", image->datamax);
845 log_msg(
"# struct ACCUM_INFO ainfo");
847 log_msg(
"# ----> ScanCt = %d", image->ainfo.scanct);
848 log_msg(
"# ----> Bscan = %.2f", image->ainfo.bscan);
849 log_msg(
"# ----> Escan = %.2f", image->ainfo.escan);
851 log_msg(
"# struct BASELINE_INFO binfo");
853 strcpy(bstr,
"Baselines = ");
857 if(image->binfo.baselines[i][0] > 0)
859 sprintf(tbuf,
"%d ", image->binfo.baselines[i][0]);
863 if(image->binfo.baselines[i][1] > 0)
865 sprintf(tbuf,
"%d ", image->binfo.baselines[i][1]);
870 log_msg(
"# ----> DoBaseline = %d", image->binfo.doBaseLine);
872 log_msg(
"# ----> a = %f", image->binfo.a);
873 log_msg(
"# ----> b = %f", image->binfo.b);
874 log_msg(
"# ----> rms = %f", image->binfo.rms);
876 log_msg(
"# struct PLOT_INFO pinfo");
878 log_msg(
"# ----> Markers = %d", image->pinfo.markers);
879 log_msg(
"# ----> Plotstyle = %d", image->pinfo.plotStyle);
880 log_msg(
"# ----> X1Mode = %d", image->pinfo.x1mode);
881 log_msg(
"# ----> X2Mode = %d", image->pinfo.x2mode);
882 log_msg(
"# ----> Gridmode = %d", image->pinfo.gridMode);
883 log_msg(
"# ----> Zline = %d", image->pinfo.zline);
884 log_msg(
"# ----> Badchshow = %d", image->pinfo.badchshow);
885 log_msg(
"# ----> Bmark = %d", image->pinfo.bmark);
886 log_msg(
"# ----> Bshow = %d", image->pinfo.bshow);
887 log_msg(
"# ----> Mshow = %d", image->pinfo.mshow);
888 log_msg(
"# ----> Bdrop = %d", image->pinfo.bdrop);
889 log_msg(
"# ----> Edrop = %d", image->pinfo.edrop);
890 log_msg(
"# ----> DoBadChan = %d", image->pinfo.dobadch);
891 log_msg(
"# ----> Yscale = %d", image->pinfo.yscale);
892 log_msg(
"# ----> Plot_noint = %d", image->pinfo.plot_noint);
893 log_msg(
"# ----> Bplot = %d", image->pinfo.bplot);
894 log_msg(
"# ----> YPlotMode = %d", image->pinfo.yplotmode);
896 log_msg(
"# ----> PlotW = %d", image->pinfo.paperw);
897 log_msg(
"# ----> PlotH = %d", image->pinfo.paperh);
899 log_msg(
"# ----> Yupper = %f", image->pinfo.yupper);
900 log_msg(
"# ----> Ylower = %f", image->pinfo.ylower);
901 log_msg(
"# ----> PlotMin = %f", image->pinfo.plotmin);
902 log_msg(
"# ----> PlotMax = %f", image->pinfo.plotmax);
904 log_msg(
"# struct GAUSSIAN ginfo");
906 log_msg(
"# ----> NFits = %d", image->ginfo.nfits);
908 for(i=0;i<image->ginfo.nfits;i++)
910 log_msg(
"# ----> [%d] Peak = %f", i, image->ginfo.fits[i].peak);
912 switch(image->ginfo.fits[i].xmode)
915 log_msg(
"# ----> [%d] Peak Vel = %f", i, image->ginfo.fits[i].center);
919 log_msg(
"# ----> [%d] Peak Chan = %f", i, image->ginfo.fits[i].center);
923 log_msg(
"# ----> [%d] Peak Freq = %f", i, image->ginfo.fits[i].center);
927 log_msg(
"# ----> [%d] Peak HP = %f", i, image->ginfo.fits[i].hp);
928 log_msg(
"# ----> [%d] Sum Gauss = %f", i, image->ginfo.fits[i].sumK);
941 if(fabs(h->openpar[0] - 54321.12345) < 0.001)
961 char lbuf[256], lcr[256], *font;
982 fprintf(fp,
"set label \"%s\" at %.6f, %.6f %s tc rgb \"%s\" font \"%s\"\n",
1006 char lbuf[256], lcr[256], *font;
1009 if(image->satActive)
1019 if(strstr(p->
label,
"Helvet"))
1025 font =
"font \"Times-Roman,10\"";
1030 sprintf(lbuf,
"%s {/Symbol \256}", p->
label);
1031 strcpy(lcr,
"right");
1036 sprintf(lbuf,
"{/Symbol \254} %s", p->
label);
1037 strcpy(lcr,
"left");
1042 sprintf(lbuf,
"{/Symbol \254} %s", p->
label);
1043 strcpy(lcr,
"rotate by 90");
1047 sprintf(lbuf,
"{/Symbol \254}");
1048 strcpy(lcr,
"rotate by 90");
1055 sprintf(lbuf,
"%s", p->
label);
1056 strcpy(lcr,
"left");
1060 fprintf(fp,
"set label \"%s\" at %.6f, %.6f %s tc rgb \"%s\" %s\n",
1072 diff = image->datamax - image->datamin;
1076 diff = image->pinfo.yupper - image->pinfo.ylower;
1079 y = p->
y + diff * 0.04;
1083 if(strstr(p->
label,
"\\n"))
1090 strcpy(lcr,
"center");
1091 fprintf(fp,
"set label \"%s\" at %.6f, %.6f %s tc rgb \"%s\" %s\n",
1113 char lbuf[256], lcr[256], *font;
1120 if(image->satActive && t->
used)
1126 font =
"Times-Roman,10";
1128 sprintf(lbuf,
"%s", p->
label);
1129 strcpy(lcr,
"left");
1131 fprintf(fp,
"set label \"%s\" at %.6f, %.6f %s tc rgb \"%s\" font \"%s\"\n",
1154 if(image->pinfo.badchshow)
1156 delta = image->datamax - image->datamin;
1159 for(i=1;i<(image->head.noint-1);i++)
1163 fprintf(fp,
"set arrow from %.3f, %.3f to %.3f, %.3f front nohead lw 0.1 lc rgb \"green\"\n",
1164 image->x1data[i], image->yplot1[i] - delta,
1165 image->x1data[i], image->yplot1[i] + delta);
1168 log_msg(
"# Turning On BadChan Markers");
1181 if(image->pinfo.mshow && image->pinfo.markers)
1183 for(i=image->pinfo.bdrop;i<(image->head.noint-image->pinfo.edrop);i++)
1185 if(i > 0 && !(i%image->pinfo.markers))
1187 fprintf(fp,
"set arrow from %.3f, %.3f to %.3f, %.3f nohead lc rgb \"green\"\n",
1188 image->x1data[i], image->pinfo.plotmin,
1189 image->x1data[i], image->pinfo.plotmax);
1192 log_msg(
"# Turning On Markers");
1206 if(image->satActive)
1212 fprintf(fp,
"set arrow from %.6f, %.6f to %.6f, %.6f front nohead lw 0.3 lc rgb \"%s\"\n",
1230 n = image->head.noint - 1;
1231 if(image->satActive)
1237 fprintf(fp,
"set arrow from %.6f, %.6f to %.6f, %.6f front nohead lw 0.1 lc rgb \"%s\"\n",
1255 float x,
y, midpoint;
1256 char lbuf[256], lcr[80], *font;
1258 if(image->satActive)
1267 fprintf(fp,
"set arrow from %.6f, %.6f to %.6f, %.6f front nohead lw 0.2 lc rgb \"%s\"\n",
1274 fprintf(fp,
"set arrow from %.6f, %.6f to %.6f, %.6f front nohead lw 0.2 lc rgb \"%s\"\n",
1282 fprintf(fp,
"set arrow from %.6f, %.6f to %.6f, %.6f front nohead lw 0.2 lc rgb \"%s\"\n",
1287 font =
"Times-Roman,10";
1291 strcpy(lcr,
"center");
1299 fprintf(fp,
"set label \"%s\" at %.6f, %.6f %s tc rgb \"%s\" font \"%s\"\n",
1321 if(image->satActive)
1325 strcpy(lcr,
"left");
1329 fprintf(fp,
"set label \"%s\" at %.6f, %.6f %s tc rgb \"%s\" font \"fixed\"\n",
1412 fprintf(fp,
"set object %d rect from %.6f,%.6f to %.6f,%.6f back fc rgb \"gray90\" fs empty\n", k+i,
1416 log_msg(
"# Drawing Postage Stamp: %d", i);
1418 fprintf(fp,
"set label \"%s\" at %f, %f center tc rgb \"%s\"\n",
1424 sprintf(tbuf,
"%5.3fK", p->
ymax);
1440 double diff, y1, y2;
1442 if(image->pinfo.bmark)
1444 diff = (image->pinfo.plotmax - image->pinfo.plotmin) / 7.0;
1446 if(image->pinfo.bmark > 0)
1454 y1 = image->pinfo.plotmin + diff * 0.2;
1455 y2 = image->pinfo.plotmin;
1458 log_msg(
"Plot_interval = %f", diff);
1464 if(image->binfo.baselines[i][0] == 0 || image->binfo.baselines[i][1] == 0)
1469 fprintf(fp,
"set object %d rect from %.6f,%.6f to %.6f,%.6f back fc rgb \"gray90\" fs empty\n", k,
1470 image->x1data[image->binfo.baselines[i][0]], y1,
1471 image->x1data[image->binfo.baselines[i][1]], y2);
1474 log_msg(
"# Turning On Basline Markers");
1488 log_msg(
"setPaperSize(): PlotW = %f, PlotH = %f", w, h);
1490 if(w > 0.0 && h > 0.0)
1492 sprintf(psize,
"%.1f, %.1f", w, h);
1496 sprintf(fsize,
"Courier,20");
1501 sprintf(fsize,
"Courier,18");
1506 sprintf(fsize,
"Courier,14");
1510 sprintf(fsize,
"Courier,12");
1513 log_msg(
"setPaperSize(): Papersize: %s, Font: %s", psize, fsize);
1520 strcpy(fsize,
"9x15");
1523 log_msg(
"setPaperSize(): Papersize: %s, Font: %s", psize, fsize);
1535 double xd, a[4], dyda[4], y;
1537 sprintf(gname,
"/tmp/%s/gline.dat",
session);
1539 if((fp = fopen(gname,
"w")) == NULL)
1541 log_msg(
"Unable to open %s for writting", gname);
1546 bzero((
char *)&image->gplot[0],
sizeof(
float) *
MAX_CHANS);
1548 log_msg(
"# Creating G-Line-Line File");
1550 for(k=0;k<image->ginfo.nfits;k++)
1553 a[1] = image->ginfo.fits[k].peak;
1554 a[2] = image->ginfo.fits[k].center;
1555 a[3] = image->ginfo.fits[k].hp;
1557 for(i=0;i<image->head.noint;i++)
1559 xd = (double)image->x1data[i];
1561 fgauss(xd, &a[0], &y, &dyda[0]);
1563 image->gplot[i] += y;
1567 for(i=0;i<image->head.noint;i++)
1569 fprintf(fp,
"%e %e\n", image->x1data[i], image->gplot[i]);
1585 sprintf(bshape,
"/tmp/%s/bsplot.dat",
session);
1587 if((fp = fopen(bshape,
"w")) == NULL)
1589 log_msg(
"Unable to open %s for writting", bshape);
1594 log_msg(
"# Creating Baseline-Shape File");
1596 for(i=0;i<image->head.noint;i++)
1598 fprintf(fp,
"%e %e\n", image->x1data[i], image->bplot[i]);
1614 sprintf(bname,
"/tmp/%s/bline.dat",
session);
1616 if((fp = fopen(bname,
"w")) == NULL)
1618 log_msg(
"Unable to open %s for writting", bname);
1623 log_msg(
"# Creating Baseline-Line File");
1625 for(i=0;i<image->head.noint;i++)
1627 fprintf(fp,
"%e %e\n",
1629 (
float)i * image->binfo.a + image->binfo.b);
1645 sprintf(zname,
"/tmp/%s/zline.dat",
session);
1647 if((fp = fopen(zname,
"w")) == NULL)
1649 log_msg(
"Unable to open %s for writting", zname);
1654 log_msg(
"# Creating Z-Line File");
1656 for(i=0;i<image->head.noint;i++)
1658 fprintf(fp,
"%e 0.0\n", image->x1data[i]);
1673 char sname[256], headBuf[1024];
1675 strncpy(sname, image->head.object, 16);
1680 fprintf(fp,
"reset\n");
1681 fprintf(fp,
"set size 1.0, 1.0\n");
1687 fprintf(fp,
"set title \"%s\" font \"%s\" noenhanced\n", headBuf,
fsize);
1691 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", image->plotwin,
psize,
startx, image->plotwin*10);
1693 fprintf(fp,
"set multiplot title \"%s\" layout 1,2 \n", headBuf);
1696 if(image->xaxisotfoff == 1)
1698 fprintf(fp,
"set xlabel \"R.A. Offset (arcsec)\" tc rgb \"red\"\n");
1701 if(image->xaxisotfoff == 2)
1703 fprintf(fp,
"set xlabel \"Dec Offset (arcsec)\" tc rgb \"red\"\n");
1708 fprintf(fp,
"set xlabel \"%sFreq Offset (MHz)\" tc rgb \"red\"\n",
osbStr);
1713 fprintf(fp,
"set xlabel \"%sVelocity (%8.8s)\" tc rgb \"red\"\n",
osbStr, image->head.veldef);
1718 fprintf(fp,
"set xlabel \"%sChannel Number\" tc rgb \"red\"\n",
osbStr);
1721 if(image->xaxisotfoff == 1)
1723 fprintf(fp,
"set x2label \"R.A. Offset (arcsec)\" tc rgb \"red\"\n");
1726 if(image->xaxisotfoff == 2)
1728 fprintf(fp,
"set x2label \"Dec Offset (arcsec)\" tc rgb \"red\"\n");
1733 fprintf(fp,
"set x2label \"%sFreq Offset (MHz)\" tc rgb \"red\"\n",
osbStr);
1738 fprintf(fp,
"set x2label \"%sVelocity (%8.8s)\" tc rgb \"red\"\n",
osbStr, image->head.veldef);
1743 fprintf(fp,
"set x2label \"%sChannel Number\" tc rgb \"red\"\n",
osbStr);
1746 if(image->pinfo.yplotmode ==
LOG_PLOT)
1748 if(!image->issmt && image->head.utdate < 2013.07)
1750 fprintf(fp,
"set ylabel \"log({/Symbol T}_{R} (K))\" tc rgb \"red\"\n");
1754 fprintf(fp,
"set ylabel \"log({/Symbol T}_{/Symbol A}* (K))\" tc rgb \"red\"\n");
1759 if(strlen(image->title))
1761 fprintf(fp,
"set ylabel \"%s\" tc rgb \"red\"\n", image->title);
1764 if(!image->issmt && image->head.utdate < 2013.07)
1766 fprintf(fp,
"set ylabel \"{/Symbol T}_{R} (K)\" tc rgb \"red\"\n");
1770 fprintf(fp,
"set ylabel \"{/Symbol T}_{/Symbol A}* (K)\" tc rgb \"red\"\n");
1776 fprintf(fp,
"unset grid\n");
1781 fprintf(fp,
"set grid noytics xtics\n");
1786 fprintf(fp,
"set grid ytics noxtics\n");
1790 fprintf(fp,
"set grid\n");
1793 fprintf(fp,
"set key off\n");
1794 fprintf(fp,
"set xrange [%e:%e]\n",
1795 image->x1data[image->pinfo.bdrop],
1796 image->x1data[(
int)image->head.noint-1-image->pinfo.edrop]);
1798 fprintf(fp,
"set x2tics out\n");
1799 fprintf(fp,
"set x2range [%e:%e]\n",
1800 image->x2data[image->pinfo.bdrop],
1801 image->x2data[(
int)image->head.noint-1-image->pinfo.edrop]);
1803 fprintf(fp,
"set yrange [%e:%e]\n", image->pinfo.plotmin, image->pinfo.plotmax);
1806 image->x1data[(
int)image->head.noint-1-image->pinfo.edrop],
1807 image->pinfo.plotmin,
1808 image->pinfo.plotmax);
1822 double x, xscale, xmax, xmin, xstart;
1823 double y, yscale,
ymax, ymin, yoffset;
1824 char datName[256], demName[256], bname[256], zname[256], gname[256], gpBuf[256], bshape[256];
1834 sprintf(datName,
"/tmp/%s/scan.dat",
session);
1836 if((fp = fopen(datName,
"w")) == NULL)
1838 log_msg(
"Unable to open %s for writting", datName);
1844 for(i=0;i<image->head.noint;i++)
1846 fprintf(fp,
"%e %e\n", image->x1data[i], image->yplot1[i]);
1859 sprintf(psname,
"/tmp/%s/pstamp-%d.dat",
session, j);
1861 if((fp = fopen(psname,
"w")) == NULL)
1863 log_msg(
"Unable to open %s for writting", psname);
1874 for(i=0;i<image->head.noint;i++)
1880 if(image->x1data[i] > xmax)
1882 xmax = image->x1data[i];
1885 if(image->x1data[i] < xmin)
1887 xmin = image->x1data[i];
1890 if(image->yplot1[i] > ymax)
1892 ymax = image->yplot1[i];
1895 if(image->yplot1[i] < ymin)
1897 ymin = image->yplot1[i];
1916 log_msg(
"(%2d): xmin = %9.3f, xmax = %9.3f, xstart = %9.3f, stampUx = %9.3f, stampLx = %9.3f, xscale = %9.3f", j,
1924 yoffset = fabs(ymin);
1933 log_msg(
"(%2d): ymin = %9.3f, ymax = %9.3f, yoffst = %9.3f, stampUy = %9.3f, stampLy = %9.3f, yscale = %9.3f", j,
1940 for(i=0;i<image->head.noint;i++)
1946 x = xstart - (double)k * image->head.deltax * xscale;
1948 y = yoffset + p->
stampLRy + (image->yplot1[i] * yscale);
1952 fprintf(fp,
"%e %e\n", x, y);
1959 x = xstart + (double)k * image->head.deltax * xscale;
1961 y = yoffset + p->
stampLRy + (image->yplot1[i] * yscale);
1965 fprintf(fp,
"%e %e\n", x, y);
1978 if(image->pinfo.zline)
1986 if(image->pinfo.bshow)
1994 if(image->pinfo.bplot)
2002 if(image->ginfo.nfits)
2011 sprintf(demName,
"/tmp/%s/scan.dem",
session);
2013 if((fp = fopen(demName,
"w")) == NULL)
2015 log_msg(
"Unable to open %s for writting", demName);
2036 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", image->plotwin,
fsize,
startx, image->plotwin*10);
2038 fprintf(fp,
"plot '%s' with %s lc rgb \"red\"", datName,
plotStyleStrs[image->pinfo.plotStyle]);
2040 if(image->pinfo.bshow)
2042 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", bname);
2045 if(image->pinfo.bplot)
2047 fprintf(fp,
", '%s' with lines lc rgb \"magenta\"", bshape);
2050 if(image->pinfo.zline)
2052 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", zname);
2055 if(image->ginfo.nfits)
2057 fprintf(fp,
", '%s' with lines lc rgb \"dark-magenta\"", gname);
2069 fprintf(fp,
", '/tmp/%s/pstamp-%d.dat' with lines lc rgb \"red\"",
session, j);
2078 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
2081 #ifdef SAVE_DEM_FILE
2092 sprintf(sysbuf,
"cp /tmp/%s/scan.dem /tmp/%s/scan-%d.dem",
session,
session, pid);
2114 char datName1[256], datName2[256], demName[256], bname[256], zname[256], gpBuf[256];
2122 sprintf(datName1,
"/tmp/%s/scan1.dat",
session);
2124 if((fp = fopen(datName1,
"w")) == NULL)
2126 log_msg(
"Unable to open %s for writting", datName1);
2131 log_msg(
"Writing Data file #1: %s", datName1);
2134 for(i=0;i<image->head.noint;i++)
2136 fprintf(fp,
"%e %e\n", image->x1data[i], image->yplot1[i]);
2142 sprintf(datName2,
"/tmp/%s/scan2.dat",
session);
2144 if((fp = fopen(datName2,
"w")) == NULL)
2146 log_msg(
"Unable to open %s for writting", datName2);
2151 log_msg(
"Writing Data file #2: %s", datName2);
2154 for(i=0;i<image->head.noint;i++)
2156 fprintf(fp,
"%e %e\n", image->x1data[i], image->yplot2[i]);
2165 if(image->pinfo.zline)
2173 if(image->pinfo.bshow)
2182 sprintf(demName,
"/tmp/%s/scan.dem",
session);
2184 if((fp = fopen(demName,
"w")) == NULL)
2186 log_msg(
"Unable to open %s for writting", demName);
2204 fprintf(fp,
"plot '%s' with %s lc rgb \"red\"", datName1,
plotStyleStrs[image->pinfo.plotStyle]);
2206 if(image->pinfo.bshow)
2208 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", bname);
2211 if(image->pinfo.zline)
2213 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", zname);
2218 fprintf(fp,
"plot '%s' with %s lc rgb \"red\"", datName2,
plotStyleStrs[image->pinfo.plotStyle]);
2220 if(image->pinfo.bshow)
2222 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", bname);
2225 if(image->pinfo.zline)
2227 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", zname);
2232 fprintf(fp,
"unset multiplot\n");
2236 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
2255 char datName1[256], datName2[256], *cp, datName3[256], datName4[256],
2256 demName[256], sname[256], headBuf[512], gpBuf[256], zname[256];
2267 case 0: cp = datName1; f = image->yplot1;
break;
2268 case 1: cp = datName2; f = image->yplot2;
break;
2269 case 2: cp = datName3; f = image->yplot3;
break;
2270 case 3: cp = datName4; f = image->yplot4;
break;
2273 sprintf(cp,
"/tmp/%s/scan%d.dat",
session, j+1);
2275 if((fp = fopen(cp,
"w")) == NULL)
2277 log_msg(
"Unable to open %s for writting", cp);
2282 log_msg(
"Writing Data file #%d: %s", j+1, cp);
2285 image->head.scan = image->mhp[j].scan;
2286 image->head.restfreq = image->mhp[j].restfreq;
2287 image->head.stsys = image->mhp[j].stsys;
2288 image->head.tcal = image->mhp[j].tcal;
2289 image->head.freqres = image->mhp[j].freqres;
2290 image->head.sideband = image->mhp[j].sideband;
2291 image->head.refpt = image->mhp[j].refpt;
2292 image->head.refpt_vel = image->mhp[j].refpt_vel;
2293 image->head.deltax = image->mhp[j].deltax;
2297 for(i=0;i<image->head.noint;i++,f++)
2299 fprintf(fp,
"%e %e\n", image->x1data[i], *f);
2310 if(image->pinfo.zline)
2319 sprintf(demName,
"/tmp/%s/scan.dem",
session);
2321 if((fp = fopen(demName,
"w")) == NULL)
2323 log_msg(
"Unable to open %s for writting", demName);
2328 strncpy(sname, image->head.object, 16);
2332 image->head.scan = image->mhp[0].scan;
2333 image->head.restfreq = image->mhp[0].restfreq;
2334 image->head.stsys = image->mhp[0].stsys;
2335 image->head.tcal = image->mhp[0].tcal;
2336 image->head.freqres = image->mhp[0].freqres;
2337 image->head.sideband = image->mhp[0].sideband;
2338 image->head.refpt = image->mhp[0].refpt;
2339 image->head.refpt_vel = image->mhp[0].refpt_vel;
2340 image->head.deltax = image->mhp[0].deltax;
2344 fprintf(fp,
"reset\n");
2345 fprintf(fp,
"set size 1.0, 1.0\n");
2347 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", image->plotwin,
fsize,
startx, image->plotwin*10);
2349 fprintf(fp,
"set multiplot title \"%s\" layout 2,2\n", headBuf);
2355 fprintf(fp,
"set xlabel \"%sFreq Offset (MHz)\" tc rgb \"red\"\n",
osbStr);
2360 fprintf(fp,
"set xlabel \"%sVelocity (%8.8s)\" tc rgb \"red\"\n",
osbStr, image->head.veldef);
2365 fprintf(fp,
"set xlabel \"%sChannel Number\" tc rgb \"red\"\n",
osbStr);
2370 fprintf(fp,
"set x2label \"%sFreq Offset (MHz)\" tc rgb \"red\"\n",
osbStr);
2375 fprintf(fp,
"set x2label \"%sVelocity (%8.8s)\" tc rgb \"red\"\n",
osbStr, image->head.veldef);
2380 fprintf(fp,
"set x2label \"%sChannel Number\" tc rgb \"red\"\n",
osbStr);
2383 if(image->pinfo.yplotmode ==
LOG_PLOT)
2385 fprintf(fp,
"set ylabel \"log(Temp (K))\" tc rgb \"red\"\n");
2389 fprintf(fp,
"set ylabel \"Temp (K)\" tc rgb \"red\"\n");
2394 fprintf(fp,
"unset grid\n");
2399 fprintf(fp,
"set grid noytics xtics\n");
2404 fprintf(fp,
"set grid ytics noxtics\n");
2408 fprintf(fp,
"set grid\n");
2411 fprintf(fp,
"set key off\n");
2412 fprintf(fp,
"set x2tics out\n");
2413 fprintf(fp,
"set yrange [%e:%e]\n", image->pinfo.plotmin, image->pinfo.plotmax);
2416 image->x1data[(
int)image->head.noint-1-image->pinfo.edrop],
2417 image->pinfo.plotmin,
2418 image->pinfo.plotmax);
2426 case 0: cp = datName1;
break;
2427 case 1: cp = datName2;
break;
2428 case 2: cp = datName3;
break;
2429 case 3: cp = datName4;
break;
2433 image->head.scan = image->mhp[j].scan;
2434 image->head.restfreq = image->mhp[j].restfreq;
2435 image->head.stsys = image->mhp[j].stsys;
2436 image->head.tcal = image->mhp[j].tcal;
2437 image->head.freqres = image->mhp[j].freqres;
2438 image->head.sideband = image->mhp[j].sideband;
2439 image->head.refpt = image->mhp[j].refpt;
2440 image->head.refpt_vel = image->mhp[j].refpt_vel;
2441 image->head.deltax = image->mhp[j].deltax;
2445 fprintf(fp,
"set xrange [%e:%e]\n",
2446 image->x1data[image->pinfo.bdrop],
2447 image->x1data[(
int)image->head.noint-1-image->pinfo.edrop]);
2449 fprintf(fp,
"set x2range [%e:%e]\n",
2450 image->x2data[image->pinfo.bdrop],
2451 image->x2data[(
int)image->head.noint-1-image->pinfo.edrop]);
2453 fprintf(fp,
"plot '%s' with %s lc rgb \"red\"", cp,
plotStyleStrs[image->pinfo.plotStyle]);
2455 if(image->pinfo.zline)
2457 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", zname);
2463 fprintf(fp,
"unset multiplot\n");
2467 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
2485 char datName1[256], datName2[256], *cp,
2486 datName3[256], datName4[256],
2487 demName[256], sname[256], headBuf[512], gpBuf[256];
2490 dlen = image->nsize /
sizeof(float);
2497 case 0: cp = datName1; f = image->yplot1;
break;
2498 case 1: cp = datName2; f = image->yplot2;
break;
2499 case 2: cp = datName3; f = image->yplot3;
break;
2500 case 3: cp = datName4; f = image->yplot4;
break;
2503 sprintf(cp,
"/tmp/%s/scan%d.dat",
session, j+1);
2505 if((fp = fopen(cp,
"w")) == NULL)
2507 log_msg(
"Unable to open %s for writting", cp);
2512 log_msg(
"Writing Data file #%d: %s; len = %d", j+1, cp, dlen);
2515 for(i=0;i<dlen;i++,f++)
2517 if(image->bplot[i] != 0.0)
2519 fprintf(fp,
"%e %e\n", image->bplot[i], *f);
2530 sprintf(demName,
"/tmp/%s/scan.dem",
session);
2532 if((fp = fopen(demName,
"w")) == NULL)
2534 log_msg(
"Unable to open %s for writting", demName);
2539 strncpy(sname, image->head.object, 16);
2544 fprintf(fp,
"reset\n");
2545 fprintf(fp,
"set size 1.0, 1.0\n");
2547 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", image->plotwin,
fsize,
startx, image->plotwin*10);
2549 fprintf(fp,
"set title \"%s\"font \"%s\" noenhanced\n", headBuf,
fsize);
2551 fprintf(fp,
"set xlabel \"IF #1 (Kelvins)\" tc rgb \"red\"\n");
2552 fprintf(fp,
"set ylabel \"IF #2 (Kelvins)\" tc rgb \"red\"\n");
2554 fprintf(fp,
"set key off\n");
2561 fprintf(fp,
"plot '%s' with %s lc rgb \"red\", ", datName1,
"lp");
2564 fprintf(fp,
"'%s' with %s lc rgb \"red\", ", datName2,
"lines");
2567 fprintf(fp,
"'%s' with %s lc rgb \"red\", ", datName3,
"lines");
2570 fprintf(fp,
"'%s' with %s lc rgb \"red\"\n", datName4,
"lines");
2577 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
2591 double min,
max, tickint, diff;
2602 for(i=image->pinfo.bdrop;i<image->head.noint-image->pinfo.edrop;i++)
2607 image->peakChan = i;
2615 image->datamin =
min;
2616 image->datamax =
max;
2618 log_msg(
"# Max = %f, Min = %f", image->datamax, image->datamin);
2623 order = (int)rint(log10(diff))-1;
2627 image->pinfo.plotmax =
max;
2628 image->pinfo.plotmin =
min;
2632 image->pinfo.plotmin = image->pinfo.ylower;
2633 image->pinfo.plotmax = image->pinfo.yupper;
2636 plot_interval = (image->pinfo.plotmax - image->pinfo.plotmin) / 8.0;
2641 tickint = pow(10.0, (
double)order);
2642 ticks = (int)rint(diff/tickint);
2644 log_msg(
"# Tickint = %f, ticks = %d", tickint, ticks);
2666 log_msg(
"# Tickint = %f, ticks = %d", tickint, ticks);
2668 image->pinfo.plotmax = ((int)floor((max + tickint) / tickint)) * tickint;
2669 image->pinfo.plotmin = image->pinfo.plotmax - (ticks +2) * tickint;
2673 log_msg(
"# Max = %f, Min = %f", image->pinfo.plotmax, image->pinfo.plotmin);
2677 image->pinfo.plotmin = image->pinfo.ylower;
2678 image->pinfo.plotmax = image->pinfo.yupper;
2690 char datName[256], demName[256], gpBuf[256];
2694 sprintf(datName,
"/tmp/%s/scan.dat",
session);
2696 if((fp = fopen(datName,
"w")) == NULL)
2698 log_msg(
"Unable to open %s for writting", datName);
2703 for(i=0;i<flux->num;i++)
2705 if(flux->values[i].freq > 0.0)
2707 fprintf(fp,
"%e %e\n", flux->values[i].freq, flux->values[i].tb);
2715 sprintf(demName,
"/tmp/%s/scan.dem",
session);
2717 if((fp = fopen(demName,
"w")) == NULL)
2719 log_msg(
"Unable to open %s for writting", demName);
2724 fprintf(fp,
"reset\n");
2725 fprintf(fp,
"set size 1.0, 1.0\n");
2726 fprintf(fp,
"set title \"%s Brightness Temperature\"\n", flux->name);
2727 fprintf(fp,
"set xlabel \"Freq (GHz)\"\n");
2728 fprintf(fp,
"set ylabel \"Brightness Temperature (K)\"\n");
2732 fprintf(fp,
"set xrange [%e:%e]\n", flux->bfreq, flux->efreq);
2736 fprintf(fp,
"set xrange [65:840]\n");
2739 fprintf(fp,
"set grid\n");
2741 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", flux->plotwin,
fsize,
startx, flux->plotwin*10);
2743 fprintf(fp,
"plot \'%s' with lines\n", datName);
2747 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
2758 int i, j, k, l, n,
first=1, wh, bfound=0;
2759 char datName[256], demName[256], xlabel[256],
2760 ylabel[256], gpBuf[256], sbname[80], headBuf[512], coeffStr[256], tbuf[256];
2761 float x, y, *f, yy, center;
2762 float xmin=9999.0, xmax = -99999, ymin = 99999.0,
ymax = -99999.0, ydiff;
2780 sprintf(datName,
"/tmp/%s/%s.dat",
session, sbname);
2782 if((fp = fopen(datName,
"w")) == NULL)
2784 log_msg(
"Unable to open %s for writting", datName);
2789 for(i=0;i<a->ar[j].num;i++)
2794 switch(a->plot_select1)
2797 x = a->ar[j].results[i].el;
2798 sprintf(xlabel,
"El (Degrees)");
2802 x = a->ar[j].results[i].ut;
2803 sprintf(xlabel,
"Time (UT)");
2807 x = a->ar[j].results[i].scan;
2808 sprintf(xlabel,
"Scan Number");
2813 sprintf(xlabel,
"Sample Number");
2828 switch(a->plot_select2)
2831 y = a->ar[j].results[i].sig;
2832 sprintf(ylabel,
"Signal Temperature (K)");
2836 y = a->ar[j].results[i].sky;
2837 sprintf(ylabel,
"Sky Temperature (K)");
2841 y = a->ar[j].results[i].smror;
2842 sprintf(ylabel,
"Ratio: (Sig - Sky) / Sky");
2846 y = a->ar[j].results[i].tsys;
2847 sprintf(ylabel,
"System Temperature (K)");
2851 y = a->ar[j].results[i].tastar;
2852 sprintf(ylabel,
"Temperature (Ta*) (K)");
2856 y = a->ar[j].results[i].tr;
2857 sprintf(ylabel,
"Temperature (Tr) (K)");
2861 y = a->ar[j].results[i].janskys;
2862 sprintf(ylabel,
"Janskys");
2866 y = a->ar[j].results[i].normalized;
2867 sprintf(ylabel,
"Normalized");
2871 y = a->ar[j].results[i].janskys;
2872 sprintf(ylabel,
"Janskys");
2886 fprintf(fp,
"%e %e\n", x, y);
2899 if((fp = fopen(datName,
"w")) == NULL)
2901 log_msg(
"Unable to open %s for writting", datName);
2910 switch(a->plot_select1)
2913 x = a->ar[j].results[i].el;
2917 x = a->ar[j].results[i].ut;
2921 x = a->ar[j].results[i].scan;
2929 switch(a->plot_select2)
2948 y = a->expectedTaStar[j];
2952 y = a->expectedTr[j];
2956 y = a->expectedJanskys[j];
2964 y = a->expectedTaStar[j];
2968 fprintf(fp,
"%e %e\n", x, y);
2992 if((fp = fopen(datName,
"w")) == NULL)
2994 log_msg(
"Unable to open %s for writting", datName);
3000 f = &a->fitcurve[j][0];
3002 for(i=0;i<n;i++,f++)
3004 switch(a->plot_select1)
3007 x = a->ar[j].results[i].el;
3011 x = a->ar[j].results[i].ut;
3015 x = a->ar[j].results[i].scan;
3025 fprintf(fp,
"%e %e\n", x, y);
3036 sprintf(demName,
"/tmp/%s/scan.dem",
session);
3038 if((fp = fopen(demName,
"w")) == NULL)
3040 log_msg(
"Unable to open %s for writting", demName);
3045 log_msg(
"Valid = 0x%x", a->valid);
3074 fprintf(fp,
"reset\n");
3075 fprintf(fp,
"set size 1.0, 1.0\n");
3077 fprintf(fp,
"set title \"%s\" font \"%s\" noenhanced\n", headBuf,
fsize);
3079 fprintf(fp,
"set xlabel \"%s\"\n", xlabel);
3080 fprintf(fp,
"set ylabel \"%s\"\n", ylabel);
3081 fprintf(fp,
"set pointsize 2\n");
3082 fprintf(fp,
"set grid\n");
3087 ydiff = (
ymax - ymin) / 10.0;
3088 center = (xmax - xmin);
3089 yy = ymin + ydiff*5.0;
3098 sprintf(coeffStr,
"Coeff for %s ",
mg_sideband[j]);
3102 sprintf(coeffStr,
"Coeff for %s ",
kp_sideband[j]);
3105 for(k=0;k<a->ncoeff+1;k++)
3107 sprintf(tbuf,
"a%d=%.3e ", k, a->coeff[j][k]);
3108 strcat(coeffStr, tbuf);
3111 log_msg(
"accumPlot(): %s", coeffStr);
3113 fprintf(fp,
"set label %d \"%s\" at %f, %f tc lt %d font \"fixed\"\n", j+11, coeffStr, center * 0.60, yy, 3+l);
3123 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", a->plotwin,
fsize,
startx, a->plotwin*10);
3125 fprintf(fp,
"plot ");
3138 fprintf(fp,
"\'%s' with lp", datName);
3162 sprintf(datName,
"/tmp/%s/%s.dat",
session, sbname);
3164 fprintf(fp,
"\'%s' with lp", datName);
3170 if(a->bplot && bfound)
3190 sprintf(datName,
"/tmp/%s/bplot-%s.dat",
session, sbname);
3192 fprintf(fp,
"\'%s' with lines", datName);
3203 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
3216 char datName[256], demName[256], gpBuf[256], headBuf[512],
3217 gname[256], zname[256];
3219 double max = -99999999.0, yy = 0.0;
3221 log_msg(
"Inside contPlot(): %d Data Points", cp->dlen);
3224 sprintf(datName,
"/tmp/%s/scan.dat",
session);
3226 if((fp = fopen(datName,
"w")) == NULL)
3228 log_msg(
"Unable to open %s for writting", datName);
3232 for(i=0;i<cp->dlen;i++)
3234 fprintf(fp,
"%e %e\n", cp->xdata[i], cp->ydata[i]);
3237 log_msg(
"Got %d datapoints & %d Gaussian points", cp->dlen, cp->ngauss);
3244 sprintf(zname,
"/tmp/%s/zline.dat",
session);
3246 if((fp = fopen(zname,
"w")) == NULL)
3248 log_msg(
"Unable to open %s for writting", zname);
3252 for(i=0;i<cp->dlen;i++)
3254 fprintf(fp,
"%e %e\n", cp->xdata[i], 0.0);
3262 log_msg(
"Inside contPlot(): %d Gaussian Data Points", cp->ngauss);
3264 sprintf(gname,
"/tmp/%s/gauss.dat",
session);
3266 if((fp = fopen(gname,
"w")) == NULL)
3268 st_fail(
"Unable to open %s for writting", gname);
3273 for(i=0;i<cp->ngauss;i++)
3275 fprintf(fp,
"%e %e\n", cp->xdata[i], cp->gdata[i]);
3277 if(cp->gdata[i] > max)
3287 sprintf(demName,
"/tmp/%s/scan.dem",
session);
3289 if((fp = fopen(demName,
"w")) == NULL)
3291 log_msg(
"Unable to open %s for writting", demName);
3298 fprintf(fp,
"reset\n");
3299 fprintf(fp,
"set size 1.0, 1.0\n");
3301 fprintf(fp,
"set title \"%s\" font \"%s\" noenhanced\n", headBuf,
fsize);
3303 fprintf(fp,
"set xlabel \"%s\"\n", cp->xlabel);
3304 fprintf(fp,
"set ylabel \"%s\"\n", cp->ylabel);
3308 fprintf(fp,
"unset grid\n");
3313 fprintf(fp,
"set grid noytics xtics\n");
3318 fprintf(fp,
"set grid ytics noxtics\n");
3322 fprintf(fp,
"set grid\n");
3325 fprintf(fp,
"set key off\n");
3327 fprintf(fp,
"set xrange [%e:%e]\n", cp->xdata[0], cp->xdata[cp->dlen-1]);
3331 fprintf(fp,
"set yrange [%e:%e]\n", cp->yplotmin, cp->yplotmax);
3334 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", cp->plotwin,
fsize,
startx, cp->plotwin*10);
3336 if(cp->ngauss && cp->yaxis_scale !=
LOG_PLOT)
3341 if(strlen(cp->glabels[i]) > 2)
3343 fprintf(fp,
"set label %d \"%s\" at %f, %f tc rgb \"blue\" font \"fixed\"\n", i+11, cp->glabels[i], cp->xdata[1], max * yy);
3352 fprintf(fp,
"plot '%s' with lp lc rgb \"red\"", datName);
3356 fprintf(fp,
"plot '%s' with %s lc rgb \"red\"", datName,
plotStyleStrs[cp->plotStyle]);
3361 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", gname);
3366 fprintf(fp,
", '%s' with lines lc rgb \"blue\"", zname);
3373 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
3386 char datName[256], demName[256], gpBuf[256];
3388 log_msg(
"Plotting ALMA Calibrator %s", f->name);
3391 sprintf(datName,
"/tmp/%s/scan.dat",
session);
3393 if((fp = fopen(datName,
"w")) == NULL)
3395 st_fail(
"Unable to open %s for writting", datName);
3400 for(i=0;i<f->num;i++)
3402 fprintf(fp,
"%s %e\n", f->history[i].date, f->history[i].flux);
3408 sprintf(demName,
"/tmp/%s/scan.dem",
session);
3410 if((fp = fopen(demName,
"w")) == NULL)
3412 st_fail(
"Unable to open %s for writting", demName);
3417 fprintf(fp,
"reset\n");
3418 fprintf(fp,
"set size 1.0, 1.0\n");
3420 fprintf(fp,
"set title \"%s Flux Density History\"\n", f->name);
3421 fprintf(fp,
"set xlabel \"Date\"\n");
3422 fprintf(fp,
"set xdata time\n");
3423 fprintf(fp,
"set timefmt \"%%Y/%%m/%%d\"\n");
3424 fprintf(fp,
"set ylabel \"Flux Density (Jk)\"\n");
3425 fprintf(fp,
"set grid\n");
3426 fprintf(fp,
"set pointsize 2\n");
3427 fprintf(fp,
"set key off\n");
3429 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", f->plotwin,
fsize,
startx, f->plotwin*10);
3431 fprintf(fp,
"plot \'%s' using 1:2 with lp\n", datName);
3435 log_msg(
"Plotting ALMA Calibrator %s", f->name);
3436 log_msg(
"Plotting %d ALMA calibrator measurements", f->num);
3437 log_msg(
"Plotting data: %s", f->datestr);
3439 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
3452 char datName[256], bplotName[256], demName[256], gpBuf[256];
3453 double xx, yy, err, ymin=999999.9,
ymax=-999999.9, ydiff;
3455 log_msg(
"plotFocusHistory(): Plotting Focus History");
3458 sprintf(datName,
"/tmp/%s/focus-results.dat",
session);
3460 if((fp = fopen(datName,
"w")) == NULL)
3462 st_fail(
"plotFocusHistory(): Unable to open %s for writting", datName);
3467 for(i=0;i<f->nfocs;i++)
3469 yy = f->focuses[i].fit;
3470 err = f->focuses[i].cnterr;
3474 xx = f->focuses[i].tamb;
3478 xx = f->focuses[i].el;
3484 yy += f->focuses[i].scaling;
3488 yy -= f->focuses[i].scaling;
3492 yy *= f->focuses[i].scaling;
3493 err *= f->focuses[i].scaling;
3497 yy /= f->focuses[i].scaling;
3498 err /= f->focuses[i].scaling;
3505 fprintf(fp,
"%e %e %e\n", xx, yy, err);
3522 sprintf(bplotName,
"/tmp/%s/focus-fit.dat",
session);
3524 if((fp = fopen(bplotName,
"w")) == NULL)
3526 st_fail(
"plotFocusHistory(): Unable to open %s for writting", bplotName);
3531 for(i=0;i<f->nfocs;i++)
3537 xx = f->focuses[i].tamb;
3541 xx = f->focuses[i].el;
3547 yy += f->focuses[i].scaling;
3551 yy -= f->focuses[i].scaling;
3555 yy *= f->focuses[i].scaling;
3559 yy /= f->focuses[i].scaling;
3566 fprintf(fp,
"%e %e\n", xx, yy);
3573 sprintf(demName,
"/tmp/%s/focus.dem",
session);
3575 if((fp = fopen(demName,
"w")) == NULL)
3577 st_fail(
"plotFocusHistory(): Unable to open %s for writting", demName);
3582 fprintf(fp,
"reset\n");
3583 fprintf(fp,
"set size 1.0, 1.0\n");
3585 fprintf(fp,
"set title \"%s Focus History\"\n",
focus_axis_str[f->axis]);
3589 fprintf(fp,
"set xlabel \"Tamb\"\n");
3593 fprintf(fp,
"set xlabel \"El\"\n");
3598 fprintf(fp,
"set ylabel \"Focus Fit (mm)\"\n");
3599 fprintf(fp,
"set grid\n");
3602 ydiff = (
ymax - ymin) / 20.0;
3604 if(f->xlabel != 0.0)
3613 if(f->ylabel != 0.0)
3626 if(strlen(f->blabels[j]) > 2)
3629 fprintf(fp,
"set label %d \"%s\" at %f, %f tc lt %d font \"6x10\"\n", j+11, f->blabels[j], xx, yy, 3);
3639 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", f->plotwin,
fsize,
startx, f->plotwin*10);
3643 fprintf(fp,
"plot \'%s' with yerrorlines", datName);
3647 fprintf(fp,
"plot \'%s' with yerror", datName);
3652 fprintf(fp,
", \'%s' with lines", bplotName);
3659 log_msg(
"Plotting Focus History");
3660 log_msg(
"Plotting %d Focus measurements", f->nfocs);
3664 log_msg(
"And, Plotting %d bplot values", f->nfocs);
3667 sprintf(gpBuf,
"load \"%s\"", demName);
3680 float sinel[11], delta_airmass, upper_airmass, lower_airmass, gfit0;
3681 char fitName[2][256], datName[2][256], demName[256], gpBuf[256], sname[80];
3682 char headBuf[512], *ftype;
3685 log_msg(
"Inside contSptipPlot()");
3689 if(cs->head1.sptip_start > 0.0 && cs->head1.sptip_stop > 0.0)
3691 lower_airmass = 1.0 / sin(cs->head1.sptip_start *
DEG_TO_RAD);
3692 upper_airmass = 1.0 / sin(cs->head1.sptip_stop *
DEG_TO_RAD);
3694 delta_airmass = (upper_airmass - lower_airmass) / 5.0;
3696 sinel[0] = sinel[10] = lower_airmass;
3697 sinel[1] = sinel[ 9] = lower_airmass + delta_airmass * 1.0;
3698 sinel[2] = sinel[ 8] = lower_airmass + delta_airmass * 2.0;
3699 sinel[3] = sinel[ 7] = lower_airmass + delta_airmass * 3.0;
3700 sinel[4] = sinel[ 6] = lower_airmass + delta_airmass * 4.0;
3701 sinel[5] = upper_airmass;
3708 sinel[k] = sinEl[k];
3712 for(chan=0;chan<2;chan++)
3715 sprintf(datName[chan],
"/tmp/%s/scan%d.dat",
session, chan);
3717 if((fp = fopen(datName[chan],
"w")) == NULL)
3719 log_msg(
"Unable to open %s for writting", datName[chan]);
3733 for(i=0;i<cs->dlen;i++,f++)
3735 fprintf(fp,
"%2d %e\n", i+1, *f);
3740 log_msg(
"Wrote Channel %d datafile %s", chan+1, datName[chan]);
3743 sprintf(fitName[chan],
"/tmp/%s/tipfit%d.dat",
session, chan);
3745 if((fp = fopen(fitName[chan],
"w")) == NULL)
3747 log_msg(
"Unable to open %s for writting", fitName[chan]);
3752 for(i=0;i<cs->dlen;i++)
3754 gfit0 = cs->results[chan].a + ( -cs->results[chan].b * sinel[i]);
3755 fprintf(fp,
"%2d %e\n", i+1, gfit0);
3760 log_msg(
"Wrote Channel %d fitfile %s", chan+1, fitName[chan]);
3763 sprintf(demName,
"/tmp/%s/scan.dem",
session);
3774 if((fp = fopen(demName, ftype)) == NULL)
3776 log_msg(
"Unable to open %s for writting", demName);
3781 strncpy(sname, cs->head1.object, 16);
3790 fprintf(fp,
"reset\n");
3791 fprintf(fp,
"set size 1.0, 1.0\n");
3792 fprintf(fp,
"set title \"%s\" font \"%s\" noenhanced\n", headBuf,
fsize);
3794 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", cs->plotwin,
fsize,
startx, cs->plotwin*10);
3796 fprintf(fp,
"set size 1.0, 1.0\n");
3797 fprintf(fp,
"set origin 0.0, 0.0\n");
3798 fprintf(fp,
"set grid\n");
3799 fprintf(fp,
"unset key\n");
3800 fprintf(fp,
"set multiplot\n");
3801 fprintf(fp,
"set xlabel \"Sample Number\"\n");
3802 fprintf(fp,
"set ylabel \"Intensity\"\n");
3803 fprintf(fp,
"set xrange [1:11]\n");
3804 fprintf(fp,
"set size 1.0, 0.5\n");
3805 fprintf(fp,
"set origin 0.0,0.5\n");
3807 fprintf(fp,
"set label 11 \"Tau0 %.3f\" at 5.5, %.3f tc rgb \"red\" font \"fixed\"\n",
3808 cs->results[chan].tau0, cs->ydata1[2]);
3809 fprintf(fp,
"set label 12 \"Siga +/- %.3f\" at 5.5, %.3f tc rgb \"red\" font \"fixed\"\n",
3810 cs->results[chan].sigmaA, cs->ydata1[1]);
3811 fprintf(fp,
"set label 13 \"Sigb +/- %.3f\" at 5.5, %.3f tc rgb \"red\" font \"fixed\"\n",
3812 cs->results[chan].sigmaB, cs->ydata1[0]);
3818 fprintf(fp,
"set title \"%s\" font \"%s\" noenhanced\n", headBuf,
fsize);
3819 fprintf(fp,
"set origin 0.0,0.0\n");
3821 fprintf(fp,
"set label 11 \"Tau0 %.3f\" at 5.5, %.3f tc rgb \"red\" font \"fixed\"\n",
3822 cs->results[chan].tau0, cs->ydata2[2]);
3823 fprintf(fp,
"set label 12 \"Siga +/- %.3f\" at 5.5, %.3f tc rgb \"red\" font \"fixed\"\n",
3824 cs->results[chan].sigmaA, cs->ydata2[1]);
3825 fprintf(fp,
"set label 13 \"Sigb +/- %.3f\" at 5.5, %.3f tc rgb \"red\" font \"fixed\"\n",
3826 cs->results[chan].sigmaB, cs->ydata2[0]);
3831 fprintf(fp,
"plot \'%s' with histeps, \'%s' with lines\n", datName[chan], fitName[chan]);
3835 fprintf(fp,
"unset multiplot\n");
3838 log_msg(
"Wrote %s in %s mode", demName, ftype);
3843 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
3855 float x1, y1, s1, n1,
xx, yy;
3856 float xmin=9999.0, xmax = -99999, ymin = 99999.0,
ymax = -99999.0, ydiff;
3857 float dataymin = 99999.0, dataymax = -99999.0, dataydiff;
3859 char datName[256], demName[256], gpBuf[256];
3860 char coeffStr[256], tbuf[256];
3863 log_msg(
"Plotting Continuum Source %s", obj->source);
3864 log_msg(
"Object %s has %d Measurements", obj->source, obj->numMeas);
3875 if(obj->measurements[0].results[j].measuredFlux > 0.0)
3880 if((fp = fopen(datName,
"w")) == NULL)
3882 st_fail(
"Unable to open %s for writting", datName);
3887 n1 = obj->normalize[j];
3889 for(i=0;i<obj->numMeas;i++)
3893 effSigma = obj->measurements[i].results[j].measuredTmbSigma /
3894 obj->measurements[i].results[j].measuredTmb;
3896 effSigma *= obj->measurements[i].results[j].beam_eff;
3904 x1 = obj->measurements[i].averageEl;
3907 y1 = obj->measurements[i].results[j].beam_eff;
3926 fprintf(fp,
"%e %e %e\n", x1, y1, s1);
3931 effSigma = obj->measurements[i].results[j].measuredFluxSigma /
3932 obj->measurements[i].results[j].measuredFlux;
3934 effSigma *= obj->measurements[i].results[j].app_eff;
3942 x1 = obj->measurements[i].averageEl;
3945 y1 = obj->measurements[i].results[j].app_eff;
3964 fprintf(fp,
"%e %e %e\n", x1, y1, s1);
3975 x1 = obj->measurements[i].averageEl;
3978 y1 = obj->measurements[i].results[j].measuredFlux;
3979 s1 = obj->measurements[i].results[j].measuredFluxSigma;
3997 fprintf(fp,
"%e %e %e\n", x1, y1, s1);
4009 x1 = obj->measurements[i].averageEl;
4012 y1 = obj->measurements[i].results[j].measuredTmb;
4013 s1 = obj->measurements[i].results[j].measuredTmbSigma;
4031 fprintf(fp,
"%e %e %e\n", x1, y1, s1);
4052 if((fp = fopen(datName,
"w")) == NULL)
4054 st_fail(
"Unable to open %s for writting", datName);
4059 n1 = obj->normalize[j];
4066 for(i=0;i<obj->numMeas;i++)
4074 x1 = obj->measurements[i].averageEl;
4088 y1 = obj->fitcurves[j][i];
4105 fprintf(fp,
"%e %e\n", x1, y1);
4114 sprintf(demName,
"/tmp/%s/scan.dem",
session);
4116 if((fp = fopen(demName,
"w")) == NULL)
4118 st_fail(
"Unable to open %s for writting", demName);
4123 fprintf(fp,
"reset\n");
4124 fprintf(fp,
"set size 1.0, 1.0\n");
4128 fprintf(fp,
"set title \"%s Beam Efficiency History\"\n", obj->source);
4129 fprintf(fp,
"set ylabel \"Normalized\"\n");
4134 fprintf(fp,
"set title \"%s Beam Efficiency History\"\n", obj->source);
4135 fprintf(fp,
"set ylabel \"Beam Efficiency\"\n");
4140 fprintf(fp,
"set title \"%s Apperature Efficiency History\"\n", obj->source);
4141 fprintf(fp,
"set ylabel \"Apperture Efficiency\"\n");
4146 fprintf(fp,
"set title \"%s Flux Density History\"\n", obj->source);
4147 fprintf(fp,
"set ylabel \"Flux Density (Jk)\"\n");
4152 fprintf(fp,
"set title \"%s Main Beam Temperature History\"\n", obj->source);
4153 fprintf(fp,
"set ylabel \"Tmb (K)\"\n");
4158 fprintf(fp,
"set xlabel \"Measurement\"\n");
4159 fprintf(fp,
"set xrange [0:%d]\n", obj->numMeas+1);
4163 fprintf(fp,
"set xlabel \"Elevation\"\n");
4165 if(obj->xmin || obj->xmax)
4167 fprintf(fp,
"set xrange [%.2f:%.2f]\n", obj->xmin, obj->xmax);
4171 fprintf(fp,
"set xrange [%.2f:%.2f]\n", 0.0, 90.0);
4178 dataydiff = (dataymax - dataymin) / 10.0;
4179 ydiff = (
ymax - ymin) / 10.0;
4181 if(dataydiff > ydiff)
4186 if(obj->xlabel != 0.0)
4195 if(obj->ylabel != 0.0)
4210 sprintf(coeffStr,
"Coeff for %s ",
mg_sideband[j]);
4212 for(k=0;k<obj->ncoeff+1;k++)
4214 sprintf(tbuf,
"a%d=%.3e ", k, obj->coeff[j][k]);
4215 strcat(coeffStr, tbuf);
4218 log_msg(
"accumPlot(): %s", coeffStr);
4221 fprintf(fp,
"set label %d \"%s\" at %f, %f tc lt %d font \"6x10\"\n", j+11, coeffStr, xx, yy, 3+l);
4231 fprintf(fp,
"set grid\n");
4232 fprintf(fp,
"set pointsize 2\n");
4234 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", obj->plotwin,
fsize,
startx, obj->plotwin*10);
4247 fprintf(fp,
"plot \'%s' with yerrorlines", datName);
4251 fprintf(fp,
"plot \'%s' with yerror", datName);
4260 fprintf(fp,
", \'%s' with yerrorlines", datName);
4264 fprintf(fp,
", \'%s' with yerror", datName);
4285 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
4298 char fname[256], demName[256], gpBuf[256],
title[256];
4302 for(i=0;i<tsys->num;i++)
4304 if(!tsys->freqs[i].used)
4309 sprintf(fname,
"/tmp/%s/tsys-%03d.dat",
session, tsys->freqs[i].freq);
4311 if((fp = fopen(fname,
"w")) == NULL)
4313 log_msg(
"Unable to open %s for writting", fname);
4319 for(el=0;el<90;el++)
4321 if(tsys->freqs[i].elev[el] > 0)
4323 fprintf(fp,
"%d %d\n", el, tsys->freqs[i].elev[el]);
4331 sprintf(demName,
"/tmp/%s/tsys.dem",
session);
4333 if((fp = fopen(demName,
"w")) == NULL)
4335 log_msg(
"Unable to open %s for writting", demName);
4340 fprintf(fp,
"reset\n");
4341 fprintf(fp,
"set size 1.0, 1.0\n");
4342 fprintf(fp,
"set title \"Receiver Tsys\"\n");
4343 fprintf(fp,
"set grid\n");
4344 fprintf(fp,
"set xlabel \"Elevation\" tc rgb \"red\"\n");
4345 fprintf(fp,
"set ylabel \"Tsys\" tc rgb \"red\"\n");
4350 for(i=0;i<tsys->num;i++)
4352 if(!tsys->freqs[i].used)
4357 sprintf(fname,
"/tmp/%s/tsys-%03d.dat",
session, tsys->freqs[i].freq);
4358 sprintf(title,
"%03d GHz", tsys->freqs[i].freq);
4362 fprintf(fp,
"plot '%s' with lines lc rgb \"red\" title \"%s\"", fname, title);
4366 fprintf(fp,
", '%s' with lines lc rgb \"red\" title \"%s\"", fname, title);
4372 log_msg(
"Plotted %d freqs", indx);
4378 sprintf(gpBuf,
"load \"/tmp/%s/tsys.dem\"",
session);
4392 char fname[256], demName[256], gpBuf[256], headBuf[1024];
4393 char xbuf[256], ybuf[256];
4395 log_msg(
"SSS: scans: %d", ss->nscans);
4396 log_msg(
"SSS: X-Axis: %d", ss->xaxis);
4397 log_msg(
"SSS: Y-Axis: %d", ss->yaxis);
4398 log_msg(
"SSS: Plotwin: %d", ss->plotwin);
4399 log_msg(
"SSS: XDelay: %d", ss->xdelay);
4404 if(ss->scans[0].scan[i] < 1.0)
4409 sprintf(fname,
"/tmp/%s/sss-%d.dat",
session, i);
4411 if((fp = fopen(fname,
"w")) == NULL)
4413 log_msg(
"Unable to open %s for writting", fname);
4419 for(j=0;j<ss->nscans;j++)
4428 default: x = ss->scans[j].scan[i];
break;
4436 default: y = ss->scans[j].peak[i];
break;
4439 fprintf(fp,
"%e %e\n", x, y);
4444 log_msg(
"Wrote %d elements to %s", j, fname);
4449 sprintf(demName,
"/tmp/%s/sss.dem",
session);
4451 if((fp = fopen(demName,
"w")) == NULL)
4453 log_msg(
"Unable to open %s for writting", demName);
4458 fprintf(fp,
"reset\n");
4459 fprintf(fp,
"set size 1.0, 1.0\n");
4463 fprintf(fp,
"set title \"%s\"\n", headBuf);
4464 fprintf(fp,
"set grid\n");
4473 default: strcpy(xbuf,
"Scan");
break;
4481 default: strcpy(ybuf,
"(K)");
break;
4484 fprintf(fp,
"set xlabel \"%s\" tc rgb \"red\"\n", xbuf);
4485 fprintf(fp,
"set ylabel \"%s\" tc rgb \"red\"\n", ybuf);
4489 fprintf(fp,
"set yrange [%e:%e]\n", ss->ylower, ss->yupper);
4494 fprintf(fp,
"set terminal x11 enhanced %d font \"%s\" position %d,%d\n", ss->plotwin,
fsize,
startx, ss->plotwin*10);
4499 if(ss->scans[0].scan[i] < 1.0)
4504 sprintf(fname,
"/tmp/%s/sss-%d.dat",
session, i);
4508 fprintf(fp,
"plot '%s' with lp lc rgb \"red\" ", fname);
4512 fprintf(fp,
", '%s' with lp lc rgb \"red\" ", fname);
4522 sprintf(gpBuf,
"load \"/tmp/%s/sss.dem\"",
session);
4534 sprintf(tbuf,
"x11 size 800,600 position %d,0",
startx);
4538 log_msg(
"Failed to open connection to gnuplot");
4544 log_msg(
"# Gnuplot gfd = %d", gfd);
4551 double xmin, xmax, ymin,
ymax;
4570 double x, y, x2, y2;
4582 log_msg(
"sendMousePosition(): Sending structure");
4615 double x, y, x2, y2;
4617 double xmin, xmax, ymin,
ymax;
4619 log_msg(
"parseGnuplot(1): Got %s", buf);
4621 if(buf && strstr(buf,
"MOUSE"))
4623 if(!strncmp(buf,
"MOUSE: MOUSE: ", 14))
4625 n = sscanf(buf,
"MOUSE: MOUSE: %lf %lf %lf %lf", &x, &x2, &y, &y2);
4629 n = sscanf(buf,
"MOUSE: %lf %lf %lf %lf", &x, &x2, &y, &y2);
4634 log_msg(
"parseGnuplot(2): Got %d args", n);
4639 log_msg(
"parseGnuplot(2): Wrong number of args: %d", n);
4640 log_msg(
"parseGnuplot(2): Got %s", buf);
4644 if(buf && strstr(buf,
"MAP_ANGLE"))
4646 n = sscanf(buf,
"MAP_ANGLE: %lf %lf", &ang1, &ang2);
4650 log_msg(
"parseGnuplot(3): Got %d Args", n);
4655 if(buf && strstr(buf,
"PLOT_RANGE"))
4657 n = sscanf(buf,
"PLOT_RANGE: %lf %lf %lf %lf", &xmin, &xmax, &ymin, &ymax);
4661 log_msg(
"parseGnuplot(4): Got %d Args", n);
4673 char cmdStr[256], plotfname[256];
4675 sprintf(cmdStr,
"set terminal postscript font \"%s\" color solid enhanced landscape size %s",
fsize,
psize);
4679 sprintf(plotfname,
"/tmp/%s/ccal_plot.ps",
session);
4680 sprintf(cmdStr,
"set out \"%s\"", plotfname);
4683 sprintf(cmdStr,
"replot");
4686 sprintf(cmdStr,
"set terminal x11 enhanced");
4689 sprintf(cmdStr,
"replot");
4700 int lastCmdCancel = 0;
4703 int expectedSize = -1, nexpected = 0, curExpected=0, bplotExpected = 0;
4704 char message[
MAX_BUF_SIZE], gpBuf[512], logdir[256], *cp, sysbuf[256];
4710 n = sscanf(argv[1],
"%dx%d", &xw, &xy);
4719 cp = getenv(
"LPSESSION");
4731 sprintf(logdir,
"LOGDIR=/tmp/%s/",
session);
4749 strcpy(
fsize,
"9x15");
4759 sel =
sock_sel(message, &len, &gfd, 1, 60, 0);
4761 log_msg(
"< Select Returned: %d", sel);
4780 log_msg(
"< Got %d bytes on fd = %d", len, sel);
4783 if(len == expectedSize)
4785 log_msg(
"Len %d matches Expected %d", len, expectedSize);
4787 if(curExpected != nexpected)
4812 if(curExpected != nexpected)
4821 log_msg(
"Received my Baseline Plot Array");
4826 if(curExpected == nexpected && !bplotExpected)
4850 log_msg(
"CONT mode not implemented yet");
4869 if(!strncmp(message,
"LP_IMAGE_INFO", 13))
4871 log_msg(
"< Got SHORT_IMAGE_INFO struct");
4881 log_msg(
"Expecting %d Arrays of %d size", nexpected, expectedSize);
4885 log_msg(
"Also Expecting a Baseline Plot Array");
4889 log_msg(
"NOT Expecting a Baseline Plot Array");
4900 if(!strncmp(message,
"FLUX_INFO", 9))
4902 log_msg(
"< Got FLUX_INFO struct");
4916 if(!strncmp(message,
"ACCUM_INFO", 9))
4918 log_msg(
"< Got ACCUM_RESULTS_SEND struct: %d", len);
4920 bcopy(message, (
char *)&
ars,
sizeof(
ars));
4932 if(!strncmp(message,
"CONTINUUM_PLAIN", 15))
4934 log_msg(
"< Got CONTINUUM_PLAIN struct: %d", len);
4948 if(!strncmp(message,
"CONTINUUM_SPTIP", 15))
4950 log_msg(
"< Got CONTINUUM_SPTIP struct: %d", len);
4964 if(!strncmp(message,
"FLUX_HISTORY", 9))
4966 log_msg(
"< Got FLUX_HISTORY struct: %d", len);
4968 bcopy(message, (
char *)&
fh,
sizeof(
fh));
4980 if(!strncmp(message,
"FOCUS_SEND", 10))
4982 log_msg(
"< Got FOCUS_HISTORY_SEND struct: %d", len);
4994 if(len ==
sizeof(
struct OBJECT))
4996 if(!strncmp(message,
"OBJECT_MAGIC", 12))
4998 log_msg(
"< Got OBJECT_MAGIC struct: %d", len);
5008 log_msg(
"ObjectDisplay(): message is not OBJECT_MAGIC");
5016 if(!strncmp(message,
"FFT_INFO", 8))
5018 log_msg(
"< Got FFT_INFO struct: %d", len);
5028 log_msg(
"main(): message is not FFT_INFO");
5036 if(!strncmp(message,
"HISTOGRAM", 9))
5038 log_msg(
"< Got HISTO_INFO struct: %d", len);
5048 log_msg(
"main(): message is not HISTO_INFO");
5056 if(!strncmp(message,
"STRINGS", 7))
5058 log_msg(
"< Got STRINGS_AND_THINGS struct: %d", len);
5060 bcopy(message, (
char *)&
sat,
sizeof(
sat));
5065 log_msg(
"main(): message is not STRINGS_AND_THINGS");
5073 if(!strncmp(message,
"TSYS_SEND", 9))
5075 log_msg(
"< Got TSYS_SEND struct: %d", len);
5085 log_msg(
"main(): message is not TSYS_SEND");
5093 if(!strncmp(message,
"SCAN_SUM_SEND", 13))
5095 log_msg(
"< Got SCAN_SUM_SEND struct: %d", len);
5097 bcopy(message, (
char *)&
sss,
sizeof(
sss));
5105 log_msg(
"main(): message is not SCAN_SUM_SEND; %s", message);
5112 if(!strncmp(message,
"exit", 4))
5114 log_msg(
"< Got command to exit()");
5123 if(!strncmp(message,
"ccur", 4))
5130 if(!strncmp(message,
"tcur", 4))
5137 if(!strncmp(message,
"cancel", 4))
5140 log_msg(
"> Sending SIGINT to gnuplot");
5141 sprintf(sysbuf,
"/bin/kill -INT %d",
gnuplot_pid);
5147 if(!strncmp(message,
"restart", 7))
5150 log_msg(
"> Sending SIGHUP to gnuplot");
5157 if(!strncmp(message,
"page", 4))
5163 if(!strncmp(message,
"show_view", 9))
5169 if(!strncmp(message,
"get_range", 9))
5175 if(!strncmp(message,
"make", 4))
5181 if(!strncmp(message,
"refresh", 7))
5222 if(!strncmp(message,
"load", 4))
5225 sprintf(gpBuf,
"load \"/tmp/%s/scan.dem\"",
session);
5229 if(!strncmp(message,
"xgraphic", 8))
5231 log_msg(
"< Got '%s'", message);
5232 sprintf(gpBuf,
"%s", message+8);
5238 log_msg(
"* sock_sel() returned %d", sel);
5247 All gnuplot available variables:
5249 pi = 3.14159265358979
5253 GPVAL_TERMOPTIONS =
"1 nopersist enhanced size 815,850 position -100,100 "
5256 GPVAL_PATCHLEVEL =
"0"
5257 GPVAL_COMPILE_OPTIONS =
"-READLINE +LIBREADLINE +HISTORY -BACKWARDS_COMPATIBILITY +BINARY_DATA \n+GD_PNG +GD_JPEG +GD_TTF +GD_GIF +ANIMATION \n-NOCWDRC +X11 +X11_POLYGON +MULTIBYTE +X11_EXTERNAL +USE_MOUSE +HIDDEN3D_QUADTREE \n+DATASTRINGS +HISTOGRAMS +OBJECTS +STRINGVARS +MACROS +IMAGE \n"
5261 GPVAL_TERMINALS =
" canvas cgm corel dpu414 dumb dxf eepic emf emtex epslatex epson_180dpi epson_60dpi epson_lx800 fig gif gpic hp2623A hp2648 hp500c hpdj hpgl hpljii hppj imagen jpeg latex mf mif mp nec_cp6 okidata pbm pcl5 pdfcairo png pngcairo postscript pslatex pstex pstricks qms regis starc svg tandy_60dpi tek40xx tek410x texdraw tgif tkcanvas tpic unknown vttek wxt x11 xlib xterm "
5262 GPVAL_pi = 3.14159265358979
5266 GPVAL_PWD =
"/home/helix/tfolkers/cactus/linuxpops/linuxpops"
5267 GPVAL_LAST_PLOT =
"splot \"/tmp/LP-9430/beam_map.dat\" every 1::0::1024 with lines"
5268 GPVAL_TERM_WINDOWID = 10485898
5269 GPVAL_X_MIN = -307.5
5273 GPVAL_DATA_X_MIN = -300.0
5274 GPVAL_DATA_X_MAX = 300.0
5275 GPVAL_Y_MIN = -307.5
5279 GPVAL_DATA_Y_MIN = -307.5
5280 GPVAL_DATA_Y_MAX = 292.5
5281 GPVAL_X2_MIN = -10.0
5283 GPVAL_X2_REVERSE = 0
5285 GPVAL_DATA_X2_MIN = 0.0
5286 GPVAL_DATA_X2_MAX = 0.0
5287 GPVAL_Y2_MIN = -10.0
5289 GPVAL_Y2_REVERSE = 0
5291 GPVAL_DATA_Y2_MIN = 0.0
5292 GPVAL_DATA_Y2_MAX = 0.0
5293 GPVAL_Z_MIN = -68.76
5297 GPVAL_DATA_Z_MIN = -68.25509
5298 GPVAL_DATA_Z_MAX = 0.010893
5299 GPVAL_CB_MIN = -68.76
5301 GPVAL_CB_REVERSE = 0
5307 GPVAL_DATA_CB_MIN = -68.25509
5308 GPVAL_DATA_CB_MAX = 0.010893
5317 GPVAL_TERM_XMIN = 87
5318 GPVAL_TERM_XMAX = 4009
5319 GPVAL_TERM_YMIN = 156
5320 GPVAL_TERM_YMAX = 3940
5322 GPVAL_VIEW_ROT_X = 65.0
5323 GPVAL_VIEW_ROT_Z = 41.0
5324 GPVAL_VIEW_SCALE = 1.0
5325 GPVAL_VIEW_ZSCALE = 1.0
struct STRINGS_AND_THINGS sat
char label[MAX_LABEL_LENGTH]
int placeHlines(struct LP_IMAGE_INFO *image, FILE *fp)
int linePlot_1(struct LP_IMAGE_INFO *image, int how)
int sendMapAngle(double ang1, double ang2)
int sock_write(struct SOCK *s, char *message, int l)
int sendMousePosition(double x, double y, double x2, double y2)
int displayHisto(struct HISTO_INFO *histo, int how)
int setPaperSize(double w, double h, char *psize, char *fsize)
struct STAMP stamps[MAX_PSTAMPS]
int placeLabels(struct LP_IMAGE_INFO *image, FILE *fp, int print)
#define FOCUS_SCALE_MULTI
int contSptipPlot(struct CONTINUUM_SPTIP *cs, int how)
#define LAST_FOCUS_HISTORY
int log_perror(char *msg)
int displayTsys(struct TSYS_SEND *tsys, int how)
int displayFFT(struct FFT_INFO *fft, int how)
int logImageInfo(struct LP_IMAGE_INFO *image)
#define MAX_TBLOCK_LABELS
int displayScanSum(struct SCAN_SUM_SEND *ss, int how)
#define LAST_CONTINUUM_PLAIN
int log_eventdEnable(int enable)
int placeDate(struct LP_IMAGE_INFO *image, FILE *fp)
int plotFocusHistory(struct FOCUS_HISTORY_SEND *f, int how)
int plotXcor(struct LP_IMAGE_INFO *image, int how)
#define ACCUM_PLOT_Y_TSYS
struct LP_IMAGE_INFO last_image
struct IMAGE_LABELS labels[MAX_TBLOCK_LABELS]
int plotFluxHistory(struct FLUX_HISTORY *f, int how)
#define LAST_FLUX_HISTORY
char * makeFrStr(double freqres)
#define ACCUM_PLOT_Y_SMROR
struct IMAGE_LABELS labels[MAX_IMAGE_LABELS]
int makeFFTHeader(struct FFT_INFO *fft, char *buf)
int displayObjHistory(struct OBJECT *obj, int how)
int gnuplot_init(char *term)
int find_ticks(struct LP_IMAGE_INFO *image)
struct FOCUS_HISTORY_SEND focus_send
int makeOSB(struct HEADER *h)
struct HISTO_INFO last_histo
int makeHistoHeader(struct HISTO_INFO *histo, char *buf)
int sexagesimal(double dang, char *str, int prec)
int sock_bufct(int bufct)
int placeMarkers(struct LP_IMAGE_INFO *image, FILE *fp)
int log_msg(const char *fmt,...)
#define LAST_CONTINUUM_SPTIP
int placeBmark(struct LP_IMAGE_INFO *image, FILE *fp)
int smart_log_open(char *name, int offset)
struct FORK_TINE tines[MAX_FORK_TINES]
int sock_send(struct SOCK *s, char *message)
struct IMAGE_HLINE hlines[MAX_IMAGE_HLINES]
struct IMAGE_FORKS forks[MAX_IMAGE_FORKS]
int makeGfile(struct LP_IMAGE_INFO *image, char *gname, FILE *fp)
struct IMAGE_MARKERS markers[MAX_IMAGE_MARKERS]
struct FLUX_INFO last_flux
int placeChanMarkers(struct LP_IMAGE_INFO *image, FILE *fp)
int readGnuplot(char *buf)
#define MAX_IMAGE_GAUSS_RESULTS
int placePstamps(struct LP_IMAGE_INFO *image, FILE *fp)
char label[MAX_LABEL_LENGTH]
int writeGnuplot(char *buf, int delay)
char label[MAX_LABEL_LENGTH]
struct CONTINUUM_SPTIP last_sptip_send
int makeLineHeader(struct LP_IMAGE_INFO *image, char *buf)
int makeBshow(struct LP_IMAGE_INFO *image, char *bname, FILE *fp)
#define ACCUM_PLOT_X_SCAN
#define MAX_IMAGE_MARKERS
int sock_sel(char *message, int *l, int *p, int n, int tim, int rd_in)
int makeZline(struct LP_IMAGE_INFO *image, char *zname, FILE *fp)
#define FOCUS_SORTED_TAMB
int placeGauss(struct LP_IMAGE_INFO *image, FILE *fp, int print)
int placeBadChans(struct LP_IMAGE_INFO *image, FILE *fp)
#define ACCUM_PLOT_Y_TASTAR
int makeHeaderAndLabels(struct LP_IMAGE_INFO *image, FILE *fp, int mode, int how)
struct IMAGE_PSTAMPS pstamp
struct IMAGE_DATE_STRING date
#define MAX_GNUPLOT_INITS
#define LAST_ACCUM_RESULTS
int placeForks(struct LP_IMAGE_INFO *image, FILE *fp, int how)
struct ACCUM_RESULTS_SEND ars
int makeContHeader(struct HEADER *h, struct ACCUM_RESULTS_SEND *a, char *buf)
int makeBfile(struct LP_IMAGE_INFO *image, char *bshape, FILE *fp)
int computeXaxis(struct LP_IMAGE_INFO *image, int logit)
struct CONTINUUM_PLAIN last_plain_send
#define FOCUS_SCALE_DIVIDE
struct XGRAPHIC_SEND xsend
struct GAUSS_INFO_RESULTS results[MAX_IMAGE_GAUSS_RESULTS]
int placeTBlock(struct LP_IMAGE_INFO *image, FILE *fp, int print)
#define ACCUM_PLOT_Y_NORMAL
struct BOUND * sock_bind(char *mbname)
char * makeDate(double d)
struct SOCK * sock_connect(char *mbname)
int linePlot_2(struct LP_IMAGE_INFO *image, int how)
int makeSSSHeader(struct SCAN_SUM_SEND *ss, char *buf)
int fluxPlot(struct FLUX_INFO *flux, int how)
int setCactusEnvironment(void)
int accumPlot(struct ACCUM_RESULTS_SEND *a, int how)
int linePlot_4(struct LP_IMAGE_INFO *image, int how)
int contPlot(struct CONTINUUM_PLAIN *cp, int how)
int sendPlotRange(double xmin, double xmax, double ymin, double ymax)
int parseGnuplot(char *buf)
#define LAST_OBJECT_HISTORY
struct TSYS_SEND last_tsys
struct TITLE_BLOCK tblock
#define ACCUM_PLOT_Y_JANSKY