1 /******************************************************* 2 3 header file for structures and functions in module sweephe.c 4 for reading and writing stored ephemerides in format ep4 5 a fast precomputed ephemeris used in some Astrodienst applications. 6 7 The design of ephemeris type ep4: 8 In all ASYS and transit application of stored ephemerides 9 except Progressed Declinations Type 56 we need only the 10 longitudes of the planets or nodes. 11 The old EP3 format contains also latitudes, and uses ephemeris time. 12 Therefore we define a new ephemeris format, which is capable of 13 replacing EP3, when some ASYS programs are changed. 14 The ASYS programs requiring different data can receive them 15 by asking the calcserv module. 16 17 We therefore store now a daily ephemeris with only logitudes, ecl and nut. 18 The ephemeris is computed and stored for midnight ephemeris time, i.e. 19 for jd = 2400000.5, 2400001.5 etc. 20 In the ephemeris record for this date, only floor(jd) is kept. 21 22 In many cases universal time (UT) is desired, not ephemeris time. 23 Because computation with our current computers is very cheap for 24 everything except trigonometrci functions, we can afford to 25 build a good interpolation into the ephemeris package. 26 27 The user can request from ephread() ephemeris positions for 28 any (double) jd, not only for midnight ephemeris time. 29 Inside the package the same quick Everett 5th-order interpolator 30 is used as in placalc. 31 It delivers positions within 0.01" for all planets except moon, mercury 32 and true node. Moon and Mercury suffer, because their positions are 33 stored only with a precision of 0.1"; true node suffers because 34 it oscillates quickly with the fastest moon terms. 35 The maximum observed differences between placalc and ephread for 12.00 noon 36 are 0.25" for moon and true node and 0.1" for Mercury; in 80% of the days 37 the differences are less than 0.1". This is significantly better than 38 the implemented precision of the placalc package itself. 39 40 The Everett interpolator delivers without any additional cost also 41 the speed of the planets. This speed is very much better than the 42 speed derived for the inner planets from the mean orbits. 43 44 The returned data from ephread are in an array of centisec, 45 with ecl and nut behind the planets. 46 The default, pflag = 0, returns all. 47 The speeds are returned in the second half of the array; 48 the speed is always there, even when the speed bit has not been set. 49 ***********************************************************/ 50 /* Copyright (C) 1997 - 2021 Astrodienst AG, Switzerland. All rights reserved. 51 52 License conditions 53 ------------------ 54 55 This file is part of Swiss Ephemeris. 56 57 Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author 58 or distributor accepts any responsibility for the consequences of using it, 59 or for whether it serves any particular purpose or works at all, unless he 60 or she says so in writing. 61 62 Swiss Ephemeris is made available by its authors under a dual licensing 63 system. The software developer, who uses any part of Swiss Ephemeris 64 in his or her software, must choose between one of the two license models, 65 which are 66 a) GNU Affero General Public License (AGPL) 67 b) Swiss Ephemeris Professional License 68 69 The choice must be made before the software developer distributes software 70 containing parts of Swiss Ephemeris to others, and before any public 71 service using the developed software is activated. 72 73 If the developer choses the AGPL software license, he or she must fulfill 74 the conditions of that license, which includes the obligation to place his 75 or her whole software project under the AGPL or a compatible license. 76 See https://www.gnu.org/licenses/agpl-3.0.html 77 78 If the developer choses the Swiss Ephemeris Professional license, 79 he must follow the instructions as found in http://www.astro.com/swisseph/ 80 and purchase the Swiss Ephemeris Professional Edition from Astrodienst 81 and sign the corresponding license contract. 82 83 The License grants you the right to use, copy, modify and redistribute 84 Swiss Ephemeris, but only under certain conditions described in the License. 85 Among other things, the License requires that the copyright notices and 86 this notice be preserved on all copies. 87 88 Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl 89 90 The authors of Swiss Ephemeris have no control or influence over any of 91 the derived works, i.e. over software or services created by other 92 programmers which use Swiss Ephemeris functions. 93 94 The names of the authors or of the copyright holder (Astrodienst) must not 95 be used for promoting any software, product or service which uses or contains 96 the Swiss Ephemeris. This copyright notice is the ONLY place where the 97 names of the authors can legally appear, except in cases where they have 98 given special permission in writing. 99 100 The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used 101 for promoting such software, products or services. 102 */ 103 104 # ifndef _EPHE_INCLUDED 105 # define _EPHE_INCLUDED 106 #ifdef __cplusplus 107 extern "C" { 108 #endif 109 110 // definitions must agree wit astrolib.h 111 #define PLACALC_SUN 0 /* used synonymously for earth too */ 112 #define PLACALC_EARTH 0 113 #define PLACALC_MOON 1 114 #define PLACALC_MERCURY 2 115 #define PLACALC_VENUS 3 116 #define PLACALC_MARS 4 117 #define PLACALC_JUPITER 5 118 #define PLACALC_SATURN 6 119 #define PLACALC_URANUS 7 120 #define PLACALC_NEPTUNE 8 121 #define PLACALC_PLUTO 9 122 #define PLACALC_LASTPLANET PLUTO 123 #define PLACALC_MEAN_NODE 10 124 #define PLACALC_TRUE_NODE 11 125 #define PLACALC_CHIRON 12 126 #define PLACALC_LILITH 13 127 #define PLACALC_CALC_N 14 /* number of planets in placalc module */ 128 #define PLACALC_CERES 14 129 #define PLACALC_PALLAS 15 130 #define PLACALC_JUNO 16 131 #define PLACALC_VESTA 17 132 #define PLACALC_EARTHHEL 18 /* heliocentric earth */ 133 #define PLACALC_PFORTUNAE 19 134 // next numbers after 19 are reserved for AC, MC, houses, signs; 135 # define PLACALC_AC 20 136 # define PLACALC_ASC 20 137 # define PLACALC_MC 21 138 # define PLACALC_CALC_N_MC 22 /* number of normal natal factors */ 139 140 # define EP4_BLOCKSIZE sizeof(struct ep4) 141 # if HPUNIX 142 # define EP4_PATH "/home/ephe/" 143 # else 144 # define EP4_PATH "ephe\\" 145 # endif 146 # define EP4_FILE "sep4_" /* packed ephemeris */ 147 # define EP4_NDAYS 10000L /* days per EP4_ file */ 148 # define NDB 10L /* 10 days per block */ 149 150 /* 151 * bits for plalist in ephread(): 152 * the planet flag bits SUN .. PLACALC_CHIRON, ECl, NUT can be set individually. 153 * plalist = 0 is equivalent to all planets and ecl,nut 154 * EP_ALL_PLANETS sets all planet bits SUN .. PLACALC_CHIRON 155 * EP_ALL_BITS sets all bits. 156 */ 157 158 # define EP_NP (PLACALC_CHIRON + 3) /* total number of factors in ep4 */ 159 /* sun .. chiron, ecl, nut */ 160 161 # define EP_ALL_PLANETS ((1 << (PLACALC_CHIRON + 1)) - 1) /* bits 0..12 set */ 162 # define EP_CALC_N (PLACALC_CHIRON+1) /* 13 planets, SUN .. PLACALC_CHIRON */ 163 # define EP_ECL_INDEX (PLACALC_CHIRON + 1) /* index for ecliptic centisec */ 164 # define EP_NUT_INDEX (PLACALC_CHIRON + 2) /* index for nutation centisec */ 165 # define EP_ECL_BIT (1 << EP_ECL_INDEX) 166 # define EP_NUT_BIT (1 << EP_NUT_INDEX) 167 # define EP_ALL_BITS (EP_ALL_PLANETS|EP_ECL_BIT|EP_NUT_BIT) 168 169 // bits for flag in ephread(), values come from placalc compatibility 170 # define EP_BIT_SPEED 16 // must get speed 171 # define EP_BIT_MUST_USE_EPHE 256 172 173 174 struct elon { /* longitudes for 10 days */ 175 short p0m; /* longitude at day 0, minutes */ 176 short p0s; /* 0.01" */ 177 short pd1m; /* delta of days 1, 0.01" */ 178 short pd1s; /* 0.01" */ 179 short pd2[NDB-2]; /* second differences, day 2 .. 9, 180 0.1" moon, mercury, 0.01" others*/ 181 }; 182 183 /* 184 * ep4 is the new ephemeris format for longitude only, ephemeris time 185 */ 186 struct ep4 { 187 short j_10000; /* floor(jd - 0.5) / 10000L; */ 188 short j_rest; /* (jd - 0.5 ) - 10000L * j_10000 189 j_rest is always positive; 190 jd = j_10000 * 10000L + j_rest + 0.5 */ 191 short ecl0m; /* true ecliptic day 0, min ; */ 192 short ecl0s; /* 0.01" */ 193 short ecld1[NDB-1]; /* first differences 0.01", day 1..9 */ 194 short nuts[NDB]; /* nutation in 0.01", day 0..9 */ 195 struct elon elo[PLACALC_CHIRON +1]; /* longitude sun...chiron */ 196 }; 197 198 199 /****************************************** 200 globals exported by module ephe.c 201 ********************************************/ 202 extern FILE *ephfp; 203 204 /****************************************** 205 functions exported by module ephe.c 206 ********************************************/ 207 208 extern centisec *ephread(double jd, int plalist, int flag, char *errtext); 209 /* 210 * This is the only function normally used by applications. 211 * ATTENTION: jd is an absolute Julian date, whereas calc() and deltat() 212 * require Astrodienst-relative Julian dates. 213 * plalist can consist of individual planet bit flags, to indicate that 214 * only these planets are wanted. 215 * plalist = 0 returns all planets, and ecl and nut. 216 * Because the computation is so fast, it is recommended to use pflag = 0. 217 * flag recognizes only the bits CALC_BIT_SPEED and CALC_MUST_USE_EPHE. 218 * If CALC_BIT_SPEED is set, of the planets are returned in the result array 219 * after all longitudes (speeds for ecl and nut are always set to zero). 220 * If CALC_BIT_MUST_USE_EPHE is NOT set, calc() will be used if reading 221 * the ephemeris fails. 222 * cp is the returned pointer, the longitude of the planet p is 223 * at cp[p] and the speed is at cp[p + EP_NP]. 224 * The returned longitudes are always normalized into [0..DEG360[, 225 * except for nut, which is small and close to zero, negative or positive. 226 */ 227 extern double *dephread2(double jd, int plalist, int flag, char *errtext); 228 229 extern int eph4_posit (int jlong, AS_BOOL writeflag, char *errtext); 230 231 extern int ephe_plac2swe(int p); 232 233 extern void shortreorder (UCHAR *p, int n); 234 235 #ifdef __cplusplus 236 } 237 #endif 238 239 # endif /* _EPHE_INCLUDED */ 240