Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
paxis.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 char peakResultsStr1[256];
62 char peakResultsStr2[256];
63 
64 
65 int doXRange()
66 {
67  int bd, ed;
68  struct LP_IMAGE_INFO *image = h0;
69 
70  _doCCur("Click Left Mouse Button on Left Edge of Desired Region");
71 
72  bd = (int)round(env->ccur);
73 
74  if(bd < 1)
75  {
76  bd = 1;
77  }
78 
79  _doCCur("Click Left Mouse Button on Right Edge of Desired Region");
80 
81  ed = (int)round(env->ccur);
82 
83  if(ed >= image->head.noint)
84  {
85  ed = image->head.noint -1;
86  }
87 
88  ed = image->head.noint - ed;
89 
90  st_report("Bdrop = %d, Edrop = %d", bd, ed);
91 
92  env->bdrop = bd;
93  env->edrop = ed;
94 
95  return(0);
96 }
97 
98 
103 int doYRange()
104 {
105  double ymin, ymax, tmp;
106 
107  _doTCur("Click the Plot at the Minimum Value");
108 
109  ymin = env->tcur;
110 
111  _doTCur("Click the Plot at the Maximum Value");
112 
113  ymax = env->tcur;
114 
115  if(ymax < ymin) /* Check for invertion */
116  {
117  tmp = ymax;
118  ymax = ymin;
119  ymin = tmp;
120  }
121 
122  env->ylower = ymin;
123  env->yupper = ymax;
125 
126  return(0);
127 }
128 
129 
130 int doZoom()
131 {
132  int bd, ed;
133  double left_x, left_y, right_x, right_y, tmp;
134 
135  _doCCur("Click Left Mouse Button on Left Edge of Desired Region");
136 
137  bd = (int)round(env->ccur);
138 
139  left_x = last_mouse_x;
140  left_y = last_mouse_y;
141 
142  _doCCur("Click Left Mouse Button on Right Edge of Desired Region");
143 
144  ed = (int)round(env->ccur);
145 
146  right_x = last_mouse_x;
147  right_y = last_mouse_y;
148 
149  /* Check for X inversion */
150  if(bd > ed)
151  {
152  tmp = left_x;
153  left_x = right_x;
154  right_x = tmp;
155  }
156 
157  /* Check for Y inversion */
158  if(left_y < right_y)
159  {
160  tmp = left_y;
161  left_y = right_y;
162  right_y = tmp;
163  }
164 
165  /* push args on stack */
166  subArgs(2, "%f", left_x);
167  subArgs(3, "%f", right_x);
168  setXRange();
169 
170  /* push args on stack */
171  subArgs(2, "%f", right_y);
172  subArgs(3, "%f", left_y);
173  setYRange();
174 
175  return(0);
176 }
177 
178 
180 {
181  int b, e, ret;
182  double x1, x2;
183 
185 
186  if(strlen(args->secondArg) && strlen(args->thirdArg))
187  {
188  x1 = atof(args->secondArg);
189  x2 = atof(args->thirdArg);
190 
191  ret = findXaxisElement(h0, x1, x2, &b, &e);
192 
193  if(!ret)
194  {
195  st_report("findXaxisElement() returned channels %d %d", b, e);
196 
197  env->bdrop = b;
198  env->edrop = h0->head.noint-e;
199  }
200  else
201  {
202  st_fail("setXRange(): Problem with Passed args %.3f %.3f", x1, x2);
203  return(1);
204  }
205  }
206  else
207  {
208  st_fail("Missing args for xrange");
209 
210  return(1);
211  }
212 
213  return(0);
214 }
215 
216 
217 
219 {
220  if(strlen(args->secondArg) && strlen(args->thirdArg))
221  {
222  env->ylower = atof(args->secondArg);
223  env->yupper = atof(args->thirdArg);
224 
226  }
227  else
228  {
229  st_fail("Missing args for yrange");
230  return(1);
231  }
232 
233  return(0);
234 }
235 
236 
238 {
239  int i;
240 
241  for(i=0;i<MAX_IMAGES;i++)
242  {
243  switch(i)
244  {
245  case 0: _h0(); break;
246  case 1: _h1(); break;
247  case 2: _h2(); break;
248  case 3: _h3(); break;
249  case 4: _h4(); break;
250  case 5: _h5(); break;
251  case 6: _h6(); break;
252  case 7: _h7(); break;
253  case 8: _h8(); break;
254  case 9: _h9(); break;
255  }
256 
257  if(h0->peakChan > 0)
258  {
259  showPeak();
260  st_report(" ");
261  }
262  }
263 
264  _h0();
265 
266  return(0);
267 }
268 
269 
270 
271 int showPeak()
272 {
273  struct LP_IMAGE_INFO *image = h0;
274 
275  computeXaxis(image, 0);
276 
277  line_determine_min_max(image);
278 
279  if(env->x1mode == XMODE_FREQ)
280  {
281  sprintf(peakResultsStr1, "%.4fK @ %7.1f MHz; %10.6f GHz",
282  image->datamax,
283  image->x1data[image->peakChan],
284  (image->head.restfreq + image->x1data[image->peakChan]) / 1000.0);
285  }
286  else
287  if(env->x1mode == XMODE_VEL)
288  {
289  sprintf(peakResultsStr1, "%.4fK @ %7.1f Km/s",
290  image->datamax,
291  image->x1data[image->peakChan]);
292  }
293  else
294  if(env->x1mode == XMODE_CHAN)
295  {
296  sprintf(peakResultsStr1, "%.4fK @ Channel %7.1f",
297  image->datamax,
298  image->x1data[image->peakChan]);
299  }
300 
301  if(env->x2mode == XMODE_FREQ)
302  {
303  sprintf(peakResultsStr2, "%.4fK @ %7.1f MHz; %10.6f GHz",
304  image->datamax,
305  image->x2data[image->peakChan],
306  (image->head.restfreq + image->x1data[image->peakChan]) / 1000.0);
307  }
308  else
309  if(env->x2mode == XMODE_VEL)
310  {
311  sprintf(peakResultsStr2, "%.4fK @ %7.1f Km/s",
312  image->datamax,
313  image->x2data[image->peakChan]);
314  }
315  else
316  if(env->x2mode == XMODE_CHAN)
317  {
318  sprintf(peakResultsStr2, "%.4fK @ Channel %7.1f",
319  image->datamax,
320  image->x2data[image->peakChan]);
321  }
322 
323  st_report("Peak = %s", peakResultsStr1);
324 
326 
327  if(env->x1mode != env->x2mode)
328  {
329  st_report("Peak = %s", peakResultsStr2);
330 
332  }
333 
334  return(0);
335 }
336 
337 int doCC()
338 {
339  st_report("Setting plotting x-axis to Channel-Channel");
340 
341  env->x1mode = XMODE_CHAN;
342  env->x2mode = XMODE_CHAN;
343 
344  return(0);
345 }
346 
347 
348 int doCF()
349 {
350  st_report("Setting plotting x-axis to Channel-Freq");
351 
352  env->x2mode = XMODE_CHAN;
353  env->x1mode = XMODE_FREQ;
354 
355  return(0);
356 }
357 
358 
359 int doCV()
360 {
361  st_report("Setting plotting x-axis to Channel-Velocity");
362 
363  env->x2mode = XMODE_CHAN;
364  env->x1mode = XMODE_VEL;
365 
366  return(0);
367 }
368 
369 
370 int doFC()
371 {
372  st_report("Setting plotting x-axis to Freq-Channel");
373 
374  env->x2mode = XMODE_FREQ;
375  env->x1mode = XMODE_CHAN;
376 
377  return(0);
378 }
379 
380 
381 int doFF()
382 {
383  st_report("Setting plotting x-axis to Freq-Freq");
384 
385  env->x2mode = XMODE_FREQ;
386  env->x1mode = XMODE_FREQ;
387 
388  return(0);
389 }
390 
391 
392 int doFV()
393 {
394  st_report("Setting plotting x-axis to Freq-Velocity");
395 
396  env->x2mode = XMODE_FREQ;
397  env->x1mode = XMODE_VEL;
398 
399  return(0);
400 }
401 
402 
403 int doVC()
404 {
405  st_report("Setting plotting x-axis to Velocity-Channel");
406 
407  env->x2mode = XMODE_VEL;
408  env->x1mode = XMODE_CHAN;
409 
410  return(0);
411 }
412 
413 
414 int doVF()
415 {
416  st_report("Setting plotting x-axis to Velocity-Freq");
417 
418  env->x2mode = XMODE_VEL;
419  env->x1mode = XMODE_FREQ;
420 
421  return(0);
422 }
423 
424 
425 int doVV()
426 {
427  st_report("Setting plotting x-axis to Velocity-Velocity");
428 
429  env->x2mode = XMODE_VEL;
430  env->x1mode = XMODE_VEL;
431 
432  return(0);
433 }
434 
435 
437 {
438  st_report("Setting plotting format to Points");
439 
441 
442  return(0);
443 }
444 
445 
446 int setHisto()
447 {
448  st_report("Setting plotting format to Historgraph");
449 
451 
452  return(0);
453 }
454 
455 
456 int setLines()
457 {
458  st_report("Setting plotting format to Lines");
459 
461 
462  return(0);
463 }
464 
465 
467 {
468  st_report("Setting plotting format to LinePts");
469 
471 
472  return(0);
473 }
474 
475 
476 int freeX()
477 {
478  env->bdrop = 0;
479  env->edrop = 0;
480 
481  env->xplotmax = 0.0;
482  env->xplotmin = 0.0;
483 
484  return(0);
485 }
486 
487 
488 int freeY()
489 {
490  env->ylower = -999999999.9;
491  env->yupper = 999999999.9;
492 
494 
495  env->yplotmax = 0.0;
496  env->yplotmin = 0.0;
497 
498  return(0);
499 }
500 
501 
502 int setGrid()
503 {
504  if(isSet(PF_O_FLAG))
505  {
507  }
508  else
509  if(isSet(PF_X_FLAG))
510  {
512  }
513  else
514  if(isSet(PF_Y_FLAG))
515  {
517  }
518  else
519  if(isSet(PF_B_FLAG))
520  {
522  }
523 
524  return(0);
525 }
526 
527 
528 double mapFtoChan(f)
529 double f;
530 {
531  int i, n, next;
532  double c = 0.0;
533  double xtab[MAX_CHANS], ytab[MAX_CHANS];
534  struct LP_IMAGE_INFO *image = h0;
535 
536  n = image->head.noint;
537 
538  if(env->x1mode == XMODE_FREQ)
539  {
540  for(i=0;i<n;i++)
541  {
542  xtab[i] = (double)image->x1data[i];
543  ytab[i] = (double)i;
544  }
545 
546  c = interpl8( &xtab[0], &ytab[0], n, f, &next );
547  }
548  else
549  if(env->x2mode == XMODE_FREQ)
550  {
551  for(i=0;i<n;i++)
552  {
553  xtab[i] = (double)image->x2data[i];
554  ytab[i] = (double)i;
555  }
556 
557  c = interpl8( &xtab[0], &ytab[0], n, f, &next );
558  }
559  else
560  {
561  st_fail("Niether X-Axis is set to Freq");
562  }
563 
564  return(c);
565 }
566 
567 
568 double mapVtoChan(v)
569 double v;
570 {
571  int i, n, next;
572  double c = 0.0;
573  double xtab[MAX_CHANS], ytab[MAX_CHANS];
574  struct LP_IMAGE_INFO *image = h0;
575 
576  n = image->head.noint;
577 
578  if(env->x1mode == XMODE_VEL)
579  {
580  for(i=0;i<n;i++)
581  {
582  xtab[i] = (double)image->x1data[i];
583  ytab[i] = (double)i;
584  }
585 
586  c = interpl8( &xtab[0], &ytab[0], n, v, &next );
587  }
588  else
589  if(env->x2mode == XMODE_VEL)
590  {
591  for(i=0;i<n;i++)
592  {
593  xtab[i] = (double)image->x2data[i];
594  ytab[i] = (double)i;
595  }
596 
597  c = interpl8( &xtab[0], &ytab[0], n, v, &next );
598  }
599  else
600  {
601  st_fail("Niether X-Axis is set to Vel");
602  }
603 
604  return(c);
605 }
606 
607 
608 
609 /* Continuum Axis Routines */
610 
612 {
613  int i, good1=0, good2=0;
614 
615  if(strlen(args->secondArg))
616  {
617  for(i=0;i<NUM_ACCUM_PLOT_X;i++)
618  {
619  if(!strncmp(args->secondArg, accum_x_strs[i], strlen(args->secondArg)))
620  {
621  env->acc_plot_select_x = i;
622  st_report("Setting Accum Plot X-Axis to %s", accum_x_strs[i]);
623  good1 = 1;
624  break;
625  }
626  }
627  }
628 
629  if(strlen(args->thirdArg))
630  {
631  for(i=0;i<NUM_ACCUM_PLOT_Y;i++)
632  {
633  if(!strncmp(args->thirdArg, accum_y_strs[i], strlen(args->thirdArg)))
634  {
635  env->acc_plot_select_y = i;
636  st_report("Setting Accum Plot Y-Axis to %s", accum_y_strs[i]);
637  good2 = 1;
638  break;
639  }
640  }
641  }
642 
643  if(!good1)
644  {
645  st_print("Possible Options; Xaxis: ");
646  for(i=1;i<NUM_ACCUM_PLOT_X;i++)
647  {
648  st_print("%s ", accum_x_strs[i]);
649  }
650 
651  st_print("\n");
652  }
653 
654  if(!good2)
655  {
656  st_print("Possible Options; Yaxis: ");
657  for(i=1;i<NUM_ACCUM_PLOT_Y;i++)
658  {
659  st_print("%s ", accum_y_strs[i]);
660  }
661 
662  st_print("\n");
663  }
664 
665  return(0);
666 }
667 
int doCF()
Definition: paxis.c:348
struct LP_IMAGE_INFO * h0
Definition: image.c:74
double tcur
Definition: env.h:271
int setLines()
Definition: paxis.c:456
char * strcmprs(char *str)
float x2data[MAX_CHANS]
Definition: image.h:118
double yplotmax
Definition: env.h:286
int _h0()
Definition: image.c:93
struct PARSE_STACK * args
Definition: parse.h:196
int edrop
Definition: env.h:52
#define GRID_MODE_X_ONLY
Definition: defines.h:115
int x1mode
Definition: env.h:145
double noint
Definition: header.h:211
struct BOX_DATA bd
Definition: obsmodes.c:132
int _h4()
Definition: image.c:137
double last_mouse_x
Definition: env.c:82
int doFF()
Definition: paxis.c:381
int setYRange()
Definition: paxis.c:218
#define MAX_CHANS
Definition: defines.h:38
#define PLOT_STYLE_LINES
Definition: defines.h:101
int gridmode
Definition: env.h:58
double ccur
Definition: env.h:176
int doYRange()
Definition: paxis.c:103
int doAccumArgs()
Definition: paxis.c:611
int acc_plot_select_x
Definition: env.h:19
int doVC()
Definition: paxis.c:403
int doCC()
Definition: paxis.c:337
int _h9()
Definition: image.c:192
int doCV()
Definition: paxis.c:359
int _h5()
Definition: image.c:148
int doVV()
Definition: paxis.c:425
#define GRID_MODE_NONE
Definition: defines.h:114
int _h3()
Definition: image.c:126
#define NUM_ACCUM_PLOT_X
Definition: accum.h:13
int _h8()
Definition: image.c:181
#define PLOT_STYLE_POINTS
Definition: defines.h:102
int doXRange()
Definition: paxis.c:65
char peakResultsStr1[256]
Definition: paxis.c:61
int _h2()
Definition: image.c:115
double interpl8(double *xtab, double *ytab, int no, double x, int *next)
Definition: convol.c:550
#define NUM_ACCUM_PLOT_Y
Definition: accum.h:24
#define XMODE_CHAN
Definition: defines.h:97
struct ENVIRONMENT * env
Definition: linuxpops.c:71
int _doCCur(char *msg)
Definition: linuxpops.c:2411
int setLinePts()
Definition: paxis.c:466
float x1data[MAX_CHANS]
Definition: image.h:117
char * thirdArg
Definition: parse.h:182
int isSet(int flag)
Definition: parse.c:646
#define PLOT_STYLE_LINEPTS
Definition: defines.h:103
struct HEADER head
Definition: image.h:104
int setXRange()
Definition: paxis.c:179
double last_mouse_y
Definition: env.c:84
int setPoints()
Definition: paxis.c:436
int doFC()
Definition: paxis.c:370
int findXaxisElement(struct LP_IMAGE_INFO *image, double x1, double x2, int *b, int *e)
Definition: xaxis.c:262
int setHisto()
Definition: paxis.c:446
void st_fail()
int freeX()
Definition: paxis.c:476
float datamax
Definition: image.h:98
int showPeak()
Definition: paxis.c:271
double ylower
Definition: env.h:287
#define GRID_MODE_FULL
Definition: defines.h:117
char * accum_x_strs[]
Definition: strings.c:136
int doZoom()
Definition: paxis.c:130
double xplotmin
Definition: env.h:282
#define Y_FIXED_SCALE
Definition: defines.h:107
int doVF()
Definition: paxis.c:414
char peakResultsStr2[256]
Definition: paxis.c:62
double xplotmax
Definition: env.h:283
#define XMODE_FREQ
Definition: defines.h:95
int yscale
Definition: env.h:149
double mapFtoChan(double f)
Definition: paxis.c:528
double mapVtoChan(double v)
Definition: paxis.c:568
int doFV()
Definition: paxis.c:392
void st_report()
int makeXaxisArray(struct LP_IMAGE_INFO *image)
Definition: xaxis.c:213
Definition: parse.h:9
char * accum_y_strs[]
Definition: strings.c:145
int computeXaxis(struct LP_IMAGE_INFO *image, int logit)
Definition: xaxis.c:70
int peakChan
Definition: image.h:77
int bdrop
Definition: env.h:31
#define MAX_IMAGES
Definition: defines.h:34
double yupper
Definition: env.h:288
int acc_plot_select_y
Definition: env.h:20
int _h6()
Definition: image.c:159
void subArgs(int wt, const char *fmt,...)
Definition: parse.c:430
int showPeaks()
Definition: paxis.c:237
int plotstyle
Definition: env.h:127
double yplotmin
Definition: env.h:285
#define Y_AUTO_SCALE
Definition: defines.h:106
char * secondArg
Definition: parse.h:181
int _doTCur(char *msg)
Definition: linuxpops.c:2580
void st_print()
int line_determine_min_max(struct LP_IMAGE_INFO *image)
Definition: line.c:694
int setGrid()
Definition: paxis.c:502
#define PLOT_STYLE_HISTO
Definition: defines.h:100
double restfreq
Definition: header.h:198
#define XMODE_VEL
Definition: defines.h:96
int x2mode
Definition: env.h:146
int _h7()
Definition: image.c:170
#define GRID_MODE_Y_ONLY
Definition: defines.h:116
int _h1()
Definition: image.c:104
int freeY()
Definition: paxis.c:488