@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,81 @@
|
|
|
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 { julDay, revJul } from '../../src/swedate';
|
|
6
|
+
import {
|
|
7
|
+
sweSolcross, sweSolcrossUt,
|
|
8
|
+
sweMooncross, sweMooncrossUt,
|
|
9
|
+
sweMooncrossNode, sweMooncrossNodeUt,
|
|
10
|
+
sweHelioCross, sweHelioCrossUt,
|
|
11
|
+
sweClose,
|
|
12
|
+
} from '../../src/sweph';
|
|
13
|
+
import { SE_MARS, SEFLG_MOSEPH, SE_GREG_CAL } from '../../src/constants';
|
|
14
|
+
|
|
15
|
+
describe('Crossings (C-style)', () => {
|
|
16
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
17
|
+
|
|
18
|
+
before(() => { swed = createDefaultSweData(); });
|
|
19
|
+
after(() => { sweClose(swed); });
|
|
20
|
+
|
|
21
|
+
describe('sweSolcross (vernal equinox 2000)', () => {
|
|
22
|
+
it('should find equinox on Mar 20', () => {
|
|
23
|
+
const start = julDay(2000, 3, 1, 0, SE_GREG_CAL);
|
|
24
|
+
const r = sweSolcross(swed, 0, start, SEFLG_MOSEPH);
|
|
25
|
+
assert.ok(r.jd > start);
|
|
26
|
+
const d = revJul(r.jd, SE_GREG_CAL);
|
|
27
|
+
assert.strictEqual(d.month, 3);
|
|
28
|
+
assert.strictEqual(d.day, 20);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('sweSolcrossUt', () => {
|
|
33
|
+
it('should find equinox after start', () => {
|
|
34
|
+
const start = julDay(2000, 3, 1, 0, SE_GREG_CAL);
|
|
35
|
+
const r = sweSolcrossUt(swed, 0, start, SEFLG_MOSEPH);
|
|
36
|
+
assert.ok(r.jd > start);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('sweMooncross', () => {
|
|
41
|
+
it('should find Moon crossing 0 deg', () => {
|
|
42
|
+
const r = sweMooncross(swed, 0, J2000, SEFLG_MOSEPH);
|
|
43
|
+
assert.ok(r.jd > 0);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('sweMooncrossUt', () => {
|
|
48
|
+
it('should find Moon crossing 0 deg (UT)', () => {
|
|
49
|
+
const r = sweMooncrossUt(swed, 0, J2000, SEFLG_MOSEPH);
|
|
50
|
+
assert.ok(r.jd > 0);
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
describe('sweMooncrossNode', () => {
|
|
55
|
+
it('should find next node crossing', () => {
|
|
56
|
+
const r = sweMooncrossNode(swed, J2000, SEFLG_MOSEPH);
|
|
57
|
+
assert.ok(r.jd > 0);
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('sweMooncrossNodeUt', () => {
|
|
62
|
+
it('should find next node crossing (UT)', () => {
|
|
63
|
+
const r = sweMooncrossNodeUt(swed, J2000, SEFLG_MOSEPH);
|
|
64
|
+
assert.ok(r.jd > 0);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
describe('sweHelioCross', () => {
|
|
69
|
+
it('Mars helio cross should succeed', () => {
|
|
70
|
+
const r = sweHelioCross(swed, SE_MARS, 0, J2000, SEFLG_MOSEPH, 1);
|
|
71
|
+
assert.ok(r.retval >= 0);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe('sweHelioCrossUt', () => {
|
|
76
|
+
it('Mars helio cross UT should succeed', () => {
|
|
77
|
+
const r = sweHelioCrossUt(swed, SE_MARS, 0, J2000, SEFLG_MOSEPH, 1);
|
|
78
|
+
assert.ok(r.retval >= 0);
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { describe, it } 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 { julDay, revJul, dateConversion, utcTimeZone, utcToJd, jdetToUtc, jdut1ToUtc } from '../../src/swedate';
|
|
6
|
+
import { sweDeltat, sweDeltatEx, sweSidtime, sweSidtime0, sweDayOfWeek } from '../../src/swephlib';
|
|
7
|
+
import { SE_GREG_CAL, SE_JUL_CAL, SEFLG_MOSEPH } from '../../src/constants';
|
|
8
|
+
|
|
9
|
+
const swed = createDefaultSweData();
|
|
10
|
+
const deltatFn = (tjd: number, iflag: number) => sweDeltatEx(tjd, iflag, swed);
|
|
11
|
+
|
|
12
|
+
describe('Date/Time (C-style)', () => {
|
|
13
|
+
describe('julDay / revJul', () => {
|
|
14
|
+
it('should return J2000 = 2451545.0', () => {
|
|
15
|
+
assert.strictEqual(julDay(2000, 1, 1, 12, SE_GREG_CAL), J2000);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should round-trip through revJul', () => {
|
|
19
|
+
const rv = revJul(J2000, SE_GREG_CAL);
|
|
20
|
+
assert.strictEqual(rv.year, 2000);
|
|
21
|
+
assert.strictEqual(rv.month, 1);
|
|
22
|
+
assert.strictEqual(rv.day, 1);
|
|
23
|
+
assert.strictEqual(rv.hour, 12);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should handle Julian calendar', () => {
|
|
27
|
+
const jd = julDay(2000, 1, 1, 12, SE_JUL_CAL);
|
|
28
|
+
assert.ok(jd !== J2000, 'Julian and Gregorian should differ');
|
|
29
|
+
const rv = revJul(jd, SE_JUL_CAL);
|
|
30
|
+
assert.strictEqual(rv.year, 2000);
|
|
31
|
+
assert.strictEqual(rv.month, 1);
|
|
32
|
+
assert.strictEqual(rv.day, 1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should handle negative years (BCE)', () => {
|
|
36
|
+
const jd = julDay(-4712, 1, 1, 12, SE_JUL_CAL);
|
|
37
|
+
assert.ok(jd >= 0 && jd < 1, `JD epoch should be near 0, got ${jd}`);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('dateConversion', () => {
|
|
42
|
+
it('should validate a valid Gregorian date', () => {
|
|
43
|
+
const dc = dateConversion(2000, 1, 1, 12, 'g');
|
|
44
|
+
assert.ok(dc.ok);
|
|
45
|
+
near(dc.jd, J2000, 0.001);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('utcTimeZone', () => {
|
|
50
|
+
it('should offset by timezone', () => {
|
|
51
|
+
const tz = utcTimeZone(2000, 1, 1, 12, 0, 0, -5);
|
|
52
|
+
assert.strictEqual(tz.hour, 17);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('utcToJd / jdetToUtc / jdut1ToUtc', () => {
|
|
57
|
+
it('should convert UTC to JD', () => {
|
|
58
|
+
const r = utcToJd(2000, 1, 1, 12, 0, 0, SE_GREG_CAL, deltatFn);
|
|
59
|
+
near(r.tjdUt, J2000, 0.001);
|
|
60
|
+
assert.ok(r.tjdEt > r.tjdUt, 'ET should be ahead of UT');
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('should round-trip through jdetToUtc', () => {
|
|
64
|
+
const r = utcToJd(2000, 1, 1, 12, 0, 0, SE_GREG_CAL, deltatFn);
|
|
65
|
+
const utc = jdetToUtc(r.tjdEt, SE_GREG_CAL, deltatFn);
|
|
66
|
+
assert.strictEqual(utc.year, 2000);
|
|
67
|
+
assert.strictEqual(utc.month, 1);
|
|
68
|
+
assert.strictEqual(utc.day, 1);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('should round-trip through jdut1ToUtc', () => {
|
|
72
|
+
const r = utcToJd(2000, 1, 1, 12, 0, 0, SE_GREG_CAL, deltatFn);
|
|
73
|
+
const utc = jdut1ToUtc(r.tjdUt, SE_GREG_CAL, deltatFn);
|
|
74
|
+
assert.strictEqual(utc.year, 2000);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('deltaT', () => {
|
|
79
|
+
it('should return positive value at J2000', () => {
|
|
80
|
+
const dt = sweDeltat(J2000, swed);
|
|
81
|
+
assert.ok(dt > 0, `deltaT should be > 0, got ${dt}`);
|
|
82
|
+
assert.ok(dt < 0.01, `deltaT should be < 0.01 days, got ${dt}`);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('should match sweDeltatEx', () => {
|
|
86
|
+
const dt = sweDeltat(J2000, swed);
|
|
87
|
+
const dtEx = sweDeltatEx(J2000, SEFLG_MOSEPH, swed);
|
|
88
|
+
near(dt, dtEx, 0.0001);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
describe('sidereal time', () => {
|
|
93
|
+
it('sweSidtime should return 0-24 hours', () => {
|
|
94
|
+
const st = sweSidtime(swed, J2000);
|
|
95
|
+
assert.ok(st > 0 && st < 24, `sidtime=${st}`);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('sweSidtime0 should return 0-24 hours', () => {
|
|
99
|
+
const st = sweSidtime0(swed, J2000, 23.44, 0);
|
|
100
|
+
assert.ok(st > 0 && st < 24);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('dayOfWeek', () => {
|
|
105
|
+
it('J2000 should be Saturday (5)', () => {
|
|
106
|
+
assert.strictEqual(sweDayOfWeek(J2000), 5);
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it('2024-01-01 should be Monday (0)', () => {
|
|
110
|
+
const jd = julDay(2024, 1, 1, 12, SE_GREG_CAL);
|
|
111
|
+
assert.strictEqual(sweDayOfWeek(jd), 0);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
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 { julDay, revJul } from '../../src/swedate';
|
|
7
|
+
import {
|
|
8
|
+
sweSolEclipseWhenGlob, sweSolEclipseWhere, sweSolEclipseHow, sweSolEclipseWhenLoc,
|
|
9
|
+
sweLunEclipseWhen, sweLunEclipseHow, sweLunEclipseWhenLoc,
|
|
10
|
+
sweLunOccultWhenGlob,
|
|
11
|
+
} from '../../src/swecl';
|
|
12
|
+
import { SE_MARS, SEFLG_MOSEPH, SE_GREG_CAL } from '../../src/constants';
|
|
13
|
+
|
|
14
|
+
describe('Eclipses (C-style)', () => {
|
|
15
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
16
|
+
|
|
17
|
+
before(() => { swed = createDefaultSweData(); });
|
|
18
|
+
after(() => { sweClose(swed); });
|
|
19
|
+
|
|
20
|
+
describe('Solar eclipse — 2024 Apr 8 total', () => {
|
|
21
|
+
it('should find the eclipse', () => {
|
|
22
|
+
const start = julDay(2024, 3, 1, 0, SE_GREG_CAL);
|
|
23
|
+
const r = sweSolEclipseWhenGlob(swed, start, SEFLG_MOSEPH, 0, 0);
|
|
24
|
+
assert.ok(r.retval > 0, `retval=${r.retval}`);
|
|
25
|
+
const d = revJul(r.tret[0], SE_GREG_CAL);
|
|
26
|
+
assert.strictEqual(d.month, 4);
|
|
27
|
+
assert.strictEqual(d.day, 8);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('should locate central path near lon -104', () => {
|
|
31
|
+
const start = julDay(2024, 3, 1, 0, SE_GREG_CAL);
|
|
32
|
+
const ecl = sweSolEclipseWhenGlob(swed, start, SEFLG_MOSEPH, 0, 0);
|
|
33
|
+
const where = sweSolEclipseWhere(swed, ecl.tret[0], SEFLG_MOSEPH);
|
|
34
|
+
assert.ok(where.retval > 0);
|
|
35
|
+
near(where.geopos[0], -104, 20);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('sweSolEclipseHow should return valid attributes', () => {
|
|
39
|
+
const start = julDay(2024, 3, 1, 0, SE_GREG_CAL);
|
|
40
|
+
const ecl = sweSolEclipseWhenGlob(swed, start, SEFLG_MOSEPH, 0, 0);
|
|
41
|
+
const how = sweSolEclipseHow(swed, ecl.tret[0], SEFLG_MOSEPH, [-104, 25, 0]);
|
|
42
|
+
assert.ok(how.retval >= 0);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('sweSolEclipseWhenLoc should find local eclipse', () => {
|
|
46
|
+
const start = julDay(2024, 3, 1, 0, SE_GREG_CAL);
|
|
47
|
+
const r = sweSolEclipseWhenLoc(swed, start, SEFLG_MOSEPH, [-104, 25, 0], 0);
|
|
48
|
+
assert.ok(r.retval > 0);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
describe('Lunar eclipse — 2025 Mar 14 total', () => {
|
|
53
|
+
it('should find the eclipse', () => {
|
|
54
|
+
const start = julDay(2025, 3, 1, 0, SE_GREG_CAL);
|
|
55
|
+
const r = sweLunEclipseWhen(swed, start, SEFLG_MOSEPH, 0, 0);
|
|
56
|
+
assert.ok(r.retval > 0);
|
|
57
|
+
const d = revJul(r.tret[0], SE_GREG_CAL);
|
|
58
|
+
assert.strictEqual(d.month, 3);
|
|
59
|
+
assert.strictEqual(d.day, 14);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should have umbral magnitude ~1.176', () => {
|
|
63
|
+
const start = julDay(2025, 3, 1, 0, SE_GREG_CAL);
|
|
64
|
+
const ecl = sweLunEclipseWhen(swed, start, SEFLG_MOSEPH, 0, 0);
|
|
65
|
+
const how = sweLunEclipseHow(swed, ecl.tret[0], SEFLG_MOSEPH, null);
|
|
66
|
+
assert.ok(how.retval > 0);
|
|
67
|
+
near(how.attr[0], 1.176, 0.05);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('sweLunEclipseWhenLoc should return', () => {
|
|
71
|
+
const start = julDay(2025, 3, 1, 0, SE_GREG_CAL);
|
|
72
|
+
const r = sweLunEclipseWhenLoc(swed, start, SEFLG_MOSEPH, [-0.1278, 51.5074, 0], 0);
|
|
73
|
+
assert.ok(typeof r.retval === 'number');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('Occultation', () => {
|
|
78
|
+
it('should search for Mars occultation without error', () => {
|
|
79
|
+
const start = julDay(2024, 1, 1, 0, SE_GREG_CAL);
|
|
80
|
+
const r = sweLunOccultWhenGlob(swed, start, SE_MARS, null, SEFLG_MOSEPH, 0, 0);
|
|
81
|
+
assert.ok(typeof r.retval === 'number');
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
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 {
|
|
6
|
+
sweFixstar, sweFixstarUt, sweFixstarMag,
|
|
7
|
+
sweFixstar2, sweFixstar2Ut, sweFixstar2Mag, sweClose,
|
|
8
|
+
} from '../../src/sweph';
|
|
9
|
+
import { SEFLG_MOSEPH } from '../../src/constants';
|
|
10
|
+
|
|
11
|
+
describe('Fixed Stars (C-style)', () => {
|
|
12
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
13
|
+
|
|
14
|
+
before(() => { swed = createDefaultSweData(); });
|
|
15
|
+
after(() => { sweClose(swed); });
|
|
16
|
+
|
|
17
|
+
describe('sweFixstar', () => {
|
|
18
|
+
it('Spica should have longitude ~203.84 at J2000', () => {
|
|
19
|
+
const r = sweFixstar(swed, 'Spica', J2000, SEFLG_MOSEPH);
|
|
20
|
+
near(r.xx[0], 203.84, 0.2);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should return canonical star name', () => {
|
|
24
|
+
const r = sweFixstar(swed, 'Spica', J2000, SEFLG_MOSEPH);
|
|
25
|
+
assert.ok(r.starOut.includes('Spica'), `starOut=${r.starOut}`);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('sweFixstarUt', () => {
|
|
30
|
+
it('should produce position close to ET variant', () => {
|
|
31
|
+
const et = sweFixstar(swed, 'Spica', J2000, SEFLG_MOSEPH);
|
|
32
|
+
const ut = sweFixstarUt(swed, 'Spica', J2000, SEFLG_MOSEPH);
|
|
33
|
+
near(ut.xx[0], et.xx[0], 0.01);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
describe('sweFixstarMag', () => {
|
|
38
|
+
it('Spica should have magnitude ~0.98', () => {
|
|
39
|
+
const r = sweFixstarMag(swed, 'Spica');
|
|
40
|
+
assert.ok(r.mag !== undefined, 'magnitude should be defined');
|
|
41
|
+
near(r.mag, 0.98, 0.1);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('sweFixstar2', () => {
|
|
46
|
+
it('should match sweFixstar result', () => {
|
|
47
|
+
const r1 = sweFixstar(swed, 'Spica', J2000, SEFLG_MOSEPH);
|
|
48
|
+
const r2 = sweFixstar2(swed, 'Spica', J2000, SEFLG_MOSEPH);
|
|
49
|
+
near(r2.xx[0], r1.xx[0], 0.001);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('sweFixstar2Ut', () => {
|
|
54
|
+
it('should return valid position', () => {
|
|
55
|
+
const r = sweFixstar2Ut(swed, 'Spica', J2000, SEFLG_MOSEPH);
|
|
56
|
+
assert.ok(r.xx[0] > 0);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe('sweFixstar2Mag', () => {
|
|
61
|
+
it('should return valid magnitude', () => {
|
|
62
|
+
const r = sweFixstar2Mag(swed, 'Spica');
|
|
63
|
+
assert.ok(r.mag !== undefined);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { describe, it, before, after } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { J2000, LONDON_ARR } from '../helpers';
|
|
4
|
+
import { createDefaultSweData } from '../../src/types';
|
|
5
|
+
import { sweSetTopo, sweClose } from '../../src/sweph';
|
|
6
|
+
import { sweHeliacalUt, sweHeliacalPhenoUt, sweVisLimitMag } from '../../src/swehel';
|
|
7
|
+
import { SEFLG_MOSEPH } from '../../src/constants';
|
|
8
|
+
|
|
9
|
+
describe('Heliacal (C-style)', () => {
|
|
10
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
11
|
+
|
|
12
|
+
before(() => {
|
|
13
|
+
swed = createDefaultSweData();
|
|
14
|
+
sweSetTopo(swed, LONDON_ARR[0], LONDON_ARR[1], LONDON_ARR[2]);
|
|
15
|
+
});
|
|
16
|
+
after(() => { sweClose(swed); });
|
|
17
|
+
|
|
18
|
+
const datm = [1013.25, 10, 50, 0.25, 0, 0];
|
|
19
|
+
const dobs = [0, 0, 0, 0, 0, 0];
|
|
20
|
+
|
|
21
|
+
describe('sweHeliacalUt', () => {
|
|
22
|
+
it('Venus heliacal rising should return result', () => {
|
|
23
|
+
const r = sweHeliacalUt(swed, J2000, LONDON_ARR, datm, dobs, 'Venus', 1, SEFLG_MOSEPH);
|
|
24
|
+
assert.ok(typeof r.retval === 'number');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('sweVisLimitMag', () => {
|
|
29
|
+
it('should return a result for Venus', () => {
|
|
30
|
+
const r = sweVisLimitMag(swed, J2000, LONDON_ARR, datm, dobs, 'Venus', SEFLG_MOSEPH);
|
|
31
|
+
assert.ok(typeof r.retval === 'number');
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,135 @@
|
|
|
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, sweClose } from '../../src/sweph';
|
|
6
|
+
import {
|
|
7
|
+
sweHouses, sweHousesEx, sweHousesEx2,
|
|
8
|
+
sweHousesArmc, sweHousesArmcEx2,
|
|
9
|
+
sweHousePos, sweHouseName,
|
|
10
|
+
} from '../../src/swehouse';
|
|
11
|
+
import { SE_SUN, SEFLG_MOSEPH, SEFLG_SPEED } from '../../src/constants';
|
|
12
|
+
|
|
13
|
+
describe('Houses (C-style)', () => {
|
|
14
|
+
let swed: ReturnType<typeof createDefaultSweData>;
|
|
15
|
+
|
|
16
|
+
before(() => { swed = createDefaultSweData(); });
|
|
17
|
+
after(() => { sweClose(swed); });
|
|
18
|
+
|
|
19
|
+
describe('sweHouses (Placidus, London, J2000)', () => {
|
|
20
|
+
it('should produce valid AC and MC', () => {
|
|
21
|
+
const cusp = new Array(37).fill(0);
|
|
22
|
+
const ascmc = new Array(10).fill(0);
|
|
23
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, 'P', cusp, ascmc);
|
|
24
|
+
near(ascmc[0], 24.03, 0.5);
|
|
25
|
+
near(ascmc[1], 279.50, 0.5);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('cusp[1] should equal AC', () => {
|
|
29
|
+
const cusp = new Array(37).fill(0);
|
|
30
|
+
const ascmc = new Array(10).fill(0);
|
|
31
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, 'P', cusp, ascmc);
|
|
32
|
+
near(cusp[1], ascmc[0], 0.001);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('sweHousesEx', () => {
|
|
37
|
+
it('should match sweHouses', () => {
|
|
38
|
+
const cusp1 = new Array(37).fill(0);
|
|
39
|
+
const ascmc1 = new Array(10).fill(0);
|
|
40
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, 'P', cusp1, ascmc1);
|
|
41
|
+
|
|
42
|
+
const cusp2 = new Array(37).fill(0);
|
|
43
|
+
const ascmc2 = new Array(10).fill(0);
|
|
44
|
+
sweHousesEx(swed, J2000, SEFLG_MOSEPH, 51.5074, -0.1278, 'P', cusp2, ascmc2);
|
|
45
|
+
near(ascmc2[0], ascmc1[0], 0.001);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('sweHousesEx2', () => {
|
|
50
|
+
it('should match sweHouses', () => {
|
|
51
|
+
const cusp1 = new Array(37).fill(0);
|
|
52
|
+
const ascmc1 = new Array(10).fill(0);
|
|
53
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, 'P', cusp1, ascmc1);
|
|
54
|
+
|
|
55
|
+
const cusp3 = new Array(37).fill(0);
|
|
56
|
+
const ascmc3 = new Array(10).fill(0);
|
|
57
|
+
sweHousesEx2(swed, J2000, SEFLG_MOSEPH, 51.5074, -0.1278, 'P', cusp3, ascmc3, null, null, null);
|
|
58
|
+
near(ascmc3[0], ascmc1[0], 0.001);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe('sweHousesArmc', () => {
|
|
63
|
+
it('should produce AC close to sweHouses', () => {
|
|
64
|
+
const cusp = new Array(37).fill(0);
|
|
65
|
+
const ascmc = new Array(10).fill(0);
|
|
66
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, 'P', cusp, ascmc);
|
|
67
|
+
const armc = ascmc[2];
|
|
68
|
+
|
|
69
|
+
const cuspA = new Array(37).fill(0);
|
|
70
|
+
const ascmcA = new Array(10).fill(0);
|
|
71
|
+
sweHousesArmc(armc, 51.5074, 23.44, 'P', cuspA, ascmcA);
|
|
72
|
+
near(ascmcA[0], ascmc[0], 0.5);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('sweHousesArmcEx2', () => {
|
|
77
|
+
it('should produce valid AC', () => {
|
|
78
|
+
const cusp = new Array(37).fill(0);
|
|
79
|
+
const ascmc = new Array(10).fill(0);
|
|
80
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, 'P', cusp, ascmc);
|
|
81
|
+
const armc = ascmc[2];
|
|
82
|
+
|
|
83
|
+
const cuspB = new Array(37).fill(0);
|
|
84
|
+
const ascmcB = new Array(10).fill(0);
|
|
85
|
+
sweHousesArmcEx2(armc, 51.5074, 23.44, 'P', cuspB, ascmcB, null, null, null);
|
|
86
|
+
assert.ok(ascmcB[0] > 0);
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('sweHousePos', () => {
|
|
91
|
+
it('Sun should be in house ~10 at J2000 London', () => {
|
|
92
|
+
const cusp = new Array(37).fill(0);
|
|
93
|
+
const ascmc = new Array(10).fill(0);
|
|
94
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, 'P', cusp, ascmc);
|
|
95
|
+
const sun = sweCalc(swed, J2000, SE_SUN, SEFLG_MOSEPH | SEFLG_SPEED);
|
|
96
|
+
const hpos = sweHousePos(ascmc[2], 51.5074, 23.44, 'P', [sun.xx[0], sun.xx[1]], null);
|
|
97
|
+
assert.ok(hpos > 0 && hpos <= 12, `hpos=${hpos}`);
|
|
98
|
+
near(hpos, 10.05, 0.2);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
describe('sweHouseName', () => {
|
|
103
|
+
it('should return Placidus for P', () => {
|
|
104
|
+
assert.strictEqual(sweHouseName('P'), 'Placidus');
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it('should return Koch for K', () => {
|
|
108
|
+
assert.strictEqual(sweHouseName('K'), 'Koch');
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should return equal for E', () => {
|
|
112
|
+
assert.ok(sweHouseName('E').toLowerCase().includes('equal'));
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('should return whole sign for W', () => {
|
|
116
|
+
assert.ok(sweHouseName('W').toLowerCase().includes('whole sign'));
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
describe('All house systems produce valid cusps', () => {
|
|
121
|
+
const systems = ['P', 'K', 'E', 'W', 'C', 'R', 'T', 'B', 'M', 'O'];
|
|
122
|
+
|
|
123
|
+
for (const sys of systems) {
|
|
124
|
+
it(`System ${sys} should produce 12 valid cusps`, () => {
|
|
125
|
+
const cusp = new Array(37).fill(0);
|
|
126
|
+
const ascmc = new Array(10).fill(0);
|
|
127
|
+
sweHouses(swed, J2000, 51.5074, -0.1278, sys, cusp, ascmc);
|
|
128
|
+
assert.ok(ascmc[0] > 0 && ascmc[0] < 360, `AC invalid for ${sys}`);
|
|
129
|
+
for (let i = 1; i <= 12; i++) {
|
|
130
|
+
assert.ok(cusp[i] >= 0 && cusp[i] < 360, `Cusp ${i} invalid for ${sys}`);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { describe, it } from 'node:test';
|
|
2
|
+
import { strict as assert } from 'node:assert';
|
|
3
|
+
import { near } from '../helpers';
|
|
4
|
+
import {
|
|
5
|
+
sweDegnorm, sweRadnorm, sweDegMidp, sweRadMidp,
|
|
6
|
+
sweCotrans, sweCotransSp, sweSplitDeg, sweD2l,
|
|
7
|
+
sweCsnorm, sweDifcsn, sweDifcs2n, sweDifdegn, sweDifrad2n,
|
|
8
|
+
sweCsroundsec,
|
|
9
|
+
sweCs2timestr, sweCs2lonlatstr, sweCs2degstr,
|
|
10
|
+
swiCutstr, swiRightTrim, swiStrcpy, swiOpenTrace,
|
|
11
|
+
} from '../../src/swephlib';
|
|
12
|
+
import { sweDifdeg2n } from '../../src/sweph';
|
|
13
|
+
import { SE_SPLIT_DEG_ZODIACAL, SE_SPLIT_DEG_ROUND_SEC } from '../../src/constants';
|
|
14
|
+
|
|
15
|
+
describe('Math Utilities (C-style)', () => {
|
|
16
|
+
describe('sweDegnorm', () => {
|
|
17
|
+
it('370 -> 10', () => { near(sweDegnorm(370), 10, 0.001); });
|
|
18
|
+
it('-10 -> 350', () => { near(sweDegnorm(-10), 350, 0.001); });
|
|
19
|
+
it('0 -> 0', () => { near(sweDegnorm(0), 0, 0.001); });
|
|
20
|
+
it('360 -> 0', () => { near(sweDegnorm(360), 0, 0.001); });
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
describe('sweRadnorm', () => {
|
|
24
|
+
it('7 -> 7-2pi', () => {
|
|
25
|
+
near(sweRadnorm(7), 7 - 2 * Math.PI, 0.001);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
describe('sweDegMidp', () => {
|
|
30
|
+
it('midpoint of 10,350 -> 0', () => {
|
|
31
|
+
near(sweDegMidp(10, 350), 0, 0.001);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('midpoint of 90,270 -> 0 or 180', () => {
|
|
35
|
+
const m = sweDegMidp(90, 270);
|
|
36
|
+
assert.ok(Math.abs(m) < 0.001 || Math.abs(m - 180) < 0.001,
|
|
37
|
+
`midpoint=${m}`);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('sweRadMidp', () => {
|
|
42
|
+
it('should return positive value', () => {
|
|
43
|
+
assert.ok(sweRadMidp(0.1, 6.1) >= 0);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
describe('sweCotrans', () => {
|
|
48
|
+
it('should transform ecliptic to equatorial', () => {
|
|
49
|
+
const xpo = [280.0, -0.5, 1.0];
|
|
50
|
+
const xpn = [0, 0, 0];
|
|
51
|
+
sweCotrans(xpo, xpn, 23.44);
|
|
52
|
+
assert.ok(xpn[0] !== 0 || xpn[1] !== 0);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('sweCotransSp', () => {
|
|
57
|
+
it('should transform with speed', () => {
|
|
58
|
+
const xpo = [280.0, -0.5, 1.0, 1.0, 0.1, 0];
|
|
59
|
+
const xpn = [0, 0, 0, 0, 0, 0];
|
|
60
|
+
sweCotransSp(xpo, xpn, 23.44);
|
|
61
|
+
assert.ok(xpn[0] !== 0);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('sweDifdeg2n', () => {
|
|
66
|
+
it('10,350 -> 20', () => { near(sweDifdeg2n(10, 350), 20, 0.001); });
|
|
67
|
+
it('350,10 -> -20', () => { near(sweDifdeg2n(350, 10), -20, 0.001); });
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
describe('sweDifdegn', () => {
|
|
71
|
+
it('10,350 -> 20', () => { near(sweDifdegn(10, 350), 20, 0.001); });
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
describe('sweDifrad2n', () => {
|
|
75
|
+
it('pi,0 -> -pi', () => { near(sweDifrad2n(Math.PI, 0), -Math.PI, 0.001); });
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
describe('sweD2l', () => {
|
|
79
|
+
it('2.5 -> 3', () => { assert.strictEqual(sweD2l(2.5), 3); });
|
|
80
|
+
it('-2.5 -> -3', () => { assert.strictEqual(sweD2l(-2.5), -3); });
|
|
81
|
+
it('2.4 -> 2', () => { assert.strictEqual(sweD2l(2.4), 2); });
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('sweSplitDeg', () => {
|
|
85
|
+
it('should split 123.456', () => {
|
|
86
|
+
const sp = sweSplitDeg(123.456, SE_SPLIT_DEG_ZODIACAL | SE_SPLIT_DEG_ROUND_SEC);
|
|
87
|
+
assert.ok(sp.deg >= 0 && sp.deg < 30);
|
|
88
|
+
assert.ok(sp.min >= 0 && sp.min < 60);
|
|
89
|
+
assert.ok(sp.sec >= 0 && sp.sec < 60);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe('sweCsnorm', () => {
|
|
94
|
+
it('should normalize centiseconds', () => {
|
|
95
|
+
assert.strictEqual(sweCsnorm(360 * 360000 + 100), 100);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
describe('sweDifcsn / sweDifcs2n / sweCsroundsec', () => {
|
|
100
|
+
it('should return numbers', () => {
|
|
101
|
+
assert.strictEqual(typeof sweDifcsn(100, 200), 'number');
|
|
102
|
+
assert.strictEqual(typeof sweDifcs2n(100, 200), 'number');
|
|
103
|
+
assert.strictEqual(typeof sweCsroundsec(12345), 'number');
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe('Formatting', () => {
|
|
108
|
+
it('sweCs2timestr noon', () => {
|
|
109
|
+
const ts = sweCs2timestr(12 * 3600 * 100, ':', false);
|
|
110
|
+
assert.ok(ts.includes('12'), ts);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('sweCs2lonlatstr 90 deg', () => {
|
|
114
|
+
const s = sweCs2lonlatstr(90 * 3600 * 100, 'E', 'W');
|
|
115
|
+
assert.ok(s.includes('90'), s);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it('sweCs2degstr 15 deg', () => {
|
|
119
|
+
const s = sweCs2degstr(15 * 3600 * 100);
|
|
120
|
+
assert.ok(s.includes('15'), s);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
describe('String utilities', () => {
|
|
125
|
+
it('swiCutstr basic split', () => {
|
|
126
|
+
const r = swiCutstr('hello,world,foo', ',');
|
|
127
|
+
assert.strictEqual(r.length, 3);
|
|
128
|
+
assert.strictEqual(r[0], 'hello');
|
|
129
|
+
assert.strictEqual(r[2], 'foo');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('swiCutstr collapses separators', () => {
|
|
133
|
+
const r = swiCutstr('a,,b,,c', ',');
|
|
134
|
+
assert.strictEqual(r.length, 3);
|
|
135
|
+
assert.strictEqual(r[1], 'b');
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
it('swiCutstr nmax', () => {
|
|
139
|
+
const r = swiCutstr('a,b,c,d,e', ',', 3);
|
|
140
|
+
assert.strictEqual(r.length, 3);
|
|
141
|
+
assert.strictEqual(r[2], 'c,d,e');
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('swiRightTrim trims spaces', () => {
|
|
145
|
+
assert.strictEqual(swiRightTrim('hello '), 'hello');
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('swiRightTrim trims tabs', () => {
|
|
149
|
+
assert.strictEqual(swiRightTrim('hello\t \n'), 'hello');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('swiStrcpy identity', () => {
|
|
153
|
+
assert.strictEqual(swiStrcpy('test'), 'test');
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('swiOpenTrace should not throw', () => {
|
|
157
|
+
swiOpenTrace();
|
|
158
|
+
});
|
|
159
|
+
});
|
|
160
|
+
});
|