astroceleste-engine 0.0.12 → 0.0.13

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/NOTICE CHANGED
@@ -33,6 +33,12 @@ Ephemeris data: NASA JPL planetary ephemerides (DE440s and others) are public do
33
33
  works of the U.S. Government, fetched at build/run time and not distributed here, except
34
34
  for a one-year DE440s excerpt used by the tests (tests/data/de440s_2000.bsp).
35
35
 
36
+ The minor-body longitude tables (src/data/minor/*.bin) and their test check points
37
+ (tests/fixtures/minor_bodies.json) are sampled from the JPL Horizons on-line solar system
38
+ data and ephemeris computation service (https://ssd.jpl.nasa.gov/horizons/), Solar
39
+ System Dynamics Group, Jet Propulsion Laboratory, California Institute of Technology, by
40
+ scripts/fetch_minor_bodies.py.
41
+
36
42
  The Zi Wei Dou Shu star brightness table (src/chinese/ziwei.rs) is taken from iztro
37
43
  (https://github.com/SylarLong/iztro), used under the MIT license:
38
44
 
package/README.md CHANGED
@@ -12,7 +12,7 @@ computed entirely in the browser (or Node), identical to the Astroceleste server
12
12
  [API guide](https://github.com/ffalcinelli/astroceleste-engine/blob/main/docs/api.md)
13
13
 
14
14
  ```js
15
- import init, { Engine, synastry, derivedChart } from "astroceleste-engine";
15
+ import init, { Engine, synastry, derivedChart, bazi, ziWei, timeLords } from "astroceleste-engine";
16
16
 
17
17
  await init();
18
18
  const engine = new Engine();
@@ -23,16 +23,27 @@ const chart = engine.chart({
23
23
  utc: "1987-05-17T14:30:00Z",
24
24
  latitude: 41.9,
25
25
  longitude: 12.5,
26
- house_system: "P", // optional: P, W, E, O
26
+ house_system: "P", // optional: P, K, R, C, T, B, M, O, E, V, W
27
27
  zodiac_type: "sidereal", // optional: tropical (default) or sidereal
28
28
  ayanamsa: "lahiri", // optional
29
+ chinese_calendar: true, // optional: add the Chinese calendar of the moment
29
30
  });
30
- const horary = engine.horary(request); // chart + horary_data
31
+ const horary = engine.horary({ ...request, quesited_house: 7 }); // chart + horary_data
31
32
  const transit = engine.transit(chart.planets, request);
33
+ const election = engine.election(request, { purpose: "contract" });
34
+ const windows = engine.elections(request, "1987-06-17T00:00:00Z", { purpose: "launch" });
32
35
  synastry(chartA.planets, chartB.planets);
33
36
  derivedChart(chart, 5);
37
+ timeLords(birthUtc, sunLongitude, ascendantLongitude, fromUtc, toUtc);
38
+ bazi(chart.chinese_calendar, request.utc, 12.5, 60); // Four Pillars, UTC offset in minutes
39
+ ziWei(chart.chinese_calendar, request.utc, 12.5, 60); // Zi Wei Dou Shu
34
40
  ```
35
41
 
42
+ Also: `engine.chineseCalendar(utc)`, `engine.kernels`, `engine.coverage`,
43
+ `engine.supports(jd)`, `chartDignities(chart, "dorothean")`, `degreeQualities(longitude)`,
44
+ `degreeQualityTable()` and `julianDay(utc)`. The [API guide](https://github.com/ffalcinelli/astroceleste-engine/blob/main/docs/api.md)
45
+ describes every option and result.
46
+
36
47
  To ship a smaller kernel, cut the range you need (positions are unchanged inside it):
37
48
 
38
49
  ```js
@@ -41,7 +52,7 @@ const small = excerptKernel(fullKernelBytes, 2415020.5, 2488069.5); // 1900-2100
41
52
  ```
42
53
 
43
54
  Errors are thrown as `Error` objects with a `code` (`ephemeris_out_of_range`,
44
- `invalid_input`, `invalid_kernel`).
55
+ `ephemeris_error`, `invalid_input`, `invalid_kernel`, `internal_error`).
45
56
 
46
57
  JPL kernels: https://ssd.jpl.nasa.gov/ftp/eph/planets/bsp/ (`de440s.bsp` covers 1849-2150,
47
58
  32 MB). Licensed under MIT OR Apache-2.0.
@@ -16,6 +16,12 @@ export class Engine {
16
16
  * The chart of a moment and place.
17
17
  */
18
18
  chart(request: any): any;
19
+ /**
20
+ * The Chinese calendar around `utc` (ISO 8601): solar terms, lunar months and the
21
+ * equation of time; `null` when the loaded kernels do not cover the year or so it
22
+ * needs.
23
+ */
24
+ chineseCalendar(utc: string): any;
19
25
  /**
20
26
  * A chart with its electional assessment under `election_data`. `criteria` may be
21
27
  * `undefined` for the defaults.
@@ -43,6 +49,10 @@ export class Engine {
43
49
  * `[firstJD, lastJD]` covered by the loaded kernels, or `undefined`.
44
50
  */
45
51
  readonly coverage: Float64Array | undefined;
52
+ /**
53
+ * The loaded kernels as `[name, firstJD, lastJD]`, in preference order.
54
+ */
55
+ readonly kernels: any;
46
56
  }
