stars.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include "astro.h"
  10. char* startab = "/lib/sky/estartab";
  11. void
  12. stars(void)
  13. {
  14. double lomoon, himoon, sd;
  15. int wrap, f, i;
  16. char *saop;
  17. static char saoa[100];
  18. sd = 1000*radsec;
  19. lomoon = omoon.point[0].ra - sd;
  20. if(lomoon < 0)
  21. lomoon += pipi;
  22. himoon = omoon.point[NPTS+1].ra + sd;
  23. if(himoon > pipi)
  24. himoon -= pipi;
  25. lomoon *= 12/pi;
  26. himoon *= 12/pi;
  27. wrap = 0;
  28. if(lomoon > himoon)
  29. wrap++;
  30. f = open(startab, OREAD);
  31. if(f < 0) {
  32. fprint(2, "%s?\n", startab);
  33. return;
  34. }
  35. epoch = 1950.0;
  36. epoch = (epoch-1900.0) * 365.24220 + 0.313;
  37. saop = saoa;
  38. /*
  39. * read mean places of stars at epoch of star table
  40. */
  41. loop:
  42. if(rline(f)) {
  43. close(f);
  44. return;
  45. }
  46. rah = atof(line+17);
  47. ram = atof(line+20);
  48. ras = atof(line+23);
  49. alpha = rah + ram/60 + ras/3600;
  50. if(wrap == 0) {
  51. if(alpha < lomoon || alpha > himoon)
  52. goto loop;
  53. } else
  54. if(alpha < lomoon && alpha > himoon)
  55. goto loop;
  56. sao = atof(line+0);
  57. sprint(saop, "%ld", sao);
  58. da = atof(line+30);
  59. dday = atof(line+37);
  60. dmin = atof(line+41);
  61. dsec = atof(line+44);
  62. dd = atof(line+50);
  63. px = atof(line+57);
  64. mag = atof(line+61);
  65. /*
  66. * convert rt ascension and declination to internal format
  67. */
  68. delta = fabs(dday) + dmin/60 + dsec/3600;
  69. if(dday < 0)
  70. delta = -delta;
  71. star();
  72. /*
  73. * if(fabs(beta) > 6.55*radian)
  74. * goto loop;
  75. */
  76. sd = .0896833e0*cos(beta)*sin(lambda-1.3820+.00092422117*eday)
  77. + 0.99597*sin(beta);
  78. if(fabs(sd) > .0183)
  79. goto loop;
  80. for(i=0; i<=NPTS+1; i++)
  81. setobj(&ostar.point[i]);
  82. occult(&omoon, &ostar, 0);
  83. if(occ.t1 >= 0 || occ.t5 >= 0) {
  84. i = PTIME;
  85. if(mag > 2)
  86. i |= DARK;
  87. if(mag < 5)
  88. i |= SIGNIF;
  89. if(occ.t1 >= 0 && occ.e1 >= 0)
  90. event("Occultation of SAO %s begins at ",
  91. saop, "", occ.t1, i);
  92. if(occ.t5 >= 0 && occ.e5 >= 0)
  93. event("Occultation of SAO %s ends at ",
  94. saop, "", occ.t5, i);
  95. while(*saop++)
  96. ;
  97. }
  98. goto loop;
  99. }