61 #define MAX_DATA_CHANNELS 8192
127 st_report(
"Setting Verbose Level to %d", v);
139 st_report(
"Suggested Levels: 1 Verbose for Parsing Info");
140 st_report(
" 2 Verbose for Auto Tau Calculations");
141 st_report(
" 4 Verbose for Critiria Slection");
142 st_report(
" 8 Verbose for Xgraphic Activity");
143 st_report(
" 16 Verbose for FBOFFSET Routines");
144 st_report(
" 32 Verbose for BASELINE Routines");
145 st_report(
" 64 Verbose for STATS Routines");
146 st_report(
" 128 Verbose for RECURSIVE Info");
147 st_report(
" 256 Verbose for Batchfile Info");
148 st_report(
" 512 Verbose for Alias Info");
149 st_report(
" 1024 Verbose for Fileops Info");
150 st_report(
" 2048 Verbose for Gridmap Routines");
151 st_report(
" 4096 Verbose for Flag Checking");
152 st_report(
" 8192 Verbose for Atm Routines");
187 st_fail(
"No scans Loaded Yet");
248 if(w > 0.0 && h > 0.0)
277 char obj[256], modeStr[256];
288 sprintf(fname,
"CF-%.2f-%.2f_%04dKHz_%d",
296 sprintf(fname,
"FFT-%.2f-%.2f_%04dKHz_%d",
304 sprintf(fname,
"HISTO-%.2f-%.2f_%04dKHz_%d",
337 sprintf(fname,
"OBJECT-%.2f-%.2f-%s",
354 sprintf(fname,
"CaptureFile-%d", pid);
372 st_report(
"Suggested Filename: %s", fname);
387 int pid, bpaper = 0, dops = 0, jpg=0;
388 char fname_out[600], fname[512], jname[600], pname[256], *prt;
389 double old_pw, old_ph;
390 static char sysbuf[2048];
394 st_fail(
"printPlot(): No privious scan loaded");
433 st_fail(
"printPlot(): /j flag AND /p flag not allowed");
467 sprintf(fname_out,
"%s.pdf", fname);
468 st_report(
"printPlot(): Converting plotfile /tmp/%s/ccal_plot.ps to %s",
session, fname_out);
469 sprintf(sysbuf,
"cat /tmp/%s/ccal_plot.ps | /usr/bin/epstopdf -f --outfile=%s",
session, fname_out);
473 sprintf(fname_out,
"%s.ps", fname);
474 st_report(
"printPlot(): Coping plotfile /tmp/%s/ccal_plot.ps to %s",
session, fname_out);
475 sprintf(sysbuf,
"mv /tmp/%s/ccal_plot.ps %s",
session, fname_out);
480 st_report(
"printPlot(): Executing Command: %s", sysbuf);
487 sprintf(jname,
"%s.jpg", fname);
488 st_report(
"printPlot(): Converting plotfile %s to %s", fname_out, jname);
489 sprintf(sysbuf,
"/usr/bin/pdftoppm -jpeg %s > /tmp/tmp.jpg", fname_out);
494 st_report(
"printPlot(): Converting image for Publication");
495 sprintf(sysbuf,
"/usr/bin/convert -resize 1280x1024 -rotate 90 /tmp/tmp.jpg %s", pname);
499 sprintf(sysbuf,
"/usr/bin/convert -rotate 90 /tmp/tmp.jpg %s", pname);
506 sprintf(pname,
"%s.png", fname);
507 st_report(
"printPlot(): Converting plotfile %s to %s", fname_out, pname);
508 sprintf(sysbuf,
"/usr/bin/pdftoppm -png %s > /tmp/tmp.png", fname_out);
513 st_report(
"printPlot(): Converting image for Publication");
514 sprintf(sysbuf,
"/usr/bin/convert -resize 1280x1024 -rotate 90 /tmp/tmp.png %s", pname);
518 sprintf(sysbuf,
"/usr/bin/convert -rotate 90 /tmp/tmp.png %s", pname);
526 sprintf(sysbuf,
"evince %s 1>> /dev/null 2>&1 &", fname_out);
565 st_report(
"printPlot(): Printing file /tmp/%s/ccal_plot.ps to %s",
session, prt);
569 sprintf(sysbuf,
"lpr -o media=11x17 -o fitplot /tmp/%s/ccal_plot.ps",
session);
573 sprintf(sysbuf,
"lpr -P%s /tmp/%s/ccal_plot.ps", prt,
session);
578 st_report(
"printPlot(): Executing Command: %s", sysbuf);
654 st_report(
"Executing Command: %s", sysbuf);
657 ret = system(sysbuf);
692 sprintf(cmdBuf,
"formula /w .lp.formulas");
713 st_warn(
"plotAccum() Not implemented yet");
729 int ns,
feed, oc = -1;
730 double ttime, freq, tsys,
tcal, scan_or_nsave;
731 double xoff, yoff, roff, doff,
az;
737 ns = (int)(p->noint / p->nophase);
738 ttime = p->noint * p->samprat;
743 freq = p->restfreq / 1000.0;
744 ns = (int)(p->inttime / p->samprat);
750 freq = p->restfreq / 1000.0;
751 ns = (int)(p->inttime / p->samprat);
761 if(strstr(p->backend,
"DIGITAL"))
768 if(strstr(p->backend,
"HU"))
773 if(strstr(p->backend,
"VU"))
778 if(strstr(p->backend,
"HL"))
783 if(strstr(p->backend,
"VL"))
808 strncpy(backend, p->backend, 8);
814 scan_or_nsave = p->align3[0]+1;
818 scan_or_nsave = p->scan;
823 if(p->openpar[5] == 5555.5)
829 if(p->openpar[8] == 9999.5 || p->openpar[8] == 9998.5)
849 st_print(
" %10.10s %10.6f %10.4f %6.2f %8.2f %5d %4.0f %5.1f %5.1f %8.8s %5.5s %8.8s %4.0f %4.0f ",
850 p->object, freq, p->utdate, p->ut, scan_or_nsave, ns, ttime, az, p->el, p->obsmode, sbname,
851 backend, tsys, tcal);
853 if(!strncmp(p->obsmode,
"CONTMAP", 7))
855 st_print(
" %3.0f %3.0f %3.0f %3.0f %3.0f %6.2f",
856 p->noxpts, p->noypts,
857 p->xcell0, p->ycell0,
858 p->scanang, p->focusr);
861 if(!strncmp(p->obsmode,
"LINEOTF", 7))
863 st_print(
" %5.2f %2d %2d %2d %2d", fabs(p->freqres),
864 (
int)p->xcell0, (
int)p->noxpts,
865 (
int)p->ycell0, (
int)p->noypts);
868 if(!strncmp(p->obsmode,
"LINE", 4))
870 xoff = p->az_offset * 3600.0;
871 yoff = p->el_offset * 3600.0;
873 roff = (p->epocra - p->xsource) * 3600.0 * cos(p->epocdec*
CTR);
874 doff = (p->epocdec - p->ysource) * 3600.0;
878 st_print(
" %5.2f %5.1f %5.1f", fabs(p->freqres), roff, doff);
883 st_print(
" %5.2f %5.1f %5.1f", fabs(p->freqres), xoff, yoff);
887 st_print(
" %5.2f %5.1f %5.1f", fabs(p->freqres), 0.0, 0.0);
927 sprintf(source,
"%16.16s", p->
object);
928 sprintf(backend,
"%8.8s", p->
backend);
929 sprintf(mode,
"%8.8s", p->
obsmode);
950 st_warn(
"Found %d Scans Matching Criteria", j-1);
985 st_warn(
"Found %d Scans Matching Criteria", j-1);
1020 st_warn(
"Found %d Scans Matching Criteria", j-1);
1058 if(env->
bkres == 0.0)
1074 strncpy(backend, h->backend, 8);
1078 ret = fnmatch(env->
backend, backend, FNM_CASEFOLD);
1086 strncpy(backend, h->backend, 8);
1091 ret = fnmatch(env->
backend, backend, FNM_CASEFOLD);
1094 if(env->
bkres == 0.0)
1126 int i, len, n=0, tip=0,
feed;
1170 st_warn(
"No data file loaded");
1273 strncpy(source, p->
object, 16);
1337 if(strncmp(p->
obsmode,
"CONTFOC", 7))
1346 if(strncmp(p->
obsmode,
"CONTEWFC", 8))
1355 if(strncmp(p->
obsmode,
"CONTNSFC", 8))
1364 if(strncmp(p->
obsmode,
"CONTSEQ", 7))
1373 if(strncmp(p->
obsmode,
"CONTMAP", 7))
1382 if(strncmp(p->
obsmode,
"CONTFIVE", 8) && strncmp(p->
obsmode,
"CONTQK5", 7))
1429 strncpy(source, p->
object, 16);
1450 st_warn(
"Found %d Scans Matching Criteria & Tsys < %.1f", n, env->
tsyslimit);
1454 st_warn(
"Found %d Scans Matching Criteria", n);
1459 st_fail(
"No Scans Matched Criteria");
1477 st_report(
"Usage: %s [-hklrsvx] [-i init_file] [-g global_memory_file]", name);
1478 st_report(
"Where: -g Use named global_memory_file instead of default.");
1479 st_report(
" -h Show this help and exit.");
1480 st_report(
" -i Load init_file upon starting.");
1481 st_report(
" -k Ignore LOCKFILE altogether.");
1482 st_report(
" -l Turn on logging. Logfile will be named: linuxpops.$(PID).log");
1483 st_report(
" -q Be quiet upon starting.");
1484 st_report(
" -r Remove stale LOCKFILE before starting.");
1485 st_report(
" -s Turn on Socket Communication to Monitor.");
1486 st_report(
" -v Show version info and exit.");
1487 st_report(
" -x Run init script and exit.");
1512 st_report(
"****************************************************************");
1521 st_report(
"****************************************************************");
1536 sprintf(
prompt,
"Linuxpops(C) >> ");
1546 sprintf(
prompt,
"Linuxpops(O) >> ");
1550 sprintf(
prompt,
"Linuxpops >> ");
1569 int opt, manGlobal=0, read_config=0, remove_lockfile=0, ignore_lockfile=0, sockets=0, runandexit=0;
1570 char *cp, configName[256], cmdBuf[256];
1573 static char message[4096*16];
1580 sprintf(
prompt,
"Linuxpops(C) >> ");
1588 cp = getenv(
"TERM");
1602 if( tcgetattr(fileno(stdin), &
term) < 0)
1604 perror(
"tcgetattr");
1611 term.c_lflag &= ~ICANON;
1612 term.c_cc[VTIME] = 1;
1615 if( tcsetattr(fileno(stdin), TCSANOW, &
term) < 0)
1617 perror(
"tcsetattr");
1623 rl_catch_signals = 0;
1629 while ((opt = getopt(argc, argv,
"i:hg:krlvqsx")) != -1)
1634 st_report(
"Setting Configuration File: %s", optarg);
1635 strcpy(configName, optarg);
1640 st_report(
"Using Global Memory %s", optarg);
1655 remove_lockfile = 1;
1659 ignore_lockfile = 1;
1691 sprintf(
logfilename,
"linuxpops.%d.log", getpid());
1710 stifle_history(256);
1730 if(!ignore_lockfile)
1740 st_report(
"Ignoring Lockfile altogether");
1749 st_fail(
"main(): Unable to map global memory");
1757 st_fail(
"main(): Unable to map global memory");
1783 st_report(
"Turning on Socket Communication");
1804 st_fail(
"Slave Task not Present");
1810 st_fail(
"Helper Task not Present");
1852 sprintf(cmdBuf,
"formula /r /i /q .lp.formulas");
1856 now = then = time(NULL);
1867 rl_refresh_line(0, 0);
1872 FD_SET(fileno(stdin), &fds);
1887 if(select(FD_SETSIZE, &fds, NULL, NULL, NULL) < 0)
1893 if(FD_ISSET(fileno(stdin), &fds))
1895 rl_callback_read_char();
1907 st_fail(
"Too many loops, %d, per second; exiting", indx);
1920 if(FD_ISSET(
xfd, &fds))
1922 sel =
sock_sel(message, &len, NULL, 0, 1, 0);
1928 printf(
"From Xgraphics Program: %s\n", message);
1931 if(!strncmp(message,
"XGRAPHIC", 8) && len ==
sizeof(
xsend))
1933 bcopy(message, (
char *)&
xsend, len);
1953 st_fail(
"Timeout waiting on read from xgraphic");
1957 st_fail(
"Got strange sock_sel from xgraphic ret: %d", sel);
1966 if(FD_ISSET(
hfd, &fds))
1968 sel =
sock_sel(message, &len, NULL, 0, 1, 0);
1972 if(strlen(message) > 2)
1976 if(!strstr(message,
"/q"))
1989 st_fail(
"Timeout waiting on read from Helper");
1993 st_fail(
"Got strange sock_sel from Helper ret: %d", sel);
2001 if(dataserv &&
dfd > 1)
2003 if(FD_ISSET(
dfd, &fds))
2005 sel =
sock_sel(message, &len, NULL, 0, 1, 0);
2009 st_print(
"Got message from Dataserv: %d bytes", len);
2015 if(strlen(message) > 2)
2017 st_print(
"From Dataser: %s", message);
2023 st_fail(
"Timeout waiting on read from Dataserv");
2027 st_fail(
"Got strange sock_sel from Dataserv ret: %d", sel);
2047 int i, len, n=0,
remove = 0, iret;
2049 char sysBuf[1024], *outFile;
2054 len = strlen(outFile);
2060 st_fail(
"Usage: prune output_file_name");
2067 st_warn(
"No data file loaded");
2074 st_report(
"Removing output file: %s", outFile);
2076 sprintf(sysBuf,
"rm -f %s", outFile);
2100 st_report(
"lp_write_sdd() returned: %d", iret);
2110 st_warn(
"Wrote %d Scans Matching Criteria to %s", n, outFile);
2114 st_fail(
"No Scans Matched Criteria");
2131 st_report(
"Turning ON Socket Communication");
2140 st_report(
"Turning OFF Socket Communication");
2155 double x1, x2, y1, y2;
2212 if(env->
ccur == 0.0)
2214 if(env->
fcur != 0.0)
2219 if(env->
vcur != 0.0)
2226 if(env->
fcur == 0.0)
2228 if(env->
ccur != 0.0)
2243 st_fail(
"Should not get here: CCUR is still 0.0; Error #1");
2247 if(env->
vcur == 0.0)
2249 if(env->
ccur != 0.0)
2264 st_fail(
"Should not get here: CCUR is still 0.0; Error #2");
2272 st_report(
"Mouse Variables: ccur fcur vcur tcur");
2290 int sel,
delay, len, ret;
2296 st_report(
"getResponse(%d): Waiting on xgraphic response", which);
2310 sel =
sock_sel(message, &len, NULL, 0, delay, 1);
2321 printf(
"%s\n", message);
2324 if(!strncmp(message,
"XGRAPHICS", 9) && len ==
sizeof(
xsend))
2326 bcopy(message, (
char *)&
xsend,
sizeof(
xsend));
2368 st_fail(
"Timeout waiting on read from xgraphic");
2375 st_fail(
"Got strange sock_sel ret: %d", sel);
2634 sprintf(sysBuf,
"dumpscans %s %s %s %s %s %s %s", env->
filename,
2643 st_fail(
"Data File Name not set");
2657 char sbuf[256], fbuf[256], sysBuf[1024];
2663 sprintf(sbuf,
" | grep -i %s", env->
source);
2672 sprintf(fbuf,
" | grep %.6f", env->
freq);
2679 sprintf(sysBuf,
"dumpscans %s %s %s", env->
gfilename, sbuf, fbuf);
2683 strcat(sysBuf,
" | less");
2691 sprintf(sysBuf,
"dumpscans -c %s ", env->
gfilename);
2697 sprintf(sysBuf,
"dumpscans %s %s %s %s %s %s %s", env->
gfilename,
2704 strcat(sysBuf,
" | less");
2711 st_fail(
"Gains File Name not set");
2724 char sysBuf[256], *cp;
2735 sprintf(sysBuf,
"checkfile %s %s %s %s %s %s %s", cp,
2754 sprintf(sysBuf,
"check_sdd %s %s %s %s %s %s", env->
filename,
2769 double
first, second, delta;
2773 fdiff = fabs(first-second);
2790 st_report(
"Setting X & Y axis to Autoscale");
2846 if(h->burn_time > 1455213600.0)
2848 freq = (h->restfreq);
2852 freq = (h->obsfreq);
2860 freq = (h->obsfreq);
2864 freq = (h->restfreq);
2920 char bigBuf[512], tbuf[512];
2928 strcpy(bigBuf,
"xgraphic ");
2935 sprintf(tbuf,
"%s ",
args->
tok[i]);
2936 strcat(bigBuf, tbuf);
2943 st_report(
"Sending: %s to xgraphic", bigBuf);
2982 st_report(
"helperWait(): Waiting for '%s', for %d Secs", response, t);
2990 if(!strncmp(message, response, strlen(response)))
2994 st_report(
"Got %s, from helper in %.2f sec(s)", message, (end-start)*86400.0);
3004 st_report(
"Got Control-C input in %.2f sec(s)", (end-start)*86400.0);
3013 st_report(
"Timeout in %.2f sec(s)", (end-start)*86400.0);
3038 st_report(
"helperWait(): Waiting for DS_IMAGE_INFO, for %d Secs", t);
3046 st_report(
"Got DS_IMAGE_INFO, from helper in %d sec(s)", i+1);
3060 st_fail(
"Timeout in helperWait(); or 0 timeout");
3111 st_report(
"setenv MAILBOXDEFS %s", getenv(
"MAILBOXDEFS"));
3128 st_fail(
"Missing arg for attach");
3132 ret = system(sysBuf);
3166 st_fail(
"Missing arg for writeirc");
3185 fprintf(fp,
"%64.64s", env->
filename);
3194 if(j > 1 && !(j%10))
3225 sprintf(tbuf,
"%4d, %8.8s, %5d, %8.8s, %16.16s, %4d - %4d, http://aro.as.arizona.edu/~tfolkers/ftp/12m_filter_tests2/%s",
3236 fprintf(fp,
"%s\n", tbuf);
3242 st_fail(
"Missing arg for recordtests");
3253 char outBuf[1024], tbuf[512], *cp;
3258 sprintf(tbuf,
"%s ",
args->
tok[i]);
3259 strcat(outBuf, tbuf);
3262 for(cp=outBuf;*cp;cp++)
3286 char sysbuf[1024], lbuf[256], sbuf[256], cbuf[256];
3288 bzero(lbuf,
sizeof(lbuf));
3289 bzero(sbuf,
sizeof(sbuf));
3290 bzero(cbuf,
sizeof(cbuf));
3294 sprintf(lbuf,
"-o landscape");
3299 sprintf(sbuf,
"-o media=11x17");
3320 sprintf(sysbuf,
"xclip -o | lpr %s %s %s", lbuf, sbuf, cbuf);
3335 char sysBuf[512], file[256];
3349 sprintf(sysBuf,
"vim +/%s %s/linuxpops/%s", p->
fctnStr,
pkg_home, file);
3376 system(
"/bin/tcsh");
3384 char *cp, sysBuf[256], pid[80];
3394 st_report(
"Starting XGraphic log watcher");
3396 sprintf(sysBuf,
"xterm -tn %s -geometry 142x45+1210+22 -e tail -f /tmp/%s/xgraphic.log /tmp/%s/xgraphic.stdout.log &", pid,
session,
session);
3407 char *cp, sysBuf[256], pid[80];
3419 sprintf(sysBuf,
"startlogwatch.csh %s %s &", pid,
session);
3537 sprintf(tbuf,
"cp /tmp/%s/scan.dat %s.raw",
session, fname);
3564 st_report(
"xdelay(): Delaying: %.0f mSec", (
double)env->
xdelay / 1e3);
3569 st_report(
"xdelay(): Delaying: %.0f mSec", (
double)d / 1e3);
int cont_display_sequence(struct LP_IMAGE_INFO *image, int plot)
struct LP_IMAGE_INFO * h0
#define BKMATCH_RESOLUTION
struct MEASUREMENT measurements[MAX_MEASUREMENTS]
int history_already_written
int findFunction(char *func, char *file)
char * strcmprs(char *str)
int incrementBogusTsys(void)
struct FLUX_HISTORY flux_history
#define LAST_PLOT_CONT_SPTIP
#define LAST_PLOT_SPEC_HISTO
struct PARSE_STACK * args
struct COMMANDS commands[]
struct ACCUM_RESULTS_SEND accum_results_send
int deNewLineIt(char *buf)
struct OBJECT_GLOBAL_MEMORY * obj_map()
struct GLOBAL_MEMORY * gm_map()
int lp_fcmp(double first, double second, double delta)
int initGnuplotBackground()
struct SOURCES * findSourceInList()
#define WAIT_FOR_MAP_ANGLE
struct DS_IMAGE_INFO ds_image_info
int sock_only(struct SOCK *handle, char *message, int tim)
int linePlot(struct LP_IMAGE_INFO *image)
int printH_FlagHelp(char *cmd)
#define LAST_PLOT_FLUX_HISTORY
#define LAST_PLOT_FLUX_INFO
int getResponse(int which)
#define LAST_PLOT_OTF_CUT
int incrementRejIgnored(void)
char tok[MAX_TOKENS][MAX_TOKENS]
double restFreq(struct HEADER *h)
int sock_fd(struct SOCK *handle)
#define LAST_PLOT_CONT_ACCUM
char savedCaptureName[256]
struct CONTINUUM_SPTIP cont_sptip_send
int sock_bufct(int bufct)
struct FREQS freqs[MAX_FREQS]
#define LAST_PLOT_SPEC_FFT
int sock_send(struct SOCK *s, char *message)
int incrementRejDates(void)
int resetRejections(void)
#define LAST_PLOT_CONT_PLAIN
struct SOCK * monitorSock
struct OBJECT objects[MAX_OBJECTS]
int printRejections(void)
int cont_display_mapscan(struct LP_IMAGE_INFO *image, int plot)
int cont_display_any_focus(struct LP_IMAGE_INFO *image, int plot, int type)
double getmJulDate(int offset)
int meetsCritiria(struct HEADER *p, int mask)
struct FLUX_INFO flux_info
char * getcTime(int offset)
#define LAST_PLOT_CONT_OBJECT
int sock_sel(char *message, int *l, int *p, int n, int tim, int rd_in)
int isScanIgnored(double scan)
struct OBJECT_GLOBAL_MEMORY * OGM
struct CONTINUUM_PLAIN cont_plain_send
int parseMouseValues(double x1, double x2, double y1, double y2)
double mapFtoChan(double f)
int incrementRejMode(void)
double mapVtoChan(double v)
int printScan(struct HEADER *p, int nsave)
struct HEADER head[MAX_IFS]
struct XGRAPHIC_SEND xsend
void subArgs(int wt, const char *fmt,...)
struct BOUND * sock_bind(char *mbname)
int incrementRejSource(void)
struct SOCK * sock_connect(char *mbname)
int incrementRejScans(void)
#define LAST_PLOT_SPEC_ACCUM
int setCactusEnvironment(void)
int incrementRejFreq(void)
int backendMatch(struct HEADER *h)
int incrementRejBackend(void)
int incrementRejFreqres(void)
int loadCalibrators(char *name)
int makeFileName(char *fname, int pid)
void process_line(char *line)
int lineConvert2LogPlot()
int to_dataserv(char *buf)