@zodiacs/engine 0.1.1-rc.16 → 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/CHANGELOG.md +458 -0
- package/LICENSING.md +18 -5
- package/NOTICE +3 -2
- package/README.md +67 -33
- package/dist/{api-VOW6Umy5.d.ts → api-WbxJ4Wj-.d.ts} +12 -6
- package/dist/ayanamsa--YQ46fET.d.ts +134 -0
- package/dist/calc.d.ts +131 -20
- package/dist/calc.js +246 -60
- package/dist/chunk-47ERTK5X.js +27 -0
- package/dist/{chunk-O3NJRGJ2.js → chunk-7TRLIFFI.js} +1 -1
- package/dist/{chunk-KHBLFXFG.js → chunk-B5LKF437.js} +29 -28
- package/dist/{chunk-ONBZ4HK7.js → chunk-BHJXUY67.js} +4 -2
- package/dist/{chunk-I7O5EGFV.js → chunk-CHSYDKBL.js} +1 -1
- package/dist/{chunk-4NV4ZEFZ.js → chunk-DMGHYCDI.js} +4 -4
- package/dist/{chunk-L6ZHWJZ6.js → chunk-FTX3JDJA.js} +15 -12
- package/dist/{chunk-2OWGBT3O.js → chunk-OG4OYTJJ.js} +47 -42
- package/dist/{chunk-WOU7JVD3.js → chunk-SRXBTP5H.js} +7 -7
- package/dist/{chunk-AECKV73C.js → chunk-TSS2SZWQ.js} +8 -2
- package/dist/chunk-WS3TDSP3.js +474 -0
- package/dist/{chunk-N4B5JNMA.js → chunk-YIITY7Q7.js} +21 -11
- package/dist/crossings.d.ts +8 -7
- package/dist/crossings.js +1 -1
- package/dist/deltat.d.ts +28 -3
- package/dist/deltat.js +1 -1
- package/dist/geo.d.ts +33 -12
- package/dist/geo.js +3 -1
- package/dist/{houses-q1O2GGp4.d.ts → houses-CFERsAlK.d.ts} +12 -2
- package/dist/houses-extra.d.ts +19 -5
- package/dist/houses-extra.js +4 -2
- package/dist/index.d.ts +34 -49
- package/dist/index.js +21 -13
- package/dist/{internal-math-CmJ9xtaW.d.ts → internal-math-DJJ8BYex.d.ts} +41 -27
- package/dist/internal-math.d.ts +3 -3
- package/dist/internal-math.js +2 -2
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +5 -5
- package/dist/receipt.d.ts +2 -268
- package/dist/receipt.js +70 -35
- package/dist/reference-span-CILpclrz.d.ts +40 -0
- package/dist/{rulers-9wljfVaO.d.ts → rulers-Dla6h_Sm.d.ts} +7 -2
- package/dist/sky.d.ts +25 -10
- package/dist/sky.js +11 -9
- package/dist/techniques.d.ts +61 -18
- package/dist/techniques.js +39 -46
- package/dist/timing.d.ts +53 -16
- package/dist/timing.js +19 -38
- package/dist/{types-B4MCoCCS.d.ts → types-B-yb_tGL.d.ts} +23 -11
- package/dist/vedic.d.ts +42 -123
- package/dist/vedic.js +43 -440
- package/dist/window.d.ts +81 -79
- package/dist/window.js +26 -27
- package/dist/zone-history-ghdyO0Sc.d.ts +268 -0
- package/package.json +3 -1
package/dist/calc.js
CHANGED
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import {
|
|
2
2
|
eclipticRows,
|
|
3
3
|
equatorRows
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7TRLIFFI.js";
|
|
5
|
+
import {
|
|
6
|
+
AYANAMSAS,
|
|
7
|
+
ayanamsaAt,
|
|
8
|
+
isUserAyanamsaName,
|
|
9
|
+
outsideSpanEpoch,
|
|
10
|
+
siderealChartOf,
|
|
11
|
+
userAyanamsa,
|
|
12
|
+
wholeSignCusps,
|
|
13
|
+
wrap360
|
|
14
|
+
} from "./chunk-WS3TDSP3.js";
|
|
15
|
+
import "./chunk-47ERTK5X.js";
|
|
5
16
|
import {
|
|
6
17
|
dateFrom
|
|
7
18
|
} from "./chunk-CPALRSPC.js";
|
|
8
19
|
import {
|
|
9
20
|
searchLongitudeCrossingsWith
|
|
10
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-TSS2SZWQ.js";
|
|
11
22
|
import {
|
|
12
23
|
assertDerivedFlags,
|
|
13
24
|
snapshotFlags,
|
|
@@ -25,13 +36,15 @@ import {
|
|
|
25
36
|
meanNodeLongitude,
|
|
26
37
|
onChartClock,
|
|
27
38
|
tilt
|
|
28
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-SRXBTP5H.js";
|
|
29
40
|
import {
|
|
41
|
+
EPHEMERIS_SPAN,
|
|
30
42
|
REFERENCE_SPAN,
|
|
43
|
+
TIME_SCALE_NAMES,
|
|
31
44
|
elapsedDays,
|
|
32
45
|
timeBasis
|
|
33
|
-
} from "./chunk-
|
|
34
|
-
import "./chunk-
|
|
46
|
+
} from "./chunk-B5LKF437.js";
|
|
47
|
+
import "./chunk-BHJXUY67.js";
|
|
35
48
|
import {
|
|
36
49
|
computeAngles,
|
|
37
50
|
computeHouses,
|
|
@@ -39,15 +52,15 @@ import {
|
|
|
39
52
|
isPolarUndefinedHouseSystem,
|
|
40
53
|
ramcOf,
|
|
41
54
|
vertexOf
|
|
42
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-DMGHYCDI.js";
|
|
43
56
|
import {
|
|
44
57
|
ENGINE_VERSION,
|
|
45
58
|
EPHEMERIS,
|
|
46
59
|
normalizeLongitude
|
|
47
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-OG4OYTJJ.js";
|
|
48
61
|
|
|
49
62
|
// src/calc.ts
|
|
50
|
-
import { GeoMoonState } from "astronomy-engine";
|
|
63
|
+
import { AstroTime, GeoMoonState } from "astronomy-engine";
|
|
51
64
|
|
|
52
65
|
// src/calc-bounds.ts
|
|
53
66
|
var MEASURED_BASIS = "largest difference from JPL Horizons (DE441) over 32 instants from JD 2379457.498125 to 2520522.646618 (TT), in all eight frames; docs/evidence/calc-api/rc16";
|
|
@@ -353,23 +366,61 @@ function geometricState(body, center, time) {
|
|
|
353
366
|
return { r: sub(r, site.r), v: sub(v, site.v) };
|
|
354
367
|
}
|
|
355
368
|
|
|
369
|
+
// src/calc-ayanamsa.ts
|
|
370
|
+
var NEAR_SUN_DEGREES = 2;
|
|
371
|
+
var AT_SUN_DEGREES = 0.3;
|
|
372
|
+
var AYANAMSA_BOUNDS = {
|
|
373
|
+
/**
|
|
374
|
+
* Epoch and linear definitions, built-in and callers': values from −359.9° to 359.9°, an epoch definition's
|
|
375
|
+
* epoch anywhere in the span, a linear one's anywhere a Date reaches, rates to ±3,600″ a year; 134,833 comparisons.
|
|
376
|
+
* A linear one's rate rounds by up to 1.5 units of 2⁻⁴⁴° in 0.002 day; calc's speeds add their own (docs/calc.md).
|
|
377
|
+
*/
|
|
378
|
+
epochOrLinear: { position: 46e-8, rate: 16e-8 },
|
|
379
|
+
/**
|
|
380
|
+
* Callers' epoch definitions on the engine's precession (IAU 2006) whose epoch is outside the span but inside
|
|
381
|
+
* EPHEMERIS_SPAN, beyond which calc refuses them: the engine's precession and ERFA's part the further the
|
|
382
|
+
* epoch is from J2000.0, most at the span's ends; 21,658 comparisons (docs/evidence/calc-epochs-2026-10-06).
|
|
383
|
+
*/
|
|
384
|
+
epochOutsideSpan: { position: 37e-4, rate: 13e-8 },
|
|
385
|
+
/**
|
|
386
|
+
* The same on Newcomb's or IAU 1976's precession, whose zodiac is held where that model puts it at J2000.0, so
|
|
387
|
+
* that most of the precession's difference from ERFA's cancels; 43,316 comparisons.
|
|
388
|
+
*/
|
|
389
|
+
olderEpochOutsideSpan: { position: 18e-6, rate: 12e-8 },
|
|
390
|
+
/** Star definitions, the star 2° or more from the Sun: 306,850 comparisons. */
|
|
391
|
+
star: { position: 13e-4, rate: 39e-5 },
|
|
392
|
+
/** Star definitions, the star 0.3° to 2° from the Sun: 238,364 comparisons. */
|
|
393
|
+
starNearSun: { position: 48e-4, rate: 0.026 },
|
|
394
|
+
/** Star definitions, the star within 0.3° of the Sun, on or near its disc: 1,653,932 comparisons. */
|
|
395
|
+
starAtSun: { position: 0.058, rate: 27 }
|
|
396
|
+
};
|
|
397
|
+
var AYANAMSA_BASIS = "largest difference of the mean ayanamsa from ERFA's construction of the same definition; docs/evidence/calc-sidereal-2026-10-05";
|
|
398
|
+
var AYANAMSA_EPOCH_BASIS = "largest difference of the mean ayanamsa from ERFA's construction of the same definition, for epochs from 0001 to 3998 outside 1800 to 2200; docs/evidence/calc-epochs-2026-10-06";
|
|
399
|
+
function ayanamsaBand(definition, elongation) {
|
|
400
|
+
if (definition.kind === "epoch" && outsideSpanEpoch(definition)) {
|
|
401
|
+
return definition.model === "engine" ? "epochOutsideSpan" : "olderEpochOutsideSpan";
|
|
402
|
+
}
|
|
403
|
+
if (definition.kind !== "star") return "epochOrLinear";
|
|
404
|
+
if (elongation === null || elongation < AT_SUN_DEGREES) return "starAtSun";
|
|
405
|
+
return elongation < NEAR_SUN_DEGREES ? "starNearSun" : "star";
|
|
406
|
+
}
|
|
407
|
+
function ayanamsaBound(definition, elongation) {
|
|
408
|
+
const band = ayanamsaBand(definition, elongation);
|
|
409
|
+
const outside = band === "epochOutsideSpan" || band === "olderEpochOutsideSpan";
|
|
410
|
+
return { ...AYANAMSA_BOUNDS[band], basis: outside ? AYANAMSA_EPOCH_BASIS : AYANAMSA_BASIS };
|
|
411
|
+
}
|
|
412
|
+
function addBounds(a, b) {
|
|
413
|
+
return Math.ceil(Number(((a + b) * 1e9).toPrecision(15))) / 1e9;
|
|
414
|
+
}
|
|
415
|
+
|
|
356
416
|
// src/calc.ts
|
|
357
417
|
var PLANETS = ["Sun", "Moon", "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto"];
|
|
358
418
|
var POINTS = ["North Node", "South Node", "Mean Node", "Mean South Node", "Black Moon Lilith"];
|
|
359
|
-
var CALC_BODIES = [...PLANETS, ...POINTS];
|
|
419
|
+
var CALC_BODIES = Object.freeze([...PLANETS, ...POINTS]);
|
|
360
420
|
var CHART_BODIES = CALC_BODIES.filter((body) => body !== "Earth" && !/^Mean|Lilith/.test(body));
|
|
361
|
-
var
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
"krishnamurti",
|
|
365
|
-
"raman",
|
|
366
|
-
"yukteswar",
|
|
367
|
-
"true-chitra",
|
|
368
|
-
"true-revati",
|
|
369
|
-
"true-pushya",
|
|
370
|
-
"galactic-center"
|
|
371
|
-
];
|
|
372
|
-
var CALC_RECEIPT_SCHEMA = "zodiacs.calc-receipt.draft-v1";
|
|
421
|
+
var CALC_FRAMES2 = Object.freeze([...CALC_FRAMES]);
|
|
422
|
+
var CALC_AYANAMSAS = Object.freeze(Object.keys(AYANAMSAS));
|
|
423
|
+
var CALC_RECEIPT_SCHEMA = "zodiacs.calc-receipt.v1";
|
|
373
424
|
var CALC_SPAN = REFERENCE_SPAN;
|
|
374
425
|
var DEG2 = Math.PI / 180;
|
|
375
426
|
var RAD2 = 180 / Math.PI;
|
|
@@ -406,7 +457,6 @@ function yesNo(value, label, fallback) {
|
|
|
406
457
|
if (typeof value !== "boolean") throw new RangeError(`${label} must be true or false.`);
|
|
407
458
|
return value;
|
|
408
459
|
}
|
|
409
|
-
var SCALES = { UTC: "utc", UT1: "ut1", TT: "tt" };
|
|
410
460
|
function readTime(value, label) {
|
|
411
461
|
const iso = (text) => {
|
|
412
462
|
try {
|
|
@@ -431,8 +481,11 @@ function readTime(value, label) {
|
|
|
431
481
|
}
|
|
432
482
|
const jd = time.jd;
|
|
433
483
|
if (typeof jd !== "number" || !Number.isFinite(jd)) throw new RangeError(`${label}.jd must be a finite Julian date.`);
|
|
434
|
-
|
|
435
|
-
|
|
484
|
+
if (typeof time.scale === "string" && TIME_SCALE_NAMES.includes(time.scale.toLowerCase()) && !TIME_SCALE_NAMES.includes(time.scale)) {
|
|
485
|
+
throw new RangeError(`${label}.scale must be one of ${TIME_SCALE_NAMES.join(", ")}: lowercase since 1.0.0.`);
|
|
486
|
+
}
|
|
487
|
+
const scale = oneOf(time.scale, TIME_SCALE_NAMES, `${label}.scale`);
|
|
488
|
+
return { record: { jd, scale, ...pinned }, ms: J2000_MS + (jd - J2000_JD) * DAY_MS, scale, pin, civil: false };
|
|
436
489
|
}
|
|
437
490
|
function readPlace(value, label, withHeight = false) {
|
|
438
491
|
const place = fields(value, label, withHeight ? ["latitude", "longitude", "height"] : ["latitude", "longitude"]);
|
|
@@ -445,17 +498,84 @@ function readPlace(value, label, withHeight = false) {
|
|
|
445
498
|
function refuse(reason, detail) {
|
|
446
499
|
return { status: "refused", reason, detail };
|
|
447
500
|
}
|
|
448
|
-
function sidereal(value) {
|
|
449
|
-
if (value === void 0 || value === "tropical") return null;
|
|
450
|
-
const name = oneOf(fields(value, "zodiac", ["sidereal"]).sidereal, CALC_AYANAMSAS, "zodiac.sidereal");
|
|
451
|
-
return refuse("not-in-this-version", `The sidereal zodiac (${name}) is not in the calc entry in this version; @zodiacs/engine/vedic gives sidereal longitudes on this ayanamsa.`);
|
|
452
|
-
}
|
|
453
501
|
var outOfRange = () => ({
|
|
454
502
|
status: "refused",
|
|
455
503
|
reason: "out-of-range",
|
|
456
504
|
detail: `The instant's UT1 or TT is outside ${CALC_SPAN.from} to ${CALC_SPAN.to}, where the engine's positions have been compared with an independent ephemeris.`,
|
|
457
505
|
span: CALC_SPAN
|
|
458
506
|
});
|
|
507
|
+
var TROPICAL = { record: "tropical", definition: null, ids: ["zodiac:tropical"] };
|
|
508
|
+
var UNIX_JD = 24405875e-1;
|
|
509
|
+
function epochTT(epoch, label) {
|
|
510
|
+
const record = epoch.record;
|
|
511
|
+
const message = `${label} must be an instant in the range of a Date.`;
|
|
512
|
+
let jd;
|
|
513
|
+
if ("jd" in record && record.scale === "tt") {
|
|
514
|
+
jd = record.jd;
|
|
515
|
+
} else {
|
|
516
|
+
if (!(Math.abs(epoch.ms) <= 864e13)) throw new RangeError(message);
|
|
517
|
+
jd = J2000_JD + timeBasis(epoch.ms, epoch.scale, epoch.pin).ttDays;
|
|
518
|
+
}
|
|
519
|
+
if (!(Math.abs(jd - UNIX_JD) <= 1e8)) throw new RangeError(message);
|
|
520
|
+
return jd;
|
|
521
|
+
}
|
|
522
|
+
function readZodiac(value) {
|
|
523
|
+
if (value === void 0 || value === "tropical") return TROPICAL;
|
|
524
|
+
const sidereal = fields(value, "zodiac", ["sidereal"]).sidereal;
|
|
525
|
+
if (sidereal === void 0 || typeof sidereal === "string") {
|
|
526
|
+
const name = oneOf(sidereal, CALC_AYANAMSAS, "zodiac.sidereal");
|
|
527
|
+
return { record: { sidereal: name }, definition: AYANAMSAS[name], ids: ["zodiac:sidereal", `ayanamsa:${name}`] };
|
|
528
|
+
}
|
|
529
|
+
const label = "zodiac.sidereal";
|
|
530
|
+
const given = fields(sidereal, label, ["name", "epoch", "value", "rate", "model"]);
|
|
531
|
+
if (given.name !== void 0 && !isUserAyanamsaName(given.name)) {
|
|
532
|
+
throw new RangeError(`${label}.name must be a lowercase identifier of at most 64 characters that is not a built-in name.`);
|
|
533
|
+
}
|
|
534
|
+
const epoch = readTime(given.epoch, `${label}.epoch`);
|
|
535
|
+
const value_ = within(given.value, `${label}.value`, -360, 360);
|
|
536
|
+
if (given.rate !== void 0 && given.model !== void 0) throw new RangeError(`${label} takes a rate or a model, not both.`);
|
|
537
|
+
const rate = given.rate === void 0 ? void 0 : within(given.rate, `${label}.rate`, -3600, 3600);
|
|
538
|
+
const model = given.model === void 0 ? void 0 : oneOf(given.model, ["engine", "newcomb", "iau1976"], `${label}.model`);
|
|
539
|
+
const definition = userAyanamsa({
|
|
540
|
+
...given.name === void 0 ? {} : { name: given.name },
|
|
541
|
+
epoch: { julianDateTT: epochTT(epoch, `${label}.epoch`) },
|
|
542
|
+
value: value_,
|
|
543
|
+
...rate === void 0 ? {} : { rate },
|
|
544
|
+
...model === void 0 ? {} : { model }
|
|
545
|
+
});
|
|
546
|
+
const user = rate === void 0 ? { name: definition.name, epoch: epoch.record, value: value_, model: model ?? "engine" } : { name: definition.name, epoch: epoch.record, value: value_, rate };
|
|
547
|
+
return { record: { sidereal: user }, definition, ids: ["zodiac:sidereal", `ayanamsa:user-${definition.kind}`] };
|
|
548
|
+
}
|
|
549
|
+
var insideEphemerisSpan = (definition) => definition.kind !== "epoch" || definition.epochTT - J2000_JD >= EPHEMERIS_SPAN.daysFromJ2000.from && definition.epochTT - J2000_JD <= EPHEMERIS_SPAN.daysFromJ2000.to;
|
|
550
|
+
function epochRefusal(zodiac) {
|
|
551
|
+
return zodiac.definition && !insideEphemerisSpan(zodiac.definition) ? {
|
|
552
|
+
status: "refused",
|
|
553
|
+
reason: "epoch-out-of-range",
|
|
554
|
+
detail: `The ayanamsa's epoch is outside ${EPHEMERIS_SPAN.fromTT} to ${EPHEMERIS_SPAN.toTT} TT (EPHEMERIS_SPAN), where the precession that carries it has been compared with ERFA's.`,
|
|
555
|
+
epochSpan: EPHEMERIS_SPAN
|
|
556
|
+
} : null;
|
|
557
|
+
}
|
|
558
|
+
var siderealFrame = (frame) => frame === "ecliptic-true-of-date" || frame === "ecliptic-mean-of-date";
|
|
559
|
+
function frameRefusal(zodiac, frame) {
|
|
560
|
+
return zodiac.definition && !siderealFrame(frame) ? refuse(
|
|
561
|
+
"unsupported-combination",
|
|
562
|
+
`The sidereal zodiac is counted along the ecliptic of date; frame ${frame} is not offered with it, only ecliptic-true-of-date and ecliptic-mean-of-date.`
|
|
563
|
+
) : null;
|
|
564
|
+
}
|
|
565
|
+
function ayanamsaValue(definition, value, subtracted, k) {
|
|
566
|
+
return {
|
|
567
|
+
name: definition.name,
|
|
568
|
+
mean: value.mean * k,
|
|
569
|
+
nutation: value.nutation * k,
|
|
570
|
+
true: value.true * k,
|
|
571
|
+
subtracted,
|
|
572
|
+
bound: { value: ayanamsaBound(definition, value.elongation).position, unit: "arcsec", label: "measured", basis: ayanamsaBound(definition, value.elongation).basis }
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
function withAyanamsa(b, add2) {
|
|
576
|
+
if (add2 === null || b.value === null) return b;
|
|
577
|
+
return { ...b, value: addBounds(b.value, add2.value), basis: `${b.basis}; plus the ayanamsa's, ${add2.value} ${b.unit}: ${add2.basis}` };
|
|
578
|
+
}
|
|
459
579
|
function resolve(time) {
|
|
460
580
|
const inside = (days2, margin = 0) => days2 >= SPAN_DAYS[0] - margin && days2 < SPAN_DAYS[1] + margin;
|
|
461
581
|
const days = (time.ms - J2000_MS) / DAY_MS;
|
|
@@ -542,8 +662,29 @@ function evaluator(body, frame, center, correction) {
|
|
|
542
662
|
return { lon, lat, dist, xyz: [turned[0] * k, turned[1] * k, turned[2] * k], raw: lon };
|
|
543
663
|
};
|
|
544
664
|
}
|
|
545
|
-
function
|
|
546
|
-
const
|
|
665
|
+
function turnedBack([x, y, z], angle) {
|
|
666
|
+
const c = Math.cos(angle * DEG2);
|
|
667
|
+
const s = Math.sin(angle * DEG2);
|
|
668
|
+
return [x * c + y * s, y * c - x * s, z];
|
|
669
|
+
}
|
|
670
|
+
function siderealOf(evaluate, definition, frame) {
|
|
671
|
+
const trueOfDate = frame === "ecliptic-true-of-date";
|
|
672
|
+
return (at2) => {
|
|
673
|
+
const row = evaluate(at2);
|
|
674
|
+
const value = ayanamsaAt(definition, at2);
|
|
675
|
+
const subtracted = trueOfDate ? value.true : value.mean;
|
|
676
|
+
return {
|
|
677
|
+
lon: wrap360(wrap360(row.lon) - subtracted),
|
|
678
|
+
lat: row.lat,
|
|
679
|
+
dist: row.dist,
|
|
680
|
+
xyz: row.xyz && turnedBack(row.xyz, subtracted),
|
|
681
|
+
raw: row.raw - subtracted,
|
|
682
|
+
ayanamsa: value
|
|
683
|
+
};
|
|
684
|
+
};
|
|
685
|
+
}
|
|
686
|
+
function positionIds(body, frame, kind, correction, zodiac) {
|
|
687
|
+
const ids = [...zodiac.ids, `frame:${frame}`, `center:${kind}`];
|
|
547
688
|
if (isPoint(body)) {
|
|
548
689
|
ids.push("correction:not-applicable", body.endsWith("Lilith") ? "lilith:mean" : body.startsWith("Mean") ? "node:mean" : "node:true-osculating");
|
|
549
690
|
} else {
|
|
@@ -578,7 +719,7 @@ function calc(request) {
|
|
|
578
719
|
const asked = fields(request, "calc request", ["body", "time", "frame", "center", "zodiac", "flags"]);
|
|
579
720
|
const body = oneOf(asked.body, CALC_BODIES, "body");
|
|
580
721
|
const time = readTime(asked.time, "time");
|
|
581
|
-
const frame = oneOf(asked.frame,
|
|
722
|
+
const frame = oneOf(asked.frame, CALC_FRAMES2, "frame", "ecliptic-true-of-date");
|
|
582
723
|
let center;
|
|
583
724
|
let centerRecord;
|
|
584
725
|
if (asked.center === void 0 || typeof asked.center === "string") {
|
|
@@ -598,13 +739,16 @@ function calc(request) {
|
|
|
598
739
|
units: oneOf(given.units, ["degrees", "radians"], "flags.units", "degrees"),
|
|
599
740
|
deflection: yesNo(given.deflection, "flags.deflection", false)
|
|
600
741
|
};
|
|
742
|
+
const zodiac = readZodiac(asked.zodiac);
|
|
601
743
|
const point = isPoint(body);
|
|
602
744
|
const kind = center.kind;
|
|
603
|
-
const refusal =
|
|
745
|
+
const refusal = (flags.deflection ? refuse("not-in-this-version", "Gravitational light deflection is not modelled in this version.") : point && kind !== "geocentric" ? refuse("unsupported-combination", `${body} is a point of the Moon's geocentric orbit; only the geocentric center is offered.`) : point && flags.cartesian ? refuse("unsupported-combination", `${body} has no distance, so no cartesian position.`) : body === "Sun" && kind === "heliocentric" ? refuse("unsupported-combination", "The Sun is the heliocentric origin.") : body === "Earth" && (kind === "geocentric" || kind === "topocentric") ? refuse("unsupported-combination", "The Earth is offered heliocentric or barycentric only.") : frameRefusal(zodiac, frame)) ?? epochRefusal(zodiac);
|
|
604
746
|
if (refusal) return refusal;
|
|
605
747
|
const correction = flags.correction;
|
|
748
|
+
const definition = zodiac.definition;
|
|
606
749
|
return inSpan(time, (basis) => {
|
|
607
|
-
const
|
|
750
|
+
const tropical = evaluator(body, frame, center, correction);
|
|
751
|
+
const evaluate = definition === null ? tropical : siderealOf(tropical, definition, frame);
|
|
608
752
|
const now = onInput(time, time.ms, evaluate);
|
|
609
753
|
const step = isTrueNode(body) ? NODE_STEP_DAYS : STEP_DAYS;
|
|
610
754
|
const analytic = flags.speeds && correction === "geometric" && inertial(frame) && !point && body !== "Moon";
|
|
@@ -648,8 +792,10 @@ function calc(request) {
|
|
|
648
792
|
row = barycentricSun(now.dist, velocity && length(velocity));
|
|
649
793
|
estimated = `the largest angle, relative distance and rate of direction that the error of astronomy-engine's barycentre, ${BARYCENTRE_ERROR.au.toExponential()} au and ${BARYCENTRE_ERROR.auPerDay.toExponential()} au/day from 1800 to 2200, allows at this distance and speed; docs/evidence/calc-api`;
|
|
650
794
|
}
|
|
651
|
-
const ids = positionIds(body, frame, kind, correction);
|
|
795
|
+
const ids = positionIds(body, frame, kind, correction, zodiac);
|
|
652
796
|
if (method) ids.push(method === "analytic" ? "speed:analytic" : `speed:central-difference-${step}d`);
|
|
797
|
+
const sidereal = definition === null ? null : now.ayanamsa;
|
|
798
|
+
const added = sidereal && ayanamsaBound(definition, sidereal.elongation);
|
|
653
799
|
return {
|
|
654
800
|
status: "ok",
|
|
655
801
|
body,
|
|
@@ -659,13 +805,18 @@ function calc(request) {
|
|
|
659
805
|
dist: now.dist,
|
|
660
806
|
speeds: speeds && { lon: speeds.lon * k, lat: speeds.lat * k, dist: speeds.dist },
|
|
661
807
|
cartesian: flags.cartesian && now.xyz ? { x: now.xyz[0], y: now.xyz[1], z: now.xyz[2], vx: velocity?.[0] ?? null, vy: velocity?.[1] ?? null, vz: velocity?.[2] ?? null } : null,
|
|
808
|
+
ayanamsa: sidereal && ayanamsaValue(definition, sidereal, frame === "ecliptic-true-of-date" ? "true" : "mean", k),
|
|
662
809
|
bounds: {
|
|
663
|
-
position: bound(row?.[0], "arcsec", estimated),
|
|
810
|
+
position: withAyanamsa(bound(row?.[0], "arcsec", estimated), added && { value: added.position, basis: added.basis }),
|
|
664
811
|
distance: point ? null : bound(row?.[1], "relative", estimated),
|
|
665
|
-
speed: method && {
|
|
812
|
+
speed: method && {
|
|
813
|
+
...withAyanamsa(bound(row?.[2], "arcsec/day", estimated), added && { value: added.rate, basis: added.basis }),
|
|
814
|
+
method,
|
|
815
|
+
stepDays: analytic ? null : step
|
|
816
|
+
}
|
|
666
817
|
},
|
|
667
818
|
receipt: receipt(
|
|
668
|
-
{ body, time: time.record, frame, center: centerRecord, zodiac:
|
|
819
|
+
{ body, time: time.record, frame, center: centerRecord, zodiac: zodiac.record, flags },
|
|
669
820
|
[instant(basis)],
|
|
670
821
|
ids,
|
|
671
822
|
time.pin
|
|
@@ -674,38 +825,52 @@ function calc(request) {
|
|
|
674
825
|
});
|
|
675
826
|
}
|
|
676
827
|
function houses(request) {
|
|
677
|
-
const asked = fields(request, "houses request", ["time", "place", "
|
|
828
|
+
const asked = fields(request, "houses request", ["time", "place", "houseSystem", "zodiac"]);
|
|
678
829
|
const time = readTime(asked.time, "time");
|
|
679
830
|
const { latitude, longitude } = readPlace(asked.place, "place");
|
|
680
|
-
const system = validateBirthSettings({ houseSystem: asked.
|
|
681
|
-
const
|
|
831
|
+
const system = validateBirthSettings({ houseSystem: asked.houseSystem }).houseSystem ?? "whole";
|
|
832
|
+
const zodiac = readZodiac(asked.zodiac);
|
|
833
|
+
const refusal = epochRefusal(zodiac);
|
|
682
834
|
if (refusal) return refusal;
|
|
835
|
+
const definition = zodiac.definition;
|
|
683
836
|
return inSpan(time, (used) => {
|
|
684
|
-
const input = onInput(time, time.ms, (at2) => ({
|
|
685
|
-
|
|
686
|
-
|
|
837
|
+
const { input, value } = onInput(time, time.ms, (at2) => ({
|
|
838
|
+
input: { gastHours: gastHours(at2), latitude, longitude, obliquity: tilt(at2.tt).tobl },
|
|
839
|
+
value: definition && ayanamsaAt(definition, at2)
|
|
840
|
+
}));
|
|
841
|
+
const tropical = computeAngles(input);
|
|
842
|
+
const { houses: computed, fellBack } = computeHouses(system, input, tropical);
|
|
843
|
+
const zodiacal = value === null ? (lon) => lon : (lon) => wrap360(wrap360(lon) - value.true);
|
|
844
|
+
const angles = value === null ? tropical : { asc: zodiacal(tropical.asc), mc: zodiacal(tropical.mc), dsc: zodiacal(tropical.dsc), ic: zodiacal(tropical.ic) };
|
|
845
|
+
const cusps = value === null ? computed.cusps : computed.system === "whole" ? wholeSignCusps(angles.asc) : computed.cusps.map(zodiacal);
|
|
846
|
+
const bounded = definition && value && ayanamsaBound(definition, value.elongation);
|
|
847
|
+
const added = bounded && { value: bounded.position, basis: bounded.basis };
|
|
687
848
|
const basis = (what) => `largest difference over the conformance suite's L2 ${what}, whose arbiter is ERFA with each system's definition`;
|
|
688
849
|
return {
|
|
689
850
|
status: "ok",
|
|
690
851
|
requested: system,
|
|
691
852
|
system: computed.system,
|
|
692
|
-
cusps
|
|
853
|
+
cusps,
|
|
693
854
|
angles,
|
|
694
855
|
// Normalized once more, as chartPoints() reports them.
|
|
695
|
-
vertex: normalizeLongitude(vertexOf(input,
|
|
696
|
-
eastPoint: normalizeLongitude(eastPointOf(input)),
|
|
856
|
+
vertex: zodiacal(normalizeLongitude(vertexOf(input, tropical))),
|
|
857
|
+
eastPoint: zodiacal(normalizeLongitude(eastPointOf(input))),
|
|
697
858
|
armc: ramcOf(input),
|
|
698
859
|
obliquity: input.obliquity,
|
|
699
860
|
flags: fellBack ? ["polar-fallback"] : [],
|
|
861
|
+
ayanamsa: value && ayanamsaValue(definition, value, "true", 1),
|
|
700
862
|
bounds: {
|
|
701
|
-
angles:
|
|
702
|
-
|
|
863
|
+
angles: withAyanamsa(
|
|
864
|
+
{ value: 0.02, unit: "arcsec", label: "measured", basis: basis("vectors of the ascendant, midheaven, Vertex and East Point") },
|
|
865
|
+
added
|
|
866
|
+
),
|
|
867
|
+
cusps: withAyanamsa({ value: 0.08, unit: "arcsec", label: "measured", basis: basis("cusp vectors, thirteen systems") }, added)
|
|
703
868
|
},
|
|
704
869
|
receipt: receipt(
|
|
705
|
-
{ time: time.record, place: { latitude, longitude }, system, zodiac:
|
|
870
|
+
{ time: time.record, place: { latitude, longitude }, houseSystem: system, zodiac: zodiac.record },
|
|
706
871
|
[instant(used)],
|
|
707
872
|
[
|
|
708
|
-
|
|
873
|
+
...zodiac.ids,
|
|
709
874
|
`house:${system}`,
|
|
710
875
|
...fellBack ? ["polar-fallback:whole"] : [],
|
|
711
876
|
"angles:gast-and-true-obliquity",
|
|
@@ -728,15 +893,21 @@ function events(request) {
|
|
|
728
893
|
const stepDays = asked.stepDays === void 0 ? 5 : asked.stepDays;
|
|
729
894
|
const budget = asked.maxSamples === Infinity ? void 0 : asked.maxSamples;
|
|
730
895
|
const limit = budget === void 0 ? {} : { maxSamples: budget };
|
|
731
|
-
const
|
|
896
|
+
const zodiac = readZodiac(asked.zodiac);
|
|
897
|
+
const refusal = (!CHART_BODIES.includes(body) ? refuse("unsupported-combination", `Crossings are searched for the bodies positions() gives; ${body} is not one.`) : from.pin !== void 0 || to.pin !== void 0 ? refuse("unsupported-combination", "Crossing searches run on the engine's \u0394T model; a pinned \u0394T is not offered.") : null) ?? epochRefusal(zodiac);
|
|
732
898
|
if (refusal) return refusal;
|
|
899
|
+
const definition = zodiac.definition;
|
|
900
|
+
const longitudeAt = definition === null ? bodyLongitude : (b, date) => {
|
|
901
|
+
const tropical = bodyLongitude(b, date);
|
|
902
|
+
return wrap360(wrap360(tropical) - onChartClock(date.getTime(), "utc", void 0, (at2) => ayanamsaAt(definition, at2).true));
|
|
903
|
+
};
|
|
733
904
|
const start = resolve(from);
|
|
734
905
|
const end = resolve(to);
|
|
735
906
|
if (start === null || end === null) return outOfRange();
|
|
736
907
|
{
|
|
737
908
|
const dated = (basis) => new Date(Math.round(basis.utcMs));
|
|
738
909
|
const found = searchLongitudeCrossingsWith(
|
|
739
|
-
|
|
910
|
+
longitudeAt,
|
|
740
911
|
body,
|
|
741
912
|
longitude,
|
|
742
913
|
dated(start),
|
|
@@ -760,17 +931,30 @@ function events(request) {
|
|
|
760
931
|
value: stepDays * 86400 / 2 ** 24,
|
|
761
932
|
unit: "s",
|
|
762
933
|
label: "estimated",
|
|
763
|
-
basis: "the bisection bracket, step / 2^24, on the engine's own longitudes; the ephemeris's error over the body's speed adds to it"
|
|
934
|
+
basis: "the bisection bracket, step / 2^24, on the engine's own longitudes; the ephemeris's error over the body's speed adds to it" + (definition === null ? "" : ", and in the sidereal zodiac the ayanamsa's")
|
|
764
935
|
}
|
|
765
936
|
},
|
|
766
937
|
receipt: receipt(
|
|
767
|
-
{ kind, body, longitude, from: from.record, to: to.record, zodiac:
|
|
938
|
+
{ kind, body, longitude, from: from.record, to: to.record, zodiac: zodiac.record, stepDays, ...limit },
|
|
768
939
|
[instant(start), instant(end)],
|
|
769
|
-
[...positionIds(body, "ecliptic-true-of-date", "geocentric", "apparent"), "search:scan-and-bisect"]
|
|
940
|
+
[...positionIds(body, "ecliptic-true-of-date", "geocentric", "apparent", zodiac), "search:scan-and-bisect"]
|
|
770
941
|
)
|
|
771
942
|
};
|
|
772
943
|
}
|
|
773
944
|
}
|
|
945
|
+
function siderealOfChart(computed, definition) {
|
|
946
|
+
const sidereal = siderealChartOf(computed, definition);
|
|
947
|
+
const value = sidereal.ayanamsaValue;
|
|
948
|
+
const { elongation } = ayanamsaAt(definition, AstroTime.FromTerrestrialTime(value.julianDateTT - J2000_JD));
|
|
949
|
+
return {
|
|
950
|
+
ayanamsa: ayanamsaValue(definition, { mean: value.mean, nutation: value.nutation, true: value.true, elongation }, "true", 1),
|
|
951
|
+
bodies: sidereal.bodies.map(({ body, lon }) => ({ body, lon })),
|
|
952
|
+
ascendant: sidereal.ascendant === null ? null : sidereal.ascendant.lon,
|
|
953
|
+
midheaven: sidereal.midheaven === null ? null : sidereal.midheaven.lon,
|
|
954
|
+
houseSystem: sidereal.houseSystem,
|
|
955
|
+
cusps: sidereal.cusps === null ? null : sidereal.cusps.map((cusp) => cusp.lon)
|
|
956
|
+
};
|
|
957
|
+
}
|
|
774
958
|
function chart(request) {
|
|
775
959
|
const asked = fields(request, "chart request", ["time", "place", "houseSystem", "timeKnown", "timeFlags", "zodiac"]);
|
|
776
960
|
const time = readTime(asked.time, "time");
|
|
@@ -778,7 +962,8 @@ function chart(request) {
|
|
|
778
962
|
const place = site === null ? null : { latitude: site.latitude, longitude: site.longitude };
|
|
779
963
|
const settings = validateBirthSettings({ houseSystem: asked.houseSystem, timeKnown: asked.timeKnown });
|
|
780
964
|
const supplied = asked.timeFlags === void 0 ? void 0 : snapshotFlags(asked.timeFlags).values;
|
|
781
|
-
const
|
|
965
|
+
const zodiac = readZodiac(asked.zodiac);
|
|
966
|
+
const refusal = epochRefusal(zodiac);
|
|
782
967
|
if (refusal) return refusal;
|
|
783
968
|
const whole = { ...time, ms: Math.round(time.ms) };
|
|
784
969
|
return inSpan(whole, (basis) => {
|
|
@@ -802,6 +987,7 @@ function chart(request) {
|
|
|
802
987
|
return {
|
|
803
988
|
status: "ok",
|
|
804
989
|
chart: computed,
|
|
990
|
+
sidereal: zodiac.definition && siderealOfChart(computed, zodiac.definition),
|
|
805
991
|
receipt: receipt(
|
|
806
992
|
{
|
|
807
993
|
time: time.record,
|
|
@@ -809,11 +995,11 @@ function chart(request) {
|
|
|
809
995
|
houseSystem,
|
|
810
996
|
timeKnown,
|
|
811
997
|
...supplied && { timeFlags: supplied },
|
|
812
|
-
zodiac:
|
|
998
|
+
zodiac: zodiac.record
|
|
813
999
|
},
|
|
814
1000
|
[used],
|
|
815
1001
|
[
|
|
816
|
-
|
|
1002
|
+
...zodiac.ids,
|
|
817
1003
|
"frame:ecliptic-true-of-date",
|
|
818
1004
|
"center:geocentric",
|
|
819
1005
|
"correction:apparent",
|
|
@@ -843,7 +1029,7 @@ function chart(request) {
|
|
|
843
1029
|
export {
|
|
844
1030
|
CALC_AYANAMSAS,
|
|
845
1031
|
CALC_BODIES,
|
|
846
|
-
CALC_FRAMES,
|
|
1032
|
+
CALC_FRAMES2 as CALC_FRAMES,
|
|
847
1033
|
CALC_RECEIPT_SCHEMA,
|
|
848
1034
|
CALC_SPAN,
|
|
849
1035
|
calc,
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/read-options.ts
|
|
2
|
+
function readOptions(value, allowed, label) {
|
|
3
|
+
const out = /* @__PURE__ */ Object.create(null);
|
|
4
|
+
if (value === void 0) return out;
|
|
5
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
6
|
+
throw new RangeError(`${label} must be an options object.`);
|
|
7
|
+
}
|
|
8
|
+
const prototype = Object.getPrototypeOf(value);
|
|
9
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
10
|
+
throw new RangeError(`${label} must be a plain options object.`);
|
|
11
|
+
}
|
|
12
|
+
for (const key of Reflect.ownKeys(value)) {
|
|
13
|
+
if (typeof key !== "string" || !allowed.includes(key)) {
|
|
14
|
+
throw new RangeError(`${label} has an unknown option: ${String(key)}.`);
|
|
15
|
+
}
|
|
16
|
+
const slot = Object.getOwnPropertyDescriptor(value, key);
|
|
17
|
+
if (!slot || !("value" in slot) || !slot.enumerable) {
|
|
18
|
+
throw new RangeError(`${label} must contain only plain data properties.`);
|
|
19
|
+
}
|
|
20
|
+
if (slot.value !== void 0) out[key] = slot.value;
|
|
21
|
+
}
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
readOptions
|
|
27
|
+
};
|