Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
image.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 
62 
63 struct LP_IMAGE_INFO H0; /* Place where all data is read into */
73 
74 struct LP_IMAGE_INFO *h0 = &H0;
75 int currentImage = 0;
76 
77 #define MAX_SAVE_IMAGE_ARRAYS 10
78 
79 
80 struct SAVE_IMAGE {
81  char magic[16]; /* Ascii keyword */
82  int ssize; /* Total size of this struct */
83  int hsize; /* Size of individual IMAGE structs */
85 };
86 
88 
89 #define SAVE_IMAGE_PREAMBLE (sizeof(save_image.magic) + sizeof(save_image.ssize) + sizeof(save_image.hsize))
90 
91 
92 /* Internal convienence function */
93 int _h0()
94 {
95  h0 = &H0;
96  currentImage = 0;
97  env->currentImage = 0;
98 
99  setPrompt();
100 
101  return(0);
102 }
103 
104 int _h1()
105 {
106  h0 = &H1;
107  currentImage = 1;
108  env->currentImage = 1;
109 
110  setPrompt();
111 
112  return(0);
113 }
114 
115 int _h2()
116 {
117  h0 = &H2;
118  currentImage = 2;
119  env->currentImage = 2;
120 
121  setPrompt();
122 
123  return(0);
124 }
125 
126 int _h3()
127 {
128  h0 = &H3;
129  currentImage = 3;
130  env->currentImage = 3;
131 
132  setPrompt();
133 
134  return(0);
135 }
136 
137 int _h4()
138 {
139  h0 = &H4;
140  currentImage = 4;
141  env->currentImage = 4;
142 
143  setPrompt();
144 
145  return(0);
146 }
147 
148 int _h5()
149 {
150  h0 = &H5;
151  currentImage = 5;
152  env->currentImage = 5;
153 
154  setPrompt();
155 
156  return(0);
157 }
158 
159 int _h6()
160 {
161  h0 = &H6;
162  currentImage = 6;
163  env->currentImage = 6;
164 
165  setPrompt();
166 
167  return(0);
168 }
169 
170 int _h7()
171 {
172  h0 = &H7;
173  currentImage = 7;
174  env->currentImage = 7;
175 
176  setPrompt();
177 
178  return(0);
179 }
180 
181 int _h8()
182 {
183  h0 = &H8;
184  currentImage = 8;
185  env->currentImage = 8;
186 
187  setPrompt();
188 
189  return(0);
190 }
191 
192 int _h9()
193 {
194  h0 = &H9;
195  currentImage = 9;
196  env->currentImage = 9;
197 
198  setPrompt();
199 
200  return(0);
201 }
202 
204 {
205  int i;
206 
207  i = atoi(args->currentCmd+1);
208 
209  /* Set pointing and make sure the 'name' gets fixed */
210  switch(i)
211  {
212  case 0: _h0(); strcpy(h0->name, "H0"); break;
213  case 1: _h1(); strcpy(h0->name, "H1"); break;
214  case 2: _h2(); strcpy(h0->name, "H2"); break;
215  case 3: _h3(); strcpy(h0->name, "H3"); break;
216  case 4: _h4(); strcpy(h0->name, "H4"); break;
217  case 5: _h5(); strcpy(h0->name, "H5"); break;
218  case 6: _h6(); strcpy(h0->name, "H6"); break;
219  case 7: _h7(); strcpy(h0->name, "H7"); break;
220  case 8: _h8(); strcpy(h0->name, "H8"); break;
221  case 9: _h9(); strcpy(h0->name, "H9"); break;
222 
223  default: st_fail("Unknown H value %d", i); return(1); break;
224  }
225 
226  setPrompt();
227  st_report("Setting Holder to %s", h0->name);
228 
229  return(0);
230 }
231 
232 
234 int i;
235 {
236  struct LP_IMAGE_INFO *image=NULL;
237 
238  switch(i)
239  {
240  case 0: image = &H0; break;
241  case 1: image = &H1; break;
242  case 2: image = &H2; break;
243  case 3: image = &H3; break;
244  case 4: image = &H4; break;
245  case 5: image = &H5; break;
246  case 6: image = &H6; break;
247  case 7: image = &H7; break;
248  case 8: image = &H8; break;
249  case 9: image = &H9; break;
250  }
251 
252  return(image);
253 }
254 
255 
256 int parseHarg(arg)
257 char *arg;
258 {
259  int val;
260 
261  if(!strncasecmp(arg, "h", 1)) /* did the user pass 'h1' instead of simply '1' */
262  {
263  val = atoi(arg+1);
264  }
265  else
266  {
267  val = atoi(arg); /* plain '1' */
268  }
269 
270  return(val);
271 }
272 
273 
274 
276 {
277  int f, t;
278  char tmp[80];
279  struct LP_IMAGE_INFO *from, *to;
280 
281  if(strlen(args->secondArg) && strlen(args->thirdArg))
282  {
283  f = parseHarg(args->secondArg);
284  t = parseHarg(args->thirdArg);
285 
286  if((f >= 0 && f < MAX_IMAGES) && (t >=0 && t < MAX_IMAGES))
287  {
288  if(f == t)
289  {
290  st_fail("copyImage(): From and To must be different");
291  printH_FlagHelp("image");
292 
293  return(1);
294  }
295 
296  from = findImage(f);
297  to = findImage(t);
298 
299  if(from && to)
300  {
301  st_report("Copying %d to %d; %s to %s", f, t, from->name, to->name);
302 
303  strcpy(tmp, to->name); /* Preserve the name */
304  bcopy((char *)from, (char *)to, sizeof(struct LP_IMAGE_INFO));
305  strcpy(to->name, tmp);
306  }
307  else
308  {
309  st_fail("copyImage(): Unable to locate from or to headers");
310  printH_FlagHelp("image");
311 
312  return(1);
313  }
314  }
315  }
316  else
317  {
318  st_fail("Missing args for image copy");
319 
320  printH_FlagHelp("image");
321 
322  return(1);
323  }
324 
325  return(0);
326 }
327 
328 
329 int _copyImage(i1, i2)
330 struct LP_IMAGE_INFO *i1, *i2;
331 {
332  char tmp[80];
333 
334  st_report("Copying %s to %s", i1->name, i2->name);
335 
336  strcpy(tmp, i2->name); /* Preserve the name */
337  bcopy((char *)i1, (char *)i2, sizeof(struct LP_IMAGE_INFO));
338  strcpy(i2->name, tmp);
339 
340  return(0);
341 }
342 
343 
345 {
346  int i;
347 
348  st_print("struct LP_IMAGE_INFO:\n");
349  st_print("{\n");
350  st_print("\tmagic: %s\n", h0->magic);
351  st_print("\tname: %s\n", h0->name);
352  st_print("\tmode: %d\n", h0->mode);
353  st_print("\tpeakChan: %d\n", h0->peakChan);
354  st_print("\tplotwin: %d\n", h0->plotwin);
355  st_print("\tnarray: %d\n", h0->narray);
356  st_print("\tnsize: %d\n", h0->nsize);
357  st_print("\thline: %d\n", h0->satActive);
358  st_print("\tdatamin: %f\n", h0->datamin);
359  st_print("\tdatamax: %f\n", h0->datamax);
360 
361 
362  st_print("\n");
363 
364  st_print("\tstruct ACCUM_INFO ainfo:\n");
365  st_print("\t{\n");
366  st_print("\t\tmagic: %s\n", h0->ainfo.magic);
367  st_print("\t\tscanct: %d\n", h0->ainfo.scanct);
368  st_print("\t\tbscan: %.2f\n", h0->ainfo.bscan);
369  st_print("\t\tescan: %.2f\n", h0->ainfo.escan);
370  st_print("\t\twt: %f\n", h0->ainfo.wt);
371  st_print("\t}\n");
372 
373  st_print("\n");
374 
375  st_print("\tstruct BASELINE_INFO binfo:\n");
376  st_print("\t{\n");
377  st_print("\t\tmagic: %s\n", h0->binfo.magic);
378  st_print("\t\tdoBaseLine: %d\n", h0->binfo.doBaseLine);
379 
380  for(i=0;i<MAX_BASELINES;i++)
381  {
382  if(i==0)
383  {
384  st_print("\t\tBaselines: [%d] %4d %4d\n",
385  i+1, h0->binfo.baselines[i][0], h0->binfo.baselines[i][1]);
386  }
387  else
388  {
389  st_print("\t\t [%d] %4d %4d\n",
390  i+1, h0->binfo.baselines[i][0], h0->binfo.baselines[i][1]);
391  }
392  }
393 
394  st_print("\t\ta: %f\n", h0->binfo.a);
395  st_print("\t\tb: %f\n", h0->binfo.b);
396  st_print("\t\trms: %f\n", h0->binfo.rms);
397  st_print("\t}\n");
398 
399  st_print("\n");
400 
401  st_print("\tstruct PLOT_INFO pinfo:\n");
402  st_print("\t{\n");
403  st_print("\t\tmagic: %s\n", h0->pinfo.magic);
404  st_print("\t\tmarkers: %d\n", h0->pinfo.markers);
405  st_print("\t\tplotStyle: %d\n", h0->pinfo.plotStyle);
406  st_print("\t\tx1mode: %d\n", h0->pinfo.x1mode);
407  st_print("\t\tx2mode: %d\n", h0->pinfo.x2mode);
408  st_print("\t\tgridMode: %d\n", h0->pinfo.gridMode);
409  st_print("\t\tzline: %d\n", h0->pinfo.zline);
410  st_print("\t\tbadchshow: %d\n", h0->pinfo.badchshow);
411  st_print("\t\tbmark: %d\n", h0->pinfo.bmark);
412  st_print("\t\tmshow: %d\n", h0->pinfo.bshow);
413  st_print("\t\tbdrop: %d\n", h0->pinfo.bdrop);
414  st_print("\t\tedrop: %d\n", h0->pinfo.edrop);
415  st_print("\t\tdobadch: %d\n", h0->pinfo.dobadch);
416  st_print("\t\tyscale: %d\n", h0->pinfo.yscale);
417  st_print("\t\tplot_noint: %d\n", h0->pinfo.plot_noint);
418  st_print("\t\tbplot: %d\n", h0->pinfo.bplot);
419  st_print("\t\tnspline: %d\n", h0->pinfo.nspline);
420  st_print("\t\typlotmode: %d\n", h0->pinfo.yplotmode);
421  st_print("\t\tylower: %f\n", h0->pinfo.ylower);
422  st_print("\t\tyupper: %f\n", h0->pinfo.yupper);
423  st_print("\t\tplotmin: %f\n", h0->pinfo.plotmin);
424  st_print("\t\tplotmax: %f\n", h0->pinfo.plotmax);
425  st_print("\t}\n");
426 
427  st_print("\n");
428 
429 
430  for(i=0;i<MAX_BAD_CHANS;i++)
431  {
432  if(h0->badChans[i] > 0.0)
433  {
434  st_print("\tbadChans[%4d] %4d\n", i, h0->badChans[i]);
435  }
436  }
437 
438  st_print("}\n");
439 
440 
441  return(0);
442 }
443 
444 
445 
447 {
448  char execBuf[256];
449 
450  sprintf(execBuf, "image /d %s %s", args->secondArg, args->thirdArg);
451 
452  parseCmd(execBuf);
453 
454  return(0);
455 }
456 
457 
458 int doImage()
459 {
460  if(isSet(PF_C_FLAG))
461  {
462  copyImage();
463 
464  return(0);
465  }
466 
467  if(isSet(PF_L_FLAG))
468  {
469  imageSummary();
470 
471  return(0);
472  }
473 
474  if(isSet(PF_P_FLAG))
475  {
477 
478  return(0);
479  }
480 
481  if(isSet(PF_S_FLAG))
482  {
483  doSum();
484 
485  return(0);
486  }
487 
488  if(isSet(PF_D_FLAG))
489  {
490  doImageDiff();
491 
492  doAutoScale();
493 
494  xx();
495 
496  return(0);
497  }
498 
499  if(isSet(PF_Y_FLAG))
500  {
501  doImageDiv();
502 
503  doAutoScale();
504 
505  xx();
506 
507  return(0);
508  }
509 
510  if(isSet(PF_T_FLAG))
511  {
512  setImageTitle();
513 
514  return(0);
515  }
516 
517  if(isSet(PF_Z_FLAG))
518  {
519  if(isSet(PF_A_FLAG)) /* Zero them all ?? */
520  {
521  clearAllImages();
522  }
523  else
524  {
525  zeroImage();
526  }
527 
528  return(0);
529  }
530 
531  printH_FlagHelp("image");
532 
533  return(0);
534 }
535 
536 
537 
539 {
540  int i;
541  char source[32], timeStr[256];
542  struct LP_IMAGE_INFO *p;
543 
544  st_print("\nHx Freq Source Scan Bscan Escan Time Resolution Channels Narrays Tsys Tcal Shifted Title\n");
545  st_print( " GHz Cnt HH:MM:SS MHz \n\n");
546 
547  for(i=0;i<MAX_IMAGES;i++)
548  {
549  p = findImage(i);
550 
551  strncpy(source, p->head.object, 16);
552  source[16] = '\0';
553  strcmprs(source);
554 
555  sexagesimal(p->head.inttime / 3600.0, timeStr, DD_MM_SS);
556 
557  if(p->shifted < 0)
558  {
559  setColor(RED);
560  }
561  else
562  if(p->shifted > 0)
563  {
564  setColor(BLUE);
565  }
566 
567  st_print("%s %10.6f %16.16s %3d %8.2f %8.2f %s %7.3f %5d %d %6.1f %6.1f %4d %s\n",
568  p->name,
569  p->head.restfreq / 1000.0, source,
570  p->ainfo.scanct, p->ainfo.bscan, p->ainfo.escan,
571  timeStr,
572  p->head.freqres, (int)p->head.noint,
573  p->narray,
574  p->head.stsys, p->head.tcal, p->shifted, p->title);
575 
576  if(p->shifted)
577  {
578  setColor(BLACK);
579  }
580  }
581 
582  return(0);
583 }
584 
585 
587 {
588  int i;
589  char tbuf[512];
590 
591  if(args->ntokens > 1)
592  {
593  h0->title[0] = '\0';
594 
595  for(i=1;i<args->ntokens;i++)
596  {
597  sprintf(tbuf, "%s ", args->tok[i]);
598  strcat(h0->title, tbuf);
599  }
600 
601  st_report("Setting %s Image Holder Title to: %s", h0->name, h0->title);
602  }
603  else
604  {
605  printH_FlagHelp("setimagetitle");
606 
607  return(1);
608  }
609 
610  return(0);
611 }
612 
613 
614 
615 
616 int hzero(image)
617 struct LP_IMAGE_INFO *image;
618 {
619  char tmp[80];
620 
621  strcpy(tmp, image->name); /* Preserve the name */
622  bzero((char *)image, sizeof(struct LP_IMAGE_INFO));
623  strcpy(image->name, tmp);
624 
625  return(0);
626 }
627 
628 
630 {
631  int i;
632 
633  for(i=0;i<MAX_IMAGES;i++)
634  {
635  switch(i)
636  {
637  case 0: _h0(); break;
638  case 1: _h1(); break;
639  case 2: _h2(); break;
640  case 3: _h3(); break;
641  case 4: _h4(); break;
642  case 5: _h5(); break;
643  case 6: _h6(); break;
644  case 7: _h7(); break;
645  case 8: _h8(); break;
646  case 9: _h9(); break;
647  }
648 
649  hzero(h0);
650  }
651 
652  _h0();
653 
654  return(0);
655 }
656 
657 
658 int hLoad()
659 {
660  int fd, ret;
661 
662  if(!strlen(args->secondArg))
663  {
664  st_fail("Missing arg for hload");
665  return(1);
666  }
667 
668  if((fd = open(args->secondArg, O_RDONLY)) < 0)
669  {
670  st_fail("hload(): Unable to open file %s", args->secondArg);
671  return(1);
672  }
673 
674  ret = read(fd, &save_image, SAVE_IMAGE_PREAMBLE);
675 
676  if(ret != SAVE_IMAGE_PREAMBLE)
677  {
678  st_fail("hload(): read returned %d; not %d", ret, SAVE_IMAGE_PREAMBLE);
679  close(fd);
680  return(1);
681  }
682 
683  if(strncmp(save_image.magic, "SAVE_IMAGE", 10))
684  {
685  st_fail("hload(): file has wrong magic work %s; not %s", save_image.magic, "SAVE_IMAGE");
686  close(fd);
687  return(1);
688  }
689 
690  if(save_image.ssize != sizeof(save_image))
691  {
692  st_fail("hload(): file wrong size %d; not %d", save_image.ssize, sizeof(save_image));
693  close(fd);
694  return(1);
695  }
696 
697  if(save_image.hsize != sizeof(struct LP_IMAGE_INFO))
698  {
699  st_fail("hload(): image elements wrong size %d; not %d", save_image.hsize, sizeof(struct LP_IMAGE_INFO));
700  close(fd);
701  return(1);
702  }
703 
704  /* Rewind the file */
705  lseek(fd, 0L, SEEK_SET);
706 
707  ret = read(fd, &save_image, sizeof(save_image));
708 
709  close(fd);
710 
711  if(ret != sizeof(save_image))
712  {
713  st_fail("hload(): struct read returned %d; not %d", ret, sizeof(save_image));
714  return(1);
715  }
716 
717  st_report("hload(): Read in %d bytes from %s", ret, args->secondArg);
718 
719  bcopy((char *)&save_image.images[0], (char *)&H0, sizeof(struct LP_IMAGE_INFO));
720  bcopy((char *)&save_image.images[1], (char *)&H1, sizeof(struct LP_IMAGE_INFO));
721  bcopy((char *)&save_image.images[2], (char *)&H2, sizeof(struct LP_IMAGE_INFO));
722  bcopy((char *)&save_image.images[3], (char *)&H3, sizeof(struct LP_IMAGE_INFO));
723  bcopy((char *)&save_image.images[4], (char *)&H4, sizeof(struct LP_IMAGE_INFO));
724  bcopy((char *)&save_image.images[5], (char *)&H5, sizeof(struct LP_IMAGE_INFO));
725  bcopy((char *)&save_image.images[6], (char *)&H6, sizeof(struct LP_IMAGE_INFO));
726  bcopy((char *)&save_image.images[7], (char *)&H7, sizeof(struct LP_IMAGE_INFO));
727  bcopy((char *)&save_image.images[8], (char *)&H8, sizeof(struct LP_IMAGE_INFO));
728  bcopy((char *)&save_image.images[9], (char *)&H9, sizeof(struct LP_IMAGE_INFO));
729 
730  imageSummary();
731 
732  return(0);
733 }
734 
735 
736 int hSave()
737 {
738  int fd, ret;
739 
740  if(!strlen(args->secondArg))
741  {
742  st_fail("Missing arg for hsave");
743  return(1);
744  }
745 
746  strcpy(save_image.magic, "SAVE_IMAGE");
747  save_image.ssize = sizeof(save_image);
748  save_image.hsize = sizeof(struct LP_IMAGE_INFO);
749 
750  bcopy((char *)&H0, (char *)&save_image.images[0], sizeof(struct LP_IMAGE_INFO));
751  bcopy((char *)&H1, (char *)&save_image.images[1], sizeof(struct LP_IMAGE_INFO));
752  bcopy((char *)&H2, (char *)&save_image.images[2], sizeof(struct LP_IMAGE_INFO));
753  bcopy((char *)&H3, (char *)&save_image.images[3], sizeof(struct LP_IMAGE_INFO));
754  bcopy((char *)&H4, (char *)&save_image.images[4], sizeof(struct LP_IMAGE_INFO));
755  bcopy((char *)&H5, (char *)&save_image.images[5], sizeof(struct LP_IMAGE_INFO));
756  bcopy((char *)&H6, (char *)&save_image.images[6], sizeof(struct LP_IMAGE_INFO));
757  bcopy((char *)&H7, (char *)&save_image.images[7], sizeof(struct LP_IMAGE_INFO));
758  bcopy((char *)&H8, (char *)&save_image.images[8], sizeof(struct LP_IMAGE_INFO));
759  bcopy((char *)&H9, (char *)&save_image.images[9], sizeof(struct LP_IMAGE_INFO));
760 
761  if((fd = open(args->secondArg, O_CREAT | O_RDWR, 0664)) < 0)
762  {
763  st_fail("hsave(): Unable to open file %s", args->secondArg);
764  return(1);
765  }
766 
767  ret = write(fd, &save_image, sizeof(save_image));
768 
769  close(fd);
770 
771  if(ret != sizeof(save_image))
772  {
773  st_fail("hsave(): write returned %d; not %d", ret, sizeof(save_image));
774  return(1);
775  }
776 
777  st_report("hsave(): Wrote %d bytes to %s", ret, args->secondArg);
778 
779  return(0);
780 }
781 
782 
783 /* Copy in any environ variable required to plot this */
784 int copyEnv2Image(image)
785 struct LP_IMAGE_INFO *image;
786 {
787  image->mode = env->mode;
788 
789  /* Baseline info */
790  image->binfo.doBaseLine = env->dobaseline;
791  bcopy((char *)&env->baselines[0], (char *)&image->binfo.baselines, sizeof(image->binfo.baselines));
792 
793  image->peakChan = env->peakChan;
794 
795  /* Plot info */
796  image->pinfo.plotStyle = env->plotstyle;
797  image->pinfo.x1mode = env->x1mode;
798  image->pinfo.x2mode = env->x2mode;
799  image->pinfo.gridMode = env->gridmode;
800  image->pinfo.markers = env->markers;
801  image->pinfo.zline = env->zline;
802  image->pinfo.bmark = env->bmark;
803  image->pinfo.bshow = env->bshow;
804  image->pinfo.mshow = env->mshow;
805  image->pinfo.bdrop = env->bdrop;
806  image->pinfo.edrop = env->edrop;
807  image->pinfo.yupper = env->yupper;
808  image->pinfo.ylower = env->ylower;
809  image->pinfo.yscale = env->yscale;
810  image->pinfo.dobadch = env->dobadchan;
811  image->pinfo.badchshow = env->badchanshow;
812 
813  /* Bad channel info */
814  bcopy((char *)&env->badchans, (char *)&image->badChans, sizeof(image->badChans));
815 
816  return(0);
817 }
818 
819 
821 struct LP_IMAGE_INFO *image;
822 int mode;
823 {
824  int i;
825 
827  {
828  st_report("Sending plot to XGraphic");
829  }
830 
831  strcpy(image->magic, "LP_IMAGE_INFO");
832 
833  image->mode = mode;
834  image->plotwin = env->plotwin;
835  image->satActive = env->usesat;
836  image->issmt = env->issmt;
837  image->xdelay = env->xdelay;
838 
839  image->pinfo.paperw = (float)env->paperw;
840  image->pinfo.paperh = (float)env->paperh;
841 
842  sock_write(xgraphic, (char *)image, SHORT_IMAGE_SIZE);
843 
844  for(i=0;i<image->narray;i++)
845  {
846  switch(i)
847  {
848  case 0:
849  sock_write(xgraphic, (char *)image->yplot1, image->nsize);
850  break;
851 
852  case 1:
853  sock_write(xgraphic, (char *)image->yplot2, image->nsize);
854  break;
855 
856  case 2:
857  sock_write(xgraphic, (char *)image->yplot3, image->nsize);
858  break;
859 
860  case 3:
861  sock_write(xgraphic, (char *)image->yplot4, image->nsize);
862  break;
863  }
864  }
865 
866  if(image->pinfo.bplot)
867  {
868  sock_write(xgraphic, (char *)image->bplot, image->nsize);
869  }
870 
872  {
874  }
875 
876  return(0);
877 }
878 
879 
881 {
882  int i;
883  char tmp[256];
884  struct LP_IMAGE_INFO *img;
885 
886  if(strlen(args->secondArg))
887  {
888  i = parseHarg(args->secondArg);
889 
890  if((i >= 0 && i < MAX_IMAGES))
891  {
892  img = findImage(i);
893 
894  strcpy(tmp, img->name); /* Preserve the name */
895  bzero((char *)img, sizeof(struct LP_IMAGE_INFO));
896  strcpy(img->name, tmp);
897  }
898  else
899  {
900  st_fail("zeroImage(): Arg %d out of range: 0 - %d", MAX_IMAGES);
901  }
902  }
903  else
904  {
905  st_fail("Missing arg for zeroImage()");
906  }
907 
908  return(0);
909 }
struct SOCK * xgraphic
Definition: linuxpops.c:75
struct LP_IMAGE_INFO * h0
Definition: image.c:74
int plotwin
Definition: image.h:78
struct LP_IMAGE_INFO accum_image
Definition: image.c:61
int dobadch
Definition: image.h:32
int xx()
Definition: linuxpops.c:605
#define MAX_BAD_CHANS
Definition: defines.h:43
int plotStyle
Definition: image.h:21
int zline
Definition: image.h:25
float wt
Definition: image.h:54
int hzero(struct LP_IMAGE_INFO *image)
Definition: image.c:616
struct LP_IMAGE_INFO H7
Definition: image.c:70
struct LP_IMAGE_INFO H1
Definition: image.c:64
int sock_write(struct SOCK *s, char *message, int l)
char * strcmprs(char *str)
int _copyImage(struct LP_IMAGE_INFO *i1, struct LP_IMAGE_INFO *i2)
Definition: image.c:329
int subtractImage()
Definition: image.c:446
int _h0()
Definition: image.c:93
int nspline
Definition: image.h:36
struct PARSE_STACK * args
Definition: parse.h:196
int edrop
Definition: env.h:52
int x1mode
Definition: env.h:145
char magic[32]
Definition: image.h:50
double noint
Definition: header.h:211
int _h4()
Definition: image.c:137
Definition: parse.h:8
float yupper
Definition: image.h:43
int bdrop
Definition: image.h:30
struct LP_IMAGE_INFO H2
Definition: image.c:65
struct LP_IMAGE_INFO H0
Definition: image.c:63
struct BASELINE_INFO binfo
Definition: image.h:101
char source[SRCLEN+1]
Definition: dataserv.c:52
int nsize
Definition: image.h:80
float escan
Definition: image.h:53
#define RED
Definition: colors.h:5
int gridmode
Definition: env.h:58
char name[32]
Definition: image.h:73
int hSave()
Definition: image.c:736
int printH_FlagHelp(char *cmd)
Definition: help.c:430
struct LP_IMAGE_INFO H5
Definition: image.c:68
int currentImage
Definition: env.h:45
struct LP_IMAGE_INFO images[MAX_SAVE_IMAGE_ARRAYS]
Definition: image.c:84
#define BLUE
Definition: colors.h:8
double tcal
Definition: header.h:202
int _h9()
Definition: image.c:192
int xdelay
Definition: env.h:144
int printImageHeader()
Definition: image.c:344
struct LP_IMAGE_INFO H9
Definition: image.c:72
char magic[32]
Definition: image.h:18
int _h5()
Definition: image.c:148
int markers
Definition: image.h:20
int edrop
Definition: image.h:31
int setPrompt()
Definition: linuxpops.c:1532
int issmt
Definition: env.h:63
int _h3()
Definition: image.c:126
int doImageDiff(void)
Definition: sum.c:188
float bscan
Definition: image.h:52
float datamin
Definition: image.h:95
int markers
Definition: env.h:72
struct PLOT_INFO pinfo
Definition: image.h:102
#define SAVE_IMAGE_PREAMBLE
Definition: image.c:89
int doBaseLine
Definition: image.h:8
int doImageDiv(void)
Definition: sum.c:293
int badchanshow
Definition: env.h:28
#define LAST_PLOT_OTF_CUT
Definition: defines.h:168
#define SHORT_IMAGE_SIZE
Definition: image.h:122
int setImageTitle()
Definition: image.c:586
int _h8()
Definition: image.c:181
int peakChan
Definition: env.h:126
char tok[MAX_TOKENS][MAX_TOKENS]
Definition: parse.h:176
#define MAX_BASELINES
Definition: defines.h:42
int _h2()
Definition: image.c:115
int badChans[MAX_BAD_CHANS]
Definition: image.h:107
int zeroImage()
Definition: image.c:880
int x1mode
Definition: image.h:22
int yplotmode
Definition: image.h:38
float rms
Definition: image.h:13
int sexagesimal(double dang, char *str, int prec)
struct SAVE_IMAGE save_image
Definition: image.c:87
struct ENVIRONMENT * env
Definition: linuxpops.c:71
int dobaseline
Definition: env.h:48
char * thirdArg
Definition: parse.h:182
int copyEnv2Image(struct LP_IMAGE_INFO *image)
Definition: image.c:784
int imageSummary()
Definition: image.c:538
int usesat
Definition: env.h:65
int isSet(int flag)
Definition: parse.c:646
struct HEADER head
Definition: image.h:104
int hLoad()
Definition: image.c:658
int x2mode
Definition: image.h:23
int bmark
Definition: image.h:27
int currentImage
Definition: image.c:75
char magic[16]
Definition: image.c:81
int satActive
Definition: image.h:81
int badchshow
Definition: image.h:26
double paperh
Definition: env.h:257
float plotmax
Definition: image.h:45
int hsize
Definition: image.c:83
void st_fail()
int plot_noint
Definition: image.h:34
int bshow
Definition: env.h:35
float datamax
Definition: image.h:98
double ylower
Definition: env.h:287
int badchans[MAX_BAD_CHANS]
Definition: env.h:29
int mode
Definition: image.h:76
struct ACCUM_INFO ainfo
Definition: image.h:100
#define DD_MM_SS
Definition: sex.h:15
int gridMode
Definition: image.h:24
char magic[32]
Definition: image.h:7
double stsys
Definition: header.h:203
float plotmin
Definition: image.h:44
int bplot
Definition: image.h:35
int dobadchan
Definition: env.h:47
int doSum(void)
Definition: sum.c:61
int mode
Definition: env.h:75
int plotwin
Definition: env.h:129
int yscale
Definition: env.h:149
int setColor(int c)
Definition: parse.c:2644
double paperw
Definition: env.h:256
float ylower
Definition: image.h:42
int parseHarg(char *arg)
Definition: image.c:256
int copyImage()
Definition: image.c:275
char magic[32]
Definition: image.h:72
void st_report()
int last_plot
Definition: env.c:93
int clearAllImages()
Definition: image.c:629
struct LP_IMAGE_INFO H6
Definition: image.c:69
int shifted
Definition: image.h:94
int bshow
Definition: image.h:28
struct LP_IMAGE_INFO H4
Definition: image.c:67
int doImage()
Definition: image.c:458
int peakChan
Definition: image.h:77
int bdrop
Definition: env.h:31
int baselines[MAX_BASELINES][2]
Definition: image.h:9
#define MAX_IMAGES
Definition: defines.h:34
double yupper
Definition: env.h:288
float a
Definition: image.h:11
char currentCmd[256]
Definition: parse.h:191
int _h6()
Definition: image.c:159
int doAutoScale()
Definition: linuxpops.c:2788
double inttime
Definition: header.h:210
#define BLACK
Definition: colors.h:4
int scanct
Definition: image.h:51
struct LP_IMAGE_INFO H3
Definition: image.c:66
#define MAX_SAVE_IMAGE_ARRAYS
Definition: image.c:77
int plotstyle
Definition: env.h:127
#define LAST_PLOT_SPEC_ACCUM
Definition: defines.h:156
int narray
Definition: image.h:79
int sendImageStruct(struct LP_IMAGE_INFO *image, int mode)
Definition: image.c:820
char * secondArg
Definition: parse.h:181
void st_print()
int yscale
Definition: image.h:33
int baselines[MAX_BASELINES][2]
Definition: env.h:30
int ntokens
Definition: parse.h:173
float b
Definition: image.h:12
int ssize
Definition: image.c:82
char title[256]
Definition: image.h:74
int zline
Definition: env.h:151
char object[16]
Definition: header.h:40
double restfreq
Definition: header.h:198
int parseCmd(char *buf)
Definition: parse.c:2090
int x2mode
Definition: env.h:146
#define VERBOSE_COMM
Definition: defines.h:69
double freqres
Definition: header.h:199
int mshow
Definition: env.h:76
int _h7()
Definition: image.c:170
int _h1()
Definition: image.c:104
int bmark
Definition: env.h:34
int setHeader()
Definition: image.c:203
struct LP_IMAGE_INFO H8
Definition: image.c:71
struct LP_IMAGE_INFO * findImage(int i)
Definition: image.c:233
int verboseLevel
Definition: linuxpops.c:80