Linuxpops  3.01.04
Spectral Anaysis Package for Single Dish Data
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
planets.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 #define ONE_HOUR (60 * 60) /* Seconds in one hour */
62 
64 
65 static char eph_tok[MAX_TOKENS][MAX_TOKENS];
66 
67 char marsDate[80];
68 
69 long fluxTablesLoadTime = -999999999;
70 
71 double mars_freqs[] = { 30.0, 80.0, 115.0, 150.0, 200.0, 230.0, 260.0, 300.0,
72  330.0, 360.0, 425.0, 650.0, 800.0, 950.0, 1000.0
73 };
74 
75 double planet_value;
76 
83 
85 
87 
88 
89 struct PLANET_LOOKUP {
90  char *vname;
91  char *fmt;
92  int type;
93  void *offset;
94 };
95 
96 #define ZRO ((struct EPH_OBJECT *)0)
97 
99  { "name", "%s", CHARSTAR, &ZRO->name },
100  { "dbase", "%s", CHARSTAR, &ZRO->dbase },
101  { "ra", "%.10f", DOUBLE, &ZRO->ra },
102  { "dec", "%.10f", DOUBLE, &ZRO->dec },
103  { "illum", "%.10f", DOUBLE, &ZRO->illum },
104  { "dmajor", "%.10f", DOUBLE, &ZRO->dmajor },
105  { "dminor", "%.10f", DOUBLE, &ZRO->dminor },
106  { "sdist", "%.10f", DOUBLE, &ZRO->sdist },
107  { "rdot", "%.10f", DOUBLE, &ZRO->rdot },
108  { "dist", "%.10f", DOUBLE, &ZRO->dist },
109  { "vel", "%.10f", DOUBLE, &ZRO->vel },
110  { "sangle", "%.10f", DOUBLE, &ZRO->sangle },
111  { "t_src", "%.10f", DOUBLE, &ZRO->tsrc },
112  { "trj", "%.10f", DOUBLE, &ZRO->trj },
113  { "flux", "%.10f", DOUBLE, &ZRO->flux },
114  { "flux2", "%.10f", DOUBLE, &ZRO->flux2 },
115  { "tmb", "%.10f", DOUBLE, &ZRO->tmb },
116  { "csize", "%.10f", DOUBLE, &ZRO->csize },
117 
118  { NULL, NULL, 0, NULL }
119 };
120 
121 
122 static int eph_get_tok(edit)
123 char *edit;
124 {
125  int c = 0;
126  char *token;
127 
128  bzero((char *)&eph_tok, sizeof(eph_tok));
129 
130  token = strtok(edit, ",\n\t ");
131  while(token != (char *)NULL)
132  {
133  sprintf(eph_tok[c++], "%s", token);
134  token = strtok((char *)NULL, ",\n\t ");
135  }
136 
137  return(c);
138 }
139 
140 int parseLine(obj, name)
141 struct EPH_OBJECT *obj;
142 char *name;
143 {
144  double hr, min, sec, deg;
145 
146  strcpy(obj->name, name);
147 
148  hr = atof(eph_tok[2]);
149  min = atof(eph_tok[3]);
150  sec = atof(eph_tok[4]);
151  obj->ra = hr + min / 60.0 + sec / 3600.0;
152 
153  deg = atof(eph_tok[5]);
154  min = atof(eph_tok[6]);
155  sec = atof(eph_tok[7]);
156  obj->dec = fabs(deg) + min / 60.0 + sec / 3600.0;
157  if(deg < 0.0)
158  {
159  obj->dec *= -1.0;
160  }
161 
162  obj->illum = atof(eph_tok[8]);
163  obj->dmajor = atof(eph_tok[9]);
164  obj->sdist = atof(eph_tok[10]);
165  obj->rdot = atof(eph_tok[11]);
166  obj->dist = atof(eph_tok[12]);
167  obj->vel = atof(eph_tok[13]);
168  obj->sangle = atof(eph_tok[14]);
169 
170  return(0);
171 }
172 
173 
174 /* Interalate between to sets of positions and params */
175 int eph_interp(ephem, p1, p2)
176 struct NEW_EPHEM *ephem;
177 struct EPH_OBJECT *p1, *p2;
178 {
179  double frac;
180  struct EPH_OBJECT *p;
181  double eccent[] = { 1.0, 1.0, 0.9952, 0.93512, 0.892467, 0.97118, 0.97247, 1.0, 1.0, 1.0, 1.0 };
182 
183  p = &ephem->planets[ephem->planet];
184 
185  frac = (ephem->time.hour + (ephem->time.min / 60.0)) / 24.0;
186 
187  strcpy(p->name, p1->name);
188 
189  p->ra = p1->ra + frac * (p2->ra - p1->ra);
190  p->dec = p1->dec + frac * (p2->dec - p1->dec);
191  p->illum = p1->illum + frac * (p2->illum - p1->illum);
192  p->dmajor = p1->dmajor + frac * (p2->dmajor - p1->dmajor);
193  p->sdist = p1->sdist + frac * (p2->sdist - p1->sdist);
194  p->rdot = p1->rdot + frac * (p2->rdot - p1->rdot);
195  p->dist = p1->dist + frac * (p2->dist - p1->dist);
196  p->vel = p1->vel + frac * (p2->vel - p1->vel);
197  p->sangle = p1->sangle + frac * (p2->sangle - p1->sangle);
198  p->dminor = p->dmajor * eccent[ephem->planet];
199  p->frac = frac;
200 
201  return(0);
202 }
203 
204 
205 int parseNewEphem(ephem)
206 struct NEW_EPHEM *ephem;
207 {
208  int n, indx=0;
209  FILE *fp;
210  char fname[256], *string, line[256], dstr[256];
211  extern char *months[12];
212  struct EPH_OBJECT p1, p2;
213 
214  bzero((char *)&p1, sizeof(p1));
215  bzero((char *)&p2, sizeof(p2));
216 
217  sprintf(fname, "%s/share/%s-Ephem.tab", pkg_home, eph_source_names[ephem->planet]);
218 
219  if((fp = fopen(fname, "r") ) <= (FILE *)0)
220  {
221  st_fail("Unable to open file %s", fname);
222 
223  return(0);
224  }
225 
226  sprintf(dstr, "%4d-%s-%02d", ephem->time.year, months[ephem->time.mon], ephem->time.day);
227 
228 // st_report("Searching for Date: %s", dstr);
229 
230  while((string = fgets(line, sizeof(line), fp)) != NULL)
231  {
232  indx++;
233 
234  if(strlen(line) < 4)
235  {
236  continue;
237  }
238 
239  if(line[0] == '#')
240  {
241  continue;
242  }
243 
244  n = eph_get_tok(line);
245 
246  if(n == 16)
247  {
248  if(!strcmp(eph_tok[0], dstr))
249  {
250  parseLine(&p1, eph_source_names[ephem->planet]);
251 
252 // st_report("Found Date on Line: %d", indx);
253 
254  /* Now read the nextline for interp */
255  if((string = fgets(line, sizeof(line), fp)) != NULL)
256  {
257  n = eph_get_tok(line);
258 
259  if(n == 16)
260  {
261  parseLine(&p2, eph_source_names[ephem->planet]);
262  eph_interp(ephem, &p1, &p2);
263 
264  if(!strcmp(eph_source_names[ephem->planet], "Mars"))
265  {
266  st_report("Mars Ephem line = %.2f", (double)indx + ephem->planets[ephem->planet].frac);
267  }
268 
269  fclose(fp);
270 
271  return(0);
272  }
273  }
274  }
275  }
276  else
277  {
278  st_report("Parsed %d tokens from %s", n, basename(fname));
279  }
280  }
281 
282  st_fail("Date: %s, not found in %s", dstr, basename(fname));
283 
284  fclose(fp);
285 
286  return(1);
287 }
288 
289 
290 double rjot(t, f)
291 double t, f;
292 {
293  double rjt;
294  double a;
295 
296  // Calculation of the Brightness-Temperature from the
297  // Physical Planck Temperature:
298 // bolt = 1.38054e-23 ! J/K
299 // plan = 6.6256e-34 ! W s**2
300 
301  a = plancK * f / boltzmann;
302  rjt = a / (exp( a / t) -1.0); // = T_b [K]
303 
304  return(rjt);
305 }
306 
307  //Derive a linear equation from two points and calculate the y (=mx+b)
308  //corresponding to a x
309 double tb_lin(f, f1, tb1, f2,tb2)
310 double f, f1, tb1, f2, tb2;
311 {
312  double tb, xslope, yaxis;
313 
314  xslope = (tb1-tb2) / (f1-f2);
315  yaxis = tb1 - xslope * f1;
316  tb = xslope * f + yaxis;
317 
318  return(tb);
319 }
320 
321 
322 
324 struct EPH_TIME *t;
325 {
326  int i, n, len, indx=0;
327  FILE *fp;
328  char fname[256], *string, line[256], dstr[256];
329  struct TBRIGHT *p;
330  double scale = 1.0;
331 
332  if(t->year < 2012) /* Tables only go back to 2012 */
333  {
334  return(0);
335  }
336 
337  st_report("Loading Planet Brightness Tables");
338 
339  for(i=1;i<7;i++)
340  {
341  if(i==4 || i == 2) /* Skip Saturn; and Mars for now */
342  {
343  continue;
344  }
345 
346  sprintf(fname, "%s/share/%s_Tb.dat", pkg_home, eph_source_names[i]);
347 
348  if((fp = fopen(fname, "r") ) <= (FILE *)0)
349  {
350  st_fail("Unable to open file %s", fname);
351 
352  continue;
353  }
354 
355  switch(i)
356  {
357  case 1: p = &venus_tbright[0]; scale = 1.0; break;
358  case 3: p = &jupiter_tbright[0]; scale = 1.0562; break;
359  case 5: p = &uranus_tbright[0]; scale = 1.0; break;
360  case 6: p = &neptune_tbright[0]; scale = 1.0; break;
361  default:
362  st_fail("Unknown Planet index %d", i);
363  continue;
364  }
365 
366  while((string = fgets(line, sizeof(line), fp)) != NULL)
367  {
368  if(line[0] == '#')
369  {
370  continue;
371  }
372 
373  n = eph_get_tok(line);
374 
375  if(n == 2)
376  {
377  p->freq = atof(eph_tok[0]);
378  p->tb = atof(eph_tok[1]) * scale;
379 
380  p++;
381  }
382  }
383  }
384 
385  // Mars is a different animal;
386  // Only load the entry for todays date.
387 
388  sprintf(fname, "%s/share/Mars_Tb.dat", pkg_home);
389  sprintf(dstr, "%4d %02d %02d %02d", t->year, t->mon+1, t->day, t->hour);
390 
391  st_report("Looking for Mars date of: %s", dstr);
392 
393  len = strlen(dstr);
394 
395  if((fp = fopen(fname, "r") ) <= (FILE *)0)
396  {
397  st_fail("Unable to open file %s", fname);
398 
399  fluxTablesLoadTime = time(NULL);
400 
401  return(1);
402  }
403 
404  while((string = fgets(line, sizeof(line), fp)) != NULL)
405  {
406  indx++;
407 
408  if(line[0] == '#')
409  {
410  continue;
411  }
412 
413  if(!strncmp(line, dstr, len))
414  {
415 // st_print("MARS: %s", line);
416 
417  strcpy(marsDate, dstr);
418 
419  n = eph_get_tok(line);
420 
421  if(n == 20) /* Good Read */
422  {
423  for(i=0;i<MAX_MARS_ENTRIES;i++)
424  {
425  mars_tbright[i].freq = mars_freqs[i];
426  mars_tbright[i].tb = atof(eph_tok[5+i]);
427  }
428 
429  fclose(fp);
430 
431  st_report("Mars date line = %d", indx);
432 
433  fluxTablesLoadTime = time(NULL);
434 
435  return(0);
436  }
437  else
438  {
439  st_fail("Got %d token in file %s", n, fname);
440  }
441  }
442  }
443 
444  /* If we got this far, we missed something */
445 
446  st_fail("Unable to locate %s, in %s", dstr, fname);
447 
448  fclose(fp);
449 
450  fluxTablesLoadTime = time(NULL);
451 
452  return(0);
453 }
454 
455 
456 double tsrcInterp(tb, f, n)
457 struct TBRIGHT *tb;
458 double f;
459 int n;
460 {
461  double diff, min, t=0.0, slope;
462  int i, len, indx=0;
463  struct TBRIGHT *p;
464  double f1, f2, t1, t2, frac, dy, dx;
465 
466  len = n / sizeof(struct TBRIGHT);
467 
468  if(interpl8_debug)
469  {
470  st_report("Size of array: %d", len);
471  st_report("Looking for %f", f);
472  }
473 
474  min = 999999.9;
475  p = tb;
476  for(i=0;i<len;i++,p++)
477  {
478  diff = fabs(f - p->freq);
479 
480  if(diff < min)
481  {
482  min = diff;
483  indx = i;
484  }
485  }
486 
487  t = tb[indx].tb;
488 
489  f1 = tb[indx].freq;
490 
491  if(interpl8_debug)
492  {
493  st_report("Found Min freq @ indx %d; min = %f, freq = %f, tb = %f", indx, min, f1, t);
494  }
495 
496  /* Now interpl8 */
497  if(f1 < f) /* We found the entry before our request freq */
498  {
499  f1 = tb[indx].freq;
500  f2 = tb[indx+1].freq;
501 
502  t1 = tb[indx].tb;
503  t2 = tb[indx+1].tb;
504  }
505  else /* We found the entry after our request freq */
506  {
507  f1 = tb[indx-1].freq;
508  t1 = tb[indx-1].tb;
509 
510  f2 = tb[indx].freq;
511  t2 = tb[indx].tb;
512  }
513 
514 
515  dy = t2 - t1;
516  dx = f2 - f1;
517  slope = dy / dx;
518  frac = (f - f1) * slope;
519 
520  if(interpl8_debug)
521  {
522  st_report("T1 %6.2f T2 %6.2f", t1, t2);
523  st_report("F1 %6.2f F2 %6.2f", f1, f2);
524  st_report("DX = %f", dx);
525  st_report("DY = %f", dy);
526  st_report("Slope = %f", slope);
527  st_report("Frac = %f", frac);
528  }
529 
530  t = t1 + frac;
531 
532  return(t);
533 }
534 
535 
537 long t;
538 {
539  if(abs(fluxTablesLoadTime-t) > ONE_HOUR)
540  {
541  return(1);
542  }
543 
544  return(0);
545 }
546 
547 
548 int computePlanetFlux(planet, obj, t, s, logit)
549 int planet, logit;
550 struct EPH_OBJECT *obj;
551 struct EPH_TIME *t;
552 struct EPH_STATE *s;
553 {
554  int tmb_color = BLACK;
555  double diameter, alpha, taper;
556  double clight, frequenz, xlambda;
557  double radius, omega_source, fluss;
558  double A, x, y/*, tbright*/;
559  double hnuk, expterm, jnuplan, jnucmb;
560  extern char *eph_source_names[];
561  long tt;
562 #ifdef USE_OLD_WAY
563  double R_mars;
564  double a0, a1, a2, a3; // Uranus calculations
565  double aa0, aa1, aa2, aa3; // Neptune calculations
566 #endif
567 
568 
569  tt = time(NULL);
570 
571  if(fluxTableOld(tt))
572  {
574  }
575 
576  obj->tsrc = 0.0;
577 
578  if(s->f_sky)
579  {
580  s->lambda = SOL / s->f_sky;
581  }
582  else
583  {
584 // st_fail("Freq set to 0.0");
585  return(0);
586  }
587 
588  if(env->issmt)
589  {
590  diameter = MG_DIAMETER;
591  taper = MG_TAPER;
592  }
593  else
594  {
595  diameter = KP_DIAMETER;
596  taper = KP_TAPER;
597  }
598 
599  if(env->dish_size)
600  {
601  diameter = env->dish_size;
602  }
603 
604  if(env->taper)
605  {
606  taper = env->taper;
607  }
608 
609 // alpha = taper * 0.0996; /* was 0.115; 04/30/2016; twf */
610 // alpha = 1.17; /* Shirley & Folkers, Mangum 1993; for 10 db taper */
611  alpha = 1.18; /* Shirley & Folkers, for 12 db taper Oct 17th, 2016 */
612 
613  alpha = taper * (1.18 / 12.0);
614 
615  s->theta_mb = alpha * (s->lambda / diameter) * (180.0 / M_PI) * 3600.0;
616 
617  if(env->theta_mb > 0.0) /* user supplied theta_mb */
618  {
619  s->theta_mb = env->theta_mb;
620  tmb_color = RED;
621  }
622 
623  if(logit)
624  {
625  st_report("Lambda: = %6.2fmm", s->lambda*1000.0);
626 
627  if(env->dish_size) /* Flag unusual dish_size */
628  {
629  setColor(RED);
630  st_report("Diameter: = %6.2fm", diameter);
631  setColor(BLACK);
632  }
633  else
634  {
635  st_report("Diameter: = %6.2fm", diameter);
636  }
637 
638  if(env->taper) /* Flag unusual taper */
639  {
640  setColor(RED);
641  st_report("Taper: = %6.2fdB", taper);
642  setColor(BLACK);
643  }
644  else
645  {
646  st_report("Taper: = %6.2fdB", taper);
647  }
648 
649  st_report("Alpha: = %6.2f", alpha);
650 
651  if(tmb_color != BLACK)
652  {
653  setColor(tmb_color);
654  st_report("Theta_mb: = %6.2f\"", s->theta_mb);
655  setColor(BLACK);
656  }
657  else
658  {
659  st_report("Theta_mb: = %6.2f\"", s->theta_mb);
660  }
661  }
662 
663 
664  switch(planet)
665  {
666  case MERCURY:
667  obj->tsrc = 450.0;
668  strcpy(obj->dbase, "Fixed");
669  break;
670 
671  case VENUS:
672 #ifdef USE_OLD_WAY
673 #warning Using Shirley
674 
675  /* Old Shirley: logistic fit to brightness temperature data */
676  obj->tsrc = 266.4 + (245.1 / (1.0 + (s->f_sky*s->f_sky / (64.7*64.7))));
677  strcpy(obj->dbase, "Shirley");
678 #else
679 //#warning Using ALMA
680 // if(s->f_sky > 116.0)
681 // {
682  obj->tsrc = tsrcInterp(&venus_tbright[0], s->f_sky, sizeof(venus_tbright));
683  strcpy(obj->dbase, "ALMA");
684 // }
685 // else /* From Shirley; March 2016 */
686 // {
687 // obj->tsrc = 362.92 * pow(s->f_sky / 90.0, -0.4055);
688 // strcpy(obj->dbase, "Shirley");
689 // }
690 #endif
691  break;
692 
693  case MARS:
694 #ifdef USE_OLD_WAY
695  /* from Ulich (1981) as discussed by Mangum */
696  R_mars = obj->sdist;
697  obj->tsrc = T_R0 * sqrt(R0 / R_mars);
698  strcpy(obj->dbase, "Ulich");
699 #else
700  obj->tsrc = tsrcInterp(&mars_tbright[0], s->f_sky, sizeof(mars_tbright));
701  strcpy(obj->dbase, "ALMA");
702 #endif
703  break;
704 
705  case JUPITER:
706 #ifdef USE_OLD_WAY
707  /* from Shirley: best linear fit to Mangum Table 1 */
708  /* with additional data points from WMAP & MASM1 */
709  obj->tsrc = 178.309 - 0.036 * s->f_sky;
710 
711  // From Glidas/Astro: iram-planet.f90
712  // 179 K at 90 GHz, 173 K at 150 GHz, 171 K at 227 GHz, 174 K at337GHz
713  // inter- and extrapolate linearily:
714  if(s->f_sky < 150.0)
715  {
716  obj->tsrc = tb_lin(s->f_sky, 90.0, 179.0, 150.0, 173.0);
717  }
718  else
719  if(s->f_sky <= 227.0)
720  {
721  obj->tsrc = tb_lin(s->f_sky, 150.0, 173.0, 227.0, 171.0);
722  }
723  else
724  if(s->f_sky > 227.0)
725  {
726  obj->tsrc = tb_lin(s->f_sky, 227.0, 171.0, 337.0, 174.0);
727  }
728 #else
729 // if(s->f_sky > 183.0)
730 // {
731  obj->tsrc = tsrcInterp(&jupiter_tbright[0], s->f_sky, sizeof(jupiter_tbright));
732  strcpy(obj->dbase, "Alma");
733 // }
734 // else /* From Shirley; March 2016 */
735 // {
736 // obj->tsrc = 173.67677 * pow(s->f_sky / 90.0, 0.0071986);
737 // strcpy(obj->dbase, "Shirley");
738 // }
739 #endif
740  break;
741 
742  case SATURN:
743  /* from Shirley: interpolated planetary flux densities */
744  /* (Table 6.2 posted in 12-meter control room */
745  obj->tsrc = (s->f_sky - 90.0) * (149.0 - 140.0) / (90.0 - 227.0);
746  obj->tsrc += 149.0;
747  strcpy(obj->dbase, "Shirley");
748  break;
749 
750  case URANUS:
751 #ifdef USE_OLD_WAY
752  // Griffin & Orton 1993, ICARUS, 105, 537
753  clight = 2.9979e+10; // [cm/s]
754  frequenz = s->f_sky * 1.e9; // [Hz]
755  xlambda = clight / frequenz; // [cm]
756  xlambda = xlambda * 1.e4; // [micrometers]
757 
758  a0 = -795.694;
759  a1 = 845.179;
760  a2 = -288.946;
761  a3 = 35.200;
762  obj->tsrc = a0 + a1 * log10(xlambda) + a2 * pow(log10(xlambda), 2.0) + a3 * pow(log10(xlambda), 3.0);
763 #else
764  obj->tsrc = tsrcInterp(&uranus_tbright[0], s->f_sky, sizeof(uranus_tbright));
765  strcpy(obj->dbase, "ALMA");
766 #endif
767  break;
768 
769  case NEPTUNE:
770 #ifdef USE_OLD_WAY
771  // Griffin & Orton 1993, ICARUS, 105, 537
772  clight = 2.9979e+10; // [cm/s]
773  frequenz = s->f_sky * 1.e9; // [Hz]
774  xlambda = clight / frequenz; // [cm]
775  xlambda = xlambda * 1.e4; // [micrometers]
776 
777  aa0 = -598.901;
778  aa1 = 655.681;
779  aa2 = -229.545;
780  aa3 = 28.994;
781 
782  obj->tsrc = aa0 + aa1 * log10(xlambda) + aa2 * pow(log10(xlambda), 2.0) + aa3 * pow(log10(xlambda), 3.0);
783 #else
784  obj->tsrc = tsrcInterp(&neptune_tbright[0], s->f_sky, sizeof(neptune_tbright));
785  strcpy(obj->dbase, "ALMA");
786 #endif
787  break;
788  }
789 
790  clight = 2.9979e+10; // [cm/s]
791  frequenz = s->f_sky * 1.e9; // [Hz]
792  xlambda = clight / frequenz; // [cm]
793 
794 #ifdef USE_RJ
795  obj->trj = rjot(obj->tsrc, frequenz);
796 #else
797  obj->trj = obj->tsrc;
798 #endif
799 
800  // Flux of the planet, independent of the telescope or the atmosphere:
801  // Derived from the Rayleigh-Jeans corrected Brightness Temperatures!
802  radius = obj->dmajor / 2.0; // ["]
803  omega_source = M_PI * pow(radius * M_PI / (180.0 * 3600.0), 2.0); // [sterad]
804  fluss = 2.0 * boltzmann / (pow(xlambda/100.0, 2.0)) * obj->trj * omega_source;// [Joule]
805  obj->flux = fluss * 1.e26; // [Jansky]
806  A = (M_PI * pow(diameter, 2.0) / 4.0);
807  env->jfact = ((2.0 * boltzmann / 1.0e-26) / A);
808 
809  if(logit)
810  {
811  st_report("Dish Area = %6.2fm^2", A);
812  st_report("JFact = %6.2f", env->jfact);
813  }
814 
815  obj->flux2 = obj->dmajor*obj->dminor*1158.1
816  * pow(s->f_sky, 3.0)
817  * (1.0 / (exp(0.04801 * s->f_sky / obj->trj)-1.0)
818  - 1.0 / (exp(0.04801 * s->f_sky / 2.7)-1.0));
819 
820  x = (obj->dmajor * obj->dminor) / pow(s->theta_mb / sqrt(log(2.0)), 2.0);
821  y = 1.0 - exp(x * -1.0);
822  obj->flux2 = obj->flux2 * y / x;
823  obj->flux2 /= 42e9;
824  obj->tmb = obj->trj * y;
825 
826 /*
827  * Shirley Tmb Calculations (CGS)
828  */
829  hnuk = (6.626e-27 * frequenz / 1.381e-16);
830  jnucmb = hnuk / (exp(6.626e-27 * frequenz / (1.381e-16 * 2.725)) - 1.0);
831  jnuplan = hnuk / (exp(6.626e-27 * frequenz / (1.381e-16 * obj->tsrc)) - 1.0);
832  expterm = 1.0 - exp(-1.0 * log(2.0) * obj->dmajor*obj->dminor / pow(s->theta_mb, 2.0));
833  obj->tmb = expterm * (jnuplan - jnucmb);
834  obj->csize = sqrt(log(2.0) / 2.0 * obj->dmajor * obj->dminor + pow(s->theta_mb, 2.0));
835 
836  if(logit)
837  {
838  st_report("JFact(Real) = %6.2f", obj->flux2 / obj->tmb);
839  }
840 
841  return(0);
842 }
843 
844 
845 #define NOW_DATE 1
846 #define USER_DATE 2
847 #define SCAN_DATE 3
848 #define ENV_DATE 4
849 
851 {
852  int i, saz, rptflag = 0, user_freq = 0, wcolor = 0;
853  double limit, ddate, dyr, dmon, dday;
854  char raStr[80], decStr[80], rptstr[256];
855  struct tm *tmn2;
856  struct EPH_OBJECT *p;
857  struct EPH_STATE *s;
858  struct EPH_TIME *t;
859  static int first = 1;
860  char cmdBuf[256];
861 
862  if(first)
863  {
864  new_ephem.time.year = getYear(7);
865  new_ephem.time.mon = getMonth(7) -1;
866  new_ephem.time.day = getDom(7);
867  new_ephem.time.hour = getHour(7);
869  wcolor = NOW_DATE;
870 
871  st_report(" ");
872  st_report("Initializing Ephem Tables");
873 
875 
876  st_report(" ");
877 
878  first = 0;
879  }
880 
881  if(isSet(PF_R_FLAG)) /* "reload" */
882  {
883  new_ephem.time.year = getYear(7);
884  new_ephem.time.mon = getMonth(7) -1;
885  new_ephem.time.day = getDom(7);
886  new_ephem.time.hour = getHour(7);
888  wcolor = NOW_DATE;
889 
891 
892  return(0);
893  }
894 
895  if(isSet(PF_N_FLAG)) /* "now" */
896  {
897  new_ephem.time.year = getYear(7);
898  new_ephem.time.mon = getMonth(7) -1;
899  new_ephem.time.day = getDom(7);
900  new_ephem.time.hour = getHour(7);
902  wcolor = NOW_DATE;
903 
904  st_report("Using 'now' for time");
906 
907  }
908  else
909  if(isSet(PF_D_FLAG)) /* Use Environmental 'date' */
910  {
911  if(env->date > 0.0)
912  {
913  dyr = round(env->date);
914 
915  dmon = (env->date - dyr) * 100.0;
916  dmon = round(dmon);
917 
918  dday = (env->date - dyr) * 100.0;
919  dday -= dmon;
920  dday *= 100.0;
921  dday = round(dday);
922 
923  new_ephem.time.year = (int)dyr;
924  new_ephem.time.mon = (int)(dmon - 1.0);
925  new_ephem.time.day = (int)dday;
926 
927  new_ephem.time.hour = 0;
928  new_ephem.time.min = 0;
929  wcolor = ENV_DATE;
930 
931  st_report("Using ENV:Date %.4f for time", env->date);
932  }
933  else
934  {
935  new_ephem.time.year = getYear(7);
936  new_ephem.time.mon = getMonth(7) -1;
937  new_ephem.time.day = getDom(7);
938  new_ephem.time.hour = getHour(7);
940  wcolor = NOW_DATE;
941 
942  st_report("Date NOT Set: Using 'now' for time");
943  }
944 
946  }
947  else
948  if(isSet(PF_U_FLAG)) /* User passed 'date' */
949  {
950  if(args->ntokens > 1)
951  {
952  ddate = atof(args->secondArg);
953  }
954  else
955  {
956  ddate = 0.0;
957  }
958 
959  if(ddate > 2012.01 && ddate < 2025.13) /* Sanity check */
960  {
961  dyr = round(ddate);
962 
963  dmon = (ddate - dyr) * 100.0;
964  dmon = round(dmon);
965 
966  dday = (ddate - dyr) * 100.0;
967  dday -= dmon;
968  dday *= 100.0;
969  dday = round(dday);
970 
971  new_ephem.time.year = (int)dyr;
972  new_ephem.time.mon = (int)(dmon - 1.0);
973  new_ephem.time.day = (int)dday;
974 
975  new_ephem.time.hour = 0;
976  new_ephem.time.min = 0;
977  wcolor = USER_DATE;
978 
979  st_report("Using User Date: %.4f for time", ddate);
980  }
981  else
982  {
983  new_ephem.time.year = getYear(7);
984  new_ephem.time.mon = getMonth(7) -1;
985  new_ephem.time.day = getDom(7);
986  new_ephem.time.hour = getHour(7);
988  wcolor = NOW_DATE;
989 
990  st_report("User Date: %.4f, NOT Valid: Using 'now' for time", ddate);
991  st_report("Valid User Date Range: 2012.0101 - 2025.1231");
992  }
993 
995  }
996  else
997  {
998  if(h0->head.scan < 1.0)
999  {
1000  st_report("No Scan Loaded for getPlanet(); Using 'now' for time");
1001 
1002  new_ephem.time.year = getYear(7);
1003  new_ephem.time.mon = getMonth(7) -1;
1004  new_ephem.time.day = getDom(7);
1005  new_ephem.time.hour = getHour(7);
1006  new_ephem.time.min = getMinute(7);
1007  wcolor = NOW_DATE;
1008  }
1009  else
1010  {
1011  tmn2 = breakTime(h0->head.burn_time);
1012 
1013  new_ephem.time.year = tmn2->tm_year+1900;
1014  new_ephem.time.mon = tmn2->tm_mon;
1015  new_ephem.time.day = tmn2->tm_mday;
1016  new_ephem.time.hour = tmn2->tm_hour;
1017  new_ephem.time.min = tmn2->tm_min;
1018  wcolor = SCAN_DATE;
1019  }
1020 
1022  {
1024  }
1025  }
1026 
1027  switch(wcolor)
1028  {
1029  case USER_DATE: setColor(RED); break;
1030  default: setColor(BLACK); break;
1031  }
1032 
1033  st_report("UT-Date: = %02d/%02d/%04d",
1035 
1036  setColor(BLACK);
1037 
1038  if(new_ephem.time.year >= 2012)
1039  {
1040  for(i=MERCURY;i<MAX_PLANETS-1;i++)
1041  {
1042  new_ephem.planet = i;
1044  }
1045  }
1046 
1047  if(env->issmt)
1048  {
1049  limit = 45.0;
1050  }
1051  else
1052  {
1053  limit = 5.0;
1054  }
1055 
1056  /* Is there a passed freq flag */
1057  if(isSet(PF_F_FLAG))
1058  {
1059  /* First check if the /u flag is set too; that means there are 2 passwd args */
1060  if(isSet(PF_U_FLAG))
1061  {
1062  if(args->ntokens > 2) /* There better be 1+2 args out there */
1063  {
1064  new_ephem.state.f_sky = atof(args->thirdArg); /* Freq arg must be second */
1065  user_freq = 1;
1066  }
1067  else
1068  {
1069  st_report("Missing arg for Freq; using ENV:Freq of %f", env->freq);
1070 
1072  }
1073  }
1074  else
1075  {
1076  if(args->ntokens > 1) /* There better be 1+ args out there */
1077  {
1078  new_ephem.state.f_sky = atof(args->secondArg);
1079  user_freq = 1;
1080  }
1081  else
1082  {
1083  st_report("Missing arg for Freq; using ENV:Freq of %f", env->freq);
1084 
1086  }
1087  }
1088  }
1089  else
1090  {
1092  }
1093 
1094  if(user_freq)
1095  {
1096  setColor(RED);
1097  st_report("User Freq: = %6.2f", new_ephem.state.f_sky);
1098  setColor(BLACK);
1099  }
1100  else
1101  {
1102  st_report("System Freq = %6.2f", new_ephem.state.f_sky);
1103  }
1104 
1105  p = &new_ephem.planets[0];
1106  s = &new_ephem.state;
1107  t = &new_ephem.time;
1108 
1109  for(i=MERCURY;i<MAX_PLANETS-1;i++,p++)
1110  {
1111  sexagesimal(p->ra, raStr, DDD_MM_SS_S100);
1112  sexagesimal(p->dec, decStr, DDD_MM_SS_S100);
1113 
1114  saz = 1;
1115  if(p->sangle < limit)
1116  {
1117  saz = 1;
1118  }
1119  else
1120  {
1121  saz = 0;
1122  }
1123 
1124  computePlanetFlux(i, p, t, s, i==MERCURY);
1125 
1126  bcopy((char *)p, (char *)&save_planet_values[i], sizeof(struct EPH_OBJECT));
1127 
1128  if(i == 0)
1129  {
1130  st_print("\n [ Tbright: A = ALMA; S = Shirley; F = Fixed ]\n\n");
1131  st_print(" Name RA Dec Vel Sun SAZ Dist Major Minor Tbright Freq FWHM Csize Tmb Flux Flux2\n");
1132  }
1133 
1134  st_print("%8.8s %s %s %5.1f %5.1f %d %5.2f %5.2f\" %5.2f\" ",
1135  p->name, raStr, decStr, p->vel,
1136  p->sangle, saz,
1137  p->dist, p->dmajor, p->dminor);
1138 
1139  st_print("%6.2f(%1.1s) %5.1f %5.1f\" %5.2f\" %6.2f %6.1f %6.1f\n",
1140  p->tsrc, p->dbase, env->freq, s->theta_mb, p->csize, p->tmb, p->flux, p->flux2);
1141 
1142  switch(i)
1143  {
1144  case MERCURY: env->mercury_tmb = p->tmb; break;
1145  case VENUS: env->venus_tmb = p->tmb; break;
1146  case MARS: env->mars_tmb = p->tmb; break;
1147  case JUPITER: env->jupiter_tmb = p->tmb; break;
1148  case SATURN: env->saturn_tmb = p->tmb; break;
1149  case URANUS: env->uranus_tmb = p->tmb; break;
1150  case NEPTUNE: env->neptune_tmb = p->tmb; break;
1151  }
1152 
1153  if(!strcasecmp(p->name, env->source))
1154  {
1155  env->expectedtmb = p->tmb;
1156  env->expectedflux = p->flux2;
1157  sprintf(rptstr, "Auto Setting Expected Tmb for %s to %f", env->source, p->tmb);
1158  rptflag = 1;
1159  }
1160  }
1161 
1162  if(rptflag && env->mode == MODE_SPEC)
1163  {
1164  st_report("%s", rptstr);
1165 
1166  sprintf(cmdBuf, "hline /c 31 %f /Cmg", env->expectedtmb);
1167  st_report(cmdBuf);
1168  parseCmd(cmdBuf);
1169  }
1170 
1171  return(0);
1172 }
1173 
1174 
1175 int dopFlux(planet, flag, bfreq, efreq)
1176 int planet, flag;
1177 double bfreq, efreq;
1178 {
1179  int i;
1180  double f;
1181  struct tm *tmn2;
1182  struct EPH_OBJECT *p;
1183  struct EPH_STATE *s;
1184  struct EPH_TIME *t;
1185  long tt;
1186 
1187  if(h0->head.scan < 1.0)
1188  {
1189  st_warn("No Scan Loaded for doFlux(); Using 'now' for time");
1190 
1191  new_ephem.time.year = getYear(7);
1192  new_ephem.time.mon = getMonth(7) -1;
1193  new_ephem.time.day = getDom(7);
1194  new_ephem.time.hour = getHour(7);
1195  new_ephem.time.min = getMinute(7);
1196  }
1197  else
1198  {
1199  tmn2 = breakTime(h0->head.burn_time);
1200 
1201  new_ephem.time.year = tmn2->tm_year+1900;
1202  new_ephem.time.mon = tmn2->tm_mon;
1203  new_ephem.time.day = tmn2->tm_mday;
1204  new_ephem.time.hour = tmn2->tm_hour;
1205  new_ephem.time.min = tmn2->tm_min;
1206  }
1207 
1208  bzero((char *)&flux_info, sizeof(flux_info));
1209 
1210  new_ephem.planet = planet;
1211  parseNewEphem(&new_ephem); /* Load appropriate ephem terms */
1212 
1213  p = &new_ephem.planets[planet];
1214  s = &new_ephem.state;
1215  t = &new_ephem.time;
1216 
1217  tt = time(NULL);
1218  if(fluxTableOld(tt))
1219  {
1221  }
1222 
1223  strcpy(flux_info.magic, "FLUX_INFO");
1224  flux_info.planet = planet;
1225 
1226  if(planet == VENUS)
1227  {
1229  for(i=0;i<MAX_VENUS_ENTRIES;i++)
1230  {
1233 
1235  }
1236  strcpy(flux_info.name, "Venus");
1237  flux_info.num = i;
1238  }
1239  else
1240  if(planet == MARS)
1241  {
1243  for(i=0;i<MAX_MARS_ENTRIES;i++)
1244  {
1246  flux_info.values[i].tb = mars_tbright[i].tb;
1247 
1249  }
1250  strcpy(flux_info.name, "Mars");
1251  flux_info.num = i;
1252  }
1253  else
1254  if(planet == JUPITER)
1255  {
1257  for(i=0;i<MAX_JUPITER_ENTRIES;i++)
1258  {
1261 
1263  }
1264  strcpy(flux_info.name, "Jupiter");
1265  flux_info.num = i;
1266  }
1267  else
1268  if(planet == URANUS)
1269  {
1271  for(i=0;i<MAX_URANUS_ENTRIES;i++)
1272  {
1275 
1277  }
1278  strcpy(flux_info.name, "Uranus");
1279  flux_info.num = i;
1280  }
1281  else
1282  if(planet == NEPTUNE)
1283  {
1285  for(i=0;i<MAX_NEPTUNE_ENTRIES;i++)
1286  {
1289 
1291  }
1292  strcpy(flux_info.name, "Neptune");
1293  flux_info.num = i;
1294  }
1295  else /* Only Meurcury & Saturn remain to be modeled */
1296  {
1297  f = 61.0;
1298 
1299  flux_info.bfreq = f;
1300 
1301  i = 0;
1302  while(f<850.0)
1303  {
1304  s->f_sky = (double)f;
1305 
1306  computePlanetFlux(planet, p, t, s, 0);
1307 
1308  flux_info.values[i].freq = f;
1309  flux_info.values[i].tb = p->trj;
1310 
1312 
1313  f += 0.2;
1314  i++;
1315  }
1316 
1317  strcpy(flux_info.name, eph_source_names[planet]);
1318  flux_info.num = i;
1319  }
1320 
1321  if(flag == 2)
1322  {
1323  if(bfreq <= 60.0)
1324  {
1325  flux_info.bfreq = 60.0;
1326  }
1327  else
1328  {
1329  flux_info.bfreq = bfreq;
1330  }
1331 
1332  if(efreq >= 850.0)
1333  {
1334  flux_info.efreq = 850.0;
1335  }
1336  else
1337  {
1338  flux_info.efreq = efreq;
1339  }
1340 
1341  flux_info.manFreq = 1;
1342  }
1343 
1344  if(xgraphic)
1345  {
1346  st_report("Sending Flux Plot to XGraphic");
1348 
1349  sock_write(xgraphic, (char *)&flux_info, sizeof(flux_info));
1350 
1352  }
1353 
1354  return(0);
1355 }
1356 
1357 
1359 {
1360  int flag = 0;
1361  double bfreq, efreq;
1362 
1363  if(strlen(args->secondArg) < 2)
1364  {
1365  st_fail("No Argument for showPlanetFlux()");
1366  return(1);
1367  }
1368 
1369  if(strlen(args->thirdArg))
1370  {
1371  bfreq = atof(args->thirdArg);
1372  flag++;
1373  }
1374 
1375  if(strlen(args->fourthArg))
1376  {
1377  efreq = atof(args->fourthArg);
1378  flag++;
1379  }
1380 
1381  if(flag == 1)
1382  {
1383  st_fail("Usage: pflux planet_name [begin_freq end_freq]");
1384  return(0);
1385  }
1386 
1387  if(!strncasecmp(args->secondArg, "Mercury", 7))
1388  {
1389  dopFlux(MERCURY, flag, bfreq, efreq);
1390  }
1391  else
1392  if(!strncasecmp(args->secondArg, "Venus", 5))
1393  {
1394  dopFlux(VENUS, flag, bfreq, efreq);
1395  }
1396  else
1397  if(!strncasecmp(args->secondArg, "Mars", 4))
1398  {
1399  st_report("Using Mars Flux for Date: %s", marsDate);
1400  dopFlux(MARS, flag, bfreq, efreq);
1401  }
1402  else
1403  if(!strncasecmp(args->secondArg, "Jupiter", 7))
1404  {
1405  dopFlux(JUPITER, flag, bfreq, efreq);
1406  }
1407  else
1408  if(!strncasecmp(args->secondArg, "Saturn", 6))
1409  {
1410  dopFlux(SATURN, flag, bfreq, efreq);
1411  }
1412  else
1413  if(!strncasecmp(args->secondArg, "Neptune", 7))
1414  {
1415  dopFlux(NEPTUNE, flag, bfreq, efreq);
1416  }
1417  else
1418  if(!strncasecmp(args->secondArg, "Uranus", 6))
1419  {
1420  dopFlux(URANUS, flag, bfreq, efreq);
1421  }
1422  else
1423  {
1424  st_fail("Unknown planet: %s", args->secondArg);
1425  return(1);
1426  }
1427 
1428  return(0);
1429 }
1430 
1431 
1432 #ifdef TOMMIE
1433 
1434 int showPlanet()
1435 {
1436  FILE *fp;
1437  char *string, line[256], ebuf[512], timeStr[256], *site;
1438 
1439  if(env->check_freq == 0 || env->check_date == 0)
1440  {
1441  st_warn("Must select freq and date first");
1442 
1443  return(1);
1444  }
1445 
1446  if(env->issmt)
1447  {
1448  site = "SMT";
1449  }
1450  else
1451  {
1452  site = "KITT_PEAK";
1453  }
1454 
1455  sexagesimal(env->ptime, timeStr, HH_MM_SS);
1456 
1457  st_report("Computing Planet Fluxes for Time/Date: %s %9.4f @ site: %s", timeStr, env->date, site);
1458 
1459  sprintf(ebuf, "cd %s/astro; ./astro_planets %f %s %9.4f %s", pkg_home, env->freq, timeStr, env->date, site);
1460 // sprintf(ebuf, "cd ../astro; ./astro_planets %f %s %9.4f %s", /*pkg_home, */env->freq, timeStr, env->date, site);
1461 
1462  st_print("%s\n", ebuf);
1463 
1464  if( (fp = popen(ebuf, "r") ) <= (FILE *)0 )
1465  {
1466  st_fail("Unable to open %s", ebuf);
1467 
1468  return(1);
1469  }
1470 
1471  st_report("");
1472 
1473  while((string = fgets(line, sizeof(line), fp)) != NULL)
1474  {
1475  st_print("%s", line);
1476  }
1477 
1478  st_report("");
1479 
1480  pclose(fp);
1481 
1482  return(0);
1483 }
1484 #endif
1485 
1486 
1487 int isPlanetVar(name)
1488 char *name;
1489 {
1490  int i;
1491  struct EPH_OBJECT *p;
1492 
1494  {
1495  st_report("Looking if arg(%s) is planet", name);
1496  }
1497 
1498  p = &save_planet_values[0];
1499 
1500  if(strlen(p->name) < 2) /* Have Planets been Loaded? */
1501  {
1502  getPlanet();
1503  }
1504 
1505  for(i=0;i<MAX_PLANETS;i++,p++)
1506  {
1507  if(verboseLevel & VERBOSE_PARSE)
1508  {
1509  st_report("isPlanetVar(): Comparing %s to %s", name, p->name);
1510  }
1511 
1512  if(p->name && !strncasecmp(p->name, name, strlen(name)))
1513  {
1514  if(verboseLevel & VERBOSE_PARSE)
1515  {
1516  st_report("isPlanetVar(): Found %s", p->name);
1517  }
1518 
1519  return(0);
1520  }
1521  }
1522 
1523  return(1);
1524 }
1525 
1526 
1528 char *name;
1529 {
1530  int i;
1531  struct EPH_OBJECT *p;
1532 
1534  {
1535  st_report("Looking if arg(%s) is planet", name);
1536  }
1537 
1538  p = &save_planet_values[0];
1539 
1540  if(strlen(p->name) < 2) /* Have Planets been Loaded? */
1541  {
1542  stquiet = 1;
1543  getPlanet();
1544  stquiet = 0;
1545  }
1546 
1547  for(i=0;i<MAX_PLANETS;i++,p++)
1548  {
1549  if(verboseLevel & VERBOSE_PARSE)
1550  {
1551  st_report("isPlanetVar(): Comparing %s to %s", name, p->name);
1552  }
1553 
1554  if(p->name && !strncasecmp(p->name, name, strlen(name)))
1555  {
1556  if(verboseLevel & VERBOSE_PARSE)
1557  {
1558  st_report("isPlanetVar(): Found %s", p->name);
1559  }
1560 
1561  return(1);
1562  }
1563  }
1564 
1565  return(0);
1566 }
1567 
1568 
1569 
1570 int lookUpPlanetVal(p, val, print)
1571 struct EPH_OBJECT *p;
1572 char *val;
1573 int print;
1574 {
1575  void *offset;
1576  char tbuf[256];
1577  struct PLANET_LOOKUP *pl;
1578 
1579  for(pl=&planet_lookup[0];pl->vname;pl++)
1580  {
1581  if(!strcmp(pl->vname, val))
1582  {
1583  offset = (long)pl->offset + (char *)p;
1584 
1585  if(pl->type == CHARSTAR)
1586  {
1587  if(print)
1588  {
1589  sprintf(tbuf, pl->fmt, (char *)offset);
1590  st_print("PLANET: %s.%s = %s\n", p->name, val, tbuf);
1591  }
1592  planet_value = 0.0;
1593  }
1594  else
1595  if(pl->type == DOUBLE)
1596  {
1597  if(print)
1598  {
1599  sprintf(tbuf, pl->fmt, *((double *)offset));
1600  st_print("PLANET: %s.%s = %s\n", p->name, val, tbuf);
1601  }
1602  planet_value = *((double *)offset);
1603  }
1604 
1605  return(0);
1606  }
1607  }
1608 
1609  return(1);
1610 }
1611 
1612 
1613 
1615 char *name;
1616 {
1617  int i;
1618  char *cp;
1619  struct EPH_OBJECT *p;
1620 
1622  {
1623  st_report("printPlanetVar(): Looking up planet variable: %s", name);
1624  }
1625 
1626  p = &save_planet_values[0];
1627 
1628  for(i=0;i<MAX_PLANETS;i++,p++)
1629  {
1630  if(!strncasecmp(p->name, name, strlen(p->name)))
1631  {
1632  if(verboseLevel & VERBOSE_PARSE)
1633  {
1634  st_report("printPlanetVar(): Found %s", p->name);
1635  }
1636 
1637  if(strlen(name) == strlen(p->name)) /* No .arg so print whole thing */
1638  {
1639  st_report("Name: %s", p->name);
1640  st_report("Dbase: %s", p->dbase);
1641  st_report("RA: %15.10f", p->ra);
1642  st_report("Dec: %15.10f", p->dec);
1643  st_report("Illum: %15.10f", p->illum);
1644  st_report("Dmajor: %15.10f", p->dmajor);
1645  st_report("Dminor: %15.10f", p->dminor);
1646  st_report("Sdist: %15.10f", p->sdist);
1647  st_report("Rdot: %15.10f", p->rdot);
1648  st_report("Dist: %15.10f", p->dist);
1649  st_report("Vel: %15.10f", p->vel);
1650  st_report("Sangle: %15.10f", p->sangle);
1651  st_report("Tsrc: %15.10f", p->tsrc);
1652  st_report("TRJ: %15.10f", p->trj);
1653  st_report("Flux: %15.10f", p->flux);
1654  st_report("Flux2: %15.10f", p->flux2);
1655  st_report("TMB: %15.10f", p->tmb);
1656  st_report("Csize: %15.10f", p->csize);
1657 
1658  return(0);
1659  }
1660  else /* Print element of struct */
1661  {
1662  cp = strstr(name, ".");
1663 
1664  if(cp)
1665  {
1666  cp++;
1667 
1668  if(!lookUpPlanetVal(p, cp, 1))
1669  {
1670  return(0);
1671  }
1672  }
1673  else
1674  {
1675  return(1);
1676  }
1677  }
1678  }
1679  }
1680 
1681  return(1);
1682 }
1683 
1684 
1685 /* Return True if Variable Found */
1687 char *name;
1688 double *dret;
1689 {
1690  int ret, oldqt;
1691 
1692  oldqt = stquiet;
1693 
1694 
1695  ret = isPlanetVar(name);
1696  if(!ret)
1697  {
1698  stquiet = 1;
1699  if(!printPlanetVar(name))
1700  {
1701  *dret = planet_value;
1702  stquiet = oldqt;
1703 
1704  return(1);
1705  }
1706  }
1707 
1708  stquiet = oldqt;
1709 
1710  return(0);
1711 }
1712 
struct SOCK * xgraphic
Definition: linuxpops.c:75
struct LP_IMAGE_INFO * h0
Definition: image.c:74
double tsrcInterp(struct TBRIGHT *tb, double f, int n)
Definition: planets.c:456
#define DOUBLE
Definition: defines.h:56
double boltzmann
Definition: env.c:76
int dopFlux(int planet, int flag, double bfreq, double efreq)
Definition: planets.c:1175
double scan
Definition: header.h:35
double rjot(double t, double f)
Definition: planets.c:290
struct TBRIGHT values[MAX_JUPITER_ENTRIES]
Definition: flux.h:25
int showPlanetFlux()
Definition: planets.c:1358
double rdot
Definition: planets.h:70
struct NEW_EPHEM new_ephem
Definition: planets.c:63
double tmb
Definition: planets.h:78
double dminor
Definition: planets.h:68
float efreq
Definition: flux.h:23
double theta_mb
Definition: env.h:272
char pkg_home[256]
Definition: makemem.c:97
int sock_write(struct SOCK *s, char *message, int l)
int first
Definition: dbase.c:106
struct PARSE_STACK * args
Definition: parse.h:196
#define MAX_PLANETS
Definition: planets.h:13
#define MAX_JUPITER_ENTRIES
Definition: planets.h:27
int year
Definition: planets.h:39
double dist
Definition: planets.h:71
#define SCAN_DATE
Definition: planets.c:847
#define MARS
Definition: planets.h:7
#define MERCURY
Definition: planets.h:5
int parseLine(struct EPH_OBJECT *obj, char *name)
Definition: planets.c:140
double f_sky
Definition: planets.h:49
int getHour(int offset)
int mon
Definition: planets.h:40
int day
Definition: planets.h:41
#define ONE_HOUR
Definition: planets.c:61
#define RED
Definition: colors.h:5
char * eph_source_names[]
Definition: strings.c:119
double ptime
Definition: env.h:258
int getMinute(int offset)
#define MAX_TOKENS
Definition: defines.h:40
struct tm * breakTime(double burnT)
Definition: beam.c:246
double tsrc
Definition: planets.h:74
#define T_R0
Definition: beam.c:68
FILE * fp
Definition: linuxpops.c:70
struct EPH_OBJECT planets[MAX_PLANETS]
Definition: planets.h:88
double illum
Definition: planets.h:66
#define NEPTUNE
Definition: planets.h:11
double jfact
Definition: env.h:212
double jupiter_tmb
Definition: env.h:213
#define min(a, b)
Definition: cactus.h:114
double dish_size
Definition: env.h:299
double neptune_tmb
Definition: env.h:229
double tb_lin(double f, double f1, double tb1, double f2, double tb2)
Definition: planets.c:309
double sdist
Definition: planets.h:69
double plancK
Definition: env.c:75
int stquiet
Definition: env.c:90
char * fmt
Definition: planets.c:91
struct TBRIGHT uranus_tbright[MAX_URANUS_ENTRIES]
Definition: planets.c:80
void * offset
Definition: planets.c:93
int issmt
Definition: env.h:63
int check_freq
Definition: env.h:42
char name[80]
Definition: flux.h:15
int getMonth(int offset)
#define LAST_PLOT_FLUX_INFO
Definition: defines.h:165
double csize
Definition: planets.h:79
int fluxTableOld(long t)
Definition: planets.c:536
char * vname
Definition: planets.c:90
double venus_tmb
Definition: env.h:280
float freq
Definition: planets.h:33
double expectedtmb
Definition: env.h:188
int num
Definition: flux.h:18
double date
Definition: env.h:182
char dbase[32]
Definition: planets.h:63
double mars_tmb
Definition: env.h:226
int getYear(int offset)
struct TBRIGHT jupiter_tbright[MAX_JUPITER_ENTRIES]
Definition: planets.c:79
#define SOL
Definition: extern.h:87
int printPlanetVar(char *name)
Definition: planets.c:1614
int sexagesimal(double dang, char *str, int prec)
struct ENVIRONMENT * env
Definition: linuxpops.c:71
char * months[12]
Definition: beam.c:85
double flux2
Definition: planets.h:77
double trj
Definition: planets.h:75
struct TBRIGHT neptune_tbright[MAX_NEPTUNE_ENTRIES]
Definition: planets.c:81
int isPlanet(char *name)
Definition: planets.c:1527
#define dy(i)
char * thirdArg
Definition: parse.h:182
#define USER_DATE
Definition: planets.c:846
char source[64]
Definition: env.h:11
double mercury_tmb
Definition: env.h:227
int isPlanetVar(char *name)
Definition: planets.c:1487
int isSet(int flag)
Definition: parse.c:646
struct HEADER head
Definition: image.h:104
double theta_mb
Definition: planets.h:56
int computePlanetFlux(int planet, struct EPH_OBJECT *obj, struct EPH_TIME *t, struct EPH_STATE *s, int logit)
Definition: planets.c:548
double dec
Definition: planets.h:65
char marsDate[80]
Definition: planets.c:67
int findPlanetVal(char *name, double *dret)
Definition: planets.c:1686
int getPlanet()
Definition: planets.c:850
void st_warn()
#define MAX_VESTA_ENTRIES
Definition: planets.h:30
#define KP_TAPER
Definition: defines.h:17
struct TBRIGHT vesta_tbright[MAX_VESTA_ENTRIES]
Definition: planets.c:82
void st_fail()
#define SATURN
Definition: planets.h:9
Definition: flux.h:13
int strcmp()
#define MG_TAPER
Definition: defines.h:9
#define JUPITER
Definition: planets.h:8
struct EPH_OBJECT save_planet_values[MAX_PLANETS]
Definition: planets.c:84
double frac
Definition: planets.h:80
int getDom(int offset)
struct PLANET_LOOKUP planet_lookup[]
Definition: planets.c:98
struct FLUX_INFO flux_info
Definition: planets.c:86
int lookUpPlanetVal(struct EPH_OBJECT *p, char *val, int print)
Definition: planets.c:1570
#define MG_DIAMETER
Definition: defines.h:5
double vel
Definition: planets.h:72
int plotwin
Definition: flux.h:19
int hour
Definition: planets.h:42
double mars_freqs[]
Definition: planets.c:71
char name[80]
Definition: planets.h:62
int planet
Definition: flux.h:17
char magic[32]
Definition: flux.h:14
double saturn_tmb
Definition: env.h:265
float bfreq
Definition: flux.h:22
int mode
Definition: env.h:75
int plotwin
Definition: env.h:129
#define MODE_SPEC
Definition: defines.h:87
struct TBRIGHT venus_tbright[MAX_VENUS_ENTRIES]
Definition: planets.c:77
int setColor(int c)
Definition: parse.c:2644
int planet
Definition: planets.h:85
#define CHARSTAR
Definition: defines.h:57
void st_report()
double expectedflux
Definition: env.h:187
int last_plot
Definition: env.c:93
#define MAX_MARS_ENTRIES
Definition: planets.h:26
int site
Definition: linuxpops.c:87
float tb
Definition: planets.h:34
int interpl8_debug
Definition: env.c:89
#define DDD_MM_SS_S100
Definition: sex.h:18
double lambda
Definition: planets.h:55
struct EPH_STATE state
Definition: planets.h:86
#define HH_MM_SS
Definition: sex.h:14
char * fourthArg
Definition: parse.h:183
#define R0
Definition: beam.c:67
int loadPlantFluxTables(struct EPH_TIME *t)
Definition: planets.c:323
double ra
Definition: planets.h:64
#define VENUS
Definition: planets.h:6
int parseNewEphem(struct NEW_EPHEM *ephem)
Definition: planets.c:205
double burn_time
Definition: header.h:181
double freq
Definition: env.h:197
double planet_value
Definition: planets.c:75
#define BLACK
Definition: colors.h:4
struct EPH_TIME time
Definition: planets.h:87
double uranus_tmb
Definition: env.h:277
double taper
Definition: env.h:300
char * secondArg
Definition: parse.h:181
int manFreq
Definition: flux.h:20
double dmajor
Definition: planets.h:67
void st_print()
#define ZRO
Definition: planets.c:96
#define KP_DIAMETER
Definition: defines.h:13
int ntokens
Definition: parse.h:173
int check_date
Definition: env.h:40
struct TBRIGHT mars_tbright[MAX_MARS_ENTRIES]
Definition: planets.c:78
int min
Definition: planets.h:43
double sangle
Definition: planets.h:73
#define ENV_DATE
Definition: planets.c:848
int parseCmd(char *buf)
Definition: parse.c:2090
#define URANUS
Definition: planets.h:10
#define MAX_URANUS_ENTRIES
Definition: planets.h:28
#define MAX_VENUS_ENTRIES
Definition: planets.h:25
long fluxTablesLoadTime
Definition: planets.c:69
#define dx(i)
#define VERBOSE_PARSE
Definition: makemem.c:90
#define MAX_NEPTUNE_ENTRIES
Definition: planets.h:29
#define NOW_DATE
Definition: planets.c:845
int verboseLevel
Definition: linuxpops.c:80
int eph_interp(struct NEW_EPHEM *ephem, struct EPH_OBJECT *p1, struct EPH_OBJECT *p2)
Definition: planets.c:175
double flux
Definition: planets.h:76