61 #include <gsl/gsl_statistics_double.h>
89 double meangsl, rmsgsl, tss, gsv;
115 meangsl = gsl_stats_mean(d, 1, n);
119 st_print(
"GSL Mean = %12.6f mK\n", meangsl);
122 tss = gsl_stats_tss_m(d, 1, n, meangsl);
124 gsv = gsl_stats_variance_m(d, 1, n, meangsl);
128 st_print(
"GSL Variance = %12.6f mK\n", gsv * 1000.0);
129 st_print(
"GSL TSS = %12.6f mK\n", tss * 1000.0);
130 st_print(
"GSL sqrt(TTS) = %12.6f mK\n", sqrt(tss) * 1000.0);
133 rmsgsl = gsl_stats_absdev_m(&d[0], 1, n, meangsl);
136 st_print(
"GSL Abs Dev = %12.6f mK\n", rmsgsl * 1000.0);
139 rmsgsl = gsl_stats_sd_m(d, 1, n, meangsl);
143 st_print(
"GSL rms = %12.6f mK\n", rmsgsl * 1000.0);
148 st_print(
"GSL Skew = %12.6f mK\n", gsl_stats_skew(d, 1, n) * 1000.0);
149 st_print(
"GSL Kurtosis = %12.6f mK\n", gsl_stats_kurtosis(d, 1, n) * 1000.0);
150 st_print(
"GSL AutoCorr = %12.6f mK\n", gsl_stats_lag1_autocorrelation(d, 1, n) * 1000.0);
171 sums += ((y[i] - mean) * (y[i] - mean));
216 float *i, iwt, *o, owt;
217 double raoff, decoff;
218 static double xoff, yoff, roff, doff, noint;
232 xoff = image->head.az_offset;
233 yoff = image->head.el_offset;
235 roff = image->head.epocra - image->head.xsource;
236 doff = image->head.epocdec - image->head.ysource;
238 noint = image->head.noint;
243 if(image->head.noint != noint)
247 printf(
"line_accum(%.2f), Rejected: NOINT Differs: %.1f, %.1f\n",
248 image->head.scan, image->head.noint, noint);
261 printf(
"line_accum(%.2f), Rejected: TSYS %.1f > TSLimit: %.1f\n",
274 printf(
"line_accum(%.2f), Rejected: AZ_OFFSET Differs: %.1f, %.1f\n",
275 image->head.scan, image->head.az_offset*3600.0, xoff*3600.0);
287 printf(
"line_accum(%.2f), Rejected: EL_OFFSET Differs: %.1f, %.1f\n",
288 image->head.scan, image->head.el_offset*3600.0, yoff*3600.0);
296 raoff = image->head.epocra - image->head.xsource;
297 decoff = image->head.epocdec - image->head.ysource;
303 printf(
"line_accum(%.2f), Rejected: RA_OFFSET Differs: %.1f, %.1f\n",
304 image->head.scan, raoff*3600.0, roff*3600.0);
316 printf(
"line_accum(%.2f), Rejected: DEC_OFFSET Differs: %.1f, %.1f\n",
317 image->head.scan, decoff*3600.0, doff*3600.0);
329 printf(
"line_accum(%.2f), Rejected: Acuum Freq Res %.3f vs. Scan Freq Res %.3f, differ\n",
342 printf(
"line_accum(%.2f), Rejected: Ra %.3f & %.3f, differ\n",
356 printf(
"line_accum(%.2f), Rejected: Dec %.3f & %.3f, differ\n",
369 printf(
"line_accum(%.2f), Rejected: Sb %d & %d, differ\n",
382 printf(
"line_accum(%.2f), Rejected: Rest Freq %.5f & %.5f, differ\n", image->head.scan,
384 image->head.restfreq / 1000.0);
401 printf(
"line_accum(%.2f), Rejected: Vel %.3f & %.3f, differ\n",
415 workingTsys += (image->head.stsys * image->head.inttime);
416 workingTcal += (image->head.tcal * image->head.inttime);
418 iwt = image->head.inttime / ( image->head.stsys * image->head.stsys );
426 *o = (*o * owt + *i * iwt) / (owt + iwt);
445 int i, j = 0, indx, cols, rows;
448 char tmp[80], tbuf[256];
464 sprintf(tbuf,
"titleblock /c");
477 st_report(
"Flagged Bad Channels will be removed");
482 st_warn(
"No Valid Data Files Loaded");
499 st_report(
"Looking for scans using ALL Freqs");
508 st_report(
"Looking for scans taken on ALL dates");
517 st_report(
"Looking for scans on ALL Sources");
526 st_report(
"Looking for Entire Range of scan numbers");
559 printf(
"Passing Scan %.2f to meetsCritiria(): ", p->
scan);
569 if(strncmp(p->
obsmode,
"LINEBSP", 7) &&
570 strncmp(p->
obsmode,
"LINEPS", 6) &&
571 strncmp(p->
obsmode,
"LINEFS", 6) &&
572 strncmp(p->
obsmode,
"LINETPON", 8) &&
573 strncmp(p->
obsmode,
"LINEAPS", 7))
620 st_print(
"No Scans Found Matching Search Criteria\n");
700 image->
datamax = -9999999999.9;
701 image->datamin = 9999999999.0;
706 if(*f > image->datamax)
718 if(fabs(image->datamax - image->datamin) <
DATASPREAD)
720 st_print(
"Scan #%7.2f is all %.4f\n", image->head.scan, image->datamin);
722 image->datamin -= 1.0;
723 image->datamax += 1.0;
761 image->head.noint = image->head.datalen /
sizeof(float);
764 image->nsize = image->head.noint *
sizeof(float);
782 g = &image->bplot[0];
784 for(i=0;i<image->head.noint;i++,f++,g++)
791 image->yplot1[0] = 0.0;
802 if(image->head.noint == 0.0)
804 st_fail(
"Nothing in Array %s to Display", image->name);
808 st_report(
"Displaying Plot: %s", image->name);
828 st_report(
"No connection to xgraphic to send plot");
888 if(!strncmp(image->head.backend,
"ARO", 3))
893 if(!strncmp(image->head.backend,
"MAC", 3) || !strncmp(image->head.backend,
"HS_", 3))
898 if(!strncmp(image->head.backend,
"FFB", 3))
942 st_fail(
"sqrt(freqres * inttime * hwdc) = %f", sq);
949 sprintf(
rmsResultsStr,
"%.2f / %.2f mK over %d chans; Factor: %f",
999 int i, bc, ec, eFlag = 0,
first=1;
1047 f = &image->yplot1[0];
1048 for(i=0;i<image->head.noint;i++)
1061 image->datamin =
min;
1062 image->datamax =
max;
1064 st_report(
"Max = %f, Min = %f", image->datamax, image->datamin);
1074 double from, to, diff, freeD, wireD;
1078 _doTCur(
"Click the Left Mouse Button on First Peak");
1081 _doTCur(
"Click the Left Mouse Button on Last Peak");
1084 diff = fabs(from - to);
1096 st_report(
"Spacing: %7.3f MHz", diff / 1e6);
1097 st_report(
"Free Space Distance: %7.3f Meters", freeD);
1098 st_report(
"Coaxial Wire Distance: %7.3f Meters", wireD);
1122 double avg = 0.0, ptmb = 0.0, rejs[4];
1127 rejs[i] = 1.0 / (1.0 + pow(10.0, -1.0 *
env->
rejections[i] / 10.0));
1208 st_report(
"Average of %s, using %d channels: %.6fK", buf, j, avg);
1212 st_report(
"Average Bandpass Temperature, using %d channels: %.6fK", j, avg);
1219 st_report(
"Using Rejections Coeff: %f %f %f %f", rejs[0], rejs[1], rejs[2], rejs[3]);
1235 st_print(
" Average Tr: %9.4f %9.4f %9.4f %9.4f\n",
1241 st_print(
" Planet Temp: %9.4f %9.4f %9.4f %9.4f\n",
1242 ptmb, ptmb, ptmb, ptmb);
1244 st_print(
"Main Beam Eff: %9.2f %9.2f %9.2f %9.2f\n",
1250 st_print(
" Rejections: %9d %9d %9d %9d\n",
1267 double s,
min=999999.9,
max=-999999.9, min1, min2, max1, max2;
1373 st_fail(
"Missing arg to pshow");
1399 double s, minT=999999.9, maxT=-999999.9,
min[4],
max[4];
1400 double frac[] = { 0.00, 0.01, 0.02, 0.03 };
1415 case 0:
_h0();
break;
1416 case 1:
_h1();
break;
1417 case 2:
_h2();
break;
1418 case 3:
_h3();
break;
1421 subArgs(2,
"%.2f", s + frac[i]);
1489 st_fail(
"Missing arg to pshow");
1500 int i, save_bkmatch, save_ckfeed, req[2];
1502 double minT=999999.9, maxT=-999999.9,
min[4],
max[4];
1508 st_report(
"Removing Baselines from Plots");
1553 if(i+1 == req[0] || i+1 == req[1])
1593 if(i+1 == req[0] || i+1 == req[1])
1633 if(i+1 == req[0] || i+1 == req[1])
1673 if(i+1 == req[0] || i+1 == req[1])
1744 st_report(
"Zeroing out %d channels at beginning of data", n);
1756 st_report(
"Zeroing out %d channels at end of data", n);
1780 st_report(
"Inverting %d Spectal Data", noint);
1783 bcopy((
char *)&
h0->
yplot1[0], (
char *)&hold[0],
sizeof(
float)*noint);
1788 for(i=0;i<noint;i++,d++,s--)
1865 if(h->
openpar[0] == 54321.12345)
1886 double freq, fr, f2, f1, nchans, delta;
1890 st_fail(
"Missing args for fillpattern: Usage: fillpattern freq");
1919 f1 = nchans / 360.0;
1922 st_report(
"freq = %.2f, fr = %.2f, nchans = %.2f, f1 = %.2f, delta = %.2f",
1923 freq, fr, nchans, f1, delta);
1927 for(i=0;i<n;i++,f++)
1932 case COS_PAT: *f = (float)cos(f2 * DEG_TO_RAD);
break;
1934 *f = (float)sin(f2 * DEG_TO_RAD);
1946 *f = (float)tan(f2 * DEG_TO_RAD);
1974 float *p,
max=-1e12;
1978 st_report(
"Converting %d floats to log-plot", n);
1982 for(i=0;i<n;i++,p++)
1991 for(i=0;i<n;i++,p++)
1993 *p = 10.0 * log10(*p / max);
2017 dlen = (int)h->head.noint;
2021 if((fp = fopen(fname,
"w")) == NULL)
2023 st_fail(
"Unable to open %s for writting", fname);
2028 st_report(
"Saving %d records to: %s", dlen, fname);
2030 fprintf(fp,
"# Scan Number %8.2f\n", h->head.scan);
2031 fprintf(fp,
"# Bscan Number %8.2f\n", h->ainfo.bscan);
2032 fprintf(fp,
"# Escan Number %8.2f\n", h->ainfo.escan);
2033 fprintf(fp,
"# Scan Count %8d\n", h->ainfo.scanct);
2034 fprintf(fp,
"# \n");
2038 fprintf(fp,
"%5d %12.6f\n", i, h->yplot1[i]);
2049 system(
"rm -f report.log");
2059 char *fname =
"report.log";
2061 if((fp = fopen(fname,
"a")) == NULL)
2063 st_fail(
"Unable to open %s for writting", fname);
2068 fprintf(fp,
"%s\n", buf);
2080 char outBuf[256], tbuf[512], src[256];
2092 strcpy(outBuf,
"REPORT: ");
2099 sprintf(tbuf,
"Source: %s ", src);
2100 strcat(outBuf, tbuf);
2106 strcat(outBuf, tbuf);
2112 strcat(outBuf, tbuf);
2117 sprintf(tbuf,
"UT: %.2f ",
h0->
head.
ut);
2118 strcat(outBuf, tbuf);
2123 sprintf(tbuf,
"LST: %.2f ",
h0->
head.
lst);
2124 strcat(outBuf, tbuf);
2129 sprintf(tbuf,
"Az: %.1f ",
h0->
head.
az);
2130 strcat(outBuf, tbuf);
2135 sprintf(tbuf,
"El: %.1f ",
h0->
head.
el);
2136 strcat(outBuf, tbuf);
2142 strcat(outBuf, tbuf);
2148 strcat(outBuf, tbuf);
2153 strcpy(tbuf,
"rms");
2162 sprintf(tbuf,
"rms: %.2f mK ",
env->
rms * 1000.0);
2163 strcat(outBuf, tbuf);
2169 strcat(outBuf, tbuf);
2178 strcat(outBuf,
"\n");
2189 if(h->openpar[8] == 9998.50 || h->openpar[8] == 9999.50)
2236 _doCCur(
"Click Left Mouse Button on Left Edge of Desired Region");
2245 _doCCur(
"Click Left Mouse Button on Right Edge of Desired Region");
2265 st_report(
"Setting Channels %d - %d to %.4f", bd, ed, avg);
2280 double bscan, havg, savg, cavg;
2281 double yfac, syfac, avyfac, trec;
2300 st_fail(
"doTrec(): Hot-Load Scan %.2f not found", bscan);
2317 st_fail(
"doTrec(): Sky Scan %.2f not found", bscan);
2325 syfac = havg / savg;
2337 st_fail(
"doTrec(): Cold-Load Scan %.2f not found", bscan);
2345 avyfac = havg / cavg;
2348 st_report(
"Yfac = %.2f, Trec = %.2f", avyfac, trec);
2379 sprintf(tbuf,
"hline /Cmg /c 0 %f", trec);
2382 strcpy(
h0->
title,
"T-receiver");
2389 sprintf(tbuf,
"label set 0 %f %f 5 0 T_{rec}: %.1f, Y_{fac}: %.2f /3", xval, yval, trec, avyfac);
2406 double bscan, havg, savg;
2425 st_fail(
"doYFactor(): Hot-Load Scan %.2f not found", bscan);
2442 st_fail(
"doYFactor(): Sky Scan %.2f not found", bscan);
2454 sprintf(tbuf,
"image /y h1 h2");
2459 strcpy(
h0->
title,
"Y-Factors");
2465 sprintf(tbuf,
"hline /Cmg /c 0 %f", yfac);
2485 int i, n, ret, nsave,
nscans=0;
2488 double freq, newfreq, fscan = 1e9, lscan = 0.0;
2489 char source[80], newsource[80];
2526 st_report(
"nsac(): Number of nsaves, %d, too large; 9 Max", n);
2538 st_report(
"nsac(): Wrong Number of arguments for command");
2574 sprintf(tbuf,
"H%d", i+1);
2583 st_report(
"Error retreiving nasave %d", nsave);
2590 sprintf(tbuf,
"NSAVE_%d", nsave);
2605 newsource[16] =
'\0';
2608 if(strncmp(source, newsource, 16))
2611 st_report(
"Sources are not the same: %s, %s", source, newsource);
2619 if(fabs(newfreq-freq) > 50.0)
2622 st_report(
"RestFreq's are not the same: %f, %f", newfreq, freq);
2673 sprintf(tbuf,
"H%d", i+1);
2701 int i, n, ret, which = 0;
2702 char fname[256], sysBuf[512], *string, line[256];
2728 sprintf(fname,
"/tmp/%s/dedit.txt",
session);
2730 st_report(
"Saving Data[%d] array to: %s", which, fname);
2732 if((fp = fopen(fname,
"w")) == NULL)
2734 st_fail(
"Unable to open %s for writting", fname);
2749 for(i=0;i<n;i++, f++)
2751 fprintf(fp,
"%5d %.10f\n", i, *f);
2761 sprintf(fname,
"/tmp/%s/dedit.txt",
session);
2765 sprintf(sysBuf,
"/usr/bin/vim %s", fname);
2774 sprintf(fname,
"/tmp/%s/dedit.txt",
session);
2776 st_report(
"Reading into Data[%d], %s", which, fname);
2778 if((fp = fopen(fname,
"r")) == NULL)
2780 st_fail(
"Unable to open %s for reaading", fname);
2787 while((
string = fgets(line,
sizeof(line), fp)) != NULL)
2789 ret = sscanf(line,
"%d %f", &i, &ff);
2803 case 4:
h0->
bplot [i] = ff;
break;
2804 case 5:
h0->
gplot [i] = ff;
break;
2809 st_print(
"doDedit(): %d, greater then noint: %d", i, n);
2814 st_print(
"doDedit(): sacanf() returned %d, and not 2", ret);
2829 sprintf(fname,
"/tmp/%s/dedit.txt",
session);
struct LP_IMAGE_INFO * h0
struct LP_IMAGE_INFO accum_image
#define BKMATCH_RESOLUTION
int hzero(struct LP_IMAGE_INFO *image)
char * strcmprs(char *str)
int _copyImage(struct LP_IMAGE_INFO *i1, struct LP_IMAGE_INFO *i2)
int incrementBogusTsys(void)
struct PARSE_STACK * args
double rejections[MAX_BEAMS]
int computeEachBaseLine(struct LP_IMAGE_INFO *image)
struct BASELINE_INFO binfo
int lp_fcmp(double first, double second, double delta)
int line_doBaseLine(struct LP_IMAGE_INFO *image)
int setHWDC(struct LP_IMAGE_INFO *image)
int linePlot(struct LP_IMAGE_INFO *image)
int printH_FlagHelp(char *cmd)
#define SPEED_OF_LIGHT_COAX
float workingY[MAX_CHANS]
int setFlag(int flag, int state)
int computeBaseLine(struct LP_IMAGE_INFO *image)
int processSpectra(struct LP_IMAGE_INFO *image)
int line_save_data(struct LP_IMAGE_INFO *h)
int getResponse(int which)
int incrementRejIgnored(void)
char tok[MAX_TOKENS][MAX_TOKENS]
int computeRms(float *y, int n, float *rms)
int line_display_spectra(struct LP_IMAGE_INFO *image, int plot)
int addIgnore(double scan)
int writeReport(char *buf)
int copyEnv2Image(struct LP_IMAGE_INFO *image)
int resetRejections(void)
int line_MinMax(struct LP_IMAGE_INFO *image)
int incrementRejNoint(void)
int incrementRejDec(void)
int printRejections(void)
int isSpecFivePoint(struct HEADER *h)
int incrementRejOffsets(void)
int meetsCritiria(struct HEADER *p, int mask)
int line_accum(struct LP_IMAGE_INFO *image)
int isScanIgnored(double scan)
int incrementRejMode(void)
int printScan(struct HEADER *p, int nsave)
int computeXaxis(struct LP_IMAGE_INFO *image, int logit)
struct ACCUM_RESULTS_SEND local_ars
int getTerminalSize(int *cols, int *rows)
int incrementRejFive(void)
int baselines[MAX_BASELINES][2]
int line_removeBadChans(struct LP_IMAGE_INFO *image, int print)
struct MISC_HEADER_PARAMS mhp[MAX_PLOT_ARRAYS]
void subArgs(int wt, const char *fmt,...)
int showAverage(char *buf)
int sendImageStruct(struct LP_IMAGE_INFO *image, int mode)
float workingX[MAX_CHANS]
int baselines[MAX_BASELINES][2]
int removeFittedData(struct LP_IMAGE_INFO *image)
int line_determine_min_max(struct LP_IMAGE_INFO *image)
int incrementRejFreq(void)
int incrementRejFreqres(void)
int lineConvert2LogPlot()
int incrementRejVel(void)