@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,78 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000 } from '../helpers';
|
|
4
|
+
import { createDefaultSweData } from '../../src/types';
|
|
5
|
+
import { sweClose } from '../../src/sweph';
|
|
6
|
+
import { sweNodAps, sweNodApsUt, sweGetOrbitalElements, sweOrbitMaxMinTrueDistance } from '../../src/swecl';
|
|
7
|
+
import { SE_MARS, SE_EARTH, SEFLG_MOSEPH } from '../../src/constants';
|
|
8
|
+
|
|
9
|
+
describe('Orbital Elements (C-style)', () => {
|
|
10
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
11
|
+
|
|
12
|
+
before(() => { swed = createDefaultSweData(); });
|
|
13
|
+
after(() => { sweClose(swed); });
|
|
14
|
+
|
|
15
|
+
describe('sweNodAps', () => {
|
|
16
|
+
it('Mars ascending node should be valid', () => {
|
|
17
|
+
const r = sweNodAps(swed, J2000, SE_MARS, SEFLG_MOSEPH, 0);
|
|
18
|
+
assert.ok(r.xnasc[0] >= 0 && r.xnasc[0] < 360);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('Mars descending node should differ from ascending', () => {
|
|
22
|
+
const r = sweNodAps(swed, J2000, SE_MARS, SEFLG_MOSEPH, 0);
|
|
23
|
+
assert.ok(Math.abs(r.xnasc[0] - r.xndsc[0]) > 90);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('sweNodApsUt', () => {
|
|
28
|
+
it('should produce valid ascending node', () => {
|
|
29
|
+
const r = sweNodApsUt(swed, J2000, SE_MARS, SEFLG_MOSEPH, 0);
|
|
30
|
+
assert.ok(r.xnasc[0] >= 0);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('sweGetOrbitalElements', () => {
|
|
35
|
+
it('Mars semi-axis should be ~1.5237 AU', () => {
|
|
36
|
+
const r = sweGetOrbitalElements(swed, J2000, SE_MARS, SEFLG_MOSEPH);
|
|
37
|
+
near(r.dret[0], 1.5237, 0.01);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('Mars eccentricity should be ~0.0933', () => {
|
|
41
|
+
const r = sweGetOrbitalElements(swed, J2000, SE_MARS, SEFLG_MOSEPH);
|
|
42
|
+
near(r.dret[1], 0.0933, 0.01);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Mars inclination should be ~1.85 deg', () => {
|
|
46
|
+
const r = sweGetOrbitalElements(swed, J2000, SE_MARS, SEFLG_MOSEPH);
|
|
47
|
+
near(r.dret[2], 1.85, 0.2);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('Earth semi-axis should be ~1.0 AU', () => {
|
|
51
|
+
const r = sweGetOrbitalElements(swed, J2000, SE_EARTH, SEFLG_MOSEPH);
|
|
52
|
+
near(r.dret[0], 1.0, 0.01);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it('Earth eccentricity should be ~0.0167', () => {
|
|
56
|
+
const r = sweGetOrbitalElements(swed, J2000, SE_EARTH, SEFLG_MOSEPH);
|
|
57
|
+
near(r.dret[1], 0.0167, 0.01);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('sweOrbitMaxMinTrueDistance', () => {
|
|
62
|
+
it('Mars dmin should be ~0.37 AU', () => {
|
|
63
|
+
const r = sweOrbitMaxMinTrueDistance(swed, J2000, SE_MARS, SEFLG_MOSEPH);
|
|
64
|
+
near(r.dmin, 0.37, 0.1);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('Mars dmax should be ~2.68 AU', () => {
|
|
68
|
+
const r = sweOrbitMaxMinTrueDistance(swed, J2000, SE_MARS, SEFLG_MOSEPH);
|
|
69
|
+
near(r.dmax, 2.68, 0.1);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('dmin < dtrue < dmax', () => {
|
|
73
|
+
const r = sweOrbitMaxMinTrueDistance(swed, J2000, SE_MARS, SEFLG_MOSEPH);
|
|
74
|
+
assert.ok(r.dmin < r.dtrue);
|
|
75
|
+
assert.ok(r.dtrue < r.dmax);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000, LONDON_ARR } from '../helpers';
|
|
4
|
+
import { createDefaultSweData } from '../../src/types';
|
|
5
|
+
import { sweClose } from '../../src/sweph';
|
|
6
|
+
import { swePheno, swePhenoUt, sweGauquelinSector } from '../../src/swecl';
|
|
7
|
+
import { SE_SUN, SE_MARS, SEFLG_MOSEPH } from '../../src/constants';
|
|
8
|
+
|
|
9
|
+
describe('Phenomena (C-style)', () => {
|
|
10
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
11
|
+
|
|
12
|
+
before(() => { swed = createDefaultSweData(); });
|
|
13
|
+
after(() => { sweClose(swed); });
|
|
14
|
+
|
|
15
|
+
describe('swePheno', () => {
|
|
16
|
+
it('Mars phase angle should be 0-180', () => {
|
|
17
|
+
const r = swePheno(swed, J2000, SE_MARS, SEFLG_MOSEPH, null);
|
|
18
|
+
assert.ok(r.attr[0] >= 0 && r.attr[0] < 180, `phase=${r.attr[0]}`);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('Mars should have elongation > 0', () => {
|
|
22
|
+
const r = swePheno(swed, J2000, SE_MARS, SEFLG_MOSEPH, null);
|
|
23
|
+
assert.ok(r.attr[2] >= 0, `elongation=${r.attr[2]}`);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
describe('swePhenoUt', () => {
|
|
28
|
+
it('should return valid phase angle', () => {
|
|
29
|
+
const r = swePhenoUt(swed, J2000, SE_MARS, SEFLG_MOSEPH, null);
|
|
30
|
+
assert.ok(r.attr[0] >= 0);
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe('sweGauquelinSector', () => {
|
|
35
|
+
it('Sun sector should be 1-36', () => {
|
|
36
|
+
const r = sweGauquelinSector(swed, J2000, SE_SUN, null, SEFLG_MOSEPH, 0,
|
|
37
|
+
LONDON_ARR, 1013.25, 10, null);
|
|
38
|
+
assert.ok(r.retval >= 0);
|
|
39
|
+
assert.ok(r.dgsect > 0 && r.dgsect <= 36, `sector=${r.dgsect}`);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000 } from '../helpers';
|
|
4
|
+
import { createDefaultSweData } from '../../src/types';
|
|
5
|
+
import { sweCalc, sweCalcPctr, sweClose } from '../../src/sweph';
|
|
6
|
+
import { SE_MARS, SE_EARTH, SEFLG_MOSEPH } from '../../src/constants';
|
|
7
|
+
|
|
8
|
+
describe('Planetocentric (C-style)', () => {
|
|
9
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
10
|
+
|
|
11
|
+
before(() => { swed = createDefaultSweData(); });
|
|
12
|
+
after(() => { sweClose(swed); });
|
|
13
|
+
|
|
14
|
+
it('Mars from Earth should match geocentric Mars', () => {
|
|
15
|
+
const geo = sweCalc(swed, J2000, SE_MARS, SEFLG_MOSEPH);
|
|
16
|
+
const pctr = sweCalcPctr(swed, J2000, SE_MARS, SE_EARTH, SEFLG_MOSEPH);
|
|
17
|
+
assert.ok(pctr.xx[0] >= 0 && pctr.xx[0] < 360);
|
|
18
|
+
near(pctr.xx[0], geo.xx[0], 0.1);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should produce valid longitude and latitude', () => {
|
|
22
|
+
const pctr = sweCalcPctr(swed, J2000, SE_MARS, SE_EARTH, SEFLG_MOSEPH);
|
|
23
|
+
assert.ok(pctr.xx[0] >= 0 && pctr.xx[0] < 360);
|
|
24
|
+
assert.ok(pctr.xx[1] >= -90 && pctr.xx[1] <= 90);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000 } from '../helpers';
|
|
4
|
+
import { createDefaultSweData } from '../../src/types';
|
|
5
|
+
import { sweCalc, sweCalcUt, sweSetTopo, sweClose } from '../../src/sweph';
|
|
6
|
+
import {
|
|
7
|
+
SE_SUN, SE_MOON, SE_MERCURY, SE_VENUS, SE_MARS, SE_JUPITER, SE_SATURN,
|
|
8
|
+
SE_URANUS, SE_NEPTUNE, SE_PLUTO, SE_MEAN_NODE, SE_TRUE_NODE,
|
|
9
|
+
SE_OSCU_APOG, SE_EARTH,
|
|
10
|
+
SEFLG_MOSEPH, SEFLG_SPEED, SEFLG_EQUATORIAL, SEFLG_HELCTR, SEFLG_TOPOCTR,
|
|
11
|
+
} from '../../src/constants';
|
|
12
|
+
|
|
13
|
+
describe('Planet Positions (C-style)', () => {
|
|
14
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
15
|
+
|
|
16
|
+
before(() => { swed = createDefaultSweData(); });
|
|
17
|
+
after(() => { sweClose(swed); });
|
|
18
|
+
|
|
19
|
+
describe('Sun', () => {
|
|
20
|
+
it('should have longitude ~280.37 at J2000', () => {
|
|
21
|
+
const r = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
22
|
+
near(r.xx[0], 280.37, 0.1);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should have speed ~1.0 deg/day', () => {
|
|
26
|
+
const r = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
27
|
+
near(r.xx[3], 1.0, 0.1);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('Moon', () => {
|
|
32
|
+
it('should have valid longitude at J2000', () => {
|
|
33
|
+
const r = sweCalc(swed, J2000, SE_MOON, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
34
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should have speed ~13 deg/day', () => {
|
|
38
|
+
const r = sweCalc(swed, J2000, SE_MOON, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
39
|
+
near(r.xx[3], 13.0, 2.0);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe('All planets', () => {
|
|
44
|
+
const planets = [
|
|
45
|
+
{ id: SE_MERCURY, name: 'Mercury' },
|
|
46
|
+
{ id: SE_VENUS, name: 'Venus' },
|
|
47
|
+
{ id: SE_MARS, name: 'Mars' },
|
|
48
|
+
{ id: SE_JUPITER, name: 'Jupiter' },
|
|
49
|
+
{ id: SE_SATURN, name: 'Saturn' },
|
|
50
|
+
{ id: SE_URANUS, name: 'Uranus' },
|
|
51
|
+
{ id: SE_NEPTUNE, name: 'Neptune' },
|
|
52
|
+
{ id: SE_PLUTO, name: 'Pluto' },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
for (const { id, name } of planets) {
|
|
56
|
+
it(`${name} should have valid longitude`, () => {
|
|
57
|
+
const r = sweCalc(swed, J2000, id, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
58
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360, `${name} lon=${r.xx[0]}`);
|
|
59
|
+
assert.ok(r.xx[2] > 0, `${name} distance should be positive`);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('sweCalcUt', () => {
|
|
65
|
+
it('should calculate Mars via UT', () => {
|
|
66
|
+
const r = sweCalcUt(swed, J2000, SE_MARS, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
67
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360);
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('Nodes and apsides', () => {
|
|
72
|
+
it('Mean node should have valid longitude', () => {
|
|
73
|
+
const r = sweCalc(swed, J2000, SE_MEAN_NODE, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
74
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('True node should have valid longitude', () => {
|
|
78
|
+
const r = sweCalc(swed, J2000, SE_TRUE_NODE, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
79
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('Osculating apogee should have valid longitude', () => {
|
|
83
|
+
const r = sweCalc(swed, J2000, SE_OSCU_APOG, SEFLG_MOSEPH);
|
|
84
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360);
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('Equatorial coordinates', () => {
|
|
89
|
+
it('Sun RA should be valid at J2000', () => {
|
|
90
|
+
const r = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_EQUATORIAL);
|
|
91
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360, `RA=${r.xx[0]}`);
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
describe('Heliocentric', () => {
|
|
96
|
+
it('Mars heliocentric should have valid longitude', () => {
|
|
97
|
+
const r = sweCalc(swed, J2000, SE_MARS, SEFLG_MOSEPH | SEFLG_HELCTR);
|
|
98
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('Earth heliocentric should have valid longitude', () => {
|
|
102
|
+
const r = sweCalc(swed, J2000, SE_EARTH, SEFLG_MOSEPH | SEFLG_HELCTR);
|
|
103
|
+
assert.ok(r.xx[0] >= 0 && r.xx[0] < 360);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('Topocentric', () => {
|
|
108
|
+
it('Sun should differ slightly from geocentric', () => {
|
|
109
|
+
const geo = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
110
|
+
sweSetTopo(swed, -0.1278, 51.5074, 0);
|
|
111
|
+
const topo = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_TOPOCTR | SEFLG_SPEED);
|
|
112
|
+
assert.ok(topo.xx[0] >= 0 && topo.xx[0] < 360);
|
|
113
|
+
// Topocentric should differ slightly from geocentric
|
|
114
|
+
assert.ok(Math.abs(topo.xx[0] - geo.xx[0]) < 1, 'Topo should be close to geo');
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000, LONDON_ARR } from '../helpers';
|
|
4
|
+
import { createDefaultSweData } from '../../src/types';
|
|
5
|
+
import { sweCalc, sweClose } from '../../src/sweph';
|
|
6
|
+
import { sweRiseTrans, sweAzalt, sweAzaltRev, sweRefrac, sweRefracExtended } from '../../src/swecl';
|
|
7
|
+
import {
|
|
8
|
+
SE_SUN, SEFLG_MOSEPH, SEFLG_SPEED,
|
|
9
|
+
SE_CALC_RISE, SE_CALC_SET,
|
|
10
|
+
SE_ECL2HOR, SE_EQU2HOR, SE_TRUE_TO_APP,
|
|
11
|
+
} from '../../src/constants';
|
|
12
|
+
|
|
13
|
+
describe('Rise/Set/Transit (C-style)', () => {
|
|
14
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
15
|
+
|
|
16
|
+
before(() => { swed = createDefaultSweData(); });
|
|
17
|
+
after(() => { sweClose(swed); });
|
|
18
|
+
|
|
19
|
+
describe('sweRiseTrans', () => {
|
|
20
|
+
it('Sun rise should be after J2000', () => {
|
|
21
|
+
const r = sweRiseTrans(swed, J2000, SE_SUN, null, SEFLG_MOSEPH,
|
|
22
|
+
SE_CALC_RISE, LONDON_ARR, 1013.25, 10, null);
|
|
23
|
+
assert.ok(r.retval >= 0);
|
|
24
|
+
assert.ok(r.tret > 0, 'rise time should be positive');
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('Sun set should be after J2000', () => {
|
|
28
|
+
const r = sweRiseTrans(swed, J2000, SE_SUN, null, SEFLG_MOSEPH,
|
|
29
|
+
SE_CALC_SET, LONDON_ARR, 1013.25, 10, null);
|
|
30
|
+
assert.ok(r.retval >= 0);
|
|
31
|
+
assert.ok(r.tret > J2000, 'set time should be after J2000');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('sweAzalt', () => {
|
|
36
|
+
it('should compute Sun azimuth at J2000', () => {
|
|
37
|
+
const sun = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
38
|
+
const xaz = [0, 0, 0];
|
|
39
|
+
sweAzalt(swed, J2000, SE_ECL2HOR, LONDON_ARR, 1013.25, 10,
|
|
40
|
+
[sun.xx[0], sun.xx[1], sun.xx[2]], xaz);
|
|
41
|
+
assert.ok(xaz[0] >= 0 && xaz[0] < 360, `azimuth=${xaz[0]}`);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('sweAzaltRev', () => {
|
|
46
|
+
it('should reverse azalt back to coordinates', () => {
|
|
47
|
+
const sun = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
48
|
+
const xaz = [0, 0, 0];
|
|
49
|
+
sweAzalt(swed, J2000, SE_ECL2HOR, LONDON_ARR, 1013.25, 10,
|
|
50
|
+
[sun.xx[0], sun.xx[1], sun.xx[2]], xaz);
|
|
51
|
+
const xout = [0, 0, 0];
|
|
52
|
+
sweAzaltRev(swed, J2000, SE_EQU2HOR, LONDON_ARR, [xaz[0], xaz[2]], xout);
|
|
53
|
+
assert.ok(xout[0] >= 0 && xout[0] < 360);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('sweRefrac', () => {
|
|
58
|
+
it('true-to-apparent should increase altitude', () => {
|
|
59
|
+
const ref = sweRefrac(10, 1013.25, 10, SE_TRUE_TO_APP);
|
|
60
|
+
assert.ok(ref > 10, `refracted=${ref}`);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
describe('sweRefracExtended', () => {
|
|
65
|
+
it('should return positive value', () => {
|
|
66
|
+
const dret = [0, 0, 0, 0];
|
|
67
|
+
const ref = sweRefracExtended(10, 0, 1013.25, 10, 0.0065, SE_TRUE_TO_APP, dret);
|
|
68
|
+
assert.ok(ref > 0);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
});
|
package/tests/helpers.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared test helpers, constants, and assertions.
|
|
3
|
+
*/
|
|
4
|
+
import { strict as assert } from 'node:assert';
|
|
5
|
+
|
|
6
|
+
/** Assert that `a` is within `tol` of `b`. */
|
|
7
|
+
export function near(a: number, b: number, tol: number): void {
|
|
8
|
+
assert.ok(
|
|
9
|
+
Math.abs(a - b) < tol,
|
|
10
|
+
`Expected ${a} to be within ${tol} of ${b} (diff: ${Math.abs(a - b)})`,
|
|
11
|
+
);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** J2000.0 epoch — 2000 Jan 1.5 UT */
|
|
15
|
+
export const J2000 = 2451545.0;
|
|
16
|
+
|
|
17
|
+
/** London geographic position */
|
|
18
|
+
export const LONDON = { longitude: -0.1278, latitude: 51.5074, altitude: 0 };
|
|
19
|
+
|
|
20
|
+
/** London as [lon, lat, alt] array for C-style functions */
|
|
21
|
+
export const LONDON_ARR: [number, number, number] = [-0.1278, 51.5074, 0];
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000 } from '../helpers';
|
|
4
|
+
import { SwissEph } from '../../src/SwissEph';
|
|
5
|
+
import { SE_SIDM_LAHIRI, SE_SIDM_TRUE_CITRA, SE_SIDM_FAGAN_BRADLEY } from '../../src/constants';
|
|
6
|
+
|
|
7
|
+
describe('Ayanamsa (modern)', () => {
|
|
8
|
+
let swe: SwissEph;
|
|
9
|
+
|
|
10
|
+
before(() => { swe = new SwissEph(); });
|
|
11
|
+
after(() => { swe.close(); });
|
|
12
|
+
|
|
13
|
+
describe('Lahiri', () => {
|
|
14
|
+
it('should be ~23.86 at J2000', () => {
|
|
15
|
+
swe.setSiderealMode(SE_SIDM_LAHIRI);
|
|
16
|
+
const aya = swe.getAyanamsa(J2000);
|
|
17
|
+
near(aya, 23.86, 0.1);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('True Citra', () => {
|
|
22
|
+
it('should be ~23.84 at J2000', () => {
|
|
23
|
+
swe.setSiderealMode(SE_SIDM_TRUE_CITRA);
|
|
24
|
+
const aya = swe.getAyanamsa(J2000);
|
|
25
|
+
near(aya, 23.84, 0.2);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('getAyanamsaName', () => {
|
|
30
|
+
it('should return Lahiri', () => {
|
|
31
|
+
assert.strictEqual(swe.getAyanamsaName(SE_SIDM_LAHIRI), 'Lahiri');
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('should return Fagan/Bradley', () => {
|
|
35
|
+
assert.strictEqual(swe.getAyanamsaName(SE_SIDM_FAGAN_BRADLEY), 'Fagan/Bradley');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('Constructor siderealMode', () => {
|
|
40
|
+
it('should accept siderealMode in options', () => {
|
|
41
|
+
const swe2 = new SwissEph({ siderealMode: SE_SIDM_LAHIRI });
|
|
42
|
+
const aya = swe2.getAyanamsa(J2000);
|
|
43
|
+
near(aya, 23.86, 0.1);
|
|
44
|
+
swe2.close();
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000 } from '../helpers';
|
|
4
|
+
import { SwissEph } from '../../src/SwissEph';
|
|
5
|
+
import { SE_SUN, SE_MOON, SE_MERCURY, SE_VENUS, SE_MARS, SE_JUPITER, SE_SATURN,
|
|
6
|
+
SE_URANUS, SE_NEPTUNE, SE_PLUTO, SE_EARTH, SE_MEAN_NODE, SE_TRUE_NODE,
|
|
7
|
+
SEFLG_EQUATORIAL, SEFLG_HELCTR,
|
|
8
|
+
} from '../../src/constants';
|
|
9
|
+
|
|
10
|
+
describe('Calculation (modern)', () => {
|
|
11
|
+
let swe: SwissEph;
|
|
12
|
+
|
|
13
|
+
before(() => { swe = new SwissEph(); });
|
|
14
|
+
after(() => { swe.close(); });
|
|
15
|
+
|
|
16
|
+
describe('Sun', () => {
|
|
17
|
+
it('should have longitude ~280.37 at J2000', () => {
|
|
18
|
+
const sun = swe.calc(J2000, SE_SUN);
|
|
19
|
+
near(sun.longitude, 280.37, 0.1);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should have speed ~1.0 deg/day', () => {
|
|
23
|
+
const sun = swe.calc(J2000, SE_SUN);
|
|
24
|
+
near(sun.longitudeSpeed, 1.0, 0.1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('should have nonzero distance', () => {
|
|
28
|
+
const sun = swe.calc(J2000, SE_SUN);
|
|
29
|
+
assert.ok(sun.distance > 0);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
describe('Moon', () => {
|
|
34
|
+
it('should have valid longitude', () => {
|
|
35
|
+
const moon = swe.calc(J2000, SE_MOON);
|
|
36
|
+
assert.ok(moon.longitude >= 0 && moon.longitude < 360);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('should have speed ~13 deg/day', () => {
|
|
40
|
+
const moon = swe.calc(J2000, SE_MOON);
|
|
41
|
+
near(moon.longitudeSpeed, 13.0, 2.0);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('All planets', () => {
|
|
46
|
+
const planets = [
|
|
47
|
+
{ id: SE_MERCURY, name: 'Mercury' },
|
|
48
|
+
{ id: SE_VENUS, name: 'Venus' },
|
|
49
|
+
{ id: SE_MARS, name: 'Mars' },
|
|
50
|
+
{ id: SE_JUPITER, name: 'Jupiter' },
|
|
51
|
+
{ id: SE_SATURN, name: 'Saturn' },
|
|
52
|
+
{ id: SE_URANUS, name: 'Uranus' },
|
|
53
|
+
{ id: SE_NEPTUNE, name: 'Neptune' },
|
|
54
|
+
{ id: SE_PLUTO, name: 'Pluto' },
|
|
55
|
+
];
|
|
56
|
+
|
|
57
|
+
for (const { id, name } of planets) {
|
|
58
|
+
it(`${name} should have valid longitude`, () => {
|
|
59
|
+
const r = swe.calc(J2000, id);
|
|
60
|
+
assert.ok(r.longitude >= 0 && r.longitude < 360, `${name}=${r.longitude}`);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('Equatorial', () => {
|
|
66
|
+
it('Sun RA should be valid', () => {
|
|
67
|
+
const r = swe.calc(J2000, SE_SUN, SEFLG_EQUATORIAL);
|
|
68
|
+
assert.ok(r.longitude >= 0 && r.longitude < 360);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe('Heliocentric', () => {
|
|
73
|
+
it('Mars heliocentric should be valid', () => {
|
|
74
|
+
const r = swe.calc(J2000, SE_MARS, SEFLG_HELCTR);
|
|
75
|
+
assert.ok(r.longitude >= 0 && r.longitude < 360);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
describe('calcPlanetocentric', () => {
|
|
80
|
+
it('Mars from Earth should match geocentric', () => {
|
|
81
|
+
const geo = swe.calc(J2000, SE_MARS);
|
|
82
|
+
const pctr = swe.calcPlanetocentric(J2000, SE_MARS, SE_EARTH);
|
|
83
|
+
near(pctr.longitude, geo.longitude, 0.01);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('fixedStar', () => {
|
|
88
|
+
it('Spica should have longitude ~203.84', () => {
|
|
89
|
+
const r = swe.fixedStar('Spica', J2000);
|
|
90
|
+
near(r.longitude, 203.84, 0.5);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it('should include star name', () => {
|
|
94
|
+
const r = swe.fixedStar('Spica', J2000);
|
|
95
|
+
assert.ok(r.starName.includes('Spica'));
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('fixedStar2', () => {
|
|
100
|
+
it('should match fixedStar', () => {
|
|
101
|
+
const r1 = swe.fixedStar('Spica', J2000);
|
|
102
|
+
const r2 = swe.fixedStar2('Spica', J2000);
|
|
103
|
+
near(r2.longitude, r1.longitude, 0.001);
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('fixedStarMagnitude', () => {
|
|
108
|
+
it('Spica should have magnitude ~0.98', () => {
|
|
109
|
+
const mag = swe.fixedStarMagnitude('Spica');
|
|
110
|
+
near(mag, 0.98, 0.1);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { J2000, LONDON } from '../helpers';
|
|
4
|
+
import { SwissEph } from '../../src/SwissEph';
|
|
5
|
+
import { SE_SUN, SEFLG_TOPOCTR } from '../../src/constants';
|
|
6
|
+
|
|
7
|
+
describe('Configuration (modern)', () => {
|
|
8
|
+
let swe: SwissEph;
|
|
9
|
+
|
|
10
|
+
before(() => { swe = new SwissEph(); });
|
|
11
|
+
after(() => { swe.close(); });
|
|
12
|
+
|
|
13
|
+
describe('setTopo', () => {
|
|
14
|
+
it('should set topocentric position without error', () => {
|
|
15
|
+
swe.setTopo(LONDON);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('topocentric calc should work after setTopo', () => {
|
|
19
|
+
swe.setTopo(LONDON);
|
|
20
|
+
const r = swe.calc(J2000, SE_SUN, SEFLG_TOPOCTR);
|
|
21
|
+
assert.ok(r.longitude >= 0 && r.longitude < 360);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('setDeltaTUserDefined', () => {
|
|
26
|
+
it('should not throw', () => {
|
|
27
|
+
swe.setDeltaTUserDefined(0.001);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe('setInterpolateNutation', () => {
|
|
32
|
+
it('should not throw', () => {
|
|
33
|
+
swe.setInterpolateNutation(true);
|
|
34
|
+
swe.setInterpolateNutation(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('close', () => {
|
|
39
|
+
it('should not crash on double close', () => {
|
|
40
|
+
const s = new SwissEph();
|
|
41
|
+
s.close();
|
|
42
|
+
// Second close should not throw
|
|
43
|
+
s.close();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near, J2000 } from '../helpers';
|
|
4
|
+
import { SwissEph } from '../../src/SwissEph';
|
|
5
|
+
import { SE_MARS } from '../../src/constants';
|
|
6
|
+
|
|
7
|
+
describe('Crossings (modern)', () => {
|
|
8
|
+
let swe: SwissEph;
|
|
9
|
+
|
|
10
|
+
before(() => { swe = new SwissEph(); });
|
|
11
|
+
after(() => { swe.close(); });
|
|
12
|
+
|
|
13
|
+
describe('sunCrossing', () => {
|
|
14
|
+
it('vernal equinox 2000 should be Mar 20', () => {
|
|
15
|
+
const start = SwissEph.julianDay(2000, 3, 1, 0);
|
|
16
|
+
const r = swe.sunCrossing(0, start);
|
|
17
|
+
const d = SwissEph.fromJulianDay(r.jd);
|
|
18
|
+
assert.strictEqual(d.month, 3);
|
|
19
|
+
assert.strictEqual(d.day, 20);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('moonCrossing', () => {
|
|
24
|
+
it('should find Moon crossing 0 deg after J2000', () => {
|
|
25
|
+
const r = swe.moonCrossing(0, J2000);
|
|
26
|
+
assert.ok(r.jd > J2000);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
describe('moonNodeCrossing', () => {
|
|
31
|
+
it('should find next node crossing', () => {
|
|
32
|
+
const r = swe.moonNodeCrossing(J2000);
|
|
33
|
+
assert.ok(r.jd > J2000);
|
|
34
|
+
assert.ok(typeof r.longitude === 'number');
|
|
35
|
+
assert.ok(typeof r.latitude === 'number');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
describe('helioCrossing', () => {
|
|
40
|
+
it('Mars should cross 0 deg helio', () => {
|
|
41
|
+
const r = swe.helioCrossing(SE_MARS, 0, J2000);
|
|
42
|
+
assert.ok(r.jd > J2000);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|