@typescriptify/sweph 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +422 -0
- package/ephe/semo_18.se1 +0 -0
- package/ephe/sepl_18.se1 +0 -0
- package/originalCode/.eslintrc.json +124 -0
- package/originalCode/.gitattributes +2 -0
- package/originalCode/.github/FUNDING.yml +5 -0
- package/originalCode/.github/workflows/test.yml +35 -0
- package/originalCode/LICENSE +840 -0
- package/originalCode/README.md +91 -0
- package/originalCode/binding.gyp +41 -0
- package/originalCode/constants.js +366 -0
- package/originalCode/docs.gif +0 -0
- package/originalCode/index.d.ts +5115 -0
- package/originalCode/index.js +7 -0
- package/originalCode/index.mjs +109 -0
- package/originalCode/package.json +55 -0
- package/originalCode/src/functions/azalt.cpp +39 -0
- package/originalCode/src/functions/azalt_rev.cpp +35 -0
- package/originalCode/src/functions/calc.cpp +29 -0
- package/originalCode/src/functions/calc_pctr.cpp +31 -0
- package/originalCode/src/functions/calc_ut.cpp +29 -0
- package/originalCode/src/functions/close.cpp +6 -0
- package/originalCode/src/functions/cotrans.cpp +26 -0
- package/originalCode/src/functions/cotrans_sp.cpp +26 -0
- package/originalCode/src/functions/cs2degstr.cpp +19 -0
- package/originalCode/src/functions/cs2lonlatstr.cpp +23 -0
- package/originalCode/src/functions/cs2timestr.cpp +23 -0
- package/originalCode/src/functions/csnorm.cpp +15 -0
- package/originalCode/src/functions/csroundsec.cpp +15 -0
- package/originalCode/src/functions/d2l.cpp +15 -0
- package/originalCode/src/functions/date_conversion.cpp +30 -0
- package/originalCode/src/functions/day_of_week.cpp +15 -0
- package/originalCode/src/functions/degnorm.cpp +15 -0
- package/originalCode/src/functions/deltat.cpp +15 -0
- package/originalCode/src/functions/deltat_ex.cpp +24 -0
- package/originalCode/src/functions/difcs2n.cpp +19 -0
- package/originalCode/src/functions/difcsn.cpp +19 -0
- package/originalCode/src/functions/difdeg2n.cpp +19 -0
- package/originalCode/src/functions/difdegn.cpp +19 -0
- package/originalCode/src/functions/fixstar.cpp +32 -0
- package/originalCode/src/functions/fixstar2.cpp +32 -0
- package/originalCode/src/functions/fixstar2_mag.cpp +28 -0
- package/originalCode/src/functions/fixstar2_ut.cpp +32 -0
- package/originalCode/src/functions/fixstar_mag.cpp +28 -0
- package/originalCode/src/functions/fixstar_ut.cpp +32 -0
- package/originalCode/src/functions/gauquelin_sector.cpp +44 -0
- package/originalCode/src/functions/get_ayanamsa.cpp +15 -0
- package/originalCode/src/functions/get_ayanamsa_ex.cpp +27 -0
- package/originalCode/src/functions/get_ayanamsa_ex_ut.cpp +27 -0
- package/originalCode/src/functions/get_ayanamsa_name.cpp +19 -0
- package/originalCode/src/functions/get_ayanamsa_ut.cpp +15 -0
- package/originalCode/src/functions/get_current_file_data.cpp +28 -0
- package/originalCode/src/functions/get_library_path.cpp +8 -0
- package/originalCode/src/functions/get_orbital_elements.cpp +29 -0
- package/originalCode/src/functions/get_planet_name.cpp +19 -0
- package/originalCode/src/functions/get_tid_acc.cpp +7 -0
- package/originalCode/src/functions/heliacal_pheno_ut.cpp +52 -0
- package/originalCode/src/functions/heliacal_ut.cpp +52 -0
- package/originalCode/src/functions/helio_cross.cpp +33 -0
- package/originalCode/src/functions/helio_cross_ut.cpp +33 -0
- package/originalCode/src/functions/house_name.cpp +20 -0
- package/originalCode/src/functions/house_pos.cpp +36 -0
- package/originalCode/src/functions/houses.cpp +35 -0
- package/originalCode/src/functions/houses_armc.cpp +38 -0
- package/originalCode/src/functions/houses_armc_ex2.cpp +47 -0
- package/originalCode/src/functions/houses_ex.cpp +37 -0
- package/originalCode/src/functions/houses_ex2.cpp +46 -0
- package/originalCode/src/functions/jdet_to_utc.cpp +38 -0
- package/originalCode/src/functions/jdut1_to_utc.cpp +38 -0
- package/originalCode/src/functions/julday.cpp +25 -0
- package/originalCode/src/functions/lat_to_lmt.cpp +27 -0
- package/originalCode/src/functions/lmt_to_lat.cpp +27 -0
- package/originalCode/src/functions/lun_eclipse_how.cpp +34 -0
- package/originalCode/src/functions/lun_eclipse_when.cpp +31 -0
- package/originalCode/src/functions/lun_eclipse_when_loc.cpp +39 -0
- package/originalCode/src/functions/lun_occult_when_glob.cpp +35 -0
- package/originalCode/src/functions/lun_occult_when_loc.cpp +43 -0
- package/originalCode/src/functions/lun_occult_where.cpp +34 -0
- package/originalCode/src/functions/mooncross.cpp +26 -0
- package/originalCode/src/functions/mooncross_node.cpp +30 -0
- package/originalCode/src/functions/mooncross_node_ut.cpp +30 -0
- package/originalCode/src/functions/mooncross_ut.cpp +26 -0
- package/originalCode/src/functions/nod_aps.cpp +42 -0
- package/originalCode/src/functions/nod_aps_ut.cpp +42 -0
- package/originalCode/src/functions/orbit_max_min_true_distance.cpp +37 -0
- package/originalCode/src/functions/pheno.cpp +29 -0
- package/originalCode/src/functions/pheno_ut.cpp +29 -0
- package/originalCode/src/functions/radnorm.cpp +15 -0
- package/originalCode/src/functions/refrac.cpp +23 -0
- package/originalCode/src/functions/refrac_extended.cpp +32 -0
- package/originalCode/src/functions/revjul.cpp +33 -0
- package/originalCode/src/functions/rise_trans.cpp +44 -0
- package/originalCode/src/functions/rise_trans_true_hor.cpp +46 -0
- package/originalCode/src/functions/set_delta_t_userdef.cpp +14 -0
- package/originalCode/src/functions/set_ephe_path.cpp +14 -0
- package/originalCode/src/functions/set_jpl_file.cpp +14 -0
- package/originalCode/src/functions/set_sid_mode.cpp +20 -0
- package/originalCode/src/functions/set_tid_acc.cpp +14 -0
- package/originalCode/src/functions/set_topo.cpp +20 -0
- package/originalCode/src/functions/sidtime.cpp +15 -0
- package/originalCode/src/functions/sidtime0.cpp +21 -0
- package/originalCode/src/functions/sol_eclipse_how.cpp +34 -0
- package/originalCode/src/functions/sol_eclipse_when_glob.cpp +31 -0
- package/originalCode/src/functions/sol_eclipse_when_loc.cpp +39 -0
- package/originalCode/src/functions/sol_eclipse_where.cpp +30 -0
- package/originalCode/src/functions/solcross.cpp +26 -0
- package/originalCode/src/functions/solcross_ut.cpp +26 -0
- package/originalCode/src/functions/split_deg.cpp +35 -0
- package/originalCode/src/functions/time_equ.cpp +25 -0
- package/originalCode/src/functions/utc_time_zone.cpp +48 -0
- package/originalCode/src/functions/utc_to_jd.cpp +37 -0
- package/originalCode/src/functions/version.cpp +8 -0
- package/originalCode/src/functions/vis_limit_mag.cpp +50 -0
- package/originalCode/src/sweph.cpp +150 -0
- package/originalCode/src/sweph.h +119 -0
- package/originalCode/swisseph/swecl.c +6428 -0
- package/originalCode/swisseph/swedate.c +588 -0
- package/originalCode/swisseph/swedate.h +81 -0
- package/originalCode/swisseph/swehel.c +3511 -0
- package/originalCode/swisseph/swehouse.c +3143 -0
- package/originalCode/swisseph/swehouse.h +98 -0
- package/originalCode/swisseph/swejpl.c +958 -0
- package/originalCode/swisseph/swejpl.h +103 -0
- package/originalCode/swisseph/swemmoon.c +1930 -0
- package/originalCode/swisseph/swemplan.c +967 -0
- package/originalCode/swisseph/swemptab.h +10640 -0
- package/originalCode/swisseph/swenut2000a.h +2819 -0
- package/originalCode/swisseph/sweodef.h +326 -0
- package/originalCode/swisseph/sweph.c +8614 -0
- package/originalCode/swisseph/sweph.h +849 -0
- package/originalCode/swisseph/swephexp.h +1020 -0
- package/originalCode/swisseph/swephlib.c +4634 -0
- package/originalCode/swisseph/swephlib.h +189 -0
- package/package.json +28 -0
- package/scripts/gen-swemptab.js +177 -0
- package/scripts/gen-swenut2000a.js +106 -0
- package/src/SwissEph/README.md +268 -0
- package/src/SwissEph/UseCases/Ayanamsa.md +363 -0
- package/src/SwissEph/UseCases/AzimuthAltitude.md +408 -0
- package/src/SwissEph/UseCases/CoordinateSystems.md +337 -0
- package/src/SwissEph/UseCases/DateAndTime.md +368 -0
- package/src/SwissEph/UseCases/DeltaT.md +258 -0
- package/src/SwissEph/UseCases/EphemerisFiles.md +338 -0
- package/src/SwissEph/UseCases/FixedStars.md +300 -0
- package/src/SwissEph/UseCases/GauquelinSectors.md +304 -0
- package/src/SwissEph/UseCases/HeliacalEvents.md +396 -0
- package/src/SwissEph/UseCases/HelioCrossings.md +325 -0
- package/src/SwissEph/UseCases/HousePosition.md +254 -0
- package/src/SwissEph/UseCases/HouseSystems.md +279 -0
- package/src/SwissEph/UseCases/LunarEclipse.md +326 -0
- package/src/SwissEph/UseCases/MeridianTransit.md +279 -0
- package/src/SwissEph/UseCases/MoonCrossings.md +373 -0
- package/src/SwissEph/UseCases/NodesAndApsides.md +307 -0
- package/src/SwissEph/UseCases/Occultation.md +352 -0
- package/src/SwissEph/UseCases/OrbitalElements.md +469 -0
- package/src/SwissEph/UseCases/Phenomena.md +328 -0
- package/src/SwissEph/UseCases/PlanetPositions.md +366 -0
- package/src/SwissEph/UseCases/Planetocentric.md +278 -0
- package/src/SwissEph/UseCases/Refraction.md +314 -0
- package/src/SwissEph/UseCases/RiseAndSet.md +433 -0
- package/src/SwissEph/UseCases/SiderealTime.md +302 -0
- package/src/SwissEph/UseCases/SolarEclipse.md +379 -0
- package/src/SwissEph/UseCases/SunCrossings.md +275 -0
- package/src/SwissEph/UseCases/TopocentricCorrection.md +335 -0
- package/src/SwissEph/errors.ts +10 -0
- package/src/SwissEph/index.ts +823 -0
- package/src/SwissEph/types.ts +291 -0
- package/src/constants.ts +762 -0
- package/src/file-reader.ts +147 -0
- package/src/index.ts +10 -0
- package/src/swecl.ts +4526 -0
- package/src/swedate.ts +376 -0
- package/src/swehel.ts +1939 -0
- package/src/swehouse.ts +2167 -0
- package/src/swejpl.ts +470 -0
- package/src/swemmoon.ts +1318 -0
- package/src/swemplan.ts +585 -0
- package/src/swemptab.ts +4448 -0
- package/src/swenut2000a.ts +2763 -0
- package/src/sweph.ts +3993 -0
- package/src/swephlib.ts +2720 -0
- package/src/types.ts +490 -0
- package/tests/c-style/ayanamsa.test.ts +63 -0
- package/tests/c-style/config.test.ts +96 -0
- package/tests/c-style/crossings.test.ts +81 -0
- package/tests/c-style/date-time.test.ts +114 -0
- package/tests/c-style/eclipses.test.ts +84 -0
- package/tests/c-style/fixed-stars.test.ts +66 -0
- package/tests/c-style/heliacal.test.ts +34 -0
- package/tests/c-style/houses.test.ts +135 -0
- package/tests/c-style/math-utils.test.ts +160 -0
- package/tests/c-style/orbital.test.ts +78 -0
- package/tests/c-style/phenomena.test.ts +42 -0
- package/tests/c-style/planetocentric.test.ts +26 -0
- package/tests/c-style/planets.test.ts +117 -0
- package/tests/c-style/rise-set.test.ts +71 -0
- package/tests/helpers.ts +21 -0
- package/tests/modern/ayanamsa.test.ts +47 -0
- package/tests/modern/calc.test.ts +113 -0
- package/tests/modern/config.test.ts +46 -0
- package/tests/modern/crossings.test.ts +45 -0
- package/tests/modern/eclipses.test.ts +81 -0
- package/tests/modern/errors.test.ts +71 -0
- package/tests/modern/heliacal.test.ts +30 -0
- package/tests/modern/houses.test.ts +87 -0
- package/tests/modern/orbital.test.ts +79 -0
- package/tests/modern/phenomena.test.ts +41 -0
- package/tests/modern/rise-set.test.ts +60 -0
- package/tests/modern/statics.test.ts +99 -0
- package/tests/modern/utilities.test.ts +70 -0
- package/tsconfig.json +20 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
|
|
2
|
+
/************************************************************
|
|
3
|
+
|
|
4
|
+
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
|
|
5
|
+
|
|
6
|
+
************************************************************/
|
|
7
|
+
/* Copyright (C) 1997 - 2021 Astrodienst AG, Switzerland. All rights reserved.
|
|
8
|
+
|
|
9
|
+
License conditions
|
|
10
|
+
------------------
|
|
11
|
+
|
|
12
|
+
This file is part of Swiss Ephemeris.
|
|
13
|
+
|
|
14
|
+
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
|
|
15
|
+
or distributor accepts any responsibility for the consequences of using it,
|
|
16
|
+
or for whether it serves any particular purpose or works at all, unless he
|
|
17
|
+
or she says so in writing.
|
|
18
|
+
|
|
19
|
+
Swiss Ephemeris is made available by its authors under a dual licensing
|
|
20
|
+
system. The software developer, who uses any part of Swiss Ephemeris
|
|
21
|
+
in his or her software, must choose between one of the two license models,
|
|
22
|
+
which are
|
|
23
|
+
a) GNU Affero General Public License (AGPL)
|
|
24
|
+
b) Swiss Ephemeris Professional License
|
|
25
|
+
|
|
26
|
+
The choice must be made before the software developer distributes software
|
|
27
|
+
containing parts of Swiss Ephemeris to others, and before any public
|
|
28
|
+
service using the developed software is activated.
|
|
29
|
+
|
|
30
|
+
If the developer choses the AGPL software license, he or she must fulfill
|
|
31
|
+
the conditions of that license, which includes the obligation to place his
|
|
32
|
+
or her whole software project under the AGPL or a compatible license.
|
|
33
|
+
See https://www.gnu.org/licenses/agpl-3.0.html
|
|
34
|
+
|
|
35
|
+
If the developer choses the Swiss Ephemeris Professional license,
|
|
36
|
+
he must follow the instructions as found in http://www.astro.com/swisseph/
|
|
37
|
+
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
|
|
38
|
+
and sign the corresponding license contract.
|
|
39
|
+
|
|
40
|
+
The License grants you the right to use, copy, modify and redistribute
|
|
41
|
+
Swiss Ephemeris, but only under certain conditions described in the License.
|
|
42
|
+
Among other things, the License requires that the copyright notices and
|
|
43
|
+
this notice be preserved on all copies.
|
|
44
|
+
|
|
45
|
+
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
|
|
46
|
+
|
|
47
|
+
The authors of Swiss Ephemeris have no control or influence over any of
|
|
48
|
+
the derived works, i.e. over software or services created by other
|
|
49
|
+
programmers which use Swiss Ephemeris functions.
|
|
50
|
+
|
|
51
|
+
The names of the authors or of the copyright holder (Astrodienst) must not
|
|
52
|
+
be used for promoting any software, product or service which uses or contains
|
|
53
|
+
the Swiss Ephemeris. This copyright notice is the ONLY place where the
|
|
54
|
+
names of the authors can legally appear, except in cases where they have
|
|
55
|
+
given special permission in writing.
|
|
56
|
+
|
|
57
|
+
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
|
|
58
|
+
for promoting such software, products or services.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
#define PREC_IAU_1976_CTIES 2.0 /* J2000 +/- two centuries */
|
|
62
|
+
#define PREC_IAU_2000_CTIES 2.0 /* J2000 +/- two centuries */
|
|
63
|
+
/* we use P03 for whole ephemeris */
|
|
64
|
+
#define PREC_IAU_2006_CTIES 75.0 /* J2000 +/- 75 centuries */
|
|
65
|
+
|
|
66
|
+
/* For reproducing JPL Horizons to 2 mas (SEFLG_JPLHOR):
|
|
67
|
+
* The user has to keep the following files up to date which contain
|
|
68
|
+
* the earth orientation parameters related to the IAU 1980 nutation
|
|
69
|
+
* theory.
|
|
70
|
+
* Download the file
|
|
71
|
+
* datacenter.iers.org/eop/-/somos/5Rgv/document/tx13iers.u24/eopc04_08.62-now
|
|
72
|
+
* and rename it as eop_1962_today.txt. For current data and estimations for
|
|
73
|
+
* the near future, also download maia.usno.navy.mil/ser7/finals.all and
|
|
74
|
+
* rename it as eop_finals.txt */
|
|
75
|
+
#define DPSI_DEPS_IAU1980_FILE_EOPC04 "eop_1962_today.txt"
|
|
76
|
+
#define DPSI_DEPS_IAU1980_FILE_FINALS "eop_finals.txt"
|
|
77
|
+
#define DPSI_DEPS_IAU1980_TJD0_HORIZONS 2437684.5
|
|
78
|
+
#define HORIZONS_TJD0_DPSI_DEPS_IAU1980 2437684.5
|
|
79
|
+
#define DPSI_IAU1980_TJD0 (64.284 / 1000.0) // arcsec
|
|
80
|
+
#define DEPS_IAU1980_TJD0 (6.151 / 1000.0) // arcsec
|
|
81
|
+
|
|
82
|
+
/* The above files must be available in order to reproduce JPL Horizons
|
|
83
|
+
* in agreement with IERS Conventions 1996 (1992), p. 22.
|
|
84
|
+
* Call swe_calc_ut() with iflag|SEFLG_JPLHOR.
|
|
85
|
+
* This options works only, if the files DPSI_DEPS_IAU1980_FILE_EOPC04
|
|
86
|
+
* and DPSI_DEPS_IAU1980_FILE_FINALS are in the ephemeris path.
|
|
87
|
+
*
|
|
88
|
+
* If the software does not find the earth orientation files
|
|
89
|
+
* in the ephemeris path, then SEFLG_JPLHOR will run as
|
|
90
|
+
* SEFLG_JPLHOR_APPROX.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/* coordinate transformation */
|
|
94
|
+
extern void swi_coortrf(double *xpo, double *xpn, double eps);
|
|
95
|
+
|
|
96
|
+
/* coordinate transformation */
|
|
97
|
+
extern void swi_coortrf2(double *xpo, double *xpn, double sineps, double coseps);
|
|
98
|
+
|
|
99
|
+
/* cartesian to polar coordinates */
|
|
100
|
+
extern void swi_cartpol(double *x, double *l);
|
|
101
|
+
|
|
102
|
+
/* cartesian to polar coordinates with velocity */
|
|
103
|
+
extern void swi_cartpol_sp(double *x, double *l);
|
|
104
|
+
extern void swi_polcart_sp(double *l, double *x);
|
|
105
|
+
|
|
106
|
+
/* polar to cartesian coordinates */
|
|
107
|
+
extern void swi_polcart(double *l, double *x);
|
|
108
|
+
|
|
109
|
+
/* GCRS to J2000 */
|
|
110
|
+
extern void swi_bias(double *x, double tjd, int32 iflag, AS_BOOL backward);
|
|
111
|
+
extern void swi_get_eop_time_range(void);
|
|
112
|
+
/* GCRS to FK5 */
|
|
113
|
+
extern void swi_icrs2fk5(double *x, int32 iflag, AS_BOOL backward);
|
|
114
|
+
|
|
115
|
+
/* precession */
|
|
116
|
+
extern int swi_precess(double *R, double J, int32 iflag, int direction );
|
|
117
|
+
extern void swi_precess_speed(double *xx, double t, int32 iflag, int direction);
|
|
118
|
+
|
|
119
|
+
extern int32 swi_guess_ephe_flag(void);
|
|
120
|
+
|
|
121
|
+
/* from sweph.c, light deflection, aberration, etc. */
|
|
122
|
+
extern void swi_deflect_light(double *xx, double dt, int32 iflag);
|
|
123
|
+
extern void swi_aberr_light(double *xx, double *xe, int32 iflag);
|
|
124
|
+
extern int swi_plan_for_osc_elem(int32 iflag, double tjd, double *xx);
|
|
125
|
+
extern int swi_trop_ra2sid_lon(double *xin, double *xout, double *xoutr, int32 iflag);
|
|
126
|
+
extern int swi_trop_ra2sid_lon_sosy(double *xin, double *xout, int32 iflag);
|
|
127
|
+
extern int swi_get_observer(double tjd, int32 iflag,
|
|
128
|
+
AS_BOOL do_save, double *xobs, char *serr);
|
|
129
|
+
extern void swi_force_app_pos_etc(void);
|
|
130
|
+
|
|
131
|
+
/* obliquity of ecliptic */
|
|
132
|
+
extern void swi_check_ecliptic(double tjd, int32 iflag);
|
|
133
|
+
extern double swi_epsiln(double J, int32 iflag);
|
|
134
|
+
extern void swi_ldp_peps(double J, double *dpre, double *deps);
|
|
135
|
+
|
|
136
|
+
/* nutation */
|
|
137
|
+
extern void swi_check_nutation(double tjd, int32 iflag);
|
|
138
|
+
extern int swi_nutation(double J, int32 iflag, double *nutlo);
|
|
139
|
+
extern void swi_nutate(double *xx, int32 iflag, AS_BOOL backward);
|
|
140
|
+
|
|
141
|
+
extern void swi_mean_lunar_elements(double tjd,
|
|
142
|
+
double *node, double *dnode,
|
|
143
|
+
double *peri, double *dperi);
|
|
144
|
+
/* */
|
|
145
|
+
extern double swi_mod2PI(double x);
|
|
146
|
+
|
|
147
|
+
/* evaluation of chebyshew series and derivative */
|
|
148
|
+
extern double swi_echeb(double x, double *coef, int ncf);
|
|
149
|
+
extern double swi_edcheb(double x, double *coef, int ncf);
|
|
150
|
+
|
|
151
|
+
/* cross product of vectors */
|
|
152
|
+
extern void swi_cross_prod(double *a, double *b, double *x);
|
|
153
|
+
/* dot product of vecotrs */
|
|
154
|
+
extern double swi_dot_prod_unit(double *x, double *y);
|
|
155
|
+
|
|
156
|
+
extern double swi_angnorm(double x);
|
|
157
|
+
|
|
158
|
+
/* generation of SWISSEPH file names */
|
|
159
|
+
extern void swi_gen_filename(double tjd, int ipli, char *fname);
|
|
160
|
+
|
|
161
|
+
/* cyclic redundancy checksum (CRC), 32 bit */
|
|
162
|
+
extern uint32 swi_crc32(unsigned char *buf, int len);
|
|
163
|
+
|
|
164
|
+
extern int swi_cutstr(char *s, char *cutlist, char *cpos[], int nmax);
|
|
165
|
+
extern char *swi_right_trim(char *s);
|
|
166
|
+
|
|
167
|
+
extern double swi_kepler(double E, double M, double ecce);
|
|
168
|
+
|
|
169
|
+
extern char *swi_get_fict_name(int32 ipl, char *s);
|
|
170
|
+
|
|
171
|
+
extern void swi_FK4_FK5(double *xp, double tjd);
|
|
172
|
+
|
|
173
|
+
extern char *swi_strcpy(char *to, char *from);
|
|
174
|
+
extern char *swi_strncpy(char *to, char *from, size_t n);
|
|
175
|
+
|
|
176
|
+
extern double swi_deltat_ephe(double tjd_ut, int32 epheflag);
|
|
177
|
+
|
|
178
|
+
#ifdef TRACE
|
|
179
|
+
# define TRACE_COUNT_MAX 10000
|
|
180
|
+
extern TLS FILE *swi_fp_trace_c;
|
|
181
|
+
extern TLS FILE *swi_fp_trace_out;
|
|
182
|
+
extern TLS int32 swi_trace_count;
|
|
183
|
+
extern void swi_open_trace(char *serr);
|
|
184
|
+
static const char *fname_trace_c = "swetrace.c";
|
|
185
|
+
static const char *fname_trace_out = "swetrace.txt";
|
|
186
|
+
#ifdef FORCE_IFLAG
|
|
187
|
+
static const char *fname_force_flg = "force.flg";
|
|
188
|
+
#endif
|
|
189
|
+
#endif /* TRACE */
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@typescriptify/sweph",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Swiss Ephemeris for TypeScript — high-precision astronomical calculations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"typecheck": "tsc --noEmit",
|
|
10
|
+
"test": "npx tsx --test tests/c-style/*.test.ts tests/modern/*.test.ts"
|
|
11
|
+
},
|
|
12
|
+
"keywords": [
|
|
13
|
+
"astronomy",
|
|
14
|
+
"astrology",
|
|
15
|
+
"ephemeris",
|
|
16
|
+
"swiss-ephemeris",
|
|
17
|
+
"planetary-positions",
|
|
18
|
+
"houses",
|
|
19
|
+
"eclipses",
|
|
20
|
+
"typescript"
|
|
21
|
+
],
|
|
22
|
+
"author": "",
|
|
23
|
+
"license": "AGPL-3.0",
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^25.3.0",
|
|
26
|
+
"typescript": "^5.9.3"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Parse swemptab.h and generate swemptab.ts with actual coefficient data.
|
|
4
|
+
*/
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const src = fs.readFileSync(
|
|
9
|
+
path.join(__dirname, '..', 'originalCode', 'swisseph', 'swemptab.h'),
|
|
10
|
+
'utf8'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const lines = src.split('\n');
|
|
14
|
+
|
|
15
|
+
// Planet prefixes in order
|
|
16
|
+
const planets = [
|
|
17
|
+
{ prefix: 'mer', name: 'Mercury', varName: 'mer404' },
|
|
18
|
+
{ prefix: 'ven', name: 'Venus', varName: 'ven404' },
|
|
19
|
+
{ prefix: 'ear', name: 'Earth', varName: 'ear404' },
|
|
20
|
+
{ prefix: 'mar', name: 'Mars', varName: 'mar404' },
|
|
21
|
+
{ prefix: 'jup', name: 'Jupiter', varName: 'jup404' },
|
|
22
|
+
{ prefix: 'sat', name: 'Saturn', varName: 'sat404' },
|
|
23
|
+
{ prefix: 'ura', name: 'Uranus', varName: 'ura404' },
|
|
24
|
+
{ prefix: 'nep', name: 'Neptune', varName: 'nep404' },
|
|
25
|
+
{ prefix: 'plu', name: 'Pluto', varName: 'plu404' },
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// Find line numbers for each array
|
|
29
|
+
function findArrayBounds(name) {
|
|
30
|
+
let start = -1, end = -1;
|
|
31
|
+
for (let i = 0; i < lines.length; i++) {
|
|
32
|
+
if (lines[i].match(new RegExp(`^static (double|signed char|const signed char)\\s+${name}\\[\\]`))) {
|
|
33
|
+
start = i + 1; // next line after declaration
|
|
34
|
+
}
|
|
35
|
+
if (start >= 0 && end < 0 && lines[i].trim() === '};') {
|
|
36
|
+
end = i;
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
// also handle -1 as last element (for args arrays)
|
|
40
|
+
if (start >= 0 && end < 0 && lines[i].trim().match(/^-1$/)) {
|
|
41
|
+
end = i + 1; // include the -1 line
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { start, end };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function findStructBounds(name) {
|
|
49
|
+
let start = -1, end = -1;
|
|
50
|
+
for (let i = 0; i < lines.length; i++) {
|
|
51
|
+
if (lines[i].match(new RegExp(`^static struct plantbl\\s+${name}`))) {
|
|
52
|
+
start = i;
|
|
53
|
+
}
|
|
54
|
+
if (start >= 0 && end < 0 && lines[i].trim() === '};') {
|
|
55
|
+
end = i;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return { start, end };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function extractNumbers(startLine, endLine) {
|
|
63
|
+
const nums = [];
|
|
64
|
+
for (let i = startLine; i < endLine; i++) {
|
|
65
|
+
const line = lines[i];
|
|
66
|
+
// Extract all numbers (integers, floats, scientific notation, possibly negative)
|
|
67
|
+
const matches = line.match(/-?\d+(\.\d+)?(e[+-]?\d+)?/gi);
|
|
68
|
+
if (matches) {
|
|
69
|
+
nums.push(...matches.map(Number));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return nums;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function extractSignedChars(startLine, endLine) {
|
|
76
|
+
const nums = [];
|
|
77
|
+
for (let i = startLine; i < endLine; i++) {
|
|
78
|
+
const line = lines[i];
|
|
79
|
+
const matches = line.match(/-?\d+/g);
|
|
80
|
+
if (matches) {
|
|
81
|
+
nums.push(...matches.map(Number));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return nums;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function formatDoubleArray(data, cols = 4) {
|
|
88
|
+
const rows = [];
|
|
89
|
+
for (let i = 0; i < data.length; i += cols) {
|
|
90
|
+
const chunk = data.slice(i, i + cols);
|
|
91
|
+
rows.push(chunk.map(v => String(v)).join(',') + ',');
|
|
92
|
+
}
|
|
93
|
+
return rows.join('\n');
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function formatIntArray(data, cols = 10) {
|
|
97
|
+
const rows = [];
|
|
98
|
+
for (let i = 0; i < data.length; i += cols) {
|
|
99
|
+
const chunk = data.slice(i, i + cols);
|
|
100
|
+
rows.push(chunk.map(v => String(v)).join(',') + ',');
|
|
101
|
+
}
|
|
102
|
+
return rows.join('\n');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Parse struct plantbl
|
|
106
|
+
function parseStruct(name) {
|
|
107
|
+
const bounds = findStructBounds(name);
|
|
108
|
+
if (bounds.start < 0) throw new Error(`Struct ${name} not found`);
|
|
109
|
+
const structLines = lines.slice(bounds.start, bounds.end + 1).join('\n');
|
|
110
|
+
|
|
111
|
+
// Extract max_harmonic array
|
|
112
|
+
const mhMatch = structLines.match(/\{\s*([\d,\s]+)\s*\}/);
|
|
113
|
+
const maxHarmonic = mhMatch[1].split(',').map(s => parseInt(s.trim())).filter(n => !isNaN(n));
|
|
114
|
+
|
|
115
|
+
// Extract max_power_of_t (single digit after the closing brace of max_harmonic)
|
|
116
|
+
const afterMh = structLines.slice(mhMatch.index + mhMatch[0].length);
|
|
117
|
+
const mptMatch = afterMh.match(/(\d+)/);
|
|
118
|
+
const maxPowerOfT = parseInt(mptMatch[1]);
|
|
119
|
+
|
|
120
|
+
// Extract distance (last number before };, may or may not be scientific notation)
|
|
121
|
+
// Get all numbers from the struct text
|
|
122
|
+
const allNums = structLines.match(/-?\d+(\.\d+)?(e[+-]?\d+)?/gi);
|
|
123
|
+
// Distance is the last one before the closing brace
|
|
124
|
+
const distance = parseFloat(allNums[allNums.length - 1]);
|
|
125
|
+
|
|
126
|
+
return { maxHarmonic, maxPowerOfT, distance };
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
let output = `/*************************************************************
|
|
130
|
+
* swemptab.ts — Moshier semi-analytical planetary ephemeris tables
|
|
131
|
+
* Auto-generated from swemptab.h
|
|
132
|
+
*
|
|
133
|
+
* Copyright (C) 1997 - 2021 Astrodienst AG, Switzerland. (AGPL)
|
|
134
|
+
*************************************************************/
|
|
135
|
+
|
|
136
|
+
import type { Plantbl } from './types';
|
|
137
|
+
|
|
138
|
+
`;
|
|
139
|
+
|
|
140
|
+
for (const planet of planets) {
|
|
141
|
+
console.log(`Processing ${planet.name}...`);
|
|
142
|
+
|
|
143
|
+
// Find and extract all arrays
|
|
144
|
+
const tablBounds = findArrayBounds(`${planet.prefix}tabl`);
|
|
145
|
+
const tabbBounds = findArrayBounds(`${planet.prefix}tabb`);
|
|
146
|
+
const tabrBounds = findArrayBounds(`${planet.prefix}tabr`);
|
|
147
|
+
const argsBounds = findArrayBounds(`${planet.prefix}args`);
|
|
148
|
+
|
|
149
|
+
const tabl = extractNumbers(tablBounds.start, tablBounds.end);
|
|
150
|
+
const tabb = extractNumbers(tabbBounds.start, tabbBounds.end);
|
|
151
|
+
const tabr = extractNumbers(tabrBounds.start, tabrBounds.end);
|
|
152
|
+
const args = extractSignedChars(argsBounds.start, argsBounds.end);
|
|
153
|
+
|
|
154
|
+
const struct = parseStruct(planet.varName);
|
|
155
|
+
|
|
156
|
+
console.log(` tabl: ${tabl.length}, tabb: ${tabb.length}, tabr: ${tabr.length}, args: ${args.length}`);
|
|
157
|
+
console.log(` maxHarmonic: [${struct.maxHarmonic}], maxPowerOfT: ${struct.maxPowerOfT}, distance: ${struct.distance}`);
|
|
158
|
+
|
|
159
|
+
output += `/* ---- ${planet.name} ---- */\n`;
|
|
160
|
+
output += `const ${planet.prefix}Tabl = new Float64Array([\n${formatDoubleArray(tabl)}\n]);\n\n`;
|
|
161
|
+
output += `const ${planet.prefix}Tabb = new Float64Array([\n${formatDoubleArray(tabb)}\n]);\n\n`;
|
|
162
|
+
output += `const ${planet.prefix}Tabr = new Float64Array([\n${formatDoubleArray(tabr)}\n]);\n\n`;
|
|
163
|
+
output += `const ${planet.prefix}Args = new Int8Array([\n${formatIntArray(args)}\n]);\n\n`;
|
|
164
|
+
output += `export const ${planet.varName}: Plantbl = {\n`;
|
|
165
|
+
output += ` maxHarmonic: [${struct.maxHarmonic.join(', ')}],\n`;
|
|
166
|
+
output += ` maxPowerOfT: ${struct.maxPowerOfT},\n`;
|
|
167
|
+
output += ` argTbl: ${planet.prefix}Args,\n`;
|
|
168
|
+
output += ` lonTbl: ${planet.prefix}Tabl,\n`;
|
|
169
|
+
output += ` latTbl: ${planet.prefix}Tabb,\n`;
|
|
170
|
+
output += ` radTbl: ${planet.prefix}Tabr,\n`;
|
|
171
|
+
output += ` distance: ${struct.distance},\n`;
|
|
172
|
+
output += `};\n\n`;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const outPath = path.join(__dirname, '..', 'src', 'swemptab.ts');
|
|
176
|
+
fs.writeFileSync(outPath, output);
|
|
177
|
+
console.log(`\nWrote ${outPath}`);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Parse swenut2000a.h and generate swenut2000a.ts with actual coefficient data.
|
|
4
|
+
*/
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
|
|
8
|
+
const src = fs.readFileSync(
|
|
9
|
+
path.join(__dirname, '..', 'originalCode', 'swisseph', 'swenut2000a.h'),
|
|
10
|
+
'utf8'
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
const lines = src.split('\n');
|
|
14
|
+
|
|
15
|
+
function extractNumbers(startLine, endLine) {
|
|
16
|
+
const nums = [];
|
|
17
|
+
for (let i = startLine - 1; i < endLine - 1; i++) {
|
|
18
|
+
const line = lines[i];
|
|
19
|
+
// Extract all numbers (integers or floats, possibly negative)
|
|
20
|
+
const matches = line.match(/-?\d+(\.\d+)?/g);
|
|
21
|
+
if (matches) {
|
|
22
|
+
nums.push(...matches.map(Number));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return nums;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// nls: lines 72-749 (data between { on line 71 and }; on line 750)
|
|
29
|
+
const nlsData = extractNumbers(72, 750);
|
|
30
|
+
// cls: lines 755-1432
|
|
31
|
+
const clsData = extractNumbers(755, 1433);
|
|
32
|
+
// npl: lines 1439-2125
|
|
33
|
+
const nplData = extractNumbers(1439, 2126);
|
|
34
|
+
// icpl: lines 2131-2817
|
|
35
|
+
const icplData = extractNumbers(2131, 2818);
|
|
36
|
+
|
|
37
|
+
console.log(`nls: ${nlsData.length} values (expected ${678 * 5} = 3390)`);
|
|
38
|
+
console.log(`cls: ${clsData.length} values (expected ${678 * 6} = 4068)`);
|
|
39
|
+
console.log(`npl: ${nplData.length} values (expected ${687 * 14} = 9618)`);
|
|
40
|
+
console.log(`icpl: ${icplData.length} values (expected ${687 * 4} = 2748)`);
|
|
41
|
+
|
|
42
|
+
// Format array as rows
|
|
43
|
+
function formatIntArray(data, cols) {
|
|
44
|
+
const rows = [];
|
|
45
|
+
for (let i = 0; i < data.length; i += cols) {
|
|
46
|
+
const row = data.slice(i, i + cols).map(v => String(v)).join(',');
|
|
47
|
+
rows.push(row + ',');
|
|
48
|
+
}
|
|
49
|
+
return rows.join('\n');
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function formatFloatArray(data, cols) {
|
|
53
|
+
const rows = [];
|
|
54
|
+
for (let i = 0; i < data.length; i += cols) {
|
|
55
|
+
const row = data.slice(i, i + cols).map(v => {
|
|
56
|
+
// Preserve decimal point for floats
|
|
57
|
+
const s = String(v);
|
|
58
|
+
return s.includes('.') ? s : s + '.0';
|
|
59
|
+
}).join(',');
|
|
60
|
+
rows.push(row + ',');
|
|
61
|
+
}
|
|
62
|
+
return rows.join('\n');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const output = `/*************************************************************
|
|
66
|
+
* swenut2000a.ts — IAU 2000A nutation model coefficient tables
|
|
67
|
+
* Auto-generated from swenut2000a.h
|
|
68
|
+
*
|
|
69
|
+
* Copyright (C) 1997 - 2021 Astrodienst AG, Switzerland. (AGPL)
|
|
70
|
+
*************************************************************/
|
|
71
|
+
|
|
72
|
+
/** 0.1 microarcsecond to degrees */
|
|
73
|
+
export const O1MAS2DEG = 1 / 3600.0 / 10000000.0;
|
|
74
|
+
|
|
75
|
+
/** Number of terms in luni-solar nutation model */
|
|
76
|
+
export const NLS = 678;
|
|
77
|
+
export const NLS_2000B = 77;
|
|
78
|
+
|
|
79
|
+
/** Number of terms in planetary nutation model */
|
|
80
|
+
export const NPL = 687;
|
|
81
|
+
|
|
82
|
+
/** Luni-solar argument multipliers: NLS * 5 values (L, L', F, D, Om) */
|
|
83
|
+
export const nls = new Int16Array([
|
|
84
|
+
${formatIntArray(nlsData, 5)}
|
|
85
|
+
]);
|
|
86
|
+
|
|
87
|
+
/** Luni-solar nutation coefficients: NLS * 6 values
|
|
88
|
+
* (S_i, Sdot_i, C_i, Cprime_i, Cdot_i, S_i) in units of 0.1 microarcsec */
|
|
89
|
+
export const cls = new Float64Array([
|
|
90
|
+
${formatFloatArray(clsData, 6)}
|
|
91
|
+
]);
|
|
92
|
+
|
|
93
|
+
/** Planetary argument multipliers: NPL * 14 values */
|
|
94
|
+
export const npl = new Int32Array([
|
|
95
|
+
${formatIntArray(nplData, 14)}
|
|
96
|
+
]);
|
|
97
|
+
|
|
98
|
+
/** Planetary nutation coefficients: NPL * 4 values */
|
|
99
|
+
export const icpl = new Int32Array([
|
|
100
|
+
${formatIntArray(icplData, 4)}
|
|
101
|
+
]);
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
const outPath = path.join(__dirname, '..', 'src', 'swenut2000a.ts');
|
|
105
|
+
fs.writeFileSync(outPath, output);
|
|
106
|
+
console.log(`Wrote ${outPath}`);
|