Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
cont.c
Go to the documentation of this file.
1 /*
2 Copyright 2021 Arizona Board of Regents on behalf of the University of Arizona.
3 
4 For commercial uses, to obtain a license to sell and or sublicense copies of
5 the Software please contact the University of Arizona at Tech Launch Arizona:
6 lewish@tla.arizona.edu.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy
9 of this software and associated documentation files (the "Software"), to deal
10 in the Software without restriction for non-commercial use educational and
11 research purposes, including without limitation the rights to use, copy,
12 modify, merge, publish, distribute, and to permit persons to whom the Software
13 is furnished to do so, subject to the following conditions:
14 
15 The entire above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 SOFTWARE.
25 
26 1. Additional Required Provisions
27 
28 1.1. Arbitration. The parties agree that if a dispute arises between them
29 concerning this Agreement, the parties may be required to submit the matter to
30 arbitration pursuant to Arizona law.
31 
32 1.2. Applicable Law and Venue. This Agreement shall be interpreted pursuant
33 to the laws of the State of Arizona. Any arbitration or litigation between the
34 Parties shall be conducted in Pima County, ARIZONA, and LICENSEE hereby
35 submits to venue and jurisdiction in Pima County, ARIZONA.
36 
37 1.3. Non-Discrimination. The Parties agree to be bound by state and federal
38 laws and regulations governing equal opportunity and non-discrimination and
39 immigration.
40 
41 1.4. Appropriation of Funds. The Parties recognize that performance by
42 ARIZONA may depend upon appropriation of funds by the State Legislature of
43 ARIZONA. If the Legislature fails to appropriate the necessary funds, or if
44 ARIZONA’S appropriation is reduced during the fiscal year, ARIZONA may cancel
45 this Agreement without further duty or obligation. ARIZONA will notify
46 LICENSEE as soon as reasonably possible after it knows of the loss of funds.
47 
48 1.5. Conflict of Interest. This Agreement is subject to the provisions of
49 A.R.S. 38-511 and other conflict of interest regulations. Within three years
50 of the EFFECTIVE DATE, ARIZONA may cancel this Agreement if any person
51 significantly involved in initiating, negotiating, drafting, securing, or
52 creating this Agreement for or on behalf of ARIZONA becomes an employee or
53 consultant in any capacity of LICENSEE with respect to the subject matter of
54 this Agreement.
55 
56  */
57 
58 
59 #include "extern.h"
60 
65 
67 int autoAccumCnt[4];
68 
69 float azPtCorr[4], elPtCorr[4];
74 
75 double autoCalibrate = 0.0;
76 double autoAccum[4];
77 
78 #define NPHASE_2 (8)
79 int two_phase_seq_five[] = { -1, 1, 1, -1,
80  1, -1, -1, 1};
81 
82 int two_phase_seq_foc[] = { 1, -1, 1, -1,
83  1, -1, 1, -1};
84 
85 /* Pre Summer 2017 Kitt Peak has a different phase order */
86 #define NPHASE_4 (16)
87 int four_phase_seq_five[] = { -1, 1, -1, 1, /* Off */
88  1, -1, 1, -1, /* On */
89  1, -1, 1, -1, /* On */
90  -1, 1, -1, 1}; /* Off */
91 
92 
93 /* Computes ratio of source strength, to mean total power. */
94 int accum_v1(data, h, invert, ar)
95 float *data;
96 struct HEADER *h;
97 int invert;
98 struct ACCUM_RESULTS *ar;
99 {
100  double source, ref, ons, ratio, offs, Tr, taStar, tau0, sinel;
101  int i, j, npts, noffs=0, nons=0, nphase, bpts, epts;
102  int *p, low_volts = 0, feed;
103  double weight, div, ttime, factor, be, tauFactor, tsys;
104  double gainEl;
105 
106  feed = getFeed(h->scan);
107 
108  if(feed >= 0 && feed < 5)
109  {
110  be = env->bm_eff[feed-1];
111  }
112  else
113  {
114  printf("Unknown Feed %d", feed);
115  be = 1.0;
116  return(1);
117  }
118 
119  ons = offs = 0.0;
120  npts = (int)h->noint;
121 
122  /* Validate data first */
123  for(i=0;i<npts;i++)
124  {
125  if(gsl_isinf((double)data[i]))
126  {
127  printf("Scan %.2f contains inf values\n", h->scan);
128  return(1);
129  }
130 
131  if(gsl_isnan((double)data[i]))
132  {
133  printf("Scan %.2f contains nan values\n", h->scan);
135 
136  return(1);
137  }
138 
139  if(data[i] < 1.0e6)
140  {
141  div = 1.0e3;
142  }
143  else
144  if(data[i] > 1.0e6 || data[i] < 1.0e9)
145  {
146  div = 1.0e6;
147  }
148  else
149  {
150  div = 1.0e9;
151  }
152 
153  if(data[i] < 1000.0)
154  {
155  low_volts++;
156  }
157  }
158 
159  /* Check if data is bad; i.e. no IF input */
160  if(low_volts == npts)
161  {
162  printf("Scan %.2f contains near zero values\n", h->scan);
163  return(1);
164  }
165 
166  /* Check if tsys is bad */
167  if((env->tsyslimit && (fabs(h->stsys) > env->tsyslimit)) || gsl_isnan(h->stsys))
168  {
169  printf("Scan %.2f Tsys Greater then %.1f: %.1f\n", h->scan, env->tsyslimit, h->stsys);
171 
172  return(1);
173  }
174 
175  /* Check if tcal is bad */
176  if(fabs(h->tcal) > BOGUS_TCAL_VALUE || gsl_isnan(h->tcal))
177  {
178  printf("Scan %.2f Tcal Bogus: %.1f\n", h->scan, h->tcal);
180 
181  return(1);
182  }
183 
184  if(env->issmt)
185  {
186  p = &two_phase_seq_five[0];
187  nphase = NPHASE_2;
188  }
189  else
190  {
191  /* Switched to 2 phase @KP in Summer of 2017 */
192  if(h->nophase == 2 || h->burn_time > 1501704800.0)
193  {
194  p = &two_phase_seq_five[0];
195  nphase = NPHASE_2;
196  }
197  else
198  {
199  p = &four_phase_seq_five[0];
200  nphase = NPHASE_4;
201  }
202  }
203 
204  if(env->doing_fives)
205  {
206  bpts = 8 * nphase;
207  epts = 11 * nphase;
208  }
209  else
210  {
211  bpts = 0;
212  epts = npts;
213  }
214 
215  j = 0;
216  for(i=bpts;i<epts;i++)
217  {
218  data[i] /= div; /* Scale it */
219 
220  if(p[j] > 0)
221  {
222  if(invert)
223  {
224  offs += data[i]; /* Sum the Offs */
225  noffs++;
226  }
227  else
228  {
229  ons += data[i]; /* Sum the Ons */
230  nons++;
231  }
232  }
233  else
234  {
235  if(invert)
236  {
237  ons += data[i]; /* Sum the Ons */
238  nons++;
239  }
240  else
241  {
242  offs += data[i]; /* Sum the Offs */
243  noffs++;
244  }
245  }
246 
247  j++;
248 
249  /* check to see if we ran off the end of the phase array */
250  if(j >= nphase)
251  {
252  if(env->issmt)
253  {
254  p = &two_phase_seq_five[0];
255  }
256  else
257  {
258  /* Switched to 2 phase @KP in Summer of 2017 */
259  if(h->nophase == 2 && h->burn_time > 1501704800.0)
260  {
261  p = &two_phase_seq_five[0];
262  }
263  else
264  {
265  p = &four_phase_seq_five[0];
266  }
267  }
268 
269  j = 0;
270  }
271  }
272 
273  if(manual_tcal > 0.0 && fabs(h->tcal-400.0) < 1.0)
274  {
275  tsys = h->stsys * manual_tcal / h->tcal;
276  }
277  else
278  {
279  tsys = h->stsys;
280  }
281 
282  weight = (h->noint * h->samprat) / (tsys * tsys);
283 
284  ref = offs / (double)noffs; /* TP = Avg of offs */
285  source = ons / (double)nons;
286  ratio = (source - ref) / ref;
287 
288  /* Correction for scaling factor used in Tsys */
289  taStar = tsys * ratio;
290 
291  /* assume Tatm = Tspill = 0.96 * Tamb,
292  * eta(warm spillover) = 0.94, Tbg = 3 K, Tamb = 300 */
293 
294  switch(env->calmode)
295  {
296  case CALMODE_NONE:
297  factor = 1.0;
298  break;
299 
300  case CALMODE_CALSCALE:
301  factor = 1.0 / env->cal_scale;
302  break;
303 
304  case CALMODE_BEAMEFF:
305  factor = 1.0 / be;
306  break;
307 
308  case CALMODE_TELE_EFF:
309 #ifdef CALC_TAU_FACTOR
310  if(fabs(env->mantau0 - 0.0) < 0.01) /* Near Zero */
311  {
312  tau0 = h->mmh2o / 19.0;
313  }
314  else
315  {
316  tau0 = env->mantau0;
317  }
318 
319  sinel = sin(h->el / 57.296);
320  tauFactor = exp(-tau0 * 1.0 / sinel);
321 #endif
322  factor = 1.0/* / tauFactor*/; /* Dont remove atm as atm_prog did it already */
323 
324  if(env->apperatureeff > 0.0)
325  {
326  factor /= env->apperatureeff;
327  }
328 
329  break;
330 
331  default:
332  factor = 1.0;
333  break;
334  }
335 
336 #ifndef CALC_TAU_FACTOR
337  if(fabs(env->mantau0 - 0.0) < 0.01) /* Near Zero */
338  {
339  tau0 = h->mmh2o / 19.0;
340  }
341  else
342  {
343  tau0 = env->mantau0;
344  }
345 
346  sinel = sin(h->el / 57.296);
347  tauFactor = exp(-tau0 * 1.0 / sinel);
348 #endif
349 
350 /* SMT Elevation Gain Curve Derived by Issaoun & Folkers 2016 */
351  if(env->elgain) /* Does user want to apply elevation gain curve? */
352  {
353  gainEl = env->elgain_term5 * pow(h->el, 4.0) +
354  env->elgain_term4 * pow(h->el, 3.0) +
355  env->elgain_term3 * pow(h->el, 2.0) +
356  env->elgain_term2 * h->el +
357  env->elgain_term1;
358 
359  if(gainEl < 0.5)
360  {
361  gainEl = 1.0;
362  }
363  }
364  else
365  {
366  gainEl = 1.0;
367  }
368 
369  if(env->elgain > 0) /* El gain produces gain factors < 1.0; so divide instead */
370  {
371  gainEl = 1.0 / gainEl;
372  }
373 
374  taStar *= gainEl;
375 
376  Tr = taStar * factor;
377 
378  ttime = npts * h->samprat;
379 
380  st_print(" %10.10s %6.2f%10.4f%6.2f%8.2f%3d%4.0f%5.1f%7.1f",
381  h->object, restFreq(h) / 1000.0, h->utdate, h->ut,
382  h->scan, (int)(npts / h->nophase),
383  ttime, h->el, source);
384 
385 
386 
387 
388  st_print("%7.1f%10.7f%5.0f%9.4f%9.4f%5.2f%7.1f",
389  ref, ratio, tsys, taStar, Tr, factor, Tr*env->jfact);
390 
391 
392  ar->results[ar->num].scan = h->scan;
393  ar->results[ar->num].ut = h->ut;
394  ar->results[ar->num].el = h->el;
395  ar->results[ar->num].sig = source;
396  ar->results[ar->num].sky = ref;
397  ar->results[ar->num].smror = ratio;
398  ar->results[ar->num].tsys = tsys;
399  ar->results[ar->num].tastar = taStar;
400  ar->results[ar->num].tr = Tr;
401  ar->results[ar->num].factor = factor;
402  ar->results[ar->num].janskys = Tr*env->jfact;
403 
404  accumArrayTmb[accumArrayCnt] = (float)taStar;
405  accumArrayTr[accumArrayCnt] = (float)Tr;
406  accumArrayFlux[accumArrayCnt] = (float)(Tr*env->jfact);
407 
408  accumArrayCnt++;
409 
411  {
412  st_fail("Accum Count > Max: %d", MAX_ACCUM_SCANS);
414  }
415 
416  if(autoCalibrate > 0.0)
417  {
418  autoAccum[feed-1] += taStar;
419  autoAccumCnt[feed-1]++;
420  }
421 
422  st_print(" %5.3f %5.3f %5.3f\n", env->mantau0, tauFactor, gainEl);
423 
424  if(env->accum)
425  {
426  env->accumtastar += (taStar * weight);
427  env->accumtr += (Tr * weight);
428 
429  env->totalweight += weight;
430 
431  env->accumcount++;
432  }
433  else
434  {
435  env->accumtastar = taStar;
436  env->accumtr = Tr;
437  }
438 
439  ar->num++;
440 
441  if(ar->num == MAX_ACCUM_SCANS)
442  {
443  st_fail("Too many scans in accumulator: %d", MAX_ACCUM_SCANS);
444  ar->num--;
445  }
446 
447  return(0);
448 }
449 
450 
451 
453 {
454  if(xgraphic)
455  {
456  strcpy(accum_results_send.magic, "ACCUM_INFO");
457 
460 
465 
467 
469  }
470 
471  return(0);
472 }
473 
474 
476 {
477  int i, j=0, samps, secs, foundmatch = 0;
478  struct HEADER *p;
479  struct tm *tn;
480  time_t iburn;
481  double timeburn, diff;
482  char durstr[256];
483 
484  p = &sa[0];
485  for(i=0;i<env->numofscans;i++,p++)
486  { /* If we want to auto reduce tips */
487  if(!meetsCritiria(p, CHECK_ALL))
488  {
489  continue;
490  }
491 
492  if(args->ntokens > 1 && args->secondArg)
493  {
494  if(!strcasecmp(args->secondArg, "foc"))
495  {
496  foundmatch = 1;
497  if(strncmp(p->obsmode, "CONTFOC", 7))
498  {
499  continue;
500  }
501  }
502 
503  if(!strcasecmp(args->secondArg, "ewf"))
504  {
505  foundmatch = 1;
506  if(strncmp(p->obsmode, "CONTEWFC", 8))
507  {
508  continue;
509  }
510  }
511 
512  if(!strcasecmp(args->secondArg, "nsf"))
513  {
514  foundmatch = 1;
515  if(strncmp(p->obsmode, "CONTNSFC", 8))
516  {
517  continue;
518  }
519  }
520 
521  if(!strcasecmp(args->secondArg, "seq"))
522  {
523  foundmatch = 1;
524  if(strncmp(p->obsmode, "CONTSEQ", 7))
525  {
526  continue;
527  }
528  }
529 
530  if(!strcasecmp(args->secondArg, "cal"))
531  {
532  foundmatch = 1;
533  if(strncmp(p->obsmode, "CONTCAL", 7))
534  {
535  continue;
536  }
537  }
538 
539  if(!strcasecmp(args->secondArg, "map"))
540  {
541  foundmatch = 1;
542  if(strncmp(p->obsmode, "CONTMAP", 7))
543  {
544  continue;
545  }
546  }
547 
548  if(!strcasecmp(args->secondArg, "qk5"))
549  {
550  foundmatch = 1;
551  if(strncmp(p->obsmode, "CONTFIVE", 8) && strncmp(p->obsmode, "CONTQK5", 7))
552  {
553  continue;
554  }
555  }
556 
557  if(!foundmatch)
558  {
559  st_fail("Unknown arg: %s", args->secondArg);
561  return(1);
562  }
563  }
564 
565  iburn = (time_t)p->burn_time;
566 
567  tn = localtime(&iburn);
568 
569  timeburn = (double)tn->tm_hour
570  + (double)tn->tm_min / 60.0
571  + (double)tn->tm_sec / 3600.0;
572 
573  if(timeburn > p->ut) /* Check for roll over */
574  {
575  diff = (timeburn - p->ut) - 17.0;
576  }
577  else
578  {
579  diff = (timeburn - p->ut) + 7.0;
580  }
581 
582  sexagesimal(diff, durstr, MMMM_SS);
583 
584  if(!(j%24))
585  {
586  st_print("\n");
587  st_print(" Source Mode Scan UT Burn_Time Samps Secs Duration\n");
588  st_print("\n");
589  }
590 
591  secs = (int)p->samprat;
592  samps = (int)(p->noint / p->nophase);
593 
594  st_print("%16.16s %8.8s %8.2f %5.2f %.0f %4d %4d %s\n", p->object, p->obsmode, p->scan, p->ut, p->burn_time, samps, secs, durstr);
595 
596  j++;
597 
598  }
599 
600  st_print("Found %d matching scans", j);
601 
602  return(0);
603 }
604 
605 
606 /* Calibration Equations based on:
607  "Quasiotical Systems; Gaussian Beam Quasioptical Propagation and Applications"
608  by Paul F. Goldsmith;
609  IEEE Press; 1998
610 */
612 {
613  int i=0, old, indx, feed, once, old_once = 0, first = 1, iret;
614  struct HEADER *p;
615  double aTr, aTaStar, ret, newFactor;
616  double lambda, v, surface;
617  double A, a, Te, Fb, Et, Es, Ea, Er, Eb, Es2, num;
618  struct ACCUM_RESULTS *ar1;
619  double contWorkingTime;
620  double contWorkingTsys;
621  float rmsTmb, rmsTr, rmsFlux;
622 
623  env->dobaseline = 0;
624 
625  if(env->mode == MODE_SPEC) /* If we accidently get here in SPEC mode */
626  {
628  return(0);
629  }
630 
631  if(env->accumreset)
632  {
633  st_report("Reseting Accumulators");
634 
635  resetRejections();
636 
637  env->accumcount = 0;
638  env->accumtastar = 0.0;
639  env->accumtr = 0.0;
640  env->totalweight = 0.0;
641  env->avgEl = 0.0;
642 
643  if(env->accumreset != 2) /* Dual Beam accumilation; don't zero */
644  {
645  bzero((char *)&accum_results, sizeof(accum_results));
646  bzero((char *)&accum_results_send, sizeof(accum_results_send));
647  }
648 
649  contWorkingTsys = 0.0;
650  contWorkingTime = 0.0;
651 
652  accumArrayCnt = 0;
653 
654  /* Reset to something useful */
656  {
658  }
659  }
660 
661  if(!env->numofscans)
662  {
663  st_warn("No Valid Data Files Loaded");
664 
665  env->accumreset = 1;
666  return(1);
667  }
668 
669  if(env->accumreset)
670  {
671  if(env->freq > 0.0)
672  {
673  st_report("Looking for scans using Freq = %.3f +/- %3.3f MHz", env->freq, env->dfreq*1000.0);
674  }
675  else
676  {
677  st_report("Looking for scans using ALL Freqs");
678  }
679 
680  if(env->check_date)
681  {
682  st_report("Looking for scans taken on %.4f", env->date);
683  }
684  else
685  {
686  st_report("Looking for scans taken on ALL dates");
687  }
688 
689  if(env->check_source)
690  {
691  st_report("Looking for scans on %s", env->source);
692  }
693  else
694  {
695  st_report("Looking for scans on ALL Sources");
696  }
697 
698  if(env->check_scans)
699  {
700  st_report("Looking for scans starting at: %.2f up to %.2f", env->bscan, env->escan);
701  }
702  else
703  {
704  st_report("Looking for Entire Range of scan numbers");
705  }
706 
707  if(env->check_feed)
708  {
709  st_report("Looking for scans ending in %.2f", env->if_feed);
710  }
711  else
712  {
713  st_report("Looking for ALL IF's");
714  }
715 
716  if(env->invert)
717  {
718  st_report("Inverting data");
719  }
720  }
721 
722 // if(env->freq > 0.0 && env->check_source)
723 // {
724  env->accum = 1;
725 
726  if(env->accumreset == 1)
727  {
728  st_report("Accumulating Scans for %s @ %.1f GHz +/- 500 MHz", env->source, env->freq);
729  }
730 // }
731 
732  if(env->issmt)
733  {
734  A = (M_PI * pow(MG_DIAMETER, 2.0) / 4.0);
735  }
736  else
737  {
738  A = (M_PI * pow(KP_DIAMETER, 2.0) / 4.0);
739  }
740 
741  st_report("Telescope Area = %.3f", A);
742 
743  env->jfact = ((2.0 * boltzmann / 1.0e-26) / A);
744 
745  if(env->kj_factor > 1.0)
746  {
747  env->jfact = env->kj_factor;
748  st_report("Using SF-Jansky Fact = %.2f Jk / Kelvin", env->jfact);
749  }
750  else
751  {
752  st_report("Using Jansky Factor = %.2f Jk / Kelvin", env->jfact);
753  }
754 
755  switch(env->calmode)
756  {
757  case CALMODE_TELE_EFF:
758  st_report("Using Atmospheric Conditions & Telescope Eff for Calibration");
759 
760  if(env->autotau)
761  {
762  st_report("Using Automatically Computed Tau0");
763  }
764  else
765  {
766  st_report("Using Fixed Tau0: = %.3f", env->mantau0);
767  }
768 
769  if(env->issmt)
770  {
771  surface = MG_SURFACE_RMS;
772  Fb = MG_SUB_DIA / MG_DIAMETER;
773  Te = MG_TAPER;
774  }
775  else
776  {
777  surface = KP_SURFACE_RMS;
778  Fb = KP_SUB_DIA / KP_DIAMETER;
779  Te = KP_TAPER;
780  }
781 
782  st_report("Using Te (Taper) = %3.0fdB", Te);
783 
784  a = Te * 0.115; /* Eq. 6.2a Goldsmith */
785  lambda = 1000.0 * SOL / env->freq * 1000.0; /* Convert to microns */
786 
787  st_report("Using Alpha = %5.2f", a);
788  st_report("Using Blockage = %5.2f%%", Fb * 100.0);
789  st_report("Using Lambda = %5.2f mm", lambda / 1000.0);
790  st_report("Using Surface = %5.2f microns", surface);
791 
792  Es = 1.0 - exp(-(2.0*a)); /* Eq. 6.12 Goldsmith */
793  st_report("Using Es (Spillover) = %.2f%%", Es*100.0);
794 
795  num = exp(-(pow(Fb, 2.0) * a)) - exp(-a); /* Eq. 6.10 Goldsmith */
796  Et = (2.0 / a) * ((num*num) / Es);
797  st_report("Using Et (Taper) = %.2f%%", Et*100.0);
798 
799 /* Compute Ruze Value */
800  v = (4.0 * M_PI * surface) / lambda;
801  v = v*v; /* square it */
802  Er = exp(-(v));
803  st_report("Using Er (Ruze) = %.2f%%", Er * 100.0);
804 
805  Es2 = 1.0 - exp(-(a)); /* Eq. 6.16 Goldsmith */
806  Eb = pow(num, 2.0) / pow(Es2, 2.0);
807 
808  /* Throw in a few percent for feedlegs, panel gaps & holes, optical telescope and shading */
809  Eb *= 0.984;
810  st_report("Using Eb (Blockage) = %.2f%%", Eb * 100.0);
811 
812  Ea = Et * Es * Er * Eb;
813  st_report("Using Ea (App Eff) = %.2f%%", Ea * 100.0);
814 
815  env->apperatureeff = Ea;
816 
817  break;
818 
819  case CALMODE_BEAMEFF:
820  st_report("Using Beam Efficencies of: %.2f %.2f %.2f %.2f for Calibration",
821  env->bm_eff[0], env->bm_eff[1], env->bm_eff[2], env->bm_eff[3]);
822  break;
823 
824  case CALMODE_CALSCALE:
825  st_report("Using Calibration Scale of: %.3f for Calibration", env->cal_scale);
826  break;
827 
828  case CALMODE_NONE:
829  st_report("NOT Appling any Calibration");
830  }
831 
832  if(env->elgain)
833  {
834  setColor(RED);
835  st_report("Using Elevation Gain");
836  setColor(BLACK);
837  }
838 
839  old = (int)sa[0].scan;
840 
841  p = &sa[0];
842  indx = 0;
843 
844  for(i=0;i<env->numofscans;i++,p++)
845  { /* If we want to auto reduce tips */
846  if(env->autotau && !strncmp(p->obsmode, "CONTSTIP", 8) && meetsCritiria(p, CHECK_FREQ | CHECK_DATE))
847  {
848  once = (int)p->scan;
849  if(once != old_once)
850  {
851  subArgs(2, "%d", once);
852  doSpTip();
853 
854  old_once = once;
855  }
856 
858 
859  continue;
860  }
861 
862  if(!meetsCritiria(p, CHECK_ALL))
863  {
864  continue;
865  }
866 
867  if(env->doing_fives)
868  {
869  if(strncmp(p->obsmode, "CONTQK5", 7)) /* We only process 5 Points */
870  {
872  continue; /* No good */
873  }
874  }
875  else
876  {
877  if(strncmp(p->obsmode, "CONTSEQ", 7)) /* We only process Seq */
878  {
880  continue; /* No good */
881  }
882  }
883 
884 
885  if(isScanIgnored(p->scan))
886  {
888  continue;
889  }
890 
891  ret = read_scan(p->scan, env->filename, h0->yplot1, &h0->head, 0);
892  env->curScan = p->scan;
893 
894  if(ret > 0.0)
895  {
896  if(!env->check_feed && (int)p->scan != old)
897  {
898  st_print("\n");
899  old = (int)p->scan;
900  }
901 
902  if(!(indx%32))
903  {
904  if(env->check_feed)
905  {
906  st_print("\n");
907  }
908 
909  st_print(" Source Freq UT-Date UTC Scan# NS Time El Sig");
910  st_print(" Sky S-R/R * Tsys = Ta* Tr *Fac Jy's ManTau0 TauFac ElGain");
911 
913  {
914  st_print(" Tau TauEL GainEl\n\n");
915  }
916  else
917  {
918  st_print("\n\n");
919  }
920  }
921 
922  feed = getFeed(h0->head.scan) -1;
923 
924  if(!(feed >= 0 && feed < 4))
925  {
926  feed = 0;
927  }
928 
929 
930 
931  ar1 = &accum_results[feed];
932 
933  /* Go do the actual Accumilation */
934  iret = accum_v1(h0->yplot1, &h0->head, env->invert, ar1);
935 
936  if(!iret) /* It was a good accum */
937  {
938  if(first)
939  {
941  first = 0;
942  }
943 
945  contWorkingTime += h0->head.inttime;
946  contWorkingTsys += h0->head.stsys;
947 
948  env->avgEl += h0->head.el;
949 
950  bcopy((char *)&h0->head, (char *)&accum_results_send.head[feed], sizeof(struct HEADER));
951 
952  accum_results_send.valid |= 1<<feed; /* Flag which feeds are valid */
953 
954  indx++;
955  }
956  }
957  }
958 
959  rmsTmb = rmsTr = rmsFlux = 0.0;
960  if(accumArrayCnt)
961  {
962  computeRms(&accumArrayTmb[0], accumArrayCnt, &rmsTmb);
963  computeRms(&accumArrayTr[0], accumArrayCnt, &rmsTr);
964  computeRms(&accumArrayFlux[0], accumArrayCnt, &rmsFlux);
965 
966  }
967 
968  if(indx == 0)
969  {
970  st_print("No Scans Found Matching Search Criteria\n");
971 
972  env->last_scan_count = 0;
973 
974  printRejections();
975 
976  env->accumreset = 1;
977 
978  return(1);
979  }
980 
981 /* Show results */
982  if(env->accum && env->accumcount)
983  {
984  aTaStar = env->accumtastar / env->totalweight;
985  aTr = env->accumtr / env->totalweight;
986 
987  st_print("\n%51.51s Weighted Average of %3d Scans: %8.4f%9.4f %7.1f\n", " ",
988  env->accumcount,
989  aTaStar,
990  aTr,
991  aTr*env->jfact);
992 
993  st_print("%76.76s RMS:%9.4f%9.4f %7.1f\n", " ", rmsTmb, rmsTr, rmsFlux);
994 
996 
997  if(autoCalibrate > 0.0)
998  {
999  for(i=0;i<4;i++)
1000  {
1001  if(autoAccumCnt[i])
1002  {
1003  newFactor = ((autoAccum[i] / autoAccumCnt[i]) * env->jfact) / autoCalibrate;
1004  tmpBeamEff[i] = newFactor * 100.0;
1005  }
1006  else
1007  {
1008  tmpBeamEff[i] = 1.0;
1009  }
1010  }
1011 
1012  if(getYesNoQuit("\n Use beam eff value of %.3f %.3f. %.3f %.3f: y/N ?",
1013  tmpBeamEff[0], tmpBeamEff[1],
1014  tmpBeamEff[2], tmpBeamEff[3]))
1015 
1016  {
1017  doAcceptEff();
1018 
1019  autoCalibrate = 0.0;
1020 
1021  accumSelected();
1022  }
1023  else
1024  {
1025  autoCalibrate = 0.0;
1026  }
1027  }
1028  }
1029 
1030  env->accumreset = 1;
1031 
1032  if(indx)
1033  {
1034  st_report("Sending Results to xgraphic");
1035 
1036  bcopy((char *)&accum_results, (char *)&accum_results_send.ar, sizeof(accum_results));
1037 
1039 
1040  accum_results_send.avgTaStar[feed] = aTaStar;
1041  accum_results_send.taSigma[feed] = rmsTmb;
1043 
1044  accum_results_send.avgTr[feed] = aTr;
1045  accum_results_send.trSigma[feed] = rmsTr;
1047 
1049  accum_results_send.jkSigma[feed] = rmsFlux;
1051 
1052  accum_results_send.scanct = indx;
1053  accum_results_send.head[feed].inttime = contWorkingTime;
1054  accum_results_send.head[feed].stsys = contWorkingTsys / (double)indx;
1055 
1056  sendAccumResults();
1057 
1058  env->avgEl /= (double)indx;
1059 
1061  }
1062 
1064 
1065  return(0);
1066 }
1067 
1068 
1070 {
1071  int i, j, n, foundone = 0;
1072  float max, *f;
1073  struct OBJECT *o;
1074 
1075  o = &OGM->objects[OGM->nobjIndx];
1076 
1077  if(!o->bplot)
1078  {
1079  st_fail("do_objectNormalize(): Must perform a 'gracefit' first");
1080  return(1);
1081  }
1082 
1083  if(isSet(PF_C_FLAG))
1084  {
1085  for(j=0;j<MAX_IFS;j++)
1086  {
1087  o->normalize[j] = 0.0;
1088  }
1089 
1090  sock_write(xgraphic, (char *)o, sizeof(struct OBJECT));
1091 
1092  return(0);
1093  }
1094 
1095  if(!o->bplot)
1096  {
1097  st_fail("do_objectNormalize(): Must perform a 'gracefit' first");
1098  return(1);
1099  }
1100 
1101  n = o->numMeas;
1102  for(j=0;j<MAX_IFS;j++)
1103  {
1104  if(o->measurements[0].results[j].measuredTmb)
1105  {
1106  foundone++;
1107  max = -999999.9;
1108 
1109  f = &o->fitcurves[j][0]; /* Find max of fitted curve */
1110 
1111  for(i=0;i<n;i++,f++)
1112  {
1113  if(*f > max)
1114  {
1115  max = *f;
1116  }
1117  }
1118 
1119 
1120  st_report("do_objectNormalize(): Max value for (%s): %f", mg_sideband[j], max);
1121 
1122  if(max)
1123  {
1124  o->normalize[j] = 1.0 / max;
1125  }
1126  }
1127  }
1128 
1129  if(foundone)
1130  {
1131  o->bplot = 1;
1132  sock_write(xgraphic, (char *)o, sizeof(struct OBJECT));
1133  }
1134 
1135 
1136  return(0);
1137 }
1138 
1139 
1140 
1142 {
1143  int i, j, n;
1144  float max = -99999.0, *f;
1145  struct ACCUM_SCAN_RESULT *p;
1146 
1147  if(isSet(PF_O_FLAG)) /* Perform this on the OBJECT array ?? */
1148  {
1150 
1151  return(0);
1152  }
1153 
1155  {
1156  st_fail("do_contNormalize(): Must perform a 'gracefit' first");
1157  return(1);
1158  }
1159 
1160  for(j=0;j<MAX_IFS;j++)
1161  {
1162  n = accum_results_send.ar[j].num;
1163 
1164  if(n)
1165  {
1166  f = &accum_results_send.fitcurve[j][0];
1167 
1168  for(i=0;i<n;i++,f++)
1169  {
1170  if(*f > max)
1171  {
1172  max = *f;
1173  }
1174  }
1175 
1176  st_report("do_contNormalize(): Max value for (%s): %f", mg_sideband[j], max);
1177 
1178  p = &accum_results_send.ar[j].results[0];
1179  for(i=0;i<n;i++,p++)
1180  {
1181  switch(env->acc_plot_select_y)
1182  {
1183  case ACCUM_PLOT_Y_SIG: p->normalized = p->sig / max; break;
1184  case ACCUM_PLOT_Y_SKY: p->normalized = p->sky / max; break;
1185  case ACCUM_PLOT_Y_SMROR: p->normalized = p->smror / max; break;
1186  case ACCUM_PLOT_Y_TSYS: p->normalized = p->tsys / max; break;
1187  case ACCUM_PLOT_Y_TASTAR: p->normalized = p->tastar / max; break;
1188  case ACCUM_PLOT_Y_TR: p->normalized = p->tr / max; break;
1189  case ACCUM_PLOT_Y_JANSKY: p->normalized = p->janskys / max; break;
1190  }
1191  }
1192  }
1193  }
1194 
1196 
1197  doGraceFit(); /* Recompute curve */
1198 
1199  return(0);
1200 }
1201 
1202 
1203 
1204 
1205 
1207 float *ydata;
1208 int dl;
1209 float scan;
1210 {
1211  int i;
1212 
1213  if(ydata == NULL)
1214  {
1215  return(1);
1216  }
1217 
1218  env->peakChan = 0;
1219  /* redetermine min and max */
1220  env->datamax = -9999999999.9;
1221  env->datamin = 9999999999.0;
1222 
1223  for(i=0;i<dl;i++)
1224  {
1225  if(ydata[i] > env->datamax)
1226  {
1227  env->datamax = ydata[i];
1228  env->peakChan = i;
1229  }
1230 
1231  if(ydata[i] < env->datamin)
1232  {
1233  env->datamin = ydata[i];
1234  }
1235  }
1236 
1237  if(fabs(env->datamax - env->datamin) < DATASPREAD)
1238  {
1239  st_print("Scan #%7.2f is all %.4f\n", scan, env->datamin);
1240 
1241  env->datamin -= 1.0;
1242  env->datamax += 1.0;
1243 
1244  return(1);
1245  }
1246 
1247  return(0);
1248 }
1249 
1250 
1251 
1253 float *ydata;
1254 int dl, avg;
1255 float *data;
1256 struct HEADER *h;
1257 {
1258  int i, j;
1259  float ascale, cal;
1260  double rfil = 0.0;
1261 
1262  /* Shouldn't get here, but: Switched to 2 phase @KP in Summer of 2017 */
1263  if(h->nophase == 2 || h->burn_time > 1501704800.0)
1264  {
1265  smt_bin_and_cal_data( ydata, dl, avg, data, h);
1266 
1267  return(0);
1268  }
1269 
1270  if(notSet(PF_O_FLAG)) /* Use Old Way Below */
1271  {
1272  if(!strncmp(h->obsmode, "CONTSEQ", 7))
1273  {
1274  return(seq_bin_and_cal_data(ydata, dl, avg, data, h, 4));
1275  }
1276  else
1277  if(!strncmp(h->obsmode, "CONTQK5", 7))
1278  {
1279  return(seq_bin_and_cal_data(ydata, dl, avg, data, h, 4));
1280  }
1281  else
1282  if(!strncmp(h->obsmode, "CONTFOC", 7))
1283  {
1284  return(foc_bin_and_cal_data(ydata, dl, avg, data, h, 4));
1285  }
1286  else
1287  if(!strncmp(h->obsmode, "CONTNSFC", 8))
1288  {
1289  return(foc_bin_and_cal_data(ydata, dl, avg, data, h, 4));
1290  }
1291  else
1292  if(!strncmp(h->obsmode, "CONTEWFC", 8))
1293  {
1294  return(foc_bin_and_cal_data(ydata, dl, avg, data, h, 4));
1295  }
1296  else
1297  if(!strncmp(h->obsmode, "CONTMAP", 7))
1298  {
1299  return(map_bin_and_cal_data(ydata, dl, avg, data, h, 4));
1300  }
1301  }
1302 
1303  st_report("kp_bin_cal(): Using 4 Phase Switch Pattern");
1304 
1305  ascale = 1.0;
1306 
1307  if(avg == SWITCHED)
1308  {
1309  for(i=0,j=0;i<dl;i++)
1310  {
1311  if(h->nophase == 2)
1312  {
1313  ydata[i] = (data[j] - data[j+1]) *ascale *0.5;
1314  rfil += (data[j] + data[j+1]) *0.5;
1315  }
1316  else
1317  {
1318  ydata[i] = (data[j] - data[j+1] + data[j+2] - data[j+3]) *ascale *0.25;
1319  rfil += (data[j] + data[j+1] + data[j+2] + data[j+3]) *0.25;
1320  }
1321 
1322  j += h->nophase;
1323  }
1324 
1325  rfil /= dl;
1326 
1327  if(rfil > 0.0)
1328  {
1329  cal = h->tcal/rfil;
1330  }
1331  else
1332  {
1333  cal = h->tcal/1.0;
1334  }
1335 
1336  if(isSet(PF_V_FLAG))
1337  {
1338  st_report("BIN_CAL: cal = %f, rfil = %f", cal, rfil);
1339  }
1340 
1341  for(i=0; i < dl; i++)
1342  {
1343  ydata[i] *= cal;
1344 
1345  if(isSet(PF_V_FLAG))
1346  {
1347  st_report("Ydata[%2d] = %6.1f", i, ydata[i]);
1348  }
1349  }
1350  }
1351  else
1352  {
1353  for(i=0,j=0;i<dl;i++)
1354  {
1355  if(h->nophase == 2)
1356  {
1357  ydata[i] = (data[j] + data[j+1]) / 2.0;
1358  j += 2;
1359  }
1360  else
1361  {
1362  ydata[i] = (data[j] + data[j+1] + data[j+2] + data[j+3]) /
1363  (float)h->nophase;
1364  j += h->nophase;
1365  }
1366  }
1367  }
1368 
1369  return(0);
1370 }
1371 
1372 
1373 
1374 /* All SMT data & 12M data after Summer 2017 */
1375 /* NOTE: Phases always come in as: Sig, Ref, Sig, Ref, Sig, Ref.... */
1376 /* No matter the dicke switching pattern */
1377 /* Usec for 2 or 4 phase Seq and Five-points */
1378 int seq_bin_and_cal_data(ydata, dl, avg, data, h, phase)
1379 float *ydata;
1380 int dl, avg, phase;
1381 float *data;
1382 struct HEADER *h;
1383 {
1384  int i, j, k, *p;
1385  double sig, ref, ratio, avg2;
1386 
1387  st_report("seq_bin_and_cal_data(%d): Using two Phase Switch Pattern", phase);
1388 
1389  if(avg == SWITCHED)
1390  {
1391  j = 0;
1392  k = 0;
1393 
1394  if(isSet(PF_V_FLAG))
1395  {
1396  avg2 = 0.0;
1397  }
1398 
1399  p = &two_phase_seq_five[0];
1400  for(i=0;i<dl;i++)
1401  {
1402  if(p[k] < 0)
1403  {
1404  if(phase == 2)
1405  {
1406  sig = data[j+1];
1407  ref = data[j];
1408  }
1409  else
1410  {
1411  sig = data[j+1] + data[j+3];
1412  ref = data[j] + data[j+2];
1413  }
1414  }
1415  else
1416  {
1417  if(phase == 2)
1418  {
1419  sig = data[j];
1420  ref = data[j+1];
1421  }
1422  else
1423  {
1424  sig = data[j] + data[j+2];
1425  ref = data[j+1] + data[j+3];
1426  }
1427  }
1428 
1429  /* tempK = (Sig - Ref)/ Ref * Tsys */
1430 
1431  ratio = (sig - ref) / ref;
1432 
1433  ydata[i] = h->stsys * ratio * (double)p[k];
1434 
1435  if(isSet(PF_V_FLAG))
1436  {
1437  st_report("Ratio: %10.6f: K = %5.1f", ratio, ydata[i] );
1438  avg2 += fabs(ydata[i]);
1439  }
1440 
1441 
1442  j += phase;
1443 
1444  k++;
1445 
1446  if(k >= (NPHASE_2 / 2))
1447  {
1448  p = &two_phase_seq_five[0];
1449 
1450  k = 0;
1451  }
1452  }
1453 
1454  if(isSet(PF_V_FLAG))
1455  {
1456  avg2 /= (double)dl;
1457  st_report("Average = %f K", avg2);
1458  }
1459  }
1460  else
1461  {
1462  for(i=0,j=0;i<dl;i++)
1463  {
1464  ydata[i] = (data[j] + data[j+1]) / 2.0;
1465  j += 2;
1466  }
1467  }
1468 
1469  return(0);
1470 }
1471 
1472 
1473 /* All SMT data & 12M data after Summer 2017 */
1474 /* NOTE: Phases always come in as: Sig, Ref, Sig, Ref, Sig, Ref.... */
1475 /* No matter the dicke switching pattern */
1476 /* Usec for 2 or 4 phase any_Focus */
1477 int foc_bin_and_cal_data(ydata, dl, avg, data, h, phase)
1478 float *ydata;
1479 int dl, avg, phase;
1480 float *data;
1481 struct HEADER *h;
1482 {
1483  int i, j, k, *p;
1484  double sig, ref, ratio;
1485 
1486  st_report("foc_bin_and_cal_data(%d): Using two Phase Switch Pattern", phase);
1487 
1488  if(avg == SWITCHED)
1489  {
1490  j = 0;
1491  k = 0;
1492 
1493  p = &two_phase_seq_foc[0];
1494  for(i=0;i<dl;i++)
1495  {
1496  if(p[k] < 0)
1497  {
1498  if(phase == 2)
1499  {
1500  sig = data[j+1];
1501  ref = data[j];
1502  }
1503  else
1504  {
1505  sig = data[j+1] + data[j+3];
1506  ref = data[j] + data[j+2];
1507  }
1508  }
1509  else
1510  {
1511  if(phase == 2)
1512  {
1513  sig = data[j];
1514  ref = data[j+1];
1515  }
1516  else
1517  {
1518  sig = data[j] + data[j+2];
1519  ref = data[j+1] + data[j+3];
1520  }
1521  }
1522 
1523  /* tempK = (Sig - Ref)/ Ref * Tsys */
1524 
1525  ratio = (sig - ref) / ref;
1526 
1527  ydata[i] = h->stsys * ratio * (double)p[k];
1528 
1529  if(isSet(PF_V_FLAG))
1530  {
1531  st_report("Ratio: %10.6f: K = %5.1f", ratio, ydata[i] );
1532  }
1533 
1534 
1535  j += phase;
1536 
1537  k++;
1538 
1539  if(k >= (NPHASE_2 / 2))
1540  {
1541  p = &two_phase_seq_foc[0];
1542 
1543  k = 0;
1544  }
1545  }
1546  }
1547  else
1548  {
1549  for(i=0,j=0;i<dl;i++)
1550  {
1551  ydata[i] = (data[j] + data[j+1]) / 2.0;
1552  j += 2;
1553  }
1554  }
1555 
1556  return(0);
1557 }
1558 
1559 
1560 /* All SMT data & 12M data after Summer 2017
1561  * NOTE: Phases always come in as: Sig, Ref, Sig, Ref, Sig, Ref....
1562  * No matter the dicke switching pattern
1563  * Used for 2 or 4 phase Cont Map
1564  * Because the sense of Sig / Ref changes half way through the map
1565  * we need to account for that to properly calibrate the ydata.
1566  */
1567 int map_bin_and_cal_data(ydata, dl, avg, data, h, phase)
1568 float *ydata;
1569 int dl, avg, phase;
1570 float *data;
1571 struct HEADER *h;
1572 {
1573  int i, j, half;
1574  double sig, ref, ratio;
1575 
1576  st_report("map_bin_and_cal_data(%d): Using %d Phase Switch Pattern", phase, phase);
1577 
1578  if(avg == SWITCHED)
1579  {
1580  j = 0;
1581  half = dl / 2;
1582  for(i=0;i<dl;i++)
1583  {
1584  if(phase == 2)
1585  {
1586  sig = data[j];
1587  ref = data[j+1];
1588  }
1589  else
1590  {
1591  sig = data[j] + data[j+2];
1592  ref = data[j+1] + data[j+3];
1593  }
1594 
1595  /* tempK = (Sig - Ref)/ Ref * Tsys */
1596 
1597  if(i < half)
1598  {
1599  ratio = (ref - sig) / sig * -1.0;
1600  }
1601  else
1602  {
1603  ratio = (sig - ref) / ref;
1604  }
1605 
1606  ydata[i] = h->stsys * ratio;
1607 
1608  if(isSet(PF_V_FLAG))
1609  {
1610  st_report("Ratio[%2d]: %10.6f: K = %6.2f", i, ratio, ydata[i] );
1611  }
1612 
1613  j += phase;
1614  }
1615  }
1616  else
1617  {
1618  for(i=0,j=0;i<dl;i++)
1619  {
1620  ydata[i] = (data[j] + data[j+1]) / 2.0;
1621  j += 2;
1622  }
1623  }
1624 
1625  return(0);
1626 }
1627 
1628 
1629 /* Most 2 phase continuum switching */
1631 float *ydata;
1632 int dl, avg;
1633 float *data;
1634 struct HEADER *h;
1635 {
1636  int i, j;
1637  float ascale = 1.0, cal;
1638  double rfil = 0.0;
1639 
1640  if(notSet(PF_O_FLAG)) /* Use Old Way Below */
1641  {
1642  if(!strncmp(h->obsmode, "CONTSEQ", 7))
1643  {
1644  return(seq_bin_and_cal_data(ydata, dl, avg, data, h, 2));
1645  }
1646  else
1647  if(!strncmp(h->obsmode, "CONTQK5", 7))
1648  {
1649  return(seq_bin_and_cal_data(ydata, dl, avg, data, h, 2));
1650  }
1651  else
1652  if(!strncmp(h->obsmode, "CONTFOC", 7))
1653  {
1654  return(foc_bin_and_cal_data(ydata, dl, avg, data, h, 2));
1655  }
1656  else
1657  if(!strncmp(h->obsmode, "CONTNSFC", 8))
1658  {
1659  return(foc_bin_and_cal_data(ydata, dl, avg, data, h, 2));
1660  }
1661  else
1662  if(!strncmp(h->obsmode, "CONTEWFC", 8))
1663  {
1664  return(foc_bin_and_cal_data(ydata, dl, avg, data, h, 2));
1665  }
1666  else
1667  if(!strncmp(h->obsmode, "CONTMAP", 7))
1668  {
1669  return(map_bin_and_cal_data(ydata, dl, avg, data, h, 2));
1670  }
1671  }
1672 
1673  st_report("smt_bin_cal(): Using 2 Phase Switch Pattern");
1674 
1675  if(avg == SWITCHED)
1676  {
1677  j = 0;
1678  for(i=0;i<dl;i++)
1679  {
1680  ydata[i] = (data[j] - data[j+1]) *ascale * 0.5;
1681  rfil += (data[j] + data[j+1]) * 0.25;
1682 
1683  j += 2;
1684  }
1685 
1686  rfil /= dl;
1687 
1688  if(isSet(PF_V_FLAG))
1689  {
1690  st_report("rfil: %f, dl = %d", rfil, dl);
1691  }
1692 
1693  if(rfil > 0.0)
1694  {
1695  cal = h->stsys/rfil;
1696  }
1697  else
1698  {
1699  cal = h->stsys;
1700  }
1701 
1702  for(i=0;i<dl;i++)
1703  {
1704  ydata[i] *= cal;
1705 
1706  if(isSet(PF_V_FLAG))
1707  {
1708  st_report("Ydata[%2d] = %6.1f", i, ydata[i]);
1709  }
1710  }
1711  }
1712  else
1713  {
1714  j = 0;
1715  for(i=0;i<dl;i++)
1716  {
1717  ydata[i] = (data[j] + data[j+1]) / 2.0;
1718  j += 2;
1719  }
1720  }
1721 
1722  return(0);
1723 }
1724 
1725 
1726 int clearFillContStruct(h, dlen, xl, yl)
1727 struct HEADER *h;
1728 int dlen;
1729 char *xl, *yl;
1730 {
1731 // st_report("Clearing Cont Send Struct");
1732  bzero((char *)&cont_plain_send, sizeof(cont_plain_send));
1733 
1734  bcopy((char *)h, (char *)&cont_plain_send.head, sizeof(struct HEADER));
1735 
1738  cont_plain_send.dlen = dlen;
1739 
1740  strcpy(cont_plain_send.xlabel, xl);
1741  strcpy(cont_plain_send.ylabel, yl);
1742 
1743  return(0);
1744 }
1745 
1746 
1747 int cont_show_phases(data, h, plot)
1748 float *data;
1749 struct HEADER *h;
1750 int plot;
1751 {
1752  float ydata[MAX_CONT_SAMPLES], *yp;
1753  int i, dlen, oldzline;
1754 
1755  dlen = (int)h->noint;
1756 
1757  zero_check("Phases", dlen, data);
1758 
1759  if(dlen > MAX_CONT_SAMPLES)
1760  {
1761  st_fail("Too many Continuum Samples: %d", dlen);
1762  return(1);
1763  }
1764 
1765  yp = &ydata[0];
1766 
1767  oldzline = env->zline; /* Save for later */
1768 
1769  if(isSet(PF_S_FLAG)) /* switched ? */
1770  {
1771  if(env->issmt)
1772  {
1773  smt_bin_and_cal_data( yp, dlen, SWITCHED, data, h);
1774  }
1775  else
1776  {
1777  kp_bin_and_cal_data( yp, dlen, SWITCHED, data, h);
1778  }
1779 
1780  dlen /= h->nophase;
1781  }
1782  else
1783  {
1784  env->zline = 0;
1785 
1786  for(i=0;i<dlen;i++)
1787  {
1788  ydata[i] = data[i];
1789  }
1790  }
1791 
1792  if(cont_determine_min_max(ydata, dlen, h->scan))
1793  {
1794  env->zline = oldzline;
1795 
1796  return(0);
1797  }
1798 
1799  if(isSet(PF_S_FLAG))
1800  {
1801  clearFillContStruct(h, dlen, "Sample Number", "Intensity");
1802  }
1803  else
1804  {
1805  clearFillContStruct(h, dlen, "Sample Number", "Counts");
1806  }
1807 
1808  for(i=0;i<dlen;i++)
1809  {
1810  cont_plain_send.xdata[i] = (float)(i) + 1.0;
1811  cont_plain_send.ydata[i] = ydata[i];
1812  }
1813 
1814  if(xgraphic)
1815  {
1817  }
1818 
1819  env->zline = oldzline;
1820 
1821  validate(SEQUENCE);
1822 
1823  return(0);
1824 }
1825 
1826 
1827 int sendCont(mode)
1828 int mode;
1829 {
1830  if(xgraphic)
1831  {
1832  if(mode == SEND_PLAIN)
1833  {
1834  strcpy(cont_plain_send.magic, "CONTINUUM_PLAIN");
1842 
1843  sock_write(xgraphic, (char *)&cont_plain_send, sizeof(cont_plain_send));
1844 
1846  }
1847  else
1848  if(mode == SEND_SPTIP)
1849  {
1850  strcpy(cont_sptip_send.magic, "CONTINUUM_SPTIP");
1857 
1858  sock_write(xgraphic, (char *)&cont_sptip_send, sizeof(cont_sptip_send));
1859 
1861  }
1862  }
1863 
1864  return(0);
1865 }
1866 
1867 
1868 int cont_display_sequence(image, plot)
1869 struct LP_IMAGE_INFO *image;
1870 int plot;
1871 {
1872  float ydata[MAX_CONT_SAMPLES], *yp;
1873  int i, dlen;
1874 
1875  if(processContinuum(&image->head, &image->yplot1[0], &ydata[0], &dlen, "Sequence"))
1876  {
1877  return(1);
1878  }
1879 
1880  clearFillContStruct(&image->head, dlen, "Sample Number", "{/Symbol T}_{/Symbol A}* (K)");
1881 
1882  yp = &ydata[0];
1883  for(i=0;i<dlen;i++,yp++)
1884  {
1885  cont_plain_send.xdata[i] = (float)(i) + 1.0;
1886  cont_plain_send.ydata[i] = *yp;
1887  }
1888 
1889  if(xgraphic)
1890  {
1892  }
1893 
1894  validate(SEQUENCE);
1895 
1896  return(0);
1897 }
1898 
1899 
1900 
1901 double findDeltaX(h)
1902 struct HEADER *h;
1903 {
1904  double deltax;
1905 
1906  if(h->scanang == 0.0)
1907  {
1908  deltax = h->deltaxr;
1909  }
1910  else
1911  if(h->scanang == 90.0)
1912  {
1913  deltax = h->deltayr;
1914  }
1915  else
1916  {
1917  deltax = sqrt(h->deltaxr * h->deltaxr + h->deltayr * h->deltayr);
1918  }
1919 
1920  return(deltax);
1921 }
1922 
1923 
1924 int cont_display_mapscan(image, plot)
1925 struct LP_IMAGE_INFO *image;
1926 int plot;
1927 {
1928  float ydata[MAX_CONT_SAMPLES]/*, *yp */;
1929  int i, dlen, size, xb, logplot = 0;
1930  double deltax, peak, npeak;
1931 
1932  if(processContinuum(&image->head, &image->yplot1[0], &ydata[0], &dlen, "ContMap"))
1933  {
1934  return(1);
1935  }
1936 
1937  if(env->map_w == 0 || env->map_h == 0)
1938  {
1939  env->map_w = (int)image->head.noxpts;
1940  env->map_h = (int)image->head.noypts;
1941  }
1942 
1943  if(env->map_w != (int)image->head.noxpts)
1944  {
1945  st_report(" ");
1946  st_report("cont_display_mapscan(): Warning: Mis-match between env->map_w and head.noxpts");
1947  st_report(" ");
1948  }
1949  if(env->map_h != (int)image->head.noypts)
1950  {
1951  st_report(" ");
1952  st_report("cont_display_mapscan(): Warning: Mis-match between env->map_h and head.noypts");
1953  st_report(" ");
1954  }
1955 
1956  size = env->map_w;
1957 
1958  if(env->map_h > env->map_w)
1959  {
1960  size = env->map_h;
1961  }
1962 
1963  xb = size / 2 - size;
1964 // xe = size / 2;
1965 
1966  npeak = 9999999999999999.0;
1967  peak = -9999999999999999.0;
1968 
1969  for(i=0;i<dlen;i++)
1970  {
1971  if(ydata[i] > peak)
1972  {
1973  peak = ydata[i];
1974  }
1975 
1976  if(ydata[i] < npeak)
1977  {
1978  npeak = ydata[i];
1979  }
1980  }
1981 
1982  st_report("Plot Data: Peak = %f, -Peak = %f", peak, npeak);
1983 
1984  npeak = fabs(npeak) + 0.001;
1985 
1986  if(npeak > peak)
1987  {
1988  peak = npeak;
1989  }
1990 
1991  clearFillContStruct(&image->head, dlen, "Map Offset", "{/Symbol T}_{/Symbol A}* (K)");
1992 
1994 
1995  if(peak == 0.0)
1996  {
1997  st_fail("Scan %.2f Has a Peak of 0.0", image->head.scan);
1998  return(1);
1999  }
2000 
2001  logplot = isSet(PF_LOG_FLAG);
2002 
2003  deltax = findDeltaX(&image->head);
2004 
2005  for(i=0;i<dlen;i++)
2006  {
2007  cont_plain_send.xdata[i] = (float)(xb+i) * deltax;
2008 
2009  if(logplot)
2010  {
2011  cont_plain_send.ydata[i] = log10(fabs(ydata[i]) / peak) * 10.0;
2012 
2013  if(gsl_isnan(cont_plain_send.ydata[i]))
2014  {
2015  cont_plain_send.ydata[i] = -100.0;
2016  }
2017  }
2018  else
2019  {
2020  cont_plain_send.ydata[i] = ydata[i];
2021  }
2022  }
2023 
2024  if(xgraphic)
2025  {
2027  }
2028 
2029  validate(CONT_MAP);
2030 
2031  return(0);
2032 }
2033 
2034 
2035 int processContinuum(head, phases, data, dl, mode)
2036 struct HEADER *head;
2037 float *phases, *data;
2038 int *dl;
2039 char *mode;
2040 {
2041  int i, dlen;
2042  float *yp;
2043  double avg;
2044 
2045  yp = &data[0];
2046 
2047  dlen = (int)head->noint;
2048 
2049  zero_check(mode, dlen, phases);
2050 
2051  dlen /= head->nophase;
2052 
2053  if(dlen > MAX_CONT_SAMPLES)
2054  {
2055  st_fail("Continuum Observation %s: too many samples: %d", mode, dlen);
2056  return(1);
2057  }
2058 
2059  if(env->issmt)
2060  {
2061  smt_bin_and_cal_data(yp, dlen, SWITCHED, phases, head);
2062  }
2063  else
2064  {
2065  kp_bin_and_cal_data(yp, dlen, SWITCHED, phases, head);
2066  }
2067 
2068  if(!strncmp(head->obsmode, "CONTQK5 ", 8) || !strncmp(head->obsmode, "CONTSEQ ", 8) || !strncmp(head->obsmode, "CONTMAP ", 8))
2069  {
2070  if(isSet(PF_B_FLAG)) /* Remove baseline average ?? */
2071  {
2072  avg = 0.0;
2073 
2074  for(i=0;i<dlen;i++) /* compute average */
2075  {
2076  avg += data[i];
2077  }
2078 
2079  avg /= (double)dlen;
2080 
2081  for(i=0;i<dlen;i++) /* Subtract average */
2082  {
2083  data[i] -= avg;
2084  }
2085 
2086  st_report("Removing an average baseline of: %.3f Kelvin", avg);
2087 
2088  env->zline = 1;
2089  }
2090  else
2091  {
2092  env->zline = 0;
2093  }
2094  }
2095 
2096  *dl = dlen;
2097 
2098  if(env->dobaseline && !strncmp(head->obsmode, "CONTMAP ", 8))
2099  {
2100  st_report("contDisplayMapScan(): Removing Baselines");
2101  cont_removeBaselines(yp, dlen, head->scan);
2102  }
2103 
2104  if(cont_determine_min_max(yp, dlen, head->scan))
2105  {
2106  return(1);
2107  }
2108 
2109  return(0);
2110 }
2111 
2112 
2113 int cont_display_five(image, plot)
2114 struct LP_IMAGE_INFO *image;
2115 int plot;
2116 {
2117  float ydata[MAX_CONT_SAMPLES];
2118  float splits[2][5], means[5];
2119  int i, j, dlen, old_plotstyle;;
2120  double bw;
2121  double x1, x2, x3; /* X coordinates */
2122  float a, b, c; /* curve constants */
2123 
2124  if(processContinuum(&image->head, &image->yplot1[0], &ydata[0], &dlen, "Five-Pt"))
2125  {
2126  return(1);
2127  }
2128 
2129  st_print("\n");
2130  st_print(" Az Offset: %7.2f, El Offset: %7.2f\n\n", image->head.uxpnt, image->head.uypnt);
2131 
2132  for(i=0,j=0;i<dlen;i+=4,j++)
2133  {
2134  st_print(" %7.2f %7.2f %7.2f %7.2f %s\n",
2135  ydata[0+i], ydata[1+i], ydata[2+i], ydata[3+i], fiveStrs[j]);
2136  }
2137 
2138  st_print("\n");
2139 
2140  x1 = -image->head.bfwhm;
2141  x2 = 0.0;
2142  x3 = image->head.bfwhm;
2143 
2144  if(env->split_phases)
2145  {
2146  splits[OFFS][0] = (fabs(ydata[ 0]) + fabs(ydata[ 3])) / 2.0; /* North */
2147  splits[ONS ][0] = (fabs(ydata[ 1]) + fabs(ydata[ 2])) / 2.0;
2148 
2149  splits[OFFS][1] = (fabs(ydata[ 4]) + fabs(ydata[ 7])) / 2.0; /* South */
2150  splits[ONS ][1] = (fabs(ydata[ 5]) + fabs(ydata[ 6])) / 2.0;
2151 
2152  splits[OFFS][2] = (fabs(ydata[ 8]) + fabs(ydata[11])) / 2.0; /* Center */
2153  splits[ONS ][2] = (fabs(ydata[ 9]) + fabs(ydata[10])) / 2.0;
2154 
2155  splits[OFFS][3] = (fabs(ydata[12]) + fabs(ydata[15])) / 2.0; /* East */
2156  splits[ONS ][3] = (fabs(ydata[13]) + fabs(ydata[14])) / 2.0;
2157 
2158  splits[OFFS][4] = (fabs(ydata[16]) + fabs(ydata[19])) / 2.0; /* West */
2159  splits[ONS ][4] = (fabs(ydata[17]) + fabs(ydata[18])) / 2.0;
2160 
2161  st_print(" %s\n", fiveStrs[0]);
2162  st_print(" %7.2f\n", splits[OFFS][0]);
2163  st_print(" %7.2f\n", splits[ONS ][0]);
2164  st_print(" \n");
2165  st_print(" \n");
2166  st_print(" \n");
2167  st_print(" \n");
2168  st_print(" %s %s %s\n", fiveStrs[3], fiveStrs[2], fiveStrs[4]);
2169  st_print(" %7.2f %7.2f %7.2f\n",
2170  splits[OFFS][3], splits[OFFS][2], splits[OFFS][4]);
2171  st_print(" %7.2f %7.2f %7.2f\n",
2172  splits[ONS ][3], splits[ONS ][2], splits[ONS ][4]);
2173  st_print(" \n");
2174  st_print(" \n");
2175  st_print(" \n");
2176  st_print(" %s\n", fiveStrs[1]);
2177  st_print(" %7.2f\n", splits[OFFS][1]);
2178  st_print(" %7.2f\n", splits[ONS ][1]);
2179  st_print(" \n");
2180 
2181  /* Determine the Gaussian curve that fits the AZ data */
2182  if( cont_gauss(splits[OFFS][3], splits[OFFS][2], splits[OFFS][4], x1, x2, x3, &a, &b, &c) )
2183  {
2184  if( (1.0 / b) > 0.0)
2185  {
2186  bw = sqrt( 1.0 / b) * 1.664;
2187  }
2188 
2189  st_print("AZ: OFFS: Peak = %7.2f, b = %f, Off: = %5.2f, BW = %7.2f, Corrected: %7.2f\n",
2190  a, b, c, bw, c+image->head.uxpnt);
2191  azPtCorr[0] = c+image->head.uxpnt;
2192  }
2193  else
2194  {
2195  st_print("AZ: OFFS: Fit Failed\n");
2196  }
2197 
2198  if( cont_gauss(splits[ONS ][3], splits[ONS ][2], splits[ONS ][4], x1, x2, x3, &a, &b, &c) )
2199  {
2200  if( (1.0 / b) > 0.0)
2201  {
2202  bw = sqrt( 1.0 / b) * 1.664;
2203  }
2204 
2205  st_print("AZ: ONS: Peak = %7.2f, b = %f, Off: = %5.2f, BW = %7.2f, Corrected: %7.2f\n",
2206  a, b, c, bw, c+image->head.uxpnt);
2207  azPtCorr[1] = c+image->head.uxpnt;
2208  }
2209  else
2210  {
2211  st_print("AZ: ONS: Fit Failed\n");
2212  }
2213 
2214  /* Determine the Gaussian curve that fits the EL data */
2215  if( cont_gauss(splits[OFFS][1], splits[OFFS][2], splits[OFFS][0], x1, x2, x3, &a, &b, &c) )
2216  {
2217  if( (1.0 / b) > 0.0)
2218  {
2219  bw = sqrt( 1.0 / b) * 1.664;
2220  }
2221 
2222  st_print("EL: OFFS: Peak = %7.2f, b = %f, Off: = %5.2f, BW = %7.2f, Corrected: %7.2f\n",
2223  a, b, c, bw, c+image->head.uypnt);
2224  elPtCorr[0] = c+image->head.uypnt;
2225  }
2226  else
2227  {
2228  st_print("EL: OFFS: Fit Failed\n");
2229  }
2230 
2231  if( cont_gauss(splits[ONS ][1], splits[ONS ][2], splits[ONS ][0], x1, x2, x3, &a, &b, &c) )
2232  {
2233  if( (1.0 / b) > 0.0)
2234  {
2235  bw = sqrt( 1.0 / b) * 1.664;
2236  }
2237 
2238  st_print("EL: ONS: Peak = %7.2f, b = %f, Off: = %5.2f, BW = %7.2f, Corrected: %7.2f\n",
2239  a, b, c, bw, c+image->head.uypnt);
2240  elPtCorr[1] = c+image->head.uypnt;
2241  }
2242  else
2243  {
2244  st_print("EL: ONS: Fit Failed\n");
2245  }
2246  }
2247  else
2248  {
2249  means[0] = (-ydata[ 0] + ydata[ 1] + ydata[ 2] - ydata[ 3]) / 4.0; /* North */
2250  means[1] = (-ydata[ 4] + ydata[ 5] + ydata[ 6] - ydata[ 7]) / 4.0; /* South */
2251  means[2] = (-ydata[ 8] + ydata[ 9] + ydata[10] - ydata[11]) / 4.0; /* Center */
2252  means[3] = (-ydata[12] + ydata[13] + ydata[14] - ydata[15]) / 4.0; /* East */
2253  means[4] = (-ydata[16] + ydata[17] + ydata[18] - ydata[19]) / 4.0; /* West */
2254 
2255  st_print(" %s\n", fiveStrs[0]);
2256  st_print(" %7.2f\n", means[0]);
2257  st_print(" \n");
2258  st_print(" \n");
2259  st_print(" \n");
2260  st_print(" %s %s %s\n", fiveStrs[3], fiveStrs[2], fiveStrs[4]);
2261  st_print(" %7.2f %7.2f %7.2f\n", means[3], means[2], means[4]);
2262  st_print(" \n");
2263  st_print(" \n");
2264  st_print(" \n");
2265  st_print(" %s\n", fiveStrs[1]);
2266  st_print(" %7.2f\n", means[1]);
2267  st_print(" \n");
2268 
2269  /* Determine the Gaussian curve that fits the AZ data */
2270  if( cont_gauss(means[3], means[2], means[4], x1, x2, x3, &a, &b, &c) )
2271  {
2272  if( (1.0 / b) > 0.0)
2273  {
2274  bw = sqrt( 1.0 / b) * 1.664;
2275  }
2276 
2277  st_print("AZ: Peak = %7.2f, b = %f, Off: = %5.2f, BW = %7.2f, Corrected: %7.2f\n",
2278  a, b, c, bw, image->head.uxpnt-c);
2279  azPtCorr[2] = c+image->head.uxpnt;
2280  }
2281  else
2282  {
2283  st_print("AZ: Fit Failed\n");
2284  }
2285  /* Determine the Gaussian curve that fits the EL data */
2286  if( cont_gauss(means[1], means[2], means[0], x1, x2, x3, &a, &b, &c) )
2287  {
2288  if( (1.0 / b) > 0.0)
2289  {
2290  bw = sqrt( 1.0 / b) * 1.664;
2291  }
2292 
2293  st_print("EL: Peak = %7.2f, b = %f, Off: = %5.2f, BW = %7.2f, Corrected: %7.2f\n",
2294  a, b, c, bw, image->head.uypnt-c);
2295  elPtCorr[2] = c+image->head.uypnt;
2296  }
2297  else
2298  {
2299  st_print("EL: Fit Failed\n");
2300  }
2301  }
2302 
2303  clearFillContStruct(&image->head, dlen, "Sample Number", "{/Symbol T}_{/Symbol A}* (K)");
2304 
2305  for(i=0;i<dlen;i++)
2306  {
2307  cont_plain_send.xdata[i] = (float)(i) + 1.0;
2308  cont_plain_send.ydata[i] = ydata[i];
2309  }
2310 
2311  if(xgraphic)
2312  {
2313  old_plotstyle = env->plotstyle;
2315 
2317 
2318  env->plotstyle = old_plotstyle;
2319  }
2320 
2321  validate(QK5);
2322 
2323  return(0);
2324 }
2325 
2326 
2327 int cont_display_any_focus(image, plot, type)
2328 struct LP_IMAGE_INFO *image;
2329 int plot, type;
2330 {
2331  int i, j, dlen, steps, save_ps;
2332  float ydata[MAX_CONT_SAMPLES], *yp;
2333  double f0, wl, aa1[4];
2334  double xd[256], yd[256], s[256];
2335  char fstr1[80], fstr2[80];
2336 
2337  switch(type)
2338  {
2339  case FOCALIZE:
2340  f0 = image->head.focusr;
2341  strcpy(fstr1, "AX-Focus");
2342  strcpy(fstr2, "AX Focus");
2343  break;
2344 
2345  case NS_FOCALIZE:
2346  f0 = image->head.focusv;
2347  strcpy(fstr1, "NS-Focus");
2348  strcpy(fstr2, "NS Focus");
2349  break;
2350 
2351  case EW_FOCALIZE:
2352  f0 = image->head.focush;
2353  strcpy(fstr1, "EW-Focus");
2354  strcpy(fstr2, "EW Focus");
2355  break;
2356 
2357  default:
2358  st_fail("Unknown Focus type: %d", type);
2359  return(1);
2360  }
2361 
2362  if(processContinuum(&image->head, &image->yplot1[0], &ydata[0], &dlen, fstr1))
2363  {
2364  return(1);
2365  }
2366 
2367  steps = (int)image->head.lamp;
2368  wl = image->head.lwid;
2369  yp = &ydata[0];
2370 
2371  if(steps == 0)
2372  {
2373  steps = 7;
2374  }
2375 
2376  if(wl == 0.0)
2377  {
2378  wl = image->head.wl;
2379  }
2380 
2381  f0 -= (wl * (int)(steps/2));
2382 
2383  if(isSet(PF_V_FLAG))
2384  {
2385  st_report(" ");
2386  }
2387 
2388  for(i=0;i<dlen;i+=2) /* subtract off's from on's */
2389  {
2390  ydata[i] -= ydata[i+1];
2391 
2392  if(isSet(PF_V_FLAG))
2393  {
2394  st_report("Ydata[%2d] = %6.1f", i, ydata[i]);
2395  }
2396  }
2397 
2398  if(isSet(PF_V_FLAG))
2399  {
2400  st_report(" ");
2401  }
2402 
2403  dlen = steps;
2404  for(i=0,j=0;i<dlen;i++) /* scale & left justify the array */
2405  {
2406  ydata[i] = ydata[j] / 2.0;
2407 
2408  if(isSet(PF_V_FLAG))
2409  {
2410  st_report("Ydata[%2d] = %6.1f", i, ydata[i]);
2411  }
2412 
2413  j+=2;
2414  }
2415 
2416  if(cont_determine_min_max(yp, dlen, image->head.scan))
2417  {
2418  return(0);
2419  }
2420 
2421  st_report("Max value = %f", env->datamax);
2422 
2423  if(env->yaxis_scale == LOG_PLOT)
2424  {
2425  clearFillContStruct(&image->head, dlen, fstr2, "log({/Symbol T}_{R} (K))");
2426 
2427  }
2428  else
2429  {
2430  clearFillContStruct(&image->head, dlen, fstr2, "{/Symbol T}_{/Symbol A}* (K)");
2431  }
2432 
2433  for(i=0;i<dlen;i++)
2434  {
2435  cont_plain_send.xdata[i] = f0 + wl * (float)(i);
2436 
2437  if(env->yaxis_scale == LOG_PLOT && env->datamax != 0.0)
2438  {
2439  cont_plain_send.ydata[i] = 10.0 * log10(ydata[i] / env->datamax);
2440  }
2441  else
2442  {
2443  cont_plain_send.ydata[i] = ydata[i];
2444  }
2445  }
2446 
2448 
2449 // if(env->yaxis_scale != LOG_PLOT)
2450  {
2451  /* Now fit a gaussian */
2452  for(i=0;i<dlen;i++)
2453  {
2454  xd[i] = f0 + wl * (float)(i);
2455  yd[i] = ydata[i];
2456  s[i] = 1.0;
2457  }
2458 
2459  aa1[0] = 0.0;
2460  aa1[1] = env->datamax;
2461  aa1[2] = xd[env->peakChan];
2462  aa1[3] = wl * 5.0;
2463 
2464  st_report("Guess: Center = %f @ %f: width = %f, dlen = %d", aa1[1], aa1[2], aa1[3], dlen);
2465 
2466  gauss_fit(&xd[0], &yd[0], &s[0], dlen-1, &aa1[0], isSet(PF_V_FLAG));
2467 
2468  st_report("%d-Point Gaussian Fit: Y = %.2f, X = %.2f, BW = %.2f", dlen, aa1[1], aa1[2], aa1[3]);
2469 
2470  env->glength = dlen;
2471 
2472  save_ps = env->plotstyle;
2474 
2475  /* plotGauss sends the plot after filling in lots of other stuff */
2476  plotGauss(xd, dlen, aa1, &image->head, 2);
2477 
2478  env->plotstyle = save_ps;
2479 
2480  }
2481 // else
2482 // {
2483 // save_ps = env->plotstyle;
2484 // env->plotstyle = PLOT_STYLE_LINEPTS;
2485 //
2486 // sendCont(SEND_PLAIN);
2487 //
2488 // env->plotstyle = save_ps;
2489 // }
2490 
2491  validate(type);
2492 
2493  return(0);
2494 }
2495 
2496 
2497 
2498 int zero_check(who, dl, data)
2499 char *who;
2500 int dl;
2501 float *data;
2502 {
2503  int i;
2504 
2505  for(i=0;i<dl;i++)
2506  {
2507  if(!data[i])
2508  {
2509  st_fail("zero_check(): %s data contains ZERO'S, ignoring.", who);
2510 
2511  return(0);
2512  }
2513  }
2514 
2515  return(0);
2516 }
2517 
2518 
2520 float *data;
2521 struct HEADER *h;
2522 {
2523  float ydata[MAX_CONT_SAMPLES], *yp;
2524  int i, dlen;
2525  char fname[512], astr[256];
2526  FILE *fp;
2527 
2528  if(processContinuum(h, data, &ydata[0], &dlen, "save-Data"))
2529  {
2530  return(1);
2531  }
2532 
2533  yp = &ydata[0];
2534 
2535  if(env->dobaseline)
2536  {
2537  st_report("contSaveData(): Removing Baselines");
2538  cont_removeBaselines(yp, dlen, h->scan);
2539  }
2540 
2541  if(env->mapangle == 0)
2542  {
2543  strcpy(astr, "AZs00");
2544  }
2545  else
2546  if(env->mapangle == 90)
2547  {
2548  strcpy(astr, "ELs90");
2549  }
2550  else
2551  if(env->mapangle == 45)
2552  {
2553  strcpy(astr, "Pos45");
2554  }
2555  else
2556  if(env->mapangle == -45)
2557  {
2558  strcpy(astr, "Neg45");
2559  }
2560  else
2561  {
2562  sprintf(astr, "%05d", env->mapangle);
2563  }
2564 
2565  sprintf(fname, "CCMS-%.2f_%.2f_%s.dat", h->scan, h->focusr, astr);
2566 
2567  if((fp = fopen(fname, "w")) == NULL)
2568  {
2569  st_fail("Unable to open %s for writting", fname);
2570  return(1);
2571  }
2572 
2573  st_report("Saving results to: %s", fname);
2574 
2575  fprintf(fp, "# Scan Number %8.2f\n", h->scan);
2576  fprintf(fp, "# AX-Focus %8.2f\n", h->focusr);
2577  fprintf(fp, "# Beam #1 Peak: %8.2f\n", beam_map.gmap_peak1);
2578  fprintf(fp, "# Beam #1 Width: %8.2f\n", beam_map.gmap_bw1);
2579  fprintf(fp, "# Deconvolved: %8.2f\n", decon_beam_size);
2580  fprintf(fp, "# Beam #2 Peak: %8.2f\n", beam_map.gmap_peak2);
2581  fprintf(fp, "# Beam #2 Width: %8.2f\n", beam_map.gmap_bw2);
2582  fprintf(fp, "# Map Angle: %8d\n", env->mapangle);
2583  fprintf(fp, "# \n");
2584 
2585  /* Don't worry about sqrt(deltaxr^2+deltayr^2) here because Nick
2586  does that in his analysis program; Just use sample number */
2587  for(i=0;i<dlen;i++,yp++)
2588  {
2589  fprintf(fp, "%3d %10.4f\n", i, *yp);
2590  }
2591 
2592  fclose(fp);
2593 
2594  return(0);
2595 }
2596 
2597 
2598 /* Display a table of switched values */
2600 float *data;
2601 struct HEADER *h;
2602 {
2603  int i, dlen, nons=0, noffs=0;
2604  float ydata[MAX_CONT_SAMPLES], *yp;
2605  double ons, offs, ratio, gainEl;
2606  char fname[256];
2607  FILE *fp;
2608 
2609  if(processContinuum(h, data, &ydata[0], &dlen, "Show-Data"))
2610  {
2611  return(1);
2612  }
2613 
2614  if(isSet(PF_S_FLAG))
2615  {
2616  nons = noffs = 0;
2617  ons = offs = 0.0;
2618 
2619  yp = &ydata[0];
2620  for(i=0;i<dlen;i++,yp++)
2621  {
2622  if(*yp > 0.0)
2623  {
2624  ons += *yp;
2625  nons++;
2626  }
2627  else
2628  {
2629  offs += *yp;
2630  noffs++;
2631  }
2632  }
2633 
2634  if(nons)
2635  {
2636  ons /= (double)nons;
2637  }
2638 
2639  if(noffs)
2640  {
2641  offs /= (double)noffs;
2642  }
2643 
2644  offs = fabs(offs);
2645 
2646  if(env->elgain) /* Does user want to apply elevation gain curve? */
2647  {
2648 
2649 /* SMT Elevation Gain Curve Derived by Issaoun & Folkers 2016 */
2650  gainEl = env->elgain_term5 * pow(h->el, 4.0) +
2651  env->elgain_term4 * pow(h->el, 3.0) +
2652  env->elgain_term3 * pow(h->el, 2.0) +
2653  env->elgain_term2 * h->el +
2654  env->elgain_term1;
2655 
2656  if(gainEl < 0.5)
2657  {
2658  gainEl = 1.0;
2659  }
2660 
2661  st_report("Scaling (Tmb / %f), based on Elev Gain Curve", gainEl);
2662 
2663  ons /= gainEl;
2664  offs /= gainEl;
2665  }
2666  else
2667  {
2668  gainEl = 1.0;
2669  }
2670 
2671  ratio = ons / offs;
2672 
2673  st_report("");
2674  st_report("M-Beam = %+6.1f, Average of %2d ONS: %f", h->mbeam[0], nons, ons);
2675  st_report("P-Beam = %+6.1f, Average of %2d OFFS: %f", h->pbeam[0], noffs, offs);
2676  st_report("Total = %6.1f, Average of %2d ONS+OFFS: %f, Ratio: %5.2f",
2677  fabs(h->pbeam[0]) + fabs(h->mbeam[0]),
2678  (nons + noffs),
2679  (ons + offs) / 2.0,
2680  ratio);
2681 
2682 
2683  st_report("");
2684 
2685  sprintf(fname, "sequence_splits.csv");
2686  fp = fopen(fname, "a");
2687 
2688  if(fp)
2689  {
2690  fprintf(fp, "%8.2f, %7.3f, %6.4f, %7.1f, %2d, %7.3f, %7.1f, %2d, %7.3f, %6.3f\n",
2691  h->scan,
2692  h->obsfreq / 1e3,
2693  gainEl,
2694  h->mbeam[0], nons, ons,
2695  h->pbeam[0], noffs, offs,
2696  ratio);
2697 
2698  fclose(fp);
2699 
2700  st_report("Wrote scan %.2f results to %s", h->scan, fname);
2701  }
2702  else
2703  {
2704  st_report("Unable to open %s for appending", fname);
2705  }
2706  }
2707  else
2708  {
2709  yp = &ydata[0];
2710  for(i=0;i<dlen;i++,yp++)
2711  {
2712  if(!(i%8))
2713  {
2714  printf("\n%3d: ", i);
2715  }
2716 
2717  printf("%10.2f ", *yp);
2718  }
2719 
2720  printf("\n");
2721  }
2722 
2723  return(0);
2724 }
2725 
2726 
2728 {
2729  if(strlen(args->secondArg))
2730  {
2731  autoCalibrate = atof(args->secondArg);
2732 
2733  autoAccum[0] = autoAccum[1] = autoAccum[2] = autoAccum[3] = 0.0;
2734  autoAccumCnt[0] = autoAccumCnt[1] = autoAccumCnt[2] = autoAccumCnt[3] = 0;
2735 
2736  accumSelected();
2737  }
2738 
2739  return(0);
2740 }
2741 
2742 
2743 int turnOns()
2744 {
2745  int ons;
2746 
2747  if(strlen(args->secondArg))
2748  {
2749  ons = atoi(args->secondArg);
2750 
2751  if(ons == 0)
2752  {
2753  env->ons = ons;
2754  showScan();
2755  }
2756  else
2757  if(ons == 1)
2758  {
2759  env->ons = ons;
2760  showScan();
2761  }
2762  else
2763  {
2764  st_fail("'Ons' must be 0 or 1");
2765  }
2766  }
2767 
2768  if(env->ons == 1)
2769  {
2770  st_report("'Ons' are On");
2771  }
2772  else
2773  {
2774  st_report("'Ons' are Off");
2775  }
2776 
2777  return(0);
2778 }
2779 
2780 
2782 {
2783  int bl, i, scan, first=1, save_ps, save_bl;
2784  char cmdBuf[256];
2785  struct HEADER *p;
2786 
2787  p = &sa[0];
2788 
2789  save_ps = env->plotstyle;
2791 
2792  save_bl = env->dobaseline;
2793 
2794  env->yaxis_scale = LINEAR_PLOT; /* It won't work otherwise */
2795 
2796  if(isSet(PF_B_FLAG)) // remove baselines ?
2797  {
2798  bl = 1;
2799  }
2800  else
2801  {
2802  bl = 0;
2803  }
2804 
2805  env->dobaseline = bl;
2806 
2807  clearInterrupt();
2808 
2809  for(i=0;i<env->numofscans;i++,p++)
2810  {
2811  if(meetsCritiria(p, CHECK_ALL))
2812  {
2813  if(env->mode == MODE_CONT)
2814  {
2815  if(strncmp(p->obsmode, "CONTMAP", 7)) /* We only process MAP's */
2816  {
2817  continue; /* No good */
2818  }
2819  }
2820 
2821  if(isScanIgnored(p->scan))
2822  {
2823  continue;
2824  }
2825 
2826  if(first)
2827  {
2828  scan = (int)p->scan;
2829  first = 0;
2830  }
2831 
2832  if((int)p->scan != scan)
2833  {
2834  scan = (int)p->scan;
2835  }
2836 
2837  st_report("crissCross(): Processing Criss Cross Scan %.2f", p->scan);
2838 
2839  sprintf(cmdBuf, "get %.2f", p->scan);
2840  parseCmd(cmdBuf);
2841 
2842  env->dobaseline = bl; /* Must set this each time; getScan() resets it to 0 */
2843 
2844  sprintf(cmdBuf, "show");
2845  parseCmd(cmdBuf);
2846 
2847  st_report("crissCross(): Delaying %.1f sec", 0.2);
2848  usleep(200000); // give xgraphics time to plot
2849 
2850  env->mapangle = p->scanang;
2851 
2852  if(isSet(PF_G_FLAG)) // Gauss it ?
2853  {
2854  st_report("crissCross(): Performing a Gaussian fit");
2855 
2856  sprintf(cmdBuf, "gauss /p");
2857  parseCmd(cmdBuf);
2858 
2859  st_report("crissCross(): Delaying %.1f sec", 0.2);
2860 
2861  usleep(200000); // give xgraphics time to plot
2862  }
2863 
2864  env->dobaseline = bl;
2865 
2866  if(isSet(PF_R_FLAG)) // Save it ?
2867  {
2868  st_report("crissCross(): Saving Data");
2869 
2870  saveData();
2871  }
2872 
2873  if(isSet(PF_J_FLAG))
2874  {
2875  st_report("crissCross(): Saving PNG Plot");
2876 
2877  sprintf(cmdBuf, "make /c /g");
2878  parseCmd(cmdBuf);
2879 
2880  usleep(1000000);
2881  }
2882 
2883  if(isSet(PF_D_FLAG)) // Delay ?
2884  {
2885  st_report("crissCross(): Delaying %d uSec", env->loopdelay2);
2886  usleep(env->loopdelay2);
2887  }
2888  else
2889  {
2890  st_report("crissCross(): Delaying %d uSec", env->loopdelay1);
2891  usleep(env->loopdelay1);
2892  }
2893 
2894  st_report(" ");
2895  }
2896 
2897  if(isInterrupt())
2898  {
2899  st_report("crissCross(): stopping");
2900  env->dobaseline = save_bl; // Restore a few things
2901  env->plotstyle = save_ps;
2902 
2903  return(0);
2904  }
2905  }
2906 
2907  env->dobaseline = save_bl; // Restore a few things
2908  env->plotstyle = save_ps;
2909 
2910  return(0);
2911 }
2912 
struct SOCK * xgraphic
Definition: linuxpops.c:75
int accumcount
Definition: env.h:17
float elPtCorr[4]
Definition: cont.c:69
int turnOns()
Definition: cont.c:2743
int cont_display_sequence(struct LP_IMAGE_INFO *image, int plot)
Definition: cont.c:1868
float yplot1[MAX_CHANS]
Definition: image.h:110
struct LP_IMAGE_INFO * h0
Definition: image.c:74
int getFeed()
int autotau
Definition: env.h:25
int plot_select2
Definition: accum.h:56
double boltzmann
Definition: env.c:76
double scan
Definition: header.h:35
struct MEASUREMENT measurements[MAX_MEASUREMENTS]
Definition: object.h:102
int clearFillContStruct(struct HEADER *h, int dlen, char *xl, char *yl)
Definition: cont.c:1726
int ons
Definition: env.h:87
double curScan
Definition: env.h:178
char * mg_sideband[]
Definition: strings.c:78
#define LOG_PLOT
Definition: defines.h:111
double pbeam[2]
Definition: header.h:146
int doSpTip(void)
Definition: sptip.c:269
double dfreq
Definition: env.h:183
int num
Definition: accum.h:47
char magic[16]
Definition: accum.h:133
float fitcurves[MAX_IFS][MAX_MEASUREMENTS]
Definition: object.h:104
#define NS_FOCALIZE
Definition: observing_par.h:47
#define MG_SURFACE_RMS
Definition: defines.h:7
int sock_write(struct SOCK *s, char *message, int l)
double taSigma[MAX_IFS]
Definition: accum.h:73
int incrementBogusTsys(void)
Definition: reject.c:217
#define LAST_PLOT_CONT_SPTIP
Definition: defines.h:162
int first
Definition: dbase.c:106
struct PARSE_STACK * args
Definition: parse.h:196
int loopdelay2
Definition: env.h:68
float yplotmin
Definition: accum.h:108
#define CALMODE_TELE_EFF
Definition: defines.h:52
struct ACCUM_RESULTS_SEND accum_results_send
Definition: cont.c:62
int numMeas
Definition: object.h:75
float paperh
Definition: accum.h:70
int two_phase_seq_foc[]
Definition: cont.c:82
int elgain
Definition: env.h:53
double cal_scale
Definition: env.h:175
double noint
Definition: header.h:211
double utdate
Definition: header.h:61
double scanang
Definition: header.h:100
char * fiveStrs[]
Definition: strings.c:158
int loopdelay1
Definition: env.h:67
int incrementBogusData(void)
Definition: reject.c:209
int scan
int accum_v1(float *data, struct HEADER *h, int invert, struct ACCUM_RESULTS *ar)
Definition: cont.c:94
double elgain_term1
Definition: env.h:216
int plotGauss(double *x, int len, double *a, struct HEADER *h, int mode)
Definition: gauss.c:962
int autoAccumCnt[4]
Definition: cont.c:67
double samprat
Definition: header.h:68
char source[SRCLEN+1]
Definition: dataserv.c:52
int glength
Definition: env.h:57
double mmh2o
Definition: header.h:96
double nophase
Definition: header.h:66
#define PLOT_STYLE_LINES
Definition: defines.h:101
#define RED
Definition: colors.h:5
int cont_save_data(float *data, struct HEADER *h)
Definition: cont.c:2519
int gridmode
Definition: env.h:58
int check_scans
Definition: env.h:43
int accumSelected()
Definition: cont.c:611
#define MAX_ACCUM_SCANS
Definition: accum.h:4
int read_scan()
float tsys
Definition: accum.h:38
double accumtastar
Definition: env.h:165
#define CALMODE_BEAMEFF
Definition: defines.h:51
#define MODE_CONT
Definition: defines.h:86
int four_phase_seq_five[]
Definition: cont.c:87
int invert
Definition: env.h:62
int cont_gauss(float y1, float y2, float y3, double x1, double x2, double x3, float *a, float *b, float *c)
Definition: gauss.c:766
FILE * fp
Definition: linuxpops.c:70
#define max(a, b)
Definition: cactus.h:115
int acc_plot_select_x
Definition: env.h:19
#define SWITCHED
Definition: defines.h:21
Definition: header.h:13
int isInterrupt()
Definition: interrupt.c:152
int seq_bin_and_cal_data(float *ydata, int dl, int avg, float *data, struct HEADER *h, int phase)
Definition: cont.c:1378
int printH_FlagHelp(char *cmd)
Definition: help.c:430
char xlabel[80]
Definition: accum.h:112
#define BOGUS_TCAL_VALUE
Definition: defines.h:171
double kj_factor
Definition: env.h:215
double jfact
Definition: env.h:212
struct ACCUM_RESULTS accum_results[4]
Definition: cont.c:61
double tcal
Definition: header.h:202
int do_contNormalize()
Definition: cont.c:1141
float scan
Definition: accum.h:32
int gauss_fit()
#define ACCUM_SCANS_MODE
Definition: extended_pars.h:4
int saveObjectAccum(struct ACCUM_RESULTS_SEND *ars)
Definition: object.c:301
double expectedTaStar[MAX_IFS]
Definition: accum.h:74
#define ACCUM_PLOT_Y_TSYS
Definition: accum.h:19
float xdata[MAX_CONT_SAMPLES]
Definition: accum.h:117
Definition: object.h:70
struct HEADER * sa
Definition: linuxpops.c:72
double apperatureeff
Definition: env.h:166
int issmt
Definition: env.h:63
float ydata[MAX_CONT_SAMPLES]
Definition: accum.h:118
int doAcceptEff()
Definition: beam.c:223
struct ACCUM_RESULTS ar[MAX_IFS]
Definition: accum.h:88
int zero_check(char *who, int dl, float *data)
Definition: cont.c:2498
float normalized
Definition: accum.h:43
double datamin
Definition: env.h:181
#define ACCUM_PLOT_Y_SMROR
Definition: accum.h:18
int peakChan
Definition: env.h:126
int incrementRejIgnored(void)
Definition: reject.c:169
double normalize[MAX_IFS]
Definition: object.h:98
double expectedtmb
Definition: env.h:188
#define MG_SUB_DIA
Definition: defines.h:6
int computeRms(float *y, int n, float *rms)
Definition: line.c:82
double date
Definition: env.h:182
double restFreq(struct HEADER *h)
Definition: linuxpops.c:2837
double autoCalibrate
Definition: cont.c:75
int processContinuum(struct HEADER *head, float *phases, float *data, int *dl, char *mode)
Definition: cont.c:2035
double findDeltaX(struct HEADER *h)
Definition: cont.c:1901
struct RESULT results[MAX_IFS]
Definition: object.h:62
struct BEAM_MAP beam_map
Definition: gridmap.c:61
#define CHECK_DATE
Definition: defines.h:61
#define ACCUM_PLOT_Y_SKY
Definition: accum.h:17
#define SOL
Definition: extern.h:87
int clearInterrupt()
Definition: interrupt.c:144
int notSet(int flag)
Definition: parse.c:669
#define MMMM_SS
Definition: sex.h:7
int cont_determine_min_max(float *ydata, int dl, float scan)
Definition: cont.c:1206
double avgTr[MAX_IFS]
Definition: accum.h:76
struct HEADER head
Definition: accum.h:115
#define LAST_PLOT_CONT_ACCUM
Definition: defines.h:160
int last_scan_count
Definition: env.h:66
int sexagesimal(double dang, char *str, int prec)
struct CONTINUUM_SPTIP cont_sptip_send
Definition: cont.c:64
int getYesNoQuit()
struct ENVIRONMENT * env
Definition: linuxpops.c:71
#define SEND_SPTIP
Definition: defines.h:135
#define OFFS
Definition: defines.h:137
int dobaseline
Definition: env.h:48
int two_phase_seq_five[]
Definition: cont.c:79
double decon_beam_size
Definition: convol.c:76
float accumArrayTmb[MAX_ACCUM_SCANS]
Definition: cont.c:70
char source[64]
Definition: env.h:11
int foc_bin_and_cal_data(float *ydata, int dl, int avg, float *data, struct HEADER *h, int phase)
Definition: cont.c:1477
int cont_display_data(float *data, struct HEADER *h)
Definition: cont.c:2599
int check_source
Definition: env.h:44
int isSet(int flag)
Definition: parse.c:646
#define PLOT_STYLE_LINEPTS
Definition: defines.h:103
struct HEADER head
Definition: image.h:104
int autoscale
Definition: accum.h:104
int plotStyle
Definition: accum.h:102
double expectedTr[MAX_IFS]
Definition: accum.h:78
int gridMode
Definition: accum.h:103
#define ACCUM_PLOT_Y_SIG
Definition: accum.h:16
int resetRejections(void)
Definition: reject.c:233
#define LAST_PLOT_CONT_PLAIN
Definition: defines.h:161
#define EW_FOCALIZE
Definition: observing_par.h:53
double datamax
Definition: env.h:180
int yaxis_scale
Definition: accum.h:99
#define FOCALIZE
Definition: observing_par.h:46
#define KP_SURFACE_RMS
Definition: defines.h:15
int plottmb
Definition: env.h:128
char magic[16]
Definition: accum.h:94
struct OBJECT objects[MAX_OBJECTS]
Definition: object.h:112
void st_warn()
#define ACCUM_PLOT_Y_TR
Definition: accum.h:21
float yplotmax
Definition: accum.h:107
float tastar
Definition: accum.h:39
char obsmode[8]
Definition: header.h:41
#define KP_TAPER
Definition: defines.h:17
double paperh
Definition: env.h:257
double autoAccum[4]
Definition: cont.c:76
int printRejections(void)
Definition: reject.c:257
double jkSigma[MAX_IFS]
Definition: accum.h:81
double mbeam[2]
Definition: header.h:147
int cont_display_mapscan(struct LP_IMAGE_INFO *image, int plot)
Definition: cont.c:1924
double obsfreq
Definition: header.h:197
double elgain_term5
Definition: env.h:220
void st_fail()
int cont_display_any_focus(struct LP_IMAGE_INFO *image, int plot, int type)
Definition: cont.c:2327
float gmap_peak1
Definition: gridmap.h:58
float gmap_bw1
Definition: gridmap.h:56
int kp_bin_and_cal_data(float *ydata, int dl, int avg, float *data, struct HEADER *h)
Definition: cont.c:1252
struct ACCUM_SCAN_RESULT results[MAX_ACCUM_SCANS]
Definition: accum.h:49
int incrementBogusTcal(void)
Definition: reject.c:225
int meetsCritiria(struct HEADER *p, int mask)
Definition: observe.c:90
double ylower
Definition: env.h:287
int smt_bin_and_cal_data(float *ydata, int dl, int avg, float *data, struct HEADER *h)
Definition: cont.c:1630
double measuredTmb
Definition: object.h:29
#define MG_TAPER
Definition: defines.h:9
int bplot
Definition: object.h:83
int map_h
Definition: env.h:74
int sendCont(int mode)
Definition: cont.c:1827
#define KP_SUB_DIA
Definition: defines.h:14
int setAutoCal()
Definition: cont.c:2727
int feed
Definition: stats.c:66
#define MG_DIAMETER
Definition: defines.h:5
double trSigma[MAX_IFS]
Definition: accum.h:77
float factor
Definition: accum.h:41
float janskys
Definition: accum.h:42
int saveData()
Definition: observe.c:729
int check_feed
Definition: env.h:41
float paperw
Definition: accum.h:69
float accumArrayTr[MAX_ACCUM_SCANS]
Definition: cont.c:72
#define DATASPREAD
Definition: defines.h:23
int accumArrayCnt
Definition: cont.c:66
double stsys
Definition: header.h:203
int isScanIgnored(double scan)
Definition: ignore.c:181
#define CALMODE_NONE
Definition: defines.h:49
int plotExpected
Definition: accum.h:61
int doGraceFit()
Definition: baseline.c:1641
int line_accumSelected()
Definition: line.c:443
#define ACCUM_PLOT_Y_TASTAR
Definition: accum.h:20
struct OBJECT_GLOBAL_MEMORY * OGM
Definition: object.h:115
struct CONTINUUM_PLAIN cont_plain_send
Definition: cont.c:63
double focusr
Definition: header.h:54
int mode
Definition: env.h:75
char ylabel[80]
Definition: accum.h:113
int plotwin
Definition: env.h:129
#define MODE_SPEC
Definition: defines.h:87
int cont_removeBaselines(float *d, int len, double scan)
Definition: gridmap.c:2710
int yscale
Definition: env.h:149
int setColor(int c)
Definition: parse.c:2644
int split_phases
Definition: env.h:136
double paperw
Definition: env.h:256
int accumreset
Definition: env.h:18
int incrementRejMode(void)
Definition: reject.c:162
void st_report()
double expectedflux
Definition: env.h:187
#define QK5
Definition: observing_par.h:66
int last_plot
Definition: env.c:93
double el
Definition: header.h:83
Definition: parse.h:9
float azPtCorr[4]
Definition: cont.c:69
double if_feed
Definition: env.h:208
int showScan()
Definition: observe.c:1205
struct HEADER head[MAX_IFS]
Definition: accum.h:87
int doing_fives
Definition: env.h:49
double avgTaStar[MAX_IFS]
Definition: accum.h:72
int numofscans
Definition: env.h:85
#define CALMODE_CALSCALE
Definition: defines.h:50
int do_objectNormalize()
Definition: cont.c:1069
float accumArrayFlux[MAX_ACCUM_SCANS]
Definition: cont.c:73
double elgain_term3
Definition: env.h:218
float fitcurve[MAX_IFS][MAX_ACCUM_SCANS]
Definition: accum.h:90
double yupper
Definition: env.h:288
#define SEQUENCE
Definition: observing_par.h:43
int acc_plot_select_y
Definition: env.h:20
double bscan
Definition: env.h:173
int sendAccumResults()
Definition: cont.c:452
#define ACCUM_PLOT_Y_NORMAL
Definition: accum.h:23
double burn_time
Definition: header.h:181
double freq
Definition: env.h:197
int map_w
Definition: env.h:73
void subArgs(int wt, const char *fmt,...)
Definition: parse.c:430
float gmap_peak2
Definition: gridmap.h:59
double inttime
Definition: header.h:210
#define BLACK
Definition: colors.h:4
int yaxis_scale
Definition: env.h:148
int plot_select1
Definition: accum.h:55
double accumtr
Definition: env.h:164
double avg
Definition: beam.h:5
#define CHECK_ALL
Definition: defines.h:64
char magic[16]
Definition: accum.h:53
double manual_tcal
Definition: env.c:86
int plotstyle
Definition: env.h:127
double avgJanskys[MAX_IFS]
Definition: accum.h:80
double elgain_term2
Definition: env.h:217
int cont_display_five(struct LP_IMAGE_INFO *image, int plot)
Definition: cont.c:2113
double totalweight
Definition: env.h:273
double bm_eff[MAX_BEAMS]
Definition: env.h:171
#define SEND_PLAIN
Definition: defines.h:134
double deltaxr
Definition: header.h:103
double mantau0
Definition: env.h:224
int validate(int which)
Definition: linuxpops.c:164
#define LINEAR_PLOT
Definition: defines.h:110
char * secondArg
Definition: parse.h:181
void st_print()
#define KP_DIAMETER
Definition: defines.h:13
int map_bin_and_cal_data(float *ydata, int dl, int avg, float *data, struct HEADER *h, int phase)
Definition: cont.c:1567
int ntokens
Definition: parse.h:173
#define MAX_CONT_SAMPLES
Definition: accum.h:26
double escan
Definition: env.h:186
int accum
Definition: env.h:16
int check_date
Definition: env.h:40
int printBurnTime()
Definition: cont.c:475
float ydata[MAX_ATM_ELEMENTS]
Definition: atm.c:91
int crissCross()
Definition: cont.c:2781
#define ONS
Definition: defines.h:138
float gmap_bw2
Definition: gridmap.h:57
float smror
Definition: accum.h:37
int mapangle
Definition: env.h:70
#define PLOT_STYLE_HISTO
Definition: defines.h:100
#define NPHASE_2
Definition: cont.c:78
int cont_show_phases(float *data, struct HEADER *h, int plot)
Definition: cont.c:1747
int zline
Definition: env.h:151
char object[16]
Definition: header.h:40
char * firstArg
Definition: parse.h:180
int parseCmd(char *buf)
Definition: parse.c:2090
#define CONT_MAP
Definition: observing_par.h:45
#define MAX_IFS
Definition: accum.h:5
double expectedJanskys[MAX_IFS]
Definition: accum.h:82
#define CHECK_FREQ
Definition: defines.h:63
double ut
Definition: header.h:62
#define NPHASE_4
Definition: cont.c:86
char filename[256]
Definition: env.h:9
double avgEl
Definition: env.h:167
double elgain_term4
Definition: env.h:219
double tsyslimit
Definition: env.h:275
#define ACCUM_PLOT_Y_JANSKY
Definition: accum.h:22
int calmode
Definition: env.h:38
float accumArrayTaStar[MAX_ACCUM_SCANS]
Definition: cont.c:71
double tmpBeamEff[4]
Definition: beam.c:83