-
Notifications
You must be signed in to change notification settings - Fork 3
/
skysub.i
946 lines (795 loc) · 36.5 KB
/
skysub.i
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
%module skysub
%include typemaps.i
%include cpointer.i
%include carrays.i
%array_functions(double, doubleArray);
%array_functions(char, charArray);
%pointer_functions(double,doublep);
%apply double *OUTPUT { double *az, double *parang, double *ra, double *dec,
double *dist, double *longit, double *lat, double *stdz, double *elev,
double *elevsea, double *horiz, double *min, double *max, double *mura,
double *mudec, double *topora, double *topodec, double *topodist,
double *jdout, double *jdb, double *jde, double *del_psi, double *del_ep,
double *ha, double *size, double *glong, double *glat, double *curep,
double *eclong, double *eclat, double *tcor, double *vcor,
double *x, double *y, double *z, double *dra, double *ddec, double *aberra,
double *aberdec};
%apply int *OUTPUT { int *use_dst, int *dow, int *nlun};
%apply double *INOUT {double *xb, double *yb, double *zb, double *xdb,
double *ydb, double *zdb, double *rab, double *decb}
/* %apply struct date_time *OUTPUT {struct date_time *date}
*/
%{
/* Header file for skycalc c-language routines.
ANSI function prototypes, plus brief descriptions, of all the
routines used in skycalc. Also includes constant definitions and
definitions of a few data structures used. */
#include <stdio.h>
#include <math.h>
#include <ctype.h>
/* #include <stdarg.h> */
#include <string.h>
#include <time.h>
/* a couple of the system-dependent magic numbers are defined here */
#define SYS_CLOCK_OK 1 /* 1 means ANSI-standard time libraries do work,
2 means they don't. This is used by compiler switches in file 5 and
the main program. */
#define LOG_FILES_OK 1 /* 1 means that log files are enabled.
Any other value means they're not. */
#define MAX_OBJECTS 500
#define MINSHORT -32767 /* min, max short integers and double precision */
#define MAXSHORT 32767
#define MAXDOUBLE 1.0e38
#define MINDOUBLE -1.0e38
#define BUFSIZE 150
#define XFORM_FROMSTD 1 /* defined quantities for apparent place transforms .. */
#define XFORM_TOSTDEP -1
#define XFORM_JUSTPRE 1
#define XFORM_DOAPPAR 0
#define XFORM_DOABER 1
#define XFORM_NOABER 0
/* some (not all) physical, mathematical, and astronomical constants
used are defined here. */
#define PI 3.14159265358979
#define TWOPI 6.28318530717959
#define PI_OVER_2 1.57079632679490 /* From Abramowitz & Stegun */
#define ARCSEC_IN_RADIAN 206264.8062471
#define DEG_IN_RADIAN 57.2957795130823
#define HRS_IN_RADIAN 3.819718634205
#define KMS_AUDAY 1731.45683633 /* km per sec in 1 AU/day */
#define SPEED_OF_LIGHT 299792.458 /* in km per sec ... exact. */
#define SS_MASS 1.00134198 /* solar system mass in solar units */
#define J2000 2451545. /* Julian date at standard epoch */
#define SEC_IN_DAY 86400.
#define FLATTEN 0.003352813 /* flattening of earth, 1/298.257 */
#define EQUAT_RAD 6378137. /* equatorial radius of earth, meters */
#define EARTHRAD_IN_AU 23454.7910556298 /* number of earth rad in 1 au */
#define ASTRO_UNIT 1.4959787066e11 /* 1 AU in meters */
#define RSUN 6.96000e8 /* IAU 1976 recom. solar radius, meters */
#define RMOON 1.738e6 /* IAU 1976 recom. lunar radius, meters */
#define PLANET_TOL 3. /* flag if nearer than 3 degrees
to a major planet ... */
#define KZEN 0.172 /* zenith extinction, mag, for use
in lunar sky brightness calculations. */
#define FIRSTJD 2415387. /* 1901 Jan 1 -- calendrical limit */
#define LASTJD 2488070. /* 2099 Dec 31 */
/* MAGIC NUMBERS which might depend on how accurately double-
precision floating point is handled on your machine ... */
#define EARTH_DIFF 0.05 /* used in numerical
differentiation to find earth velocity -- this value gives
about 8 digits of numerical accuracy on the VAX, but is
about 3 orders of magnitude larger than the value where roundoff
errors become apparent. */
#define MIDN_TOL 0.00001 /* this is no longer
used -- it was formerly
how close (in days) a julian date has to be to midnight
before a warning flag is printed for the reader. VAX
double precision renders a Julian date considerably
more accurately than this. The day and date are now based
on the same rounding of the julian date, so they should
always agree. */
/* FUNCTION PROTOTYPES and type definitions ....
These are used in breaking the code into function libraries.
They work properly on a strictly ANSI compiler, so they
apparently comply with the ANSI standard format. */
/* these global variables determine whether the program updates the
time and date whenever asked for output. */
struct coord
{
int sign; /* carry sign explicitly since -0 not neg. */
double hh;
double mm;
double ss;
};
struct date_time {
int y;
int mo;
int d;
int h;
int mn;
float s;
};
struct objct {
char name[20];
double ra;
double dec;
double mura;
double mudec;
float ep;
float xtra; /* mag, whatever */
};
/* elements of planetary orbits */
struct elements {
char name[9];
double incl;
double Omega;
double omega;
double a;
double daily;
double ecc;
double L_0;
double mass;
};
char getch();
/* get a (possibly pushed back) character */
void ungetch(int c); /* push character back on input */
/* some functions for getting well-tested input. */
int legal_num_part(char);
int legal_int_part(char);
int legal_command_char(char);
int parsedouble(char *,double *);
/* return values 0 = ok, with number, 1 = found a valid command,
but no number, and -1 = an error of some sort (unexpected char)*/
int getdouble(double *, double, double, char *);
int parseint(char *, int *);
int getint(int *, int, int, char *);
%};
/* char zname[40]; try declaring these globally for smoother behavior
char znabr[3];
char sname[40];
*/
/* "Outside the fence" versions of structures which may be accessed
explictly from Python. */
struct date_time {
int y;
int mo;
int d;
int h;
int mn;
float s;
};
struct coord
{
int sign; /* carry sign explicitly since -0 not neg. */
double hh;
double mm;
double ss;
};
#define MAX_OBJECTS 500
#define MINSHORT -32767 /* min, max short integers and double precision */
#define MAXSHORT 32767
#define MAXDOUBLE 1.0e38
#define MINDOUBLE -1.0e38
#define BUFSIZE 150
#define XFORM_FROMSTD 1 /* defined quantities for apparent place transforms .. */
#define XFORM_TOSTDEP -1
#define XFORM_JUSTPRE 1
#define XFORM_DOAPPAR 0
#define XFORM_DOABER 1
#define XFORM_NOABER 0
/* some (not all) physical, mathematical, and astronomical constants
used are defined here. */
#define PI 3.14159265358979
#define TWOPI 6.28318530717959
#define PI_OVER_2 1.57079632679490 /* From Abramowitz & Stegun */
#define ARCSEC_IN_RADIAN 206264.8062471
#define DEG_IN_RADIAN 57.2957795130823
#define HRS_IN_RADIAN 3.819718634205
#define KMS_AUDAY 1731.45683633 /* km per sec in 1 AU/day */
#define SPEED_OF_LIGHT 299792.458 /* in km per sec ... exact. */
#define SS_MASS 1.00134198 /* solar system mass in solar units */
#define J2000 2451545. /* Julian date at standard epoch */
#define SEC_IN_DAY 86400.
#define FLATTEN 0.003352813 /* flattening of earth, 1/298.257 */
#define EQUAT_RAD 6378137. /* equatorial radius of earth, meters */
#define EARTHRAD_IN_AU 23454.7910556298 /* number of earth rad in 1 au */
#define ASTRO_UNIT 1.4959787066e11 /* 1 AU in meters */
#define RSUN 6.96000e8 /* IAU 1976 recom. solar radius, meters */
#define RMOON 1.738e6 /* IAU 1976 recom. lunar radius, meters */
#define PLANET_TOL 3. /* flag if nearer than 3 degrees
to a major planet ... */
#define KZEN 0.172 /* zenith extinction, mag, for use
in lunar sky brightness calculations. */
#define FIRSTJD 2415387. /* 1901 Jan 1 -- calendrical limit */
#define LASTJD 2488070. /* 2099 Dec 31 */
/* MAGIC NUMBERS which might depend on how accurately double-
precision floating point is handled on your machine ... */
#define EARTH_DIFF 0.05 /* used in numerical
differentiation to find earth velocity -- this value gives
about 8 digits of numerical accuracy on the VAX, but is
about 3 orders of magnitude larger than the value where roundoff
errors become apparent. */
#define MIDN_TOL 0.00001 /* this is no longer
used -- it was formerly
how close (in days) a julian date has to be to midnight
before a warning flag is printed for the reader. VAX
double precision renders a Julian date considerably
more accurately than this. The day and date are now based
on the same rounding of the julian date, so they should
always agree. */
extern int update_on;
extern double update_delta;
extern FILE *sclogfl;
extern double star_tzero, star_terr,
star_period, star_perr; /* for ephemeris calculations ... global */
/* This routine should look almost exactly like printf in terms of its
arguments (format list, then a variable number of arguments
to be formatted and printed). It is designed to behave just
like printf (though perhaps not all format types are supported yet)
EXCEPT that IF the globally-defined file pointer "sclogfl" is
defined, IT ALSO WRITES TO THAT FILE using fprintf. The skeleton
for this came from Kernighan and Ritchie, 2nd edition, page 156 --
their "minprintf" example. I modified it to include the
entire format string (e.g., %8.2f, %7d) and to write to the
file as well as standard output. */
/* elements of K&R hp calculator, basis of commands */
extern char buf[BUFSIZE];
extern int bufp;
extern double bab_to_dec(struct coord);
extern void dec_to_bab (double, struct coord *);
extern int get_line(char *);
extern double get_coord();
extern double myround(double, int);
extern void round_coord(struct coord *, struct coord *, int);
extern void put_hrs(double, int, int, int, int);
extern void put_coords(double, int, int);
extern void put_colon_coords(double, int, int);
extern void fput_hrs(FILE *, double, int, int, int, int);
extern void fput_coords(FILE *, double, int, int);
void load_site(char *, double *longit, double *lat, double *stdz,
int *use_dst, char *, char *, double *elevsea, double *elev,
double *horiz, char *);
/* sets the site-specific quantities; these are
longit = W longitude in decimal hours
lat = N latitude in decimal degrees
stdz = standard time zone offset, hours
elevsea = elevation above sea level (for absolute location)
elev = observatory elevation above horizon, meters
horiz = (derived) added zenith distance for rise/set due
to elevation
use_dst = 0 don't use it
1 use USA convention
2 use Spanish convention
< 0 Southern hemisphere (reserved, unimplimented)
zone_name = name of time zone, e. g. Eastern
zabr = single-character abbreviation of time zone
site_name = name of site. */
extern double atan_circ(double, double); /* x, y ... use atan2 instead ... */
extern void min_max_alt(double, double, double *min, double *max);
/* latitude, dec, min, max */
extern double altit(double, double, double, double *az, double *parang);
/* dec, ha, lat, azimuth, parallactic ... altitude returned. */
extern double secant_z(double);
extern double true_airmass(double); /* arg is sec-z */
extern double ha_alt(double, double, double); /* declination, latitude, altitude.*/
extern double subtend(double, double, double, double);
/* ra1, dec1, ra2, dec2 */
extern int get_pm(double, double *mura, double *mudec); /* dec, mu-ra (s/yr), mu-dec (") */
extern int get_date(struct date_time *date);
extern int get_time(struct date_time *date);
extern double date_to_jd(struct date_time);
extern int day_of_week(double); /* takes jd, returns 0=Mon --> 6 = Sun */
#define IGREG 2299161
extern void caldat(double, struct date_time *date, int *dow);
/* jd, date_time, day of week */
extern double day_of_year(double);
extern void print_day(int);
extern void print_all(double);
extern void print_current(struct date_time, int, int);
/* date, night_date, enter_ut */
extern void print_calendar(double, int *dow);
extern void print_time(double, int); /* jd, precision. */
extern double frac_part(double);
extern double lst(double, double); /* jd, W longitude in hours. */
extern double adj_time(double); /* adjusts decimal time to +-12 */
extern void lpmoon(double, double, double, double *ra, double
*dec, double *dist);
/* double jd,lat,sid,*ra,*dec,*dist; */
extern void lpsun(double, double *ra, double *dec);
/* double jd, *ra, *dec; */
extern void eclrot(double, double *x, double *y, double *z);
/* double jd, *x, *y, *z; */
extern double circulo(double x);
/* modulo 360 degrees. */
extern void geocent(double, double, double, double *x, double *y, double *z);
/* double geolong (dec. hrs), geolat (deg), height (m),
*x_geo, *y_geo, *z_geo; */
extern double etcorr(double);
/* et correction for a given jd */
extern void topocorr(double,double,double,double,double,
double, double *ra, double *dec, double *dist);
/* topocentric correction, arguments are
extern double ra, dec, dist, geolat, lst,
elev,double * topora, *topodec, *topodist */
extern void accumoon(double, double, double, double, double *ra,
double *dec,double *dist,
double *topora, double *topodec, double *topodist);
/*
double jd,geolat,lst,elevsea;
double *geora,*geodec,*geodist,*topora,*topodec,*topodist; */
extern void flmoon(int, int, double *jdout);
/* lunation, phase 0=new, 3=last, jd of phase */
extern float lun_age(double, int *nlun);
/* for jd in, finds day since last new and lunation of last new moon */
extern void print_phase(double);
/* verbal description of moon phase given jd */
extern double lunskybright (double, double, double, double, double, double);
/* Evaluates predicted LUNAR part of sky brightness, in
V magnitudes per square arcsecond, following K. Krisciunas
and B. E. Schaeffer (1991) PASP 103, 1033.
alpha = separation of sun and moon as seen from earth,
converted internally to its supplement,
rho = separation of moon and object,
kzen = zenith extinction coefficient,
altmoon = altitude of moon above horizon,
alt = altitude of object above horizon
moondist = distance to moon, in earth radii
all are in decimal degrees. */
extern void accusun(double, double, double,
double *ra, double *dec, double *dist,
double *topora, double *topodec, double *x,
double *y, double *z);
/* (jd,lst,geolat,ra,dec,dist,topora,topodec,x,y,z) */
/* implemenataion of Jean Meeus' more accurate solar
ephemeris. For ultimate use in helio correction! From
Astronomical Formulae for Calculators, pp. 79 ff. This
gives sun's position wrt *mean* equinox of date, not
*apparent*. Accuracy is << 1 arcmin. Positions given are
geocentric ... parallax due to observer's position on earth is
ignored. This is up to 8 arcsec; routine is usually a little
better than that.
// -- topocentric correction *is* included now. -- //
Light travel time is apparently taken into
account for the ra and dec, but I don't know if aberration is
and I don't know if distance is simlarly antedated.
x, y, and z are heliocentric equatorial coordinates of the
EARTH, referred to mean equator and equinox of date. */
extern double jd_moon_alt(double, double, double, double, double);
/* alt,jdguess,lat,longit,elevsea
returns jd at which moon is at a given
altitude, given jdguess as a starting point. In current version
uses high-precision moon -- execution time does not seem to be
excessive on modern hardware. If it's a problem on your machine,
you can replace calls to 'accumoon' with 'lpmoon' and remove
the 'elevsea' argument. */
extern double jd_sun_alt(double, double, double, double);
/* alt,jdguess,lat,longit;
returns jd at which sun is at a given
altitude, given jdguess as a starting point. Uses
low-precision sun, which is plenty good enough. */
extern float ztwilight(double);
/* double alt;
evaluates a polynomial expansion for the approximate brightening
in magnitudes of the zenith in twilight compared to its
value at full night, as function of altitude of the sun (in degrees).
To get this expression I looked in Meinel, A.,
& Meinel, M., "Sunsets, Twilight, & Evening Skies", Cambridge U.
Press, 1983; there's a graph on p. 38 showing the decline of
zenith twilight. I read points off this graph and fit them with a
polynomial; I don't even know what band there data are for! */
/* Comparison with Ashburn, E. V. 1952, JGR, v.57, p.85 shows that this
is a good fit to his B-band measurements. */
extern void find_dst_bounds(int, double, int, double *jdb, double *jde);
/* int yr;
double stdz;
int use_dst;
double *jdb,*jde;
finds jd's at which daylight savings time begins
and ends. The parameter use_dst allows for a number
of conventions, namely:
0 = don't use it at all (standard time all the time)
1 = use USA convention (1st Sun in April to
last Sun in Oct after 1986; last Sun in April before)
2 = use Spanish convention (for Canary Islands)
-1 = use Chilean convention (CTIO).
-2 = Australian convention (for AAT).
Negative numbers denote sites in the southern hemisphere,
where jdb and jde are beginning and end of STANDARD time for
the year.
It's assumed that the time changes at 2AM local time; so
when clock is set ahead, time jumps suddenly from 2 to 3,
and when time is set back, the hour from 1 to 2 AM local
time is repeated. This could be changed in code if need be. */
extern double zone(int, double, double, double, double);
/*
int use_dst;
double stdz,jd,jdb,jde;
Returns zone time offset when standard time zone is stdz,
when daylight time begins (for the year) on jdb, and ends
(for the year) on jde. This is parochial to the northern
hemisphere.
Extension -- specifying a negative value of use_dst reverses
the logic for the Southern hemisphere; then DST is assumed for
the Southern hemisphere summer (which is the end and beginning
of the year. */
extern double true_jd(struct date_time, int, int, int, double);
/* date, use_dst, enter_ut, night_date, stdz
takes the values in the date-time structure, the standard time
zone (in hours west), the prevailing conventions for date and
time entry, and returns the value of the true julian date. */
extern void print_tz(double, int, double, double , char);
/* double jd;
int use;
double jdb,jde;
char zabr;
prints correct time abbreviation, given zabr as the
single character abbreviation for the time zone,
"D" or "S" depending on daylight or standard (dst
begins at jdb, ends at jde) and current jd. */
extern void xyz_cel(double, double, double, double *ra, double *dec);
/* x,y,z,ra,dec
double x,y,z; cartesian coordinate triplet
double *ra, *dec; corresponding right ascension and declination,
returned in decimal hours and decimal degrees. */
extern void aberrate(double, double *, int);
/* epoch, vec, from_std)
double epoch, decimal year ...
vec[]; celestial unit vector ...
int from_std; 1 = apply aberration, -1 = take aberration out. */
extern void nutation_params(double, double *del_psi, double *del_ep);
/* double date_epoch, *del_psi, *del_ep;
computes the nutation parameters delta psi and
delta epsilon at julian epoch (in years) using approximate
formulae given by Jean Meeus, Astronomical Formulae for
Calculators, Willman-Bell, 1985, pp. 69-70. Accuracy
appears to be a few hundredths of an arcsec or better
and numerics have been checked against his example.
Nutation parameters are returned in radians. */
extern void cooxform(double, double, double, double, double *ra, double *dec,
int, int, int);
/* cooxform(rin, din, std_epoch,
date_epoch, rout, dout, just_precess, do_aber, from_std)
double rin, din; input ra and dec
double std_epoch;
double date_epoch;
double *rout, *dout; output
int just_precess; flag ... 1 does just precession, 0
includes aberration and nutation.
int do_aber; flag ... 1 does aberration, 0 does not.
int from_std; flag ... 1 --> from std to date,
-1 --> from date to std. */
/* General routine for precession and apparent place. Either
transforms from current epoch (given by jd) to a standard
epoch or back again, depending on value of the switch
"from_std"; 1 transforms from standard to current, -1 goes
the other way. Optionally does apparent place including
nutation and annual aberration
(but neglecting diurnal aberration, parallax, proper motion,
and GR deflection of light); switch for this is "just_precess",
1 does only precession, 0 includes other aberration & nutation. */
/* Precession uses a matrix procedures
as outlined in Taff's Computational Spherical Astronomy book.
This is the so-called 'rigorous' method which should give very
accurate answers all over the sky over an interval of several
centuries. Naked eye accuracy holds to ancient times, too.
Precession constants used are the new IAU1976 -- the 'J2000'
system.
Nutation is incorporated into matrix formalism by constructing an
approximate nutation matrix and taking a matrix product with
precession matrix.
Aberration is done by adding the vector velocity of the earth to
the velocity of the light ray .... not kosher relativistically,
but empirically correct to a high order for the angle. */
extern double near_hor_refr(double, double);
/* double app_alt, pressure */
/* Almanac 1992, p. B62 -- ignores temperature variation */
/* formula for near horizon, function-ized for iteration ... */
extern double refract_size(double, double);
/* double alt altitude in degrees
double elev; meters */
/* Almanac for 1992, p. B 62. Ignores variation in temperature
and just assumes T = 20 celsius. */
extern void refract_corr(double *ha, double *dec, double,
double, double *size, int);
/* ha , dec, lat, elev, size, sense
double *ha, *dec, lat, eleve, *size;
int sense; */
/* if sense == 1 , applies refraction to a true ha and dec; if
== -1, de-corrects already refracted coordinates. Uses elevation of
observatory above sea level to estimate a mean atmospheric pressure. */
extern void mass_precess();
extern void print_apparent(double,double,double,double,double,double,double,double,
double);
/* (rain,decin,epochin,mura_sec,mudec,jd,lat,longit,elev)
double rain, decin, epochin, mura_sec, mudec, jd, lat, longit, elev;
*/
extern void galact(double, double, double, double *glong, double *glat);
/* double ra,dec,epoch,*glong,*glat;
Homebrew algorithm for 3-d Euler rotation into galactic.
Perfectly rigorous, and with reasonably accurate input
numbers derived from original IAU definition of galactic
pole (12 49, +27.4, 1950) and zero of long (at PA 123 deg
from pole.) */
extern void gal2radec(double, double, double, double *ra, double *dec);
/* inverts the above. */
extern void eclipt(double, double, double, double, double *curep,
double *eclong, double *eclat);
/* ra,dec,epoch,jd,curep,eclong,eclat */
/* ra in decimal hrs, other coords in dec. deg. */
/* converts ra and dec to ecliptic coords -- precesses to current
epoch first (and hands current epoch back for printing.) */
/* Planetary part, added 1992 August. The intention of this is
to compute low-precision planetary positions for general info
and to inform user if observation might be interfered with by
a planet -- a rarity, but it happens. Also designed to make
handy low-precision planet positions available for casual
planning purposes. Do not try to point blindly right at the
middle of a planetary disk with these routines! */
extern double jd_el; /* ************** */
extern struct elements el[10];
extern void comp_el(double);
/* double jd; */
extern void planetxyz(int, double, double *x, double *y, double *z);
/* int p;
double jd, *x, *y, *z;
produces ecliptic x,y,z coordinates for planet number 'p'
at date jd. */
extern void planetvel(int, double, double *x, double *y, double *z);
/* ( p, jd, vx, vy, vz)
int p;
double jd, *vx, *vy, *vz;
numerically evaluates planet velocity by brute-force
numerical differentiation. Very unsophisticated algorithm. */
/* answer should be in ecliptic coordinates, in AU per day.*/
extern void xyz2000(double jd, double x, double y, double z);
/* double jd, x, y, z;
simply transforms a vector x, y, and z to 2000 coordinates
and prints -- for use in diagnostics. */
extern void earthview(double *, double *, double *, int,
double *ra, double *dec);
/* double *x, *y, *z;
int i;
double *ra, *dec;
given computed planet positions for planets 1-10, computes
ra and dec of i-th planet as viewed from earth (3rd) */
extern void pposns(double,double, double, int, double *, double *);
/* (jd,lat,sid,print_option,planra,plandec)
double jd,lat,sid;
int print_option;
double *planra, *plandec;
computes and optionally prints positions for all the planets.
print_option 1 = print positions, 0 = silent */
extern void barycor(double, double *xb, double *yb, double *zb,
double *xdb, double *ydb, double *zdb);
/* jd,x,y,z,xdot,ydot,zdot)
double jd,*x,*y,*z;
double *xdot,*ydot,*zdot;
This routine takes the position
x,y,z and velocity xdot,ydot,zdot, assumed heliocentric,
and corrects them to the solar system barycenter taking into
account the nine major planets. Routine evolved by inserting
planetary data (given above) into an earlier, very crude
barycentric correction. */
extern void helcor(double, double, double, double, double,
double, double *tcor, double *vcor);
/* jd,ra,dec,ha,lat,elevsea,tcor,vcor
double jd,ra,dec,ha;
double lat,elevsea,*tcor,*vcor;
finds heliocentric correction for given jd, ra, dec, ha, and lat.
tcor is time correction in seconds, vcor velocity in km/s, to
be added to the observed values.
Input ra and dec assumed to be at current epoch */
/* A couple of eclipse predictors.... */
extern float overlap(double, double, double);
/* double r1, r2, sepn;
for two circles of radii r1 and r2,
computes the overlap area in terms of the area of r1
if their centers are separated by
sepn. */
extern void solecl(double, double, double);
/* sun_moon,distmoon,distsun)
double sun_moon,distmoon,distsun; */
extern int lunecl(double, double, double, double, double, double);
/* (georamoon,geodecmoon,geodistmoon,rasun,decsun,distsun)
quickie lunar eclipse predictor -- makes a number of
minor assumptions, e. g. small angle approximations, plus
projects phenomena onto a plane at distance = geocentric
distance of moon . */
extern void planet_alert(double, double, double, double);
/* double jd,ra,dec,tolerance;
/* given a jd, ra, and dec, this computes rough positions
for all the planets, and alerts the user if any of them
are within less than a settable tolerance of the ra and dec. */
int setup_time_place(struct date_time date, double, double, double,
int, char *, char, char *, int, int, double *, double *, double *,
double *, double *, double *);
/* setup_time_place(date,longit,lat,stdz,use_dst,zone_name,
zabr,site_name,enter_ut,night_date,jdut,jdlocal,jdb,jde,sid,
curepoch)
struct date_time date;
extern double lat, longit, stdz, *jdut, *jdlocal, *jdb, *jde, *sid, *curepoch;
int use_dst, enter_ut, night_date;
char zabr;
char *site_name;
char *zone_name;
This takes the date (which contains the time), and the site parameters,
and prints out a banner giving the various dates and times; also
computes and returns various jd's, the sidereal time, and the epoch.
Returns negative number to signal error if date is out of range of
validity of algorithms, or if you specify a bad time during daylight-time
change; returns zero if successful. */
extern void print_tonight(struct date_time,double,double,double,double,double,
char *, double, char *, char, int, double *, double *, int);
/* print_tonight(date,lat,longit,elevsea,elev,horiz,site_name,stdz,
zone_name,zabr,use_dst,jdb,jde,int_long)
struct date_time date;
extern double lat, longit, elevsea, elev, horiz, stdz, *jdb, *jde;
char *site_name, *zone_name, zabr;
int use_dst, shortt_long; short_long is a fossil argument which
allows a slightly shorter version to be printed.
Given site and time information, prints a summary of
the important phenomena for a single night.
The coding in this routine is extremely tortuous ... I even use
the dreaded goto statement! It's inelegant, but (a) the logic is
indeed somewhat complicated and (b) it works. */
extern void print_circumstances(double, double, double, double, double,
double, double, double, double, double, double, double);
/* (objra,objdec,objepoch,jd,curep,
mura_arcs,mura_sec,mudec,sid,lat,elevsea,horiz)
double objra,objdec,objepoch,curep,mura_arcs,mura_sec,mudec,lat,horiz;
double jd,sid,elevsea;
Given object, site, and time information, prints the circumstances
of an observation. The heart of the "calculator" mode. */
extern void hourly_airmass(struct date_time, double, double, double, double, int,
double, double, double, double, double, double, char *);
/* hourly_airmass(date,stdz,lat,longit,horiz,use_dst,objra,objdec,
objepoch, mura_sec,mura_arcs,mudec)
Given a slew of information, prints a table of hourly airmass, etc.
for use in scheduling observations. Also prints sun and moon
altitude when these are relevant. Precesses coordinates as well. */
extern void print_params(struct date_time,int, int, double, double,
double, char *, double, double, int, double, double, double,
double, double, double);
/* print_params(date,enter_ut,night_date,stdz,lat,longit,site_name,
elevsea,elev,use_dst,objra,objdec,objepoch,mura_sec,mura_arcs,
mudec)
struct date_time date;
int enter_ut;
int night_date;
double stdz;
double lat;
double longit;
char *site_name;
double elevsea;
double elev;
int use_dst;
double objra;
double objdec;
double objepoch;
double mura_sec;
double mura_arcs;
double mudec;
This simply prints a nicely formatted list of the *input* parameters
without doing any computations. Helpful for the perplexed user, and
for checking things. */
extern void print_menu();
extern void print_tutorial();
extern void print_examples();
extern void print_accuracy();
extern void print_legalities();
extern void ephemgen(double, double, double, double, double);
/* double ra, dec, ep, lat, longit
Prompts for elements of an ephemeris, then
generates a printout of the *geocentric*
ephemeris of an object. Uses current values of ra and dec;
ignores observatory parameters, which are much more important
for velocity than for time. Not *strictly* correct in that
earth's position in helio-to-geo conversion is computed (strictly
speaking) for heliocentric jd, while ephemeris is for (presumably)
geocentric jd. This makes a difference of at most 30 km/s over c,
or about 1 in 10**4, for the heliocentric correction. Pretty trivial.
Observatory parameters are used in determining observability of
phenomenon.
*/
#define ALT_3 19.47 /* 19.47 degrees altitude => sec z = 3 */
#define ALT_2 30.
#define ALT_15 41.81
#define SID_RATE 1.0027379093 /* sidereal / solar rate */
extern double hrs_up(double, double, double, double);
/* double jdup, jddown, jdeve, jdmorn;
If an object comes up past a given point at jdup,
and goes down at jddown, and evening and morning
are at jdeve and jdmorn, computes how long
object is up *and* it's dark. ... Written as
function 'cause it's done three times below. */
extern void print_air(double, int);
/* double secz;
int prec; */
extern void print_ha_air(double, double, int, int);
/* double ha, secz;
int prec1, prec2; */
extern void obs_season(double, double, double, double, double);
/* double ra, dec, epoch, lat, longit;
prints a table of observability through an observing
season. The idea is to help the observer come up
with an accurately computed "range of acceptable
dates", to quote NOAO proposal forms ... */
extern int get_sys_date(struct date_time *, int, int, int, double, double);
/* date, use_dst, enter_ut, night_date, stdz, toffset)
Reads the system clock; loads up the date structure
to conform to the prevailing conventions for the interpretation
of times. Optionally adds "toffset" minutes to the system
clock, as in x minutes in the future. */
extern void indexx(int, float *, int *);
/* Sort routine from Press et al., "Numerical Recipes in C",
1st edition, Cambridge University Press.
int n,indx[];
float arrin[];
*/
extern struct objct objs[MAX_OBJECTS];
extern int nobjects;
extern int read_obj_list();
/* Reads a list of objects from a file. Here's the rules:
-- each line of file must be formatted as follows:
name rahr ramn rasec decdeg decmin decsec epoch [optional number]
-- the name cannot have any spaces in it.
-- if the declination is negative, the first character of the
declination degrees must be a minus sign, and there can
be no blank space after the minus sign (e. g., -0 18 22 is ok;
- 12 13 14 is NOT ok).
-- other than that, it doesn't matter how you space the lines.
I chose this format because it's the standard format for
pointing files at my home institution. If you'd like to code
another format, please be my guest! */
extern int find_by_name(double *, double *, double, struct date_time, int, int,
int, double, double, double);
/* find_by_name(ra, dec, epoch, date, use_dst, enter_ut, night_date, stdz,
lat, longit)
double *ra, *dec, epoch, stdz, lat, longit;
struct date_time date;
int use_dst, enter_ut, night_date;
finds object by name in list, and sets ra and dec to
those coords if found. Precesses to current value of
epoch. */
extern void type_list(struct date_time date, int, int, int,
double, double, double);
/* type_list(date, use_dst, enter_ut, night_date, stdz,
lat, longit)
double stdz, lat, longit;
struct date_time date;
int use_dst, enter_ut, night_date;
*/
extern int find_nearest(double *rab, double *decb, double, struct date_time,
int, int, int, double, double, double);
/* find_nearest(ra, dec, epoch, date, use_dst, enter_ut, night_date, stdz,
lat, longit)
double *ra, *dec, epoch, stdz, lat, longit;
struct date_time date;
int use_dst, enter_ut, night_date;
given ra,dec, and epoch, sorts items in list with
respect to arc distance away, and queries user
whether to accept. */
extern void set_zenith(struct date_time, int, int, int, double, double,
double, double, double *ra, double *dec);
/* set_zenith(date, use_dst, enter_ut, night_date, stdz, lat,
longit, epoch, ra, dec)
sets RA and dec to zenith as defined by present time and date;
coords are set to actual zenith but in currently used epoch. */
extern void printephase(struct date_time, int, int, int,
double, double, double, double, double, double);
/* printephase(date, use_dst, enter_ut, night_date, stdz, lat,
longit, epoch, ra, dec)
prints phase of a repeating phenomenon at this instant. */
extern int set_to_jd(struct date_time *, int, int, int,
double, double);
/* set_to_jd(date, use_dst, enter_ut, night_date, stdz, jd)
Takes a jd and loads up the date structure
to conform to the prevailing conventions for the interpretation
of times. */
void parellipse(double, double, double, double, double, double,
double *dra, double *ddec, double *aberra, double *aberdec);
/* void parellipse(double jd, double ra, double dec, double epoch, double lat,
* * double longit, double *dra,
* * double *ddec, double *aberra, double *aberdec)
* * */
void radec_to_constel(double, double, double, char *constel);