47
57
 
48
58
  /**
@@ -116,10 +126,12 @@ export interface InitOutput {
116
126
  readonly derivedChart: (a: any, b: number, c: number, d: number) => [number, number, number];
117
127
  readonly engine_addKernel: (a: number, b: number, c: number, d: number, e: number) => [number, number];
118
128
  readonly engine_chart: (a: number, b: any) => [number, number, number];
129
+ readonly engine_chineseCalendar: (a: number, b: number, c: number) => [number, number, number];
119
130
  readonly engine_coverage: (a: number) => [number, number];
120
131
  readonly engine_election: (a: number, b: any, c: any) => [number, number, number];
121
132
  readonly engine_elections: (a: number, b: any, c: number, d: number, e: any) => [number, number, number];
122
133
  readonly engine_horary: (a: number, b: any) => [number, number, number];
134
+ readonly engine_kernels: (a: number) => [number, number, number];
123
135
  readonly engine_new: () => number;
124
136
  readonly engine_supports: (a: number, b: number) => number;
125
137
  readonly engine_transit: (a: number, b: any, c: any) => [number, number, number];
@@ -42,6 +42,22 @@ export class Engine {
42
42
  }
43
43
  return takeFromExternrefTable0(ret[0]);
44
44
  }
45
+ /**
46
+ * The Chinese calendar around `utc` (ISO 8601): solar terms, lunar months and the
47
+ * equation of time; `null` when the loaded kernels do not cover the year or so it
48
+ * needs.
49
+ * @param {string} utc
50
+ * @returns {any}
51
+ */
52
+ chineseCalendar(utc) {
53
+ const ptr0 = passStringToWasm0(utc, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
54
+ const len0 = WASM_VECTOR_LEN;
55
+ const ret = wasm.engine_chineseCalendar(this.__wbg_ptr, ptr0, len0);
56
+ if (ret[2]) {
57
+ throw takeFromExternrefTable0(ret[1]);
58
+ }
59
+ return takeFromExternrefTable0(ret[0]);
60
+ }
45
61
  /**
46
62
  * `[firstJD, lastJD]` covered by the loaded kernels, or `undefined`.
47
63
  * @returns {Float64Array | undefined}
@@ -98,6 +114,17 @@ export class Engine {
98
114
  }
99
115
  return takeFromExternrefTable0(ret[0]);
100
116
  }
117
+ /**
118
+ * The loaded kernels as `[name, firstJD, lastJD]`, in preference order.
119
+ * @returns {any}
120
+ */
121
+ get kernels() {
122
+ const ret = wasm.engine_kernels(this.__wbg_ptr);
123
+ if (ret[2]) {
124
+ throw takeFromExternrefTable0(ret[1]);
125
+ }
126
+ return takeFromExternrefTable0(ret[0]);
127
+ }
101
128
  constructor() {
102
129
  const ret = wasm.engine_new();
103
130
  this.__wbg_ptr = ret;
@@ -308,11 +335,11 @@ export function ziWei(calendar, birth, longitude, utcOffsetMinutes, options) {
308
335
  function __wbg_get_imports() {
309
336
  const import0 = {
310
337
  __proto__: null,
311
- __wbg_Error_67e7344beaa85059: function(arg0, arg1) {
338
+ __wbg_Error_30c8987f7c2ed4e2: function(arg0, arg1) {
312
339
  const ret = Error(getStringFromWasm0(arg0, arg1));
313
340
  return ret;
314
341
  },
315
- __wbg_Number_c54e7112a3fa7e3e: function(arg0) {
342
+ __wbg_Number_14af1003b8dd5ead: function(arg0) {
316
343
  const ret = Number(arg0);
317
344
  return ret;
318
345
  },
@@ -323,68 +350,68 @@ function __wbg_get_imports() {
323
350
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
324
351
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
325
352
  },
326
- __wbg___wbindgen_bigint_get_as_i64_b482365c149396c8: function(arg0, arg1) {
353
+ __wbg___wbindgen_bigint_get_as_i64_a2383202b9353e4c: function(arg0, arg1) {
327
354
  const v = arg1;
328
355
  const ret = typeof(v) === 'bigint' ? v : undefined;
329
356
  getDataViewMemory0().setBigInt64(arg0 + 8 * 1, isLikeNone(ret) ? BigInt(0) : ret, true);
330
357
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
331
358
  },
332
- __wbg___wbindgen_boolean_get_7a12af2b3f899c5a: function(arg0) {
359
+ __wbg___wbindgen_boolean_get_5b446f51afd21013: function(arg0) {
333
360
  const v = arg0;
334
361
  const ret = typeof(v) === 'boolean' ? v : undefined;
335
362
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
336
363
  },
337
- __wbg___wbindgen_debug_string_0e68cf47c9cbd9b0: function(arg0, arg1) {
364
+ __wbg___wbindgen_debug_string_4687d8d8c2017d52: function(arg0, arg1) {
338
365
  const ret = debugString(arg1);
339
366
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
340
367
  const len1 = WASM_VECTOR_LEN;
341
368
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
342
369
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
343
370
  },
344
- __wbg___wbindgen_in_50072d4d6e45c193: function(arg0, arg1) {
371
+ __wbg___wbindgen_in_92f62ee1427d9e49: function(arg0, arg1) {
345
372
  const ret = arg0 in arg1;
346
373
  return ret;
347
374
  },
348
- __wbg___wbindgen_is_bigint_60fc0336cb14f5d7: function(arg0) {
375
+ __wbg___wbindgen_is_bigint_b123553bed3bb382: function(arg0) {
349
376
  const ret = typeof(arg0) === 'bigint';
350
377
  return ret;
351
378
  },
352
- __wbg___wbindgen_is_function_fcda5e3902d732fe: function(arg0) {
379
+ __wbg___wbindgen_is_function_1f9d30630b8b1d3d: function(arg0) {
353
380
  const ret = typeof(arg0) === 'function';
354
381
  return ret;
355
382
  },
356
- __wbg___wbindgen_is_null_5160b3e381865372: function(arg0) {
383
+ __wbg___wbindgen_is_null_e343b7d08827ba72: function(arg0) {
357
384
  const ret = arg0 === null;
358
385
  return ret;
359
386
  },
360
- __wbg___wbindgen_is_object_edb6b15aa3afe12e: function(arg0) {
387
+ __wbg___wbindgen_is_object_3c45d4f2dde4e749: function(arg0) {
361
388
  const val = arg0;
362
389
  const ret = typeof(val) === 'object' && val !== null;
363
390
  return ret;
364
391
  },
365
- __wbg___wbindgen_is_string_c4f7cb494a2a21f1: function(arg0) {
392
+ __wbg___wbindgen_is_string_90b56bc79aad6f6c: function(arg0) {
366
393
  const ret = typeof(arg0) === 'string';
367
394
  return ret;
368
395
  },
369
- __wbg___wbindgen_is_undefined_8c687d0b90d5b524: function(arg0) {
396
+ __wbg___wbindgen_is_undefined_8865fb403f8fe9d8: function(arg0) {
370
397
  const ret = arg0 === undefined;
371
398
  return ret;
372
399
  },
373
- __wbg___wbindgen_jsval_eq_9fdcd3c0a860dd3b: function(arg0, arg1) {
400
+ __wbg___wbindgen_jsval_eq_02babf21faa37971: function(arg0, arg1) {
374
401
  const ret = arg0 === arg1;
375
402
  return ret;
376
403
  },
377
- __wbg___wbindgen_jsval_loose_eq_3c30021c243b64cd: function(arg0, arg1) {
404
+ __wbg___wbindgen_jsval_loose_eq_677f21e468d6b461: function(arg0, arg1) {
378
405
  const ret = arg0 == arg1;
379
406
  return ret;
380
407
  },
381
- __wbg___wbindgen_number_get_1dc732b810cb937c: function(arg0, arg1) {
408
+ __wbg___wbindgen_number_get_2e0e7dee9f701a71: function(arg0, arg1) {
382
409
  const obj = arg1;
383
410
  const ret = typeof(obj) === 'number' ? obj : undefined;
384
411
  getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
385
412
  getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
386
413
  },
387
- __wbg___wbindgen_string_get_92ab86bb19cbc12f: function(arg0, arg1) {
414
+ __wbg___wbindgen_string_get_0380ccaa2f57f0d9: function(arg0, arg1) {
388
415
  const obj = arg1;
389
416
  const ret = typeof(obj) === 'string' ? obj : undefined;
390
417
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
@@ -392,30 +419,30 @@ function __wbg_get_imports() {
392
419
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
393
420
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
394
421
  },
395
- __wbg___wbindgen_throw_5d9e815e6fdf150f: function(arg0, arg1) {
422
+ __wbg___wbindgen_throw_41e9ee4f547fc59a: function(arg0, arg1) {
396
423
  throw new Error(getStringFromWasm0(arg0, arg1));
397
424
  },
398
- __wbg_call_269c5566fbede3eb: function() { return handleError(function (arg0, arg1) {
425
+ __wbg_call_6137034ef55c9d0f: function() { return handleError(function (arg0, arg1) {
399
426
  const ret = arg0.call(arg1);
400
427
  return ret;
401
428
  }, arguments); },
402
- __wbg_done_cffed884d87aa22e: function(arg0) {
429
+ __wbg_done_b41a1d26cdb37fb6: function(arg0) {
403
430
  const ret = arg0.done;
404
431
  return ret;
405
432
  },
406
- __wbg_entries_972a87586902cf87: function(arg0) {
433
+ __wbg_entries_fb6397112b1de25f: function(arg0) {
407
434
  const ret = Object.entries(arg0);
408
435
  return ret;
409
436
  },
410
- __wbg_get_6cf5a4d4d8ad3c5a: function() { return handleError(function (arg0, arg1) {
437
+ __wbg_get_658f6698067d9515: function() { return handleError(function (arg0, arg1) {
411
438
  const ret = Reflect.get(arg0, arg1);
412
439
  return ret;
413
440
  }, arguments); },
414
- __wbg_get_b1f0ab13c737f856: function(arg0, arg1) {
441
+ __wbg_get_6c896e0571ddae51: function(arg0, arg1) {
415
442
  const ret = arg0[arg1 >>> 0];
416
443
  return ret;
417
444
  },
418
- __wbg_get_unchecked_363572bdd397d473: function(arg0, arg1) {
445
+ __wbg_get_unchecked_288889d017702237: function(arg0, arg1) {
419
446
  const ret = arg0[arg1 >>> 0];
420
447
  return ret;
421
448
  },
@@ -423,7 +450,7 @@ function __wbg_get_imports() {
423
450
  const ret = arg0[arg1];
424
451
  return ret;
425
452
  },
426
- __wbg_instanceof_ArrayBuffer_d4ff01f8247925ae: function(arg0) {
453
+ __wbg_instanceof_ArrayBuffer_a99f175873e5d9b8: function(arg0) {
427
454
  let result;
428
455
  try {
429
456
  result = arg0 instanceof ArrayBuffer;
@@ -433,7 +460,7 @@ function __wbg_get_imports() {
433
460
  const ret = result;
434
461
  return ret;
435
462
  },
436
- __wbg_instanceof_Map_1ff6a2b54c899f0d: function(arg0) {
463
+ __wbg_instanceof_Map_b2611749102d7ba3: function(arg0) {
437
464
  let result;
438
465
  try {
439
466
  result = arg0 instanceof Map;
@@ -443,7 +470,7 @@ function __wbg_get_imports() {
443
470
  const ret = result;
444
471
  return ret;
445
472
  },
446
- __wbg_instanceof_Uint8Array_598adc0fef426aa8: function(arg0) {
473
+ __wbg_instanceof_Uint8Array_828cef2aaacafc31: function(arg0) {
447
474
  let result;
448
475
  try {
449
476
  result = arg0 instanceof Uint8Array;
@@ -453,72 +480,72 @@ function __wbg_get_imports() {
453
480
  const ret = result;
454
481
  return ret;
455
482
  },
456
- __wbg_isArray_5674713bb7b79043: function(arg0) {
483
+ __wbg_isArray_e15a2ff68ffdbef2: function(arg0) {
457
484
  const ret = Array.isArray(arg0);
458
485
  return ret;
459
486
  },
460
- __wbg_isSafeInteger_8f51c743827d1ec5: function(arg0) {
487
+ __wbg_isSafeInteger_717808ad6a54bd9e: function(arg0) {
461
488
  const ret = Number.isSafeInteger(arg0);
462
489
  return ret;
463
490
  },
464
- __wbg_iterator_22ddeb808cf55a6f: function() {
491
+ __wbg_iterator_e3c31c892080e444: function() {
465
492
  const ret = Symbol.iterator;
466
493
  return ret;
467
494
  },
468
- __wbg_length_31bdaf014f5fbde2: function(arg0) {
495
+ __wbg_length_7f3c00c40364105e: function(arg0) {
469
496
  const ret = arg0.length;
470
497
  return ret;
471
498
  },
472
- __wbg_length_4e1adc0d42e23620: function(arg0) {
499
+ __wbg_length_d4bdea10311bd9cf: function(arg0) {
473
500
  const ret = arg0.length;
474
501
  return ret;
475
502
  },
476
- __wbg_new_1da3429bc3c4541c: function(arg0) {
503
+ __wbg_new_1dbf7428bba60a42: function(arg0) {
477
504
  const ret = new Uint8Array(arg0);
478
505
  return ret;
479
506
  },
480
- __wbg_new_8d36e20aa758e411: function() {
507
+ __wbg_new_28744009d011f847: function() {
481
508
  const ret = new Map();
482
509
  return ret;
483
510
  },
484
- __wbg_new_a32a1ab6c6655abe: function(arg0, arg1) {
511
+ __wbg_new_343a093a3c2ffb4e: function(arg0, arg1) {
485
512
  const ret = new Error(getStringFromWasm0(arg0, arg1));
486
513
  return ret;
487
514
  },
488
- __wbg_new_bebc3f4757acf305: function() {
515
+ __wbg_new_617a8cdb8bb1130e: function() {
489
516
  const ret = new Object();
490
517
  return ret;
491
518
  },
492
- __wbg_new_ffa92086ea89f79c: function() {
519
+ __wbg_new_ee2291f50781bf1d: function() {
493
520
  const ret = new Array();
494
521
  return ret;
495
522
  },
496
- __wbg_next_95053e306b1c3aed: function(arg0) {
523
+ __wbg_next_33784799010f1bbe: function(arg0) {
497
524
  const ret = arg0.next;
498
525
  return ret;
499
526
  },
500
- __wbg_next_f31ecb8646d2c605: function() { return handleError(function (arg0) {
527
+ __wbg_next_f4aac29c42af995c: function() { return handleError(function (arg0) {
501
528
  const ret = arg0.next();
502
529
  return ret;
503
530
  }, arguments); },
504
- __wbg_prototypesetcall_ae9f5e7459250748: function(arg0, arg1, arg2) {
531
+ __wbg_prototypesetcall_bc27214492979395: function(arg0, arg1, arg2) {
505
532
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
506
533
  },
507
- __wbg_set_13d25b81ab403f5e: function(arg0, arg1, arg2) {
508
- arg0[arg1 >>> 0] = arg2;
509
- },
510
- __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
511
- arg0[arg1] = arg2;
512
- },
513
- __wbg_set_a377297433dfea63: function() { return handleError(function (arg0, arg1, arg2) {
534
+ __wbg_set_145a351398b48c65: function() { return handleError(function (arg0, arg1, arg2) {
514
535
  const ret = Reflect.set(arg0, arg1, arg2);
515
536
  return ret;
516
537
  }, arguments); },
517
- __wbg_set_bf6dde4923b9b059: function(arg0, arg1, arg2) {
538
+ __wbg_set_6ae97e73113c4f0b: function(arg0, arg1, arg2) {
518
539
  const ret = arg0.set(arg1, arg2);
519
540
  return ret;
520
541
  },
521
- __wbg_value_c227f843d21da141: function(arg0) {
542
+ __wbg_set_6be42768c690e380: function(arg0, arg1, arg2) {
543
+ arg0[arg1] = arg2;
544
+ },
545
+ __wbg_set_bea140a88be9b277: function(arg0, arg1, arg2) {
546
+ arg0[arg1 >>> 0] = arg2;
547
+ },
548
+ __wbg_value_f3c585ee8f5ba40c: function(arg0) {
522
549
  const ret = arg0.value;
523
550
  return ret;
524
551
  },
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "astroceleste-engine",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for astroceleste-engine",
5
- "version": "0.0.12",
5
+ "version": "0.0.13",
6
6
  "license": "MIT OR Apache-2.0",
7
7
  "repository": {
8
8
  "type": "git",