Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
observe.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 
61 
62 /* Trap missing parameters */
64 {
65  if(env->escan < 1.0)
66  {
67  st_report("Resetting Ending Scan Number to 10000.0");
68  env->escan = 10000.0;
69  }
70 
71  if(env->dfreq < 0.00001)
72  {
73  if(env->mode == MODE_SPEC)
74  {
75  env->dfreq = 0.001;
76  }
77  else
78  {
79  env->dfreq = 0.5;
80  }
81 
82  st_report("Resetting Delta Freq to %f GHz", env->dfreq);
83 
84  }
85 
86  return(0);
87 }
88 
89 
90 int meetsCritiria(p, mask)
91 struct HEADER *p;
92 int mask;
93 {
94  int feed, ret;
95  double freq;
96  char source[64];
97 
98  verifyParams();
99 
100  if(env->mode == MODE_NOT_SET)
101  {
102  st_report("Resetting Mode MODE_CONT");
103  env->mode = MODE_CONT;
104  }
105 
106  if(mask & CHECK_SOURCE)
107  {
108  strncpy(source, p->object, 16);
109  source[16] = '\0';
110  strcmprs(source);
111 
112  if(env->check_source && strcasecmp(source, env->source)) /* Change to exact name lenght matching */
113  {
115  {
116  printf("Reject Name\n");
117  }
118 
120 
121  return(0); /* Skip */
122  }
123  }
124 
125  if(mask & CHECK_SCANS)
126  {
127  if(p->scan > (env->escan+0.99) || p->scan < env->bscan)
128  {
130  {
131  printf("Reject Scan Range\n");
132  }
133 
135 
136  return(0);
137  }
138  }
139 
140  if(mask & CHECK_DATE)
141  {
142  if(env->check_date)
143  {
145  {
146  printf("Checking %.4f vs %.4f\n", p->utdate, env->date);
147  }
148 
149  if((ret = lp_fcmp(p->utdate, env->date, 0.00005)))
150  {
151  if(verboseLevel & VERBOSE_CRITIRIA)
152  {
153  printf("Reject %d Date: %.4f\n", ret, p->utdate);
154  }
155 
157 
158  return(0);
159  }
160  }
161  }
162 
163  if(mask & CHECK_BKEND)
164  {
165  if(!backendMatch(p))
166  {
168  {
169  printf("Reject Backend\n");
170  }
171 
173 
174  return(0);
175  }
176  }
177 
178  if(mask & CHECK_FREQ)
179  {
180  if(env->mode == MODE_CONT)
181  {
183  {
184  printf("Reject Freq\n");
185  }
186  freq = restFreq(p) / 1000.0;
187  }
188  else
189  {
190  freq = p->restfreq / 1000.0;
191  }
192 
193  if(env->freq > 0.0 && lp_fcmp(freq, env->freq, env->dfreq))
194  {
196  {
197  printf("Reject Freq\n");
198  }
199 
201 
202  return(0); /* No good */
203  }
204  }
205 
206 /* Reject the 'matching freq' IF's that don't match freq selection & SB */
207  if(env->issmt && env->strictsb)
208  {
209  feed = getFeed(p->scan); /* 1, 2, 3, 4 */
210 
211  if(p->sideband == LSB)
212  {
213  if(feed == 2 || feed == 4)
214  {
216  {
217  printf("Reject Strict\n");
218  }
219 
220  incrementRejSb();
221 
222  return(0);
223  }
224  }
225  else
226  if((int)p->sideband == USB)
227  {
228  if(feed == 1 || feed == 3)
229  {
231  {
232  printf("Reject Strict\n");
233  }
234 
235  incrementRejSb();
236 
237  return(0);
238  }
239  }
240  }
241 
243  {
244  printf("Passed All Preliminary Checks\n");
245  }
246 
247  return(1);
248 }
249 
250 
252 {
253  if(env->bkmatch != BKMATCH_FEED)
254  {
255  st_fail("Backend Match NOT set to FEED; Use 'accum'");
256 
257  return(1);
258  }
259 
260  return(0);
261 }
262 
263 
264 int setFeed(want)
265 double want;
266 {
267  if(strstr(env->filename, "_hc.")) /* Check for MAC data */
268  {
269  env->if_feed = (want + 10.0) / 100.0;
270  }
271  else
272  if(env->issmt && env->bkres == 0.250)
273  {
274  env->if_feed = (want + 4.0) / 100.0;
275  }
276  else
277  {
278  env->if_feed = want / 100.0;
279  }
280 
281  return(0);
282 }
283 
284 
285 
286 /* Show only IF #1 */
287 int showC1()
288 {
289  float old_feed;
290  int old_check;
291 
292  if(checkMatch())
293  {
294  return(1);
295  }
296 
297  old_check = env->check_feed;
298 
299  /* save any selected IF feed */
300  if(env->check_feed)
301  {
302  old_feed = env->if_feed;
303  }
304 
305  setFeed(1.0);
306  env->feed = 0;
307 
308  env->check_feed = 1;
309 
310  accumSelected();
311 
312  /* restore any selected IF feed */
313  if(old_check)
314  {
315  env->if_feed = old_feed;
316  }
317  else
318  {
319  env->if_feed = 0.0;
320  env->check_feed = 0;
321  }
322 
323  return(0);
324 }
325 
326 
327 int showC2()
328 {
329  float old_feed;
330  int old_check;
331 
332  if(checkMatch())
333  {
334  return(1);
335  }
336 
337  old_check = env->check_feed;
338 
339  /* save any selected IF feed */
340  if(env->check_feed)
341  {
342  old_feed = env->if_feed;
343  }
344 
345  setFeed(2.0);
346  env->feed = 1;
347 
348  env->check_feed = 1;
349 
350  accumSelected();
351 
352  /* restore any selected IF feed */
353  if(old_check)
354  {
355  env->if_feed = old_feed;
356  }
357  else
358  {
359  env->if_feed = 0.0;
360  env->check_feed = 0;
361  }
362 
363  return(0);
364 }
365 
366 
367 /* Show only IF #3 */
368 int showC3()
369 {
370  float old_feed;
371  int old_check;
372 
373  if(checkMatch())
374  {
375  return(1);
376  }
377 
378  old_check = env->check_feed;
379 
380  /* save any selected IF feed */
381  if(env->check_feed)
382  {
383  old_feed = env->if_feed;
384  }
385 
386  setFeed(3.0);
387  env->feed = 2;
388 
389  env->check_feed = 1;
390 
391  accumSelected();
392 
393  /* restore any selected IF feed */
394  if(old_check)
395  {
396  env->if_feed = old_feed;
397  }
398  else
399  {
400  env->if_feed = 0.0;
401  env->check_feed = 0;
402  }
403 
404  return(0);
405 }
406 
407 /* Show only IF #4 */
408 int showC4()
409 {
410  float old_feed;
411  int old_check;
412 
413  if(checkMatch())
414  {
415  return(1);
416  }
417 
418  old_check = env->check_feed;
419 
420  /* save any selected IF feed */
421  if(env->check_feed)
422  {
423  old_feed = env->if_feed;
424  }
425 
426  setFeed(4.0);
427  env->feed = 3;
428 
429  env->check_feed = 1;
430 
431  accumSelected();
432 
433  /* restore any selected IF feed */
434  if(old_check)
435  {
436  env->if_feed = old_feed;
437  }
438  else
439  {
440  env->if_feed = 0.0;
441  env->check_feed = 0;
442  }
443 
444  return(0);
445 }
446 
447 
448 int showCb()
449 {
450  float old_feed;
451  int old_check;
452 
453  if(checkMatch())
454  {
455  return(1);
456  }
457 
458  old_check = env->check_feed;
459 
460  /* save any selected IF feed */
461  if(env->check_feed)
462  {
463  old_feed = env->if_feed;
464  }
465 
466  _h1();
467 
468  setFeed(1.0);
469  env->feed = 0;
470 
471  env->check_feed = 1;
472 
473  accumSelected();
474 
475  _h2();
476 
477  setFeed(2.0);
478  env->feed = 1;
479 
480  accumSelected();
481 
482  _h0();
483 
484  subArgs(2, "H1");
485  subArgs(3, "H2");
486 
487  doSum();
488 
489  doAutoScale();
490 
491  xx();
492 
493  /* restore any selected IF feed */
494  if(old_check)
495  {
496  env->if_feed = old_feed;
497  }
498  else
499  {
500  env->if_feed = 0.0;
501  env->check_feed = 0;
502  }
503 
504  return(0);
505 }
506 
507 
508 int showC12()
509 {
510  float old_feed;
511  int old_check;
512 
513  if(checkMatch())
514  {
515  return(1);
516  }
517 
518  old_check = env->check_feed;
519 
520  /* save any selected IF feed */
521  if(env->check_feed)
522  {
523  old_feed = env->if_feed;
524  }
525 
526  setFeed(1.0);
527  env->feed = 0;
528 
529  env->check_feed = 1;
530 
531  accumSelected();
532 
533  setFeed(2.0);
534  env->feed = 1;
535 
536  env->accumreset = 2; /* Set for Dual Beam Accum */
537 
538  accumSelected();
539 
540  /* restore any selected IF feed */
541  if(old_check)
542  {
543  env->if_feed = old_feed;
544  }
545  else
546  {
547  env->if_feed = 0.0;
548  env->check_feed = 0;
549  }
550 
551  return(0);
552 }
553 
554 
555 int showC34()
556 {
557  float old_feed;
558  int old_check;
559 
560  if(checkMatch())
561  {
562  return(1);
563  }
564 
565  old_check = env->check_feed;
566 
567  /* save any selected IF feed */
568  if(env->check_feed)
569  {
570  old_feed = env->if_feed;
571  }
572 
573  setFeed(3.0);
574  env->feed = 2;
575 
576  env->check_feed = 1;
577 
578  accumSelected();
579 
580  setFeed(4.0);
581  env->feed = 3;
582 
583  env->accumreset = 2; /* Set for Dual Beam Accum */
584 
585  accumSelected();
586 
587  /* restore any selected IF feed */
588  if(old_check)
589  {
590  env->if_feed = old_feed;
591  }
592  else
593  {
594  env->if_feed = 0.0;
595  env->check_feed = 0;
596  }
597 
598  return(0);
599 }
600 
601 int showC13()
602 {
603  float old_feed;
604  int old_check;
605 
606  if(checkMatch())
607  {
608  return(1);
609  }
610 
611  old_check = env->check_feed;
612 
613  /* save any selected IF feed */
614  if(env->check_feed)
615  {
616  old_feed = env->if_feed;
617  }
618 
619  setFeed(1.0);
620  env->feed = 0;
621 
622  env->check_feed = 1;
623 
624  accumSelected();
625 
626  setFeed(3.0);
627  env->feed = 2;
628 
629  env->accumreset = 2; /* Set for Dual Beam Accum */
630 
631  accumSelected();
632 
633  /* restore any selected IF feed */
634  if(old_check)
635  {
636  env->if_feed = old_feed;
637  }
638  else
639  {
640  env->if_feed = 0.0;
641  env->check_feed = 0;
642  }
643 
644  return(0);
645 }
646 
647 
648 int showC24()
649 {
650  float old_feed;
651  int old_check;
652 
653  if(checkMatch())
654  {
655  return(1);
656  }
657 
658  old_check = env->check_feed;
659 
660  /* save any selected IF feed */
661  if(env->check_feed)
662  {
663  old_feed = env->if_feed;
664  }
665 
666  setFeed(2.0);
667  env->feed = 1;
668 
669  env->check_feed = 1;
670 
671  accumSelected();
672 
673  setFeed(4.0);
674  env->feed = 3;
675 
676  env->accumreset = 2; /* Set for Dual Beam Accum */
677 
678  accumSelected();
679 
680  /* restore any selected IF feed */
681  if(old_check)
682  {
683  env->if_feed = old_feed;
684  }
685  else
686  {
687  env->if_feed = 0.0;
688  env->check_feed = 0;
689  }
690 
691  return(0);
692 }
693 
694 
696 {
697  if(h0->head.scan < 1.0)
698  {
699  st_warn("No Scan Loaded for showPhases; Use 'get scan#'");
700  return(0);
701  }
702 
704 
705  return(0);
706 }
707 
708 
709 int showData()
710 {
711  if(env->mode == MODE_SPEC)
712  {
713  line_showTable();
714  return(0);
715  }
716 
717  if(h0->head.scan < 1.0)
718  {
719  st_warn("No Scan loaded; Use 'get scan#'");
720  return(0);
721  }
722 
724 
725  return(0);
726 }
727 
728 
729 int saveData()
730 {
731  if(h0->head.scan < 1.0)
732  {
733  st_warn("No Scan loaded; Use 'get scan#'");
734  return(0);
735  }
736 
737  if(env->mode == MODE_CONT)
738  {
740  }
741  else
742  {
744  }
745 
746  return(0);
747 }
748 
749 
751 {
752  int i, ret, noint;
753  float *f1, *f2;
754  double ratio;
755  struct HEADER *h;
756  struct LP_IMAGE_INFO *image = h0;
757 
758  h = &image->head;
759  noint = h->noint;
760 
761  if(env->newres > 0.0 && env->newres > h->freqres)
762  {
763  ratio = fabs(env->newres / h->freqres);
764 
765  ret = chgres(&image->yplot1[0], noint, fabs(h->freqres), env->newres);
766 
767  if(!ret)
768  {
769  /* Move the valid results down to the bottom */
770  f1 = &image->yplot1[0];
771  f2 = &image->yplot1[0];
772 
773  for(i=0;i<noint;i++,f1++)
774  {
775  if(gsl_finite(*f1)) /* If it's good copy to next slot starting at 0 */
776  {
777  *f2 = *f1;
778  f2++;
779  }
780  }
781 
782  h->noint = floor(h->noint / ratio) - 4.0; /* Throw a couple off each end */
783  h->refpt /= ratio;
784  h->deltax *= ratio;
785  h->freqres *= ratio;
786 
787  env->bmark = 0; /* turn off baseline boxes */
788  env->mshow = 0; /* turn off markers */
789  }
790  else
791  {
792  st_fail("Failure: %d in changeRes() function", ret);
793  }
794  }
795  else
796  {
797  st_fail("newres value %f is 0.0 or is < current freqres: %f", env->newres, h->freqres);
798  }
799 
800  return(0);
801 }
802 
803 
805 {
806  int i, dlen;
807 
808  if(env->mode == MODE_SPEC)
809  {
810  line_showTable();
811  return(0);
812  }
813 
814  if(!strncmp(h0->head.obsmode, "CONTOPT", 7))
815  {
817  return(0);
818  }
819 
820  if(h0->head.scan < 1.0)
821  {
822  st_warn("No Scan loaded; Use 'get scan#'");
823  return(0);
824  }
825 
826  dlen = h0->head.datalen / sizeof(float);
827 
828  /* ignore telescope positin data on end */
829  if(!strncmp(h0->head.obsmode, "CONTMAP", 7))
830  {
831  dlen -= h0->head.noxpts;
832  }
833 
834  for(i=0;i<dlen;i++)
835  {
836  if(!(i%8))
837  {
838  st_print("\n%5d: ", i);
839  }
840 
841  st_print("%7.0f ", h0->yplot1[i]);
842  }
843 
844  st_print("\n");
845 
846  return(0);
847 }
848 
849 
850 
851 int pReview()
852 {
853  int i, ret;
854  char tbuf[256];
855  struct HEADER *p;
856 
857  p = &sa[0];
858 
859  for(i=0;i<env->numofscans;i++,p++)
860  {
861  if(meetsCritiria(p, CHECK_ALL))
862  {
863  if(strncmp(p->obsmode, "LINEBSP", 7) &&
864  strncmp(p->obsmode, "LINEPS", 6) &&
865  strncmp(p->obsmode, "LINEFS", 6) &&
866  strncmp(p->obsmode, "LINETPON", 8) &&
867  strncmp(p->obsmode, "LINEAPS", 7))
868  {
869  continue; /* No good */
870  }
871 
872  if(p->openpar[5] == 5555.5) /* a BSP focal */
873  {
874  continue; /* Ignore */
875  }
876 
877  sprintf(tbuf, "%.2f", p->scan);
878 
879  /* quad only works with xxxx.01, xxxx.03, xxxx.05, xxxx.11 */
880  if(strstr(tbuf, ".01") || strstr(tbuf, ".03") || strstr(tbuf, ".05") || strstr(tbuf, ".11"))
881  {
882  subArgs(2, tbuf);
883  doPshow();
884 
885  ret = getYesNoQuit("Hit any key to continue");
886 
887  if(ret == 2) /* 'q' */
888  {
889  return(0);
890  }
891  }
892  }
893  }
894 
895  return(0);
896 }
897 
898 
899 int qReview()
900 {
901  int i, ret;
902  char tbuf[256];
903  struct HEADER *p;
904 
905  p = &sa[0];
906 
907  for(i=0;i<env->numofscans;i++,p++)
908  {
909  if(meetsCritiria(p, CHECK_ALL))
910  {
911  if(strncmp(p->obsmode, "LINEBSP", 7) &&
912  strncmp(p->obsmode, "LINEPS", 6) &&
913  strncmp(p->obsmode, "LINEFS", 6) &&
914  strncmp(p->obsmode, "LINETOPN", 8) &&
915  strncmp(p->obsmode, "LINEAPS", 7))
916  {
917  continue; /* No good */
918  }
919 
920  if(p->openpar[5] == 5555.5) /* a BSP focal */
921  {
922  continue; /* Ignore */
923  }
924 
925  sprintf(tbuf, "%.2f", p->scan);
926 
927  /* quad only works with xxxx.01, xxxx.05, xxxx.11 */
928  if(strstr(tbuf, ".01") || strstr(tbuf, ".05") || strstr(tbuf, ".11"))
929  {
930  subArgs(2, tbuf);
931  doQshow();
932 
933  ret = getYesNoQuit("Hit any key to continue");
934 
935  if(ret == 2) /* 'q' */
936  {
937  return(0);
938  }
939  }
940  }
941  }
942 
943  return(0);
944 }
945 
946 
948 {
949  int i, ret, ver;
950  extern int doingOTF;
951  char tbuf[256], cmdBuf[256], fname[256];
952  struct HEADER *p;
953  FILE *fp;
954 
955  /* Set the plotting to autoscale unless the /f arg is sent */
956  if(notSet(PF_F_FLAG))
957  {
958  doAutoScale();
959  }
960 
961  if(isSet(PF_I_FLAG)) /* review Ignored scans? */
962  {
963  reviewIgnored();
964 
965  return(0);
966  }
967 
968  p = &sa[0];
969 
970  if(env->mode == MODE_CONT && isSet(PF_S_FLAG))
971  {
972  sprintf(fname, "sequence_splits.csv");
973 
974  st_report("Removing any previous '%s' file", fname);
975  sprintf(cmdBuf, "rm -f %s", fname);
976  system(cmdBuf);
977 
978  fp = fopen(fname, "a");
979 
980  if(fp)
981  {
982  fprintf(fp, "#\n");
983  fprintf(fp, "# Scan, Freq, EG, mbeam, mCnt, mTmb, pbeam, pCnt, pTmb, Ratio\n");
984  fprintf(fp, "#\n");
985 
986  fclose(fp);
987  }
988  }
989 
990  clearInterrupt();
991 
992  for(i=0;i<env->numofscans;i++,p++)
993  {
994  if(meetsCritiria(p, CHECK_ALL))
995  {
996  if(env->mode == MODE_CONT)
997  {
998  if(strncmp(p->obsmode, "CONTSEQ", 7) && strncmp(p->obsmode, "CONTMAP", 7) && strncmp(p->obsmode, "CONTOPT", 7)) /* We only process Seq */
999  {
1000  continue; /* No good */
1001  }
1002  }
1003  else
1004  if(env->mode == MODE_OTF)
1005  {
1006  if(strncmp(p->obsmode, "LINEOTF", 7)) /* We only process OTF */
1007  {
1008  continue; /* No good */
1009  }
1010  }
1011  else
1012  { /* We only process BSP & PS for now*/
1013  if(strncmp(p->obsmode, "LINEBSP", 7) &&
1014  strncmp(p->obsmode, "LINEPS", 6) &&
1015  strncmp(p->obsmode, "LINEFS", 6) &&
1016  strncmp(p->obsmode, "LINETPON", 8) &&
1017  strncmp(p->obsmode, "LINEAPS", 7))
1018  {
1019  continue; /* No good */
1020  }
1021 
1022  if(p->openpar[5] == 5555.5) /* a BSP focal */
1023  {
1024  continue; /* Ignore */
1025  }
1026  }
1027 
1028  if(env->mode == MODE_OTF)
1029  {
1030  if(!doingOTF)
1031  {
1032  st_fail("Must start OTF process first");
1033  return(1);
1034  }
1035 
1036  sprintf(tbuf, "scan_done %.0f", p->scan);
1037  to_dataserv(tbuf);
1038 
1039  if(isSet(PF_N_FLAG))
1040  {
1041  usleep(env->loopdelay2);
1042  }
1043  else
1044  {
1045  ret = getYesNoQuit("Ignore Scan %.2f: y/N ?", p->scan);
1046  }
1047 
1048  if(ret == 1) /* 'y' */
1049  {
1050  ver = atoi( env->filename + strlen(env->filename)-3 );
1051 
1052  sprintf(tbuf, "ignore %d %.2f", ver, p->scan);
1053 
1054  to_dataserv(tbuf);
1055  }
1056  else
1057  if(ret == 2) /* 'q' */
1058  {
1059  return(0);
1060  }
1061 
1062  continue;
1063  }
1064 
1065  subArgs(2, "%.2f", p->scan);
1066 
1067  getScan(1);
1068 
1069  if(!strncmp(h0->head.obsmode, "CONTOPT", 7))
1070  {
1071  setFlag(PF_3_FLAG, 1);
1072  }
1073 
1074  /* if we are in cont mode, and the user requests a split, and it's NOT a seq */
1075  if(env->mode == MODE_CONT && isSet(PF_S_FLAG) && strncmp(h0->head.obsmode, "CONTSEQ", 7))
1076  {
1077  continue;
1078  }
1079 
1080  showScan();
1081 
1082  /* if we are in cont mode, and the user requests a split, and it's a seq */
1083  if(env->mode == MODE_CONT && isSet(PF_S_FLAG) && !strncmp(h0->head.obsmode, "CONTSEQ", 7))
1084  {
1085  if(isScanIgnored(p->scan) == 0)
1086  {
1087  sprintf(cmdBuf, "data /s");
1088  parseCmd(cmdBuf);
1089  }
1090  }
1091 
1092  if(isSet(PF_N_FLAG) || (env->mode == MODE_CONT && isSet(PF_S_FLAG)))
1093  {
1094  usleep(env->loopdelay1);
1095 
1096  if(isInterrupt()) /* Check for Control-C input; any will cause reading to stop */
1097  {
1098  st_print("Control-C hit; Stoping\n");
1099 
1100  return(0);
1101  }
1102  }
1103  else
1104  {
1105  ret = getYesNoQuit("Ignore Scan %.2f: y/N ?", p->scan);
1106 
1107  st_report("Got %d", ret);
1108  }
1109 
1110  if(ret == 1) /* 'y' */
1111  {
1112  subArgs(2, "%.2f", p->scan);
1113  ignoreScans();
1114  }
1115  else
1116  if(ret == 2) /* 'q' */
1117  {
1118  return(0);
1119  }
1120  else
1121  if(ret == 3) /* 'b' 'back' */
1122  {
1123  if(i != 0)
1124  {
1125  i--;
1126  i--;
1127  if(i != 0)
1128  {
1129  p--;
1130  p--;
1131  }
1132  }
1133  }
1134  }
1135  }
1136 
1137  return(0);
1138 }
1139 
1140 
1141 
1143 {
1144  int i;
1145  int old_check;
1146  float old_feed;
1147  struct HEADER *p;
1148 
1149  old_check = env->check_feed;
1150 
1151  /* save any selected IF feed */
1152  if(env->check_feed)
1153  {
1154  old_feed = env->if_feed;
1155  }
1156 
1157  setFeed(1.0);
1158  env->feed = 0;
1159 
1160  env->check_feed = 1;
1161 
1162  p = &sa[0];
1163 
1164  st_print(
1165 "\n Source Freq Date UT Scan El Mode Tsys Tcal \
1166 Tamb %Hum BP Dewpt mmH2O tHum Refrac Tau0\n\n");
1167 
1168  for(i=0;i<env->numofscans;i++,p++)
1169  {
1170  if(meetsCritiria(p, CHECK_ALL))
1171  {
1172  if(strncmp(p->obsmode, "CONTSEQ", 7)) /* We only process Seq */
1173  {
1174  continue; /* No good */
1175  }
1176 
1177  subArgs(2, "%.2f", p->scan);
1178 
1179  getScan(0);
1180 
1181  st_print(
1182 " %10.10s %10.6f %10.4f %6.2f %7.2f %5.1f %8.8s %3.0f %3.0f\
1183  %5.1f %3.0f %3.0f %5.1f %5.1f %5.1f %4.1f %5.3f\n",
1184  p->object, p->restfreq, p->utdate, p->ut, p->scan, p->el, p->obsmode, p->stsys, p->tcal,
1186  }
1187  }
1188 
1189  /* restore any selected IF feed */
1190  if(old_check)
1191  {
1192  env->if_feed = old_feed;
1193  }
1194  else
1195  {
1196  env->if_feed = 0.0;
1197  env->check_feed = 0;
1198  }
1199 
1200  return(0);
1201 }
1202 
1203 
1204 
1206 {
1207  double fscan;
1208 
1209  if(h0->head.scan == 0.0)
1210  {
1211  st_warn("No scan to plot; Use the 'get or gget' command first");
1212 
1213  return(0);
1214  }
1215 
1216  env->curScan = fscan = h0->head.scan;
1217 
1218  if(env->mode == MODE_CONT && !strncmp(h0->head.obsmode, "CONT", 4))
1219  {
1220  if(!strncmp(h0->head.obsmode, "CONTSEQ ", 8))
1221  {
1222  st_report("Processing Continuum Sequence, Scan %.2f", fscan);
1224  }
1225  else
1226  if(!strncmp(h0->head.obsmode, "CONTMAP ", 8))
1227  {
1228  st_report("Processing Continuum Az-El Grid, Scan %.2f", fscan);
1230  }
1231  else
1232  if(!strncmp(h0->head.obsmode, "CONTFIVE", 8))
1233  {
1234  st_report("Processing Continuum Five-Point, Scan %.2f", fscan);
1236  }
1237  else
1238  if(!strncmp(h0->head.obsmode, "CONTQK5 ", 8))
1239  {
1240  st_report("Processing Continuum Five-Point, Scan %.2f", fscan);
1242  }
1243  else
1244  if(!strncmp(h0->head.obsmode, "CONTFOC ", 8))
1245  {
1246  st_report("Processing Continuum Focus, Scan %.2f", fscan);
1248  }
1249  else
1250  if(!strncmp(h0->head.obsmode, "CONTNSFC", 8))
1251  {
1252  st_report("Processing Continuum NS-Focus, Scan %.2f", fscan);
1254  }
1255  else
1256  if(!strncmp(h0->head.obsmode, "CONTEWFC", 8))
1257  {
1258  st_report("Processing Continuum EW-Focus, Scan %.2f", fscan);
1260  }
1261  else
1262  if(!strncmp(h0->head.obsmode, "CONTSTIP", 8))
1263  {
1264  st_report("Processing Continuum SPTIP, Scan %.2f", fscan);
1266  }
1267  else
1268  if(!strncmp(h0->head.obsmode, "CONTOPT ", 8))
1269  {
1270  st_report("Processing Continuum CONTOPT, Scan %.2f", fscan);
1272  }
1273  else
1274  {
1275  st_fail("Unknown Continuum Observing Mode %8.8s", h0->head.obsmode);
1276  }
1277  }
1278  else
1279  if(env->mode == MODE_SPEC && !strncmp(h0->head.obsmode, "LINE", 4))
1280  {
1281  if(!strncmp(h0->head.obsmode, "LINEAPS", 7))
1282  {
1283  st_report("Processing Line APS, Scan %.2f", fscan);
1285  }
1286  else
1287  if(!strncmp(h0->head.obsmode, "LINEAPM", 7))
1288  {
1289  st_report("Processing Line APM, Scan %.2f", fscan);
1291  }
1292  else
1293  if(!strncmp(h0->head.obsmode, "LINEBSP", 7))
1294  {
1295  st_report("Processing Line BSP, Scan %.2f", fscan);
1297  }
1298  else
1299  if(!strncmp(h0->head.obsmode, "LINEPS", 6))
1300  {
1301  st_report("Processing Line PS, Scan %.2f", fscan);
1303  }
1304  else
1305  if(!strncmp(h0->head.obsmode, "LINEFS", 6))
1306  {
1307  st_report("Processing Line FS, Scan %.2f", fscan);
1309  }
1310  else
1311  if(!strncmp(h0->head.obsmode, "LINEPCAL", 8))
1312  {
1313  st_report("Processing Line PCAL, Scan %.2f", fscan);
1315  }
1316  else
1317  if(!strncmp(h0->head.obsmode, "LINETPON", 8))
1318  {
1319  st_report("Processing Line TPON, Scan %.2f", fscan);
1321  }
1322  else
1323  if(!strncmp(h0->head.obsmode, "LINETPMF", 8))
1324  {
1325  st_report("Processing Line TPMF, Scan %.2f", fscan);
1327  }
1328  else
1329  {
1330  st_fail("Unknown Observing Mode %8.8s", h0->head.obsmode);
1331  }
1332  }
1333  else
1334  if(env->mode == MODE_OTF && !strncmp(h0->head.obsmode, "LINE", 4))
1335  {
1336  if(!strncmp(h0->head.obsmode, "LINEPCAL", 8))
1337  {
1338  st_report("Processing Line PCAL, Scan %.2f", fscan);
1340  }
1341  else
1342  if(!strncmp(h0->head.obsmode, "LINETPMF", 8))
1343  {
1344  st_report("Processing Line TPMF, Scan %.2f", fscan);
1346  }
1347  else
1348  if(!strncmp(h0->head.obsmode, "LINEOTF ", 8))
1349  {
1350  st_report("Processing Line OTF, Scan %.2f", fscan);
1352  }
1353  }
1354 
1355  return(0);
1356 }
1357 
1358 
1359 
1360 int doCal(d)
1361 double d;
1362 {
1363  int ret;
1364  double extra = 0.0, s;
1365  char tbuf[256];
1366 
1367  if(!strlen(env->gfilename))
1368  {
1369  st_fail("No gainsfile defined");
1370 
1371  return(1);
1372  }
1373 
1374  /* Go find the last scan in the gains file */
1375  ret = read_scan(-1.0, env->gfilename, h0->yplot1, &h0->head, 0);
1376 
1377  if(ret == -1)
1378  {
1379  st_fail("No gain scans found in %s", env->gfilename);
1380 
1381  return(0);
1382  }
1383 
1384  if(ret > 0)
1385  {
1386  if(isSet(PF_V_FLAG))
1387  {
1388  extra = 0.20;
1389  s = (double)ret+d+extra;
1390 
1391  st_report("Fetching Vane Scan: %f", s);
1392  }
1393  else
1394  if(isSet(PF_S_FLAG))
1395  {
1396  extra = 0.40;
1397  s = (double)ret+d+extra;
1398 
1399  st_report("Fetching Sky Scan: %f", s);
1400  }
1401  else
1402  if(isSet(PF_C_FLAG))
1403  {
1404  extra = 0.60;
1405  s = (double)ret+d+extra;
1406 
1407  st_report("Fetching Cold Scan: %f", s);
1408  }
1409  else
1410  {
1411  extra = 0.0;
1412  s = (double)ret+d+extra;
1413 
1414  st_report("Fetching Gain Scan: %f", s);
1415  }
1416 
1417  sprintf(tbuf, "gget %.2f; show", s);
1418  st_report(tbuf);
1419 
1420  parseCmd(tbuf);
1421  }
1422  else
1423  {
1424  st_fail("No gain scan found");
1425 
1426  return(1);
1427  }
1428 
1429  return(0);
1430 }
1431 
1432 
1433 int doCal1()
1434 {
1435  return(doCal(0.01));
1436 }
1437 
1438 int doCal11()
1439 {
1440  return(doCal(0.11));
1441 }
1442 
1443 int doCal2()
1444 {
1445  return(doCal(0.02));
1446 }
1447 
1448 int doCal12()
1449 {
1450  return(doCal(0.12));
1451 }
1452 
1453 int doCal3()
1454 {
1455  return(doCal(0.03));
1456 }
1457 
1458 int doCal4()
1459 {
1460  return(doCal(0.04));
1461 }
1462 
1463 
1464 
1465 int doQuick(d)
1466 double d;
1467 {
1468  int i;
1469  double last_scan = 0.0;
1470  char tbuf[256];
1471  struct HEADER *p;
1472 
1473  p = &sa[0];
1474 
1475  /* find the last scan */
1476  for(i=0;i<env->numofscans;i++,p++)
1477  {
1478  if(isSet(PF_A_FLAG))
1479  {
1480  last_scan = round(p->scan);
1481  }
1482  else
1483  if(meetsCritiria(p, CHECK_ALL))
1484  {
1485  last_scan = round(p->scan);
1486  }
1487  }
1488 
1489  if(last_scan > 0.0)
1490  {
1491  sprintf(tbuf, "get %.2f; show", last_scan+d);
1492  st_report(tbuf);
1493 
1494  parseCmd(tbuf);
1495  }
1496  else
1497  {
1498  st_fail("No last scan found matching criteria");
1499  return(1);
1500  }
1501 
1502  return(0);
1503 }
1504 
1505 
1507 {
1508  return(doQuick(0.01));
1509 }
1510 
1512 {
1513  return(doQuick(0.11));
1514 }
1515 
1517 {
1518  return(doQuick(0.02));
1519 }
1520 
1522 {
1523  return(doQuick(0.12));
1524 }
1525 
1527 {
1528  return(doQuick(0.03));
1529 }
1530 
1532 {
1533  return(doQuick(0.04));
1534 }
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
#define LSB
double dewpt
Definition: header.h:95
int xx()
Definition: linuxpops.c:605
int getFeed()
int doCal3()
Definition: observe.c:1453
double scan
Definition: header.h:35
double curScan
Definition: env.h:178
#define PSPLOT
Definition: defines.h:30
double dfreq
Definition: env.h:183
int showC24()
Definition: observe.c:648
#define NS_FOCALIZE
Definition: observing_par.h:47
int showC12()
Definition: observe.c:508
int tellWeather()
Definition: observe.c:1142
char * strcmprs(char *str)
#define MODE_OTF
Definition: defines.h:88
int _h0()
Definition: image.c:93
int loopdelay2
Definition: env.h:68
int doQshow()
Definition: line.c:1396
double noint
Definition: header.h:211
int showTable()
Definition: observe.c:804
double datalen
Definition: header.h:34
double utdate
Definition: header.h:61
Definition: parse.h:8
int loopdelay1
Definition: env.h:67
double noxpts
Definition: header.h:106
int reviewIgnored()
Definition: ignore.c:264
#define CHECK_SCANS
Definition: defines.h:60
int lp_fcmp(double first, double second, double delta)
Definition: linuxpops.c:2768
char source[SRCLEN+1]
Definition: dataserv.c:52
double mmh2o
Definition: header.h:96
int chgres(float *told, int nchan, float oldres, float newres)
Definition: chngres.c:106
int cont_save_data(float *data, struct HEADER *h)
Definition: cont.c:2519
int display_optical_table(float *data, struct HEADER *h)
Definition: optical.c:324
int accumSelected()
Definition: cont.c:611
int read_scan()
#define MODE_CONT
Definition: defines.h:86
int line_showTable()
Definition: line.c:997
int doQuick1()
Definition: observe.c:1506
FILE * fp
Definition: linuxpops.c:70
int feed
Definition: env.h:55
Definition: header.h:13
int isInterrupt()
Definition: interrupt.c:152
int showC34()
Definition: observe.c:555
char gfilename[256]
Definition: env.h:10
double tcal
Definition: header.h:202
int incrementRejSb(void)
Definition: reject.c:138
int doQuick4()
Definition: observe.c:1531
double newres
Definition: env.h:230
struct HEADER * sa
Definition: linuxpops.c:72
int setFlag(int flag, int state)
Definition: parse.c:685
int issmt
Definition: env.h:63
double openpar[10]
Definition: header.h:155
int showC4()
Definition: observe.c:408
int line_save_data(struct LP_IMAGE_INFO *h)
Definition: line.c:2003
int doCal1()
Definition: observe.c:1433
int getScan(int verbose)
Definition: io.c:812
int pReview()
Definition: observe.c:851
double date
Definition: env.h:182
double restFreq(struct HEADER *h)
Definition: linuxpops.c:2837
int cont_display_optical(struct LP_IMAGE_INFO *image, int plot)
Definition: optical.c:286
int _h2()
Definition: image.c:115
int doPshow()
Definition: line.c:1264
#define CHECK_DATE
Definition: defines.h:61
int clearInterrupt()
Definition: interrupt.c:144
int line_display_spectra(struct LP_IMAGE_INFO *image, int plot)
Definition: line.c:743
int ignoreScans()
Definition: ignore.c:106
int notSet(int flag)
Definition: parse.c:669
int strictsb
Definition: env.h:139
int showPhases()
Definition: observe.c:695
int getYesNoQuit()
struct ENVIRONMENT * env
Definition: linuxpops.c:71
int setFeed(double want)
Definition: observe.c:264
int doCal4()
Definition: observe.c:1458
double pressure
Definition: header.h:92
int showData()
Definition: observe.c:709
char source[64]
Definition: env.h:11
int cont_display_data(float *data, struct HEADER *h)
Definition: cont.c:2599
int check_source
Definition: env.h:44
double humidity
Definition: header.h:93
int isSet(int flag)
Definition: parse.c:646
struct HEADER head
Definition: image.h:104
int showC13()
Definition: observe.c:601
int doQuick3()
Definition: observe.c:1526
int incrementRejDates(void)
Definition: reject.c:193
int doCal11()
Definition: observe.c:1438
int showCb()
Definition: observe.c:448
#define EW_FOCALIZE
Definition: observing_par.h:53
#define FOCALIZE
Definition: observing_par.h:46
void st_warn()
char obsmode[8]
Definition: header.h:41
double bkres
Definition: env.h:170
int cont_display_mapscan(struct LP_IMAGE_INFO *image, int plot)
Definition: cont.c:1924
void st_fail()
int cont_display_any_focus(struct LP_IMAGE_INFO *image, int plot, int type)
Definition: cont.c:2327
double ref_correct
Definition: header.h:179
int doQuick2()
Definition: observe.c:1516
int meetsCritiria(struct HEADER *p, int mask)
Definition: observe.c:90
int changeRes()
Definition: observe.c:750
int checkMatch()
Definition: observe.c:251
int feed
Definition: stats.c:66
int saveData()
Definition: observe.c:729
int check_feed
Definition: env.h:41
int doCal12()
Definition: observe.c:1448
double stsys
Definition: header.h:203
int isScanIgnored(double scan)
Definition: ignore.c:181
int doQuick(double d)
Definition: observe.c:1465
#define CHECK_SOURCE
Definition: defines.h:59
double tip_humid
Definition: header.h:176
int doSum(void)
Definition: sum.c:61
int mode
Definition: env.h:75
#define MODE_SPEC
Definition: defines.h:87
int accumreset
Definition: env.h:18
double refpt
Definition: header.h:207
#define MODE_NOT_SET
Definition: defines.h:84
void st_report()
double el
Definition: header.h:83
int reviewStack()
Definition: observe.c:947
#define BKMATCH_FEED
Definition: defines.h:121
int showC3()
Definition: observe.c:368
double deltax
Definition: header.h:209
double if_feed
Definition: env.h:208
int showScan()
Definition: observe.c:1205
int numofscans
Definition: env.h:85
int showC1()
Definition: observe.c:287
#define CHECK_BKEND
Definition: defines.h:62
#define USB
double bscan
Definition: env.h:173
int verifyParams()
Definition: observe.c:63
double freq
Definition: env.h:197
int cont_display_sptip(struct LP_IMAGE_INFO *image, int plot)
Definition: sptip.c:391
int doAutoScale()
Definition: linuxpops.c:2788
int bkmatch
Definition: env.h:32
void subArgs(int wt, const char *fmt,...)
Definition: parse.c:430
int incrementRejSource(void)
Definition: reject.c:177
#define CHECK_ALL
Definition: defines.h:64
int incrementRejScans(void)
Definition: reject.c:185
int cont_display_five(struct LP_IMAGE_INFO *image, int plot)
Definition: cont.c:2113
double tamb
Definition: header.h:91
double fscan
Definition: header.h:224
void st_print()
int showC2()
Definition: observe.c:327
int doQuick12()
Definition: observe.c:1521
double escan
Definition: env.h:186
int check_date
Definition: env.h:40
int doCal2()
Definition: observe.c:1443
#define VERBOSE_CRITIRIA
Definition: defines.h:68
int doCal(double d)
Definition: observe.c:1360
int incrementRejFreq(void)
Definition: reject.c:146
int backendMatch(struct HEADER *h)
Definition: linuxpops.c:1033
int doQuick11()
Definition: observe.c:1511
int cont_show_phases(float *data, struct HEADER *h, int plot)
Definition: cont.c:1747
char object[16]
Definition: header.h:40
double restfreq
Definition: header.h:198
int parseCmd(char *buf)
Definition: parse.c:2090
int incrementRejBackend(void)
Definition: reject.c:201
double freqres
Definition: header.h:199
int mshow
Definition: env.h:76
double tauh2o
Definition: header.h:213
int _h1()
Definition: image.c:104
int bmark
Definition: env.h:34
#define CHECK_FREQ
Definition: defines.h:63
double ut
Definition: header.h:62
int qReview()
Definition: observe.c:899
char filename[256]
Definition: env.h:9
int doingOTF
Definition: otf.c:64
int to_dataserv(char *buf)
Definition: otf.c:82
int verboseLevel
Definition: linuxpops.c:80