-
Notifications
You must be signed in to change notification settings - Fork 105
/
swetest.c
4082 lines (4022 loc) · 141 KB
/
swetest.c
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
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
swetest.c A test program
Authors: Dieter Koch and Alois Treindl, Astrodienst Zuerich
**************************************************************/
/* Copyright (C) 1997 - 2021 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU Affero General Public License (AGPL)
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the AGPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the AGPL or a compatible license.
See https://www.gnu.org/licenses/agpl-3.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/* attention: Microsoft Compiler does not accept strings > 2048 char */
static char *infocmd0 = "\n\
Swetest computes a complete set of geocentric planetary positions,\n\
for a given date or a sequence of dates.\n\
Input can either be a date or an absolute julian day number.\n\
0:00 (midnight).\n\
With the proper options, swetest can be used to output a printed\n\
ephemeris and transfer the data into other programs like spreadsheets\n\
for graphical display.\n\
Version: \n\
\n";
static char *infocmd1 = "\n\
Command line options:\n\
help commands:\n\
-?, -h display whole info\n\
-hcmd display commands\n\
-hplan display planet numbers\n\
-hform display format characters\n\
-hdate display input date format\n\
-hexamp display examples\n\
-glp report file location of library\n\
input time formats:\n\
-bDATE begin date; e.g. -b1.1.1992 if\n\
Note: the date format is day month year (European style).\n\
-bj... begin date as an absolute Julian day number; e.g. -bj2415020.5\n\
-j... same as -bj\n\
-tHH[:MM[:SS]] input time (as Ephemeris Time)\n\
-ut input date is Universal Time (UT1)\n\
-utHH[:MM[:SS]] input time (as Universal Time)\n\
-utcHH[:MM[:SS]] input time (as Universal Time Coordinated UTC)\n\
H,M,S can have one or two digits. Their limits are unchecked.\n\
output time for eclipses, occultations, risings/settings is UT by default\n\
-lmt output date/time is LMT (with -geopos)\n\
-lat output date/time is LAT (with -geopos)\n\
object, number of steps, step with\n\
-pSEQ planet sequence to be computed.\n\
See the letter coding below.\n\
-dX differential ephemeris: print differential ephemeris between\n\
body X and each body in list given by -p\n\
example: -p2 -d0 -fJl -n366 -b1.1.1992 prints the longitude\n\
distance between SUN (planet 0) and MERCURY (planet 2)\n\
for a full year starting at 1 Jan 1992.\n\
-dhX differential ephemeris: print differential ephemeris between\n\
heliocentric body X and each body in list given by -p\n\
example: -p8 -dh8 -ftl -n36600 -b1.1.1500 -s5 prints the longitude\n\
distance between geocentric and heliocentric Neptune (planet 8)\n\
for 500 year starting at 1 Jan 1500.\n\
Using this option mostly makes sense for a single planet\n\
to find out how much its geocentric and heliocentric positions can differ\n\
over extended periods of time\n\
-DX midpoint ephemeris, works the same way as the differential\n\
mode -d described above, but outputs the midpoint position.\n\
-nN output data for N consecutive timesteps; if no -n option\n\
is given, the default is 1. If the option -n without a\n\
number is given, the default is 20.\n\
-sN timestep N days, default 1. This option is only meaningful\n\
when combined with option -n.\n\
If an 'y' is appended, the time step is in years instead of days, \n\
for example -s10y for a time step of 10 years.\n\
If an 'mo' is appended, the time step is in months instead of days, \n\
for example -s3mo for a time step of 3 months.\n\
If an 'm' is appended, the time step is in minutes instead of days, \n\
for example -s15m for a time step of 15 minutes.\n\
If an 's' is appended, the time step is in seconds instead of days, \n\
for example -s1s for a time step of 1 second.\n\
";
static char *infocmd2 = "\
output format:\n\
-fSEQ use SEQ as format sequence for the output columns;\n\
default is PLBRS.\n\
-head don\'t print the header before the planet data. This option\n\
is useful when you want to paste the output into a\n\
spreadsheet for displaying graphical ephemeris.\n\
+head header before every step (with -s..) \n\
-gPPP use PPP as gap between output columns; default is a single\n\
blank. -g followed by white space sets the\n\
gap to the TAB character; which is useful for data entry\n\
into spreadsheets.\n\
-hor list data for multiple planets 'horizontally' in same line.\n\
all columns of -fSEQ are repeated except time colums tTJyY.\n\
astrological house system:\n\
-house[long,lat,hsys] \n\
include house cusps. The longitude, latitude (degrees with\n\
DECIMAL fraction) and house system letter can be given, with\n\
commas separated, + for east and north. If none are given,\n\
Greenwich UK and Placidus is used: 0.00,51.50,p.\n\
The output lists 12 house cusps, Asc, MC, ARMC, Vertex,\n\
Equatorial Ascendant, co-Ascendant as defined by Walter Koch, \n\
co-Ascendant as defined by Michael Munkasey, and Polar Ascendant. \n\
Houses can only be computed if option -ut is given.\n\
A equal\n\
B Alcabitius\n\
C Campanus\n\
D equal / MC\n\
E equal = A\n\
F Carter poli-equatorial\n\
G 36 Gauquelin sectors\n\
H horizon / azimuth\n\
I Sunshine\n\
i Sunshine alternative\n\
K Koch\n\
L Pullen S-delta\n\
M Morinus\n\
N Whole sign, Aries = 1st house\n\
O Porphyry\n\
P Placidus\n\
Q Pullen S-ratio\n\
R Regiomontanus\n\
S Sripati\n\
T Polich/Page (\"topocentric\")\n\
U Krusinski-Pisa-Goelzer\n\
V equal Vehlow\n\
W equal, whole sign\n\
X axial rotation system/ Meridian houses\n\
Y APC houses\n\
The use of lower case letters is deprecated. They will have a\n\
different meaning in future releases of Swiss Ephemeris.\n\
-hsy[hsys] \n\
house system to be used (for house positions of planets)\n\
for long, lat, hsys, see -house\n\
The use of lower case letters is deprecated. They will have a\n\
different meaning in future releases of Swiss Ephemeris.\n\
";
static char *infocmd3 = "\
-geopos[long,lat,elev] \n\
Geographic position. Can be used for azimuth and altitude\n\
or house cusps calculations.\n\
The longitude, latitude (degrees with DECIMAL fraction)\n\
and elevation (meters) can be given, with\n\
commas separated, + for east and north. If none are given,\n\
Greenwich is used: 0,51.5,0.\n\
For topocentric planet positions please user the parameter -topo\n\
sidereal astrology:\n\
-ay.. ayanamsha, with number of method, e.g. ay0 for Fagan/Bradley\n\
-sid.. sidereal, with number of method (see below)\n\
-sidt0.. dito, but planets are projected on the ecliptic plane of the\n\
reference date of the ayanamsha (more info in general documentation\n\
www.astro.com/swisseph/swisseph.htm)\n\
-sidsp.. dito, but planets are projected on the solar system plane.\n\
(see www.astro.com/swisseph/swisseph.htm)\n\
-sidudef[jd,ay0,...] sidereal, with user defined ayanamsha; \n\
jd=julian day number in TT/ET\n\
ay0=initial value of ayanamsha, \n\
...=optional parameters, comma-sparated:\n\
'jdisut': ayanamsha reference date is UT\n\
'eclt0': project on ecliptic of reference date (like -sidt0..)\n\
'ssyplane': project on solar system plane (like -sidsp..)\n\
e.g. '-sidudef2452163.8333333,25.0,jdisut': ayanamsha is 25.0° on JD 2452163.8333333 UT\n\
number of ayanamsha method:\n\
0 for Fagan/Bradley\n\
1 for Lahiri\n\
2 for De Luce\n\
3 for Raman\n\
4 for Usha/Shashi\n\
5 for Krishnamurti\n\
6 for Djwhal Khul\n\
7 for Yukteshwar\n\
8 for J.N. Bhasin\n\
9 for Babylonian/Kugler 1\n\
10 for Babylonian/Kugler 2\n\
11 for Babylonian/Kugler 3\n\
12 for Babylonian/Huber\n\
13 for Babylonian/Eta Piscium\n\
14 for Babylonian/Aldebaran = 15 Tau\n\
15 for Hipparchos\n\
16 for Sassanian\n\
17 for Galact. Center = 0 Sag\n\
18 for J2000\n\
19 for J1900\n\
20 for B1950\n\
21 for Suryasiddhanta\n\
22 for Suryasiddhanta, mean Sun\n\
23 for Aryabhata\n\
24 for Aryabhata, mean Sun\n\
25 for SS Revati\n\
26 for SS Citra\n\
27 for True Citra\n\
28 for True Revati\n\
29 for True Pushya (PVRN Rao)\n\
30 for Galactic (Gil Brand)\n\
31 for Galactic Equator (IAU1958)\n\
32 for Galactic Equator\n\
33 for Galactic Equator mid-Mula\n\
34 for Skydram (Mardyks)\n\
35 for True Mula (Chandra Hari)\n\
36 Dhruva/Gal.Center/Mula (Wilhelm)\n\
37 Aryabhata 522\n\
38 Babylonian/Britton\n\
39 Vedic/Sheoran\n\
40 Cochrane (Gal.Center = 0 Cap)\n\
41 Galactic Equator (Fiorenza)\n\
42 Vettius Valens\n\
43 Lahiri 1940\n\
44 Lahiri VP285 (1980)\n\
45 Krishnamurti VP291\n\
46 Lahiri ICRC\n\
ephemeris specifications:\n\
-edirPATH change the directory of the ephemeris files \n\
-eswe swiss ephemeris\n\
-ejpl jpl ephemeris (DE431), or with ephemeris file name\n\
-ejplde200.eph \n\
-emos moshier ephemeris\n\
-true true positions\n\
-noaberr no aberration\n\
-nodefl no gravitational light deflection\n\
-noaberr -nodefl astrometric positions\n\
-j2000 no precession (i.e. J2000 positions)\n\
-icrs ICRS (use Internat. Celestial Reference System)\n\
-nonut no nutation \n\
";
static char *infocmd4 = "\
-speed calculate high precision speed \n\
-speed3 'low' precision speed from 3 positions \n\
do not use this option. -speed parameter\n\
is faster and more precise \n\
-iXX force iflag to value XX\n\
-testaa96 test example in AA 96, B37,\n\
i.e. venus, j2450442.5, DE200.\n\
attention: use precession IAU1976\n\
and nutation 1980 (s. swephlib.h)\n\
-testaa95\n\
-testaa97\n\
-roundsec round to seconds\n\
-roundmin round to minutes\n\
-ep use extra precision in output for some data\n\
-dms use dms instead of fractions, at some places\n\
-lim print ephemeris file range\n\
observer position:\n\
-hel compute heliocentric positions\n\
-bary compute barycentric positions (bar. earth instead of node) \n\
-topo[long,lat,elev] \n\
topocentric positions. The longitude, latitude (degrees with\n\
DECIMAL fraction) and elevation (meters) can be given, with\n\
commas separated, + for east and north. If none are given,\n\
Greenwich is used 0.00,51.50,0\n\
-pc... compute planetocentric positions\n\
to specify the central body, use the internal object number\n\
of Swiss Ephemeris, e.g. 3 for Venus, 4 for Mars, \n\
-pc3 Venus-centric \n\
-pc4 Mars-centric \n\
-pc5 Jupiter-centric (barycenter)\n\
-pc9599 Jupiter-centric (center of body)\n\
-pc9699 Saturn-centric (center of body)\n\
For asteroids use MPC number + 10000, e.g.\n\
-pc10433 Eros-centric (Eros = 433 + 10000)\n\
orbital elements:\n\
-orbel compute osculating orbital elements relative to the\n\
mean ecliptic J2000. (Note, all values, including time of\n\
pericenter vary considerably depending on the date for which the\n\
osculating ellipse is calculated\n\
\n\
special events:\n\
-solecl solar eclipse\n\
output 1st line:\n\
eclipse date,\n\
time of maximum (UT):\n\
geocentric angle between centre of Sun and Moon reaches minimum.\n\
core shadow width (negative with total eclipses),\n\
eclipse magnitudes:\n\
1. NASA method (= 2. with partial ecl. and \n\
ratio lunar/solar diameter with total and annular ecl.)\n\
2. fraction of solar diameter covered by moon;\n\
if the value is > 1, it means that Moon covers more than\n\
just the solar disk\n\
3. fraction of solar disc covered by moon (obscuration)\n\
with total and annular eclipses it is the ratio of\n\
the sizes of the solar disk and the lunar disk.\n\
Saros series and eclipse number\n\
Julian day number (6-digit fraction) of maximum\n\
output 2nd line:\n\
start and end times for partial and total phases\n\
delta t in sec\n\
output 3rd line:\n\
geographical longitude and latitude of maximum eclipse,\n\
totality duration at that geographical position,\n\
output with -local, see below.\n\
-occult occultation of planet or star by the moon. Use -p to \n\
specify planet (-pf -xfAldebaran for stars) \n\
output format same as with -solecl, with the following differences:\n\
Magnitude is defined like no. 2. with solar eclipses.\n\
There are no saros series.\n\
";
static char *infocmd5 = "\
-lunecl lunar eclipse\n\
output 1st line:\n\
eclipse date,\n\
time of maximum (UT),\n\
eclipse magnitudes: umbral and penumbral\n\
method as method 2 with solar eclipses\n\
Saros series and eclipse number \n\
Julian day number (6-digit fraction) of maximum\n\
output 2nd line:\n\
6 contacts for start and end of penumbral, partial, and\n\
total phase\n\
delta t in sec\n\
output 3rd line:\n\
geographic position where the Moon is in zenith at maximum eclipse\n\
-local only with -solecl or -occult, if the next event of this\n\
kind is wanted for a given geogr. position.\n\
Use -geopos[long,lat,elev] to specify that position.\n\
If -local is not set, the program \n\
searches for the next event anywhere on earth.\n\
output 1st line:\n\
eclipse date,\n\
time of maximum,\n\
eclipse magnitudes, as with global solar eclipse function \n\
(with occultations: only diameter method, see solar eclipses, method 2)\n\
Saros series and eclipse number (with solar eclipses only)\n\
Julian day number (6-digit fraction) of maximum\n\
output 2nd line:\n\
local eclipse duration for totality (zero with partial occultations)\n\
local four contacts,\n\
delta t in sec\n\
Occultations with the remark \"(daytime)\" cannot be observed because\n\
they are taking place by daylight. Occultations with the remark\n\
\"(sunrise)\" or \"(sunset)\" can be observed only partly because part\n\
of them takes place in daylight.\n\
-hev[type] heliacal events,\n\
type 1 = heliacal rising\n\
type 2 = heliacal setting\n\
type 3 = evening first\n\
type 4 = morning last\n\
type 0 or missing = all four events are listed.\n\
-rise rising and setting of a planet or star.\n\
Use -geopos[long,lat,elev] to specify geographical position.\n\
-metr southern and northern meridian transit of a planet of star\n\
Use -geopos[long,lat,elev] to specify geographical position.\n\
specifications for eclipses:\n\
-total total eclipse (only with -solecl, -lunecl)\n\
-partial partial eclipse (only with -solecl, -lunecl)\n\
-annular annular eclipse (only with -solecl)\n\
-anntot annular-total (hybrid) eclipse (only with -solecl)\n\
-penumbral penumbral lunar eclipse (only with -lunecl)\n\
-central central eclipse (only with -solecl, nonlocal)\n\
-noncentral non-central eclipse (only with -solecl, nonlocal)\n\
";
static char *infocmd6 = "\
specifications for risings and settings:\n\
-norefrac neglect refraction (with option -rise)\n\
-disccenter find rise of disc center (with option -rise)\n\
-discbottom find rise of disc bottom (with option -rise)\n\
-hindu hindu version of sunrise (with option -rise)\n\
specifications for heliacal events:\n\
-at[press,temp,rhum,visr]:\n\
pressure in hPa\n\
temperature in degrees Celsius\n\
relative humidity in %\n\
visual range, interpreted as follows:\n\
> 1 : meteorological range in km\n\
1>visr>0 : total atmospheric coefficient (ktot)\n\
= 0 : calculated from press, temp, rhum\n\
Default values are -at1013.25,15,40,0\n\
-obs[age,SN] age of observer and Snellen ratio\n\
Default values are -obs36,1\n\
-opt[age,SN,binocular,magn,diam,transm]\n\
age and SN as with -obs\n\
0 monocular or 1 binocular\n\
telescope magnification\n\
optical aperture in mm\n\
optical transmission\n\
Default values: -opt36,1,1,1,0,0 (naked eye)\n\
backward search:\n\
-bwd\n";
/* characters still available:
ijklruv
*/
static char *infoplan = "\n\
Planet selection letters:\n\
planetary lists:\n\
d (default) main factors 0123456789mtABCcg\n\
p main factors as above, plus main asteroids DEFGHI\n\
h ficticious factors J..X\n\
a all factors\n\
(the letters above can only appear as a single letter)\n\n\
single body numbers/letters:\n\
0 Sun (character zero)\n\
1 Moon (character 1)\n\
2 Mercury\n\
3 Venus\n\
4 Mars\n\
5 Jupiter\n\
6 Saturn\n\
7 Uranus\n\
8 Neptune\n\
9 Pluto\n\
m mean lunar node\n\
t true lunar node\n\
n nutation\n\
o obliquity of ecliptic\n\
q delta t\n\
y time equation\n\
b ayanamsha\n\
A mean lunar apogee (Lilith, Black Moon) \n\
B osculating lunar apogee \n\
c intp. lunar apogee \n\
g intp. lunar perigee \n\
C Earth (in heliocentric or barycentric calculation)\n\
For planets Jupiter to Pluto the center of body (COB) can be\n\
calculated using the additional parameter -cob\n\
dwarf planets, plutoids\n\
F Ceres\n\
9 Pluto\n\
s -xs136199 Eris\n\
s -xs136472 Makemake\n\
s -xs136108 Haumea\n\
some minor planets:\n\
D Chiron\n\
E Pholus\n\
G Pallas \n\
H Juno \n\
I Vesta \n\
s minor planet, with MPC number given in -xs\n\
some planetary moons and center of body of a planet:\n\
v with moon number given in -xv:\n\
v -xv9501 Io/Jupiter:\n\
v -xv9599 Jupiter, center of body (COB):\n\
v -xv94.. Mars moons:\n\
v -xv95.. Jupiter moons and COB:\n\
v -xv96.. Saturn moons and COB:\n\
v -xv97.. Uranus moons and COB:\n\
v -xv98.. Neptune moons and COB:\n\
v -xv99.. Pluto moons and COB:\n\
The numbers of the moons are given here: \n\
https://www.astro.com/ftp/swisseph/ephe/sat/plmolist.txt\n\
fixed stars:\n\
f fixed star, with name or number given in -xf option\n\
f -xfSirius Sirius\n\
fictitious objects:\n\
J Cupido \n\
K Hades \n\
L Zeus \n\
M Kronos \n\
N Apollon \n\
O Admetos \n\
P Vulkanus \n\
Q Poseidon \n\
R Isis (Sevin) \n\
S Nibiru (Sitchin) \n\
T Harrington \n\
U Leverrier's Neptune\n\
V Adams' Neptune\n\
W Lowell's Pluto\n\
X Pickering's Pluto\n\
Y Vulcan\n\
Z White Moon\n\
w Waldemath's dark Moon\n\
z hypothetical body, with number given in -xz\n\
sidereal time:\n\
x sidereal time\n\
e print a line of labels\n\
\n";
/* characters still available
CcEeMmOoqWwz
*/
static char *infoform = "\n\
Output format SEQ letters:\n\
In the standard setting five columns of coordinates are printed with\n\
the default format PLBRS. You can change the default by providing an\n\
option like -fCCCC where CCCC is your sequence of columns.\n\
The coding of the sequence is like this:\n\
y year\n\
Y year.fraction_of_year\n\
p planet index\n\
P planet name\n\
J absolute juldate\n\
T date formatted like 23.02.1992 \n\
t date formatted like 920223 for 1992 february 23\n\
L longitude in degree ddd mm'ss\"\n\
l longitude decimal\n\
Z longitude ddsignmm'ss\"\n\
S speed in longitude in degree ddd:mm:ss per day\n\
SS speed for all values specified in fmt\n\
s speed longitude decimal (degrees/day)\n\
ss speed for all values specified in fmt\n\
B latitude degree\n\
b latitude decimal\n\
R distance decimal in AU\n\
r distance decimal in AU, Moon in seconds parallax\n\
W distance decimal in light years\n\
w distance decimal in km\n\
q relative distance (1000=nearest, 0=furthest)\n\
A right ascension in hh:mm:ss\n\
a right ascension hours decimal\n\
m Meridian distance \n\
z Zenith distance \n\
D declination degree\n\
d declination decimal\n\
I azimuth degree\n\
i azimuth decimal\n\
H altitude degree\n\
h altitude decimal\n\
K altitude (with refraction) degree\n\
k altitude (with refraction) decimal\n\
G house position in degrees\n\
g house position in degrees decimal\n\
j house number 1.0 - 12.99999\n\
X x-, y-, and z-coordinates ecliptical\n\
x x-, y-, and z-coordinates equatorial\n\
U unit vector ecliptical\n\
u unit vector equatorial\n\
Q l, b, r, dl, db, dr, a, d, da, dd\n\
n nodes (mean): ascending/descending (Me - Ne); longitude decimal\n\
N nodes (osculating): ascending/descending, longitude; decimal\n\
f apsides (mean): perihelion, aphelion, second focal point; longitude dec.\n\
F apsides (osc.): perihelion, aphelion, second focal point; longitude dec.\n\
+ phase angle\n\
- phase\n\
* elongation\n\
/ apparent diameter of disc (without refraction)\n\
= magnitude\n";
static char *infoform2 = "\
v (reserved)\n\
V (reserved)\n\
";
static char *infodate = "\n\
Date entry:\n\
In the interactive mode, when you are asked for a start date,\n\
you can enter data in one of the following formats:\n\
\n\
1.2.1991 three integers separated by a nondigit character for\n\
day month year. Dates are interpreted as Gregorian\n\
after 4.10.1582 and as Julian Calendar before.\n\
Time is always set to midnight (0 h).\n\
If the three letters jul are appended to the date,\n\
the Julian calendar is used even after 1582.\n\
If the four letters greg are appended to the date,\n\
the Gregorian calendar is used even before 1582.\n\
\n\
j2400123.67 the letter j followed by a real number, for\n\
the absolute Julian daynumber of the start date.\n\
Fraction .5 indicates midnight, fraction .0\n\
indicates noon, other times of the day can be\n\
chosen accordingly.\n\
\n\
<RETURN> repeat the last entry\n\
\n\
. stop the program\n\
\n\
+20 advance the date by 20 days\n\
\n\
-10 go back in time 10 days\n";
static char *infoexamp = "\n\
\n\
Examples:\n\
\n\
swetest -p2 -b1.12.1900 -n15 -s2\n\
ephemeris of Mercury (-p2) starting on 1 Dec 1900,\n\
15 positions (-n15) in two-day steps (-s2)\n\
\n\
swetest -p2 -b1.12.1900 -n15 -s2 -fTZ -roundsec -g, -head\n\
same, but output format = date and zodiacal position (-fTZ),\n\
separated by comma (-g,) and rounded to seconds (-roundsec),\n\
without header (-head).\n\
\n\
swetest -ps -xs433 -b1.12.1900\n\
position of asteroid 433 Eros (-ps -xs433)\n\
\n\
swetest -pf -xfAldebaran -b1.1.2000\n\
position of fixed star Aldebaran \n\
\n\
swetest -p1 -d0 -b1.12.1900 -n10 -fPTl -head\n\
angular distance of moon (-p1) from sun (-d0) for 10\n\
consecutive days (-n10).\n\
\n\
swetest -p6 -DD -b1.12.1900 -n100 -s5 -fPTZ -head -roundmin\n\
Midpoints between Saturn (-p6) and Chiron (-DD) for 100\n\
consecutive steps (-n100) with 5-day steps (-s5) with\n\
longitude in degree-sign format (-f..Z) rounded to minutes (-roundmin)\n\
\n\
swetest -b5.1.2002 -p -house12.05,49.50,K -ut12:30\n\
Koch houses for a location in Germany at a given date and time\n\
\n\
swetest -b1.1.2016 -g -fTlbR -p0123456789Dmte -hor -n366 -roundsec\n\
tabular ephemeris (all planets Sun - Pluto, Chiron, mean node, true node)\n\
in one horizontal row, tab-separated, for 366 days. For each planet\n\
list longitude, latitude and geocentric distance.\n";
/**************************************************************/
#include "swephexp.h" /* this includes "sweodef.h" */
#include "swephlib.h"
#include "sweph.h"
#include <math.h>
/*
* programmers warning: It looks much worse than it is!
* Originally swetest.c was a small and simple test program to test
* the main functions of the Swiss Ephemeris and to demonstrate
* its precision.
* It compiles on Unix, on MSDOS and as a non-GUI utility on 16-bit
* and 32-bit windows.
* This portability has forced us into some clumsy constructs, which
* end to hide the actual simplicity of the use of Swiss Ephemeris.
* For example, the mechanism implemented here in swetest.c to find
* the binary ephemeris files overrides the much simpler mechanism
* inside the SwissEph library. This was necessary because we wanted
* swetest.exe to run directly off the CDROM and search with some
* intelligence for ephemeris files already installed on a system.
*/
#if MSDOS
# include <direct.h>
# include <dos.h>
# ifdef _MSC_VER
# include <sys\types.h>
# endif
#ifdef __MINGW32__
# include <sys/stat.h>
#else
# include <sys\stat.h>
#endif
# include <float.h>
#else
# ifdef MACOS
# include <console.h>
# else
# include <sys/stat.h>
# endif
#endif
#define J2000 2451545.0 /* 2000 January 1.5 */
#define square_sum(x) (x[0]*x[0]+x[1]*x[1]+x[2]*x[2])
#define SEFLG_EPHMASK (SEFLG_JPLEPH|SEFLG_SWIEPH|SEFLG_MOSEPH)
#define BIT_ROUND_SEC 1
#define BIT_ROUND_MIN 2
#define BIT_ZODIAC 4
#define BIT_LZEROES 8
#define BIT_TIME_LZEROES 8
#define BIT_TIME_LMT 16
#define BIT_TIME_LAT 32
#define BIT_ALLOW_361 64
#define PLSEL_D "0123456789mtA"
#define PLSEL_P "0123456789mtABCcgDEFGHI"
#define PLSEL_H "JKLMNOPQRSTUVWXYZw"
#define PLSEL_A "0123456789mtABCcgDEFGHIJKLMNOPQRSTUVWXYZw"
#define DIFF_DIFF 'd'
#define DIFF_GEOHEL 'h'
#define DIFF_MIDP 'D'
#define MODE_HOUSE 1
#define MODE_LABEL 2
#define MODE_AYANAMSA 4
#define SEARCH_RANGE_LUNAR_CYCLES 20000
#define LEN_SOUT 1000 // length of output string variable
#define SIND(x) sin((x) * DEGTORAD)
#define COSD(x) cos((x) * DEGTORAD)
#define ACOSD(x) (acos((x)) * RADTODEG)
static char se_pname[AS_MAXCH];
static char *zod_nam[] = {"ar", "ta", "ge", "cn", "le", "vi",
"li", "sc", "sa", "cp", "aq", "pi"};
static char star[AS_MAXCH] = "algol", star2[AS_MAXCH];
static char sastno[AS_MAXCH] = "433";
static char shyp[AS_MAXCH] = "1";
static char *dms(double x, int32 iflag);
static int make_ephemeris_path(char *argv0, char *ephepath);
static int letter_to_ipl(int letter);
static int print_line(int mode, AS_BOOL is_first, int sid_mode);
static int do_special_event(double tjd, int32 ipl, char *star, int32 special_event, int32 special_mode, double *geopos, double *datm, double *dobs, char *serr) ;
static int32 orbital_elements(double tjd_et, int32 ipl, int32 iflag, char *serr);
static char *hms_from_tjd(double x);
static void do_printf(char *info);
static char *hms(double x, int32 iflag);
static void remove_whitespace(char *s);
#if MSDOS
static int cut_str_any(char *s, char *cutlist, char *cpos[], int nmax);
#endif
static int32 call_swe_fixstar(char *star, double te, int32 iflag, double *x, char *serr);
static void jd_to_time_string(double jut, char *stimeout);
static char *our_strcpy(char *to, char *from);
/* globals shared between main() and print_line() */
static char *fmt = "PLBRS";
static char *gap = " ";
static double t, te, tut, jut = 0, tstep = 1;
static int jmon, jday, jyear;
static int ipl = SE_SUN, ipldiff = SE_SUN, nhouses = 12;
static int iplctr = SE_SUN;
static char spnam[AS_MAXCH], spnam2[AS_MAXCH], serr[AS_MAXCH];
static char serr_save[AS_MAXCH], serr_warn[AS_MAXCH];
static int gregflag = SE_GREG_CAL;
static AS_BOOL gregflag_auto = TRUE;
static int diff_mode = 0;
static AS_BOOL use_dms = FALSE;
static AS_BOOL universal_time = FALSE;
static AS_BOOL universal_time_utc = FALSE;
static int32 round_flag = 0;
static int32 time_flag = 0;
static AS_BOOL short_output = FALSE;
static AS_BOOL list_hor = FALSE;
static int32 special_event = 0;
static int32 special_mode = 0;
static AS_BOOL do_orbital_elements = FALSE;
static AS_BOOL hel_using_AV = FALSE;
static AS_BOOL with_header = TRUE;
static AS_BOOL with_chart_link = FALSE;
static double x[6], x2[6], xequ[6], xcart[6], xcartq[6], xobl[6], xaz[6], xt[6], hpos, hpos2, hposj, armc, xsv[6];
static int hpos_meth = 0;
static double geopos[10];
static double attr[20], tret[20], datm[4], dobs[6];
static int32 iflag = 0, iflag2; /* external flag: helio, geo... */
static char *hs_nam[] =
{"undef", "Ascendant", "MC", "ARMC", "Vertex", "equat. Asc.","co-Asc. W.Koch", "co-Asc Munkasey", "Polar Asc."};
static int direction = 1;
static AS_BOOL direction_flag = FALSE;
static AS_BOOL step_in_minutes = FALSE;
static AS_BOOL step_in_seconds = FALSE;
static AS_BOOL step_in_years = FALSE;
static AS_BOOL step_in_months = FALSE;
static int32 helflag = 0;
static double tjd = 2415020.5;
static int32 nstep = 1, istep;
static int32 search_flag = 0;
static char sout[LEN_SOUT];
static int32 whicheph = SEFLG_SWIEPH;
static char *psp;
static int32 norefrac = 0;
static int32 disccenter = 0;
static int32 discbottom = 0;
static int32 hindu = 0;
/* for test of old models only */
static char *astro_models;
static int do_set_astro_models = FALSE;
static char smod[2000];
static AS_BOOL inut = FALSE; /* for Astrodienst internal feature */
static AS_BOOL have_gap_parameter = FALSE;
static AS_BOOL use_swe_fixstar2 = FALSE;
static AS_BOOL output_extra_prec = FALSE;
static AS_BOOL show_file_limit = FALSE;
#define SP_LUNAR_ECLIPSE 1
#define SP_SOLAR_ECLIPSE 2
#define SP_OCCULTATION 3
#define SP_RISE_SET 4
#define SP_MERIDIAN_TRANSIT 5
#define SP_HELIACAL 6
# define SP_MODE_HOW 2 /* an option for Lunar */
# define SP_MODE_LOCAL 8 /* an option for Solar */
# define SP_MODE_HOCAL 4096
# define ECL_LUN_PENUMBRAL 1 /* eclipse types for hocal list */
# define ECL_LUN_PARTIAL 2
# define ECL_LUN_TOTAL 3
# define ECL_SOL_PARTIAL 4
# define ECL_SOL_ANNULAR 5
# define ECL_SOL_TOTAL 6
int main(int argc, char *argv[])
{
char sdate_save[AS_MAXCH];
char s1[AS_MAXCH], s2[AS_MAXCH];
char *sp, *sp2;
char *spno;
char *plsel = PLSEL_D;
#if HPUNIX
char hostname[80];
#endif
int i, j, n, iflag_f = -1, iflgt;
int line_count, line_limit = 36525; // days in a century
double daya;
double top_long = 0.0; /* Greenwich UK */
double top_lat = 51.5;
double top_elev = 0;
AS_BOOL have_geopos = FALSE;
int ihsy = 'P';
int year_start = 0, mon_start = 1, day_start = 1;
AS_BOOL do_houses = FALSE;
char ephepath[AS_MAXCH];
char fname[AS_MAXCH];
char sdate[AS_MAXCH];
char *begindate = NULL;
char stimein[AS_MAXCH];
char stimeout[AS_MAXCH];
int32 iflgret;
AS_BOOL is_first = TRUE;
AS_BOOL with_glp = FALSE;
AS_BOOL with_header_always = FALSE;
AS_BOOL do_ayanamsa = FALSE;
AS_BOOL do_planeto_centric = FALSE;
double aya_t0 = 0, aya_val0 = 0;
AS_BOOL no_speed = FALSE;
int32 sid_mode = SE_SIDM_FAGAN_BRADLEY;
double t2, thour = 0;
double delt;
double tid_acc = 0;
datm[0] = 1013.25; datm[1] = 15; datm[2] = 40; datm[3] = 0;
dobs[0] = 0; dobs[1] = 0;
dobs[2] = 0; dobs[3] = 0; dobs[4] = 0; dobs[5] = 0;
serr[0] = serr_save[0] = serr_warn[0] = sdate_save[0] = '\0';
*stimein = '\0';
strcpy(ephepath, "");
strcpy(fname, SE_FNAME_DFT);
for (i = 1; i < argc; i++) {
if (strncmp(argv[i], "-utc", 4) == 0) {
universal_time = TRUE;
universal_time_utc = TRUE;
if (strlen(argv[i]) > 4) {
strncpy(stimein, argv[i] + 4, 30);
stimein[30] = '\0';
}
} else if (strncmp(argv[i], "-ut", 3) == 0) {
universal_time = TRUE;
if (strlen(argv[i]) > 3) {
strncpy(stimein, argv[i] + 3, 30);
stimein[30] = '\0';
}
} else if (strncmp(argv[i], "-glp", 4) == 0) {
with_glp = TRUE;
} else if (strncmp(argv[i], "-hor", 4) == 0) {
list_hor = TRUE;
} else if (strncmp(argv[i], "-head", 5) == 0) {
with_header = FALSE;
} else if (strncmp(argv[i], "+head", 5) == 0) {
with_header_always = TRUE;
} else if (strcmp(argv[i], "-j2000") == 0) {
iflag |= SEFLG_J2000;
} else if (strcmp(argv[i], "-icrs") == 0) {
iflag |= SEFLG_ICRS;
} else if (strcmp(argv[i], "-cob") == 0) {
iflag |= SEFLG_CENTER_BODY;
} else if (strncmp(argv[i], "-ay", 3) == 0) {
do_ayanamsa = TRUE;
sid_mode = atol(argv[i]+3);
/*swe_set_sid_mode(sid_mode, 0, 0);*/
} else if (strncmp(argv[i], "-sidt0", 6) == 0) {
iflag |= SEFLG_SIDEREAL;
sid_mode = atol(argv[i]+6);
if (sid_mode == 0)
sid_mode = SE_SIDM_FAGAN_BRADLEY;
sid_mode |= SE_SIDBIT_ECL_T0;
/*swe_set_sid_mode(sid_mode, 0, 0);*/
} else if (strncmp(argv[i], "-sidsp", 6) == 0) {
iflag |= SEFLG_SIDEREAL;
sid_mode = atol(argv[i]+6);
if (sid_mode == 0)
sid_mode = SE_SIDM_FAGAN_BRADLEY;
sid_mode |= SE_SIDBIT_SSY_PLANE;
} else if (strncmp(argv[i], "-sidudef", 8) == 0) {
iflag |= SEFLG_SIDEREAL;
sid_mode = SE_SIDM_USER;
strcpy(s1, argv[i] + 8);
aya_t0 = atof(s1);
if ((sp = strchr(s1, ',')) != NULL) {
aya_val0 = atof(sp+1);
}
if (strstr(sp, "jdisut") != NULL) {
sid_mode |= SE_SIDBIT_USER_UT;
}
/*swe_set_sid_mode(sid_mode, 0, 0);*/
} else if (strncmp(argv[i], "-sidbit", 7) == 0) {
sid_mode |= atoi(argv[i]+7);
} else if (strncmp(argv[i], "-sid", 4) == 0) {
iflag |= SEFLG_SIDEREAL;
sid_mode = atol(argv[i]+4);
/*if (sid_mode > 0)
swe_set_sid_mode(sid_mode, 0, 0);*/
} else if (strcmp(argv[i], "-jplhora") == 0) {
iflag |= SEFLG_JPLHOR_APPROX;
} else if (strcmp(argv[i], "-tpm") == 0) {
iflag |= SEFLG_TEST_PLMOON;
} else if (strcmp(argv[i], "-jplhor") == 0) {
iflag |= SEFLG_JPLHOR;
} else if (strncmp(argv[i], "-j", 2) == 0) {
begindate = argv[i] + 1;
} else if (strncmp(argv[i], "-ejpl", 5) == 0) {
whicheph = SEFLG_JPLEPH;
if (*(argv[i]+5) != '\0') {
strncpy(fname, argv[i]+5, AS_MAXCH - 1);
fname[AS_MAXCH-1] = '\0';
}
} else if (strncmp(argv[i], "-edir", 5) == 0) {
if (*(argv[i]+5) != '\0') {
strncpy(ephepath, argv[i]+5, AS_MAXCH - 1);
ephepath[AS_MAXCH-1] = '\0';
}
} else if (strcmp(argv[i], "-eswe") == 0) {
whicheph = SEFLG_SWIEPH;
} else if (strcmp(argv[i], "-emos") == 0) {
whicheph = SEFLG_MOSEPH;
} else if (strncmp(argv[i], "-helflag", 8) == 0) {
helflag = atoi(argv[i]+8);
if (helflag >= SE_HELFLAG_AV)
hel_using_AV = TRUE;
} else if (strcmp(argv[i], "-hel") == 0) {
iflag |= SEFLG_HELCTR;
} else if (strcmp(argv[i], "-bary") == 0) {
iflag |= SEFLG_BARYCTR;
} else if (strncmp(argv[i], "-house", 6) == 0) {
sout[0] = '\0';
sout[1] = '\0';
sp = argv[i] + 6;
if (*sp == '[') sp++;
sscanf(sp, "%lf,%lf,%c", &top_long, &top_lat, sout);
top_elev = 0;
if (*sout) ihsy = sout[0];
do_houses = TRUE;
have_geopos = TRUE;
} else if (strncmp(argv[i], "-hsy", 4) == 0) {
ihsy = *(argv[i] + 4);
if (ihsy == '\0') ihsy = 'P';
if (strlen(argv[i]) > 5)
hpos_meth = atoi(argv[i] + 5);
have_geopos = TRUE;
} else if (strncmp(argv[i], "-topo", 5) == 0) {
iflag |= SEFLG_TOPOCTR;
sp = argv[i] + 5;
if (*sp == '[') sp++;
sscanf(sp, "%lf,%lf,%lf", &top_long, &top_lat, &top_elev);
have_geopos = TRUE;
} else if (strncmp(argv[i], "-geopos", 7) == 0) {
sp = argv[i] + 7;
if (*sp == '[') sp++;
sscanf(sp, "%lf,%lf,%lf", &top_long, &top_lat, &top_elev);
have_geopos = TRUE;
} else if (strcmp(argv[i], "-true") == 0) {
iflag |= SEFLG_TRUEPOS;
} else if (strcmp(argv[i], "-noaberr") == 0) {
iflag |= SEFLG_NOABERR;
} else if (strcmp(argv[i], "-nodefl") == 0) {
iflag |= SEFLG_NOGDEFL;
} else if (strcmp(argv[i], "-nonut") == 0) {
iflag |= SEFLG_NONUT;
} else if (strcmp(argv[i], "-speed3") == 0) {
iflag |= SEFLG_SPEED3;
} else if (strcmp(argv[i], "-speed") == 0) {
iflag |= SEFLG_SPEED;
} else if (strcmp(argv[i], "-nospeed") == 0) {
no_speed = TRUE;
} else if (strncmp(argv[i], "-testaa", 7) == 0) {
whicheph = SEFLG_JPLEPH;
strcpy(fname, SE_FNAME_DE200);
if (strcmp(argv[i]+7, "95") == 0)