sweph 2.10.2-4 → 2.10.3-2

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.
Files changed (61) hide show
  1. package/README.md +12 -11
  2. package/deps/swisseph/swecl.c +32 -42
  3. package/deps/swisseph/swehouse.c +5 -1
  4. package/deps/swisseph/sweph.c +194 -288
  5. package/deps/swisseph/sweph.h +3 -6
  6. package/deps/swisseph/swephexp.h +3 -3
  7. package/deps/swisseph/swephlib.c +11 -12
  8. package/deps/swisseph/swephlib.h +0 -2
  9. package/index.d.ts +7 -7
  10. package/package.json +2 -2
  11. package/src/functions/calc.cpp +1 -1
  12. package/src/functions/calc_pctr.cpp +1 -1
  13. package/src/functions/calc_ut.cpp +1 -1
  14. package/src/functions/deltat_ex.cpp +1 -1
  15. package/src/functions/fixstar.cpp +1 -1
  16. package/src/functions/fixstar2.cpp +1 -1
  17. package/src/functions/fixstar2_mag.cpp +1 -1
  18. package/src/functions/fixstar2_ut.cpp +1 -1
  19. package/src/functions/fixstar_mag.cpp +1 -1
  20. package/src/functions/fixstar_ut.cpp +1 -1
  21. package/src/functions/gauquelin_sector.cpp +1 -1
  22. package/src/functions/get_ayanamsa_ex.cpp +1 -1
  23. package/src/functions/get_ayanamsa_ex_ut.cpp +1 -1
  24. package/src/functions/get_orbital_elements.cpp +1 -1
  25. package/src/functions/heliacal_pheno_ut.cpp +1 -1
  26. package/src/functions/heliacal_ut.cpp +1 -1
  27. package/src/functions/helio_cross.cpp +1 -1
  28. package/src/functions/helio_cross_ut.cpp +1 -1
  29. package/src/functions/house_pos.cpp +1 -1
  30. package/src/functions/houses_armc_ex2.cpp +1 -1
  31. package/src/functions/houses_ex2.cpp +1 -1
  32. package/src/functions/lat_to_lmt.cpp +1 -1
  33. package/src/functions/lmt_to_lat.cpp +1 -1
  34. package/src/functions/lun_eclipse_how.cpp +1 -1
  35. package/src/functions/lun_eclipse_when.cpp +1 -1
  36. package/src/functions/lun_eclipse_when_loc.cpp +1 -1
  37. package/src/functions/lun_occult_when_glob.cpp +1 -1
  38. package/src/functions/lun_occult_when_loc.cpp +1 -1
  39. package/src/functions/lun_occult_where.cpp +1 -1
  40. package/src/functions/mooncross.cpp +1 -1
  41. package/src/functions/mooncross_node.cpp +1 -1
  42. package/src/functions/mooncross_node_ut.cpp +1 -1
  43. package/src/functions/mooncross_ut.cpp +1 -1
  44. package/src/functions/nod_aps.cpp +1 -1
  45. package/src/functions/nod_aps_ut.cpp +1 -1
  46. package/src/functions/orbit_max_min_true_distance.cpp +1 -1
  47. package/src/functions/pheno.cpp +1 -1
  48. package/src/functions/pheno_ut.cpp +1 -1
  49. package/src/functions/rise_trans.cpp +1 -1
  50. package/src/functions/rise_trans_true_hor.cpp +1 -1
  51. package/src/functions/set_ephe_path.cpp +1 -1
  52. package/src/functions/set_jpl_file.cpp +1 -1
  53. package/src/functions/sol_eclipse_how.cpp +1 -1
  54. package/src/functions/sol_eclipse_when_glob.cpp +1 -1
  55. package/src/functions/sol_eclipse_when_loc.cpp +1 -1
  56. package/src/functions/sol_eclipse_where.cpp +1 -1
  57. package/src/functions/solcross.cpp +1 -1
  58. package/src/functions/solcross_ut.cpp +1 -1
  59. package/src/functions/time_equ.cpp +1 -1
  60. package/src/functions/utc_to_jd.cpp +1 -1
  61. package/src/functions/vis_limit_mag.cpp +1 -1
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Sweph
2
2
 
3
3
  The definitive Swiss Ephemeris bindings for Node.js
4
- Everything you need to create Astrology and Astronomy applications with javascript and node
4
+ Everything you need to create Astrology and Astronomy applications with JavaScript and node
5
5
 
6
6
  * 100% API coverage
7
7
  * Built-in Typescript declarations and ESM exports
@@ -9,9 +9,9 @@ Everything you need to create Astrology and Astronomy applications with javascri
9
9
  * Version matched
10
10
  * Made with the N-API
11
11
 
12
- [Official programmers documentation for the Swiss Ephemeris by Astrodienst AG](https://www.astro.com/swisseph/swephprg.htm)
12
+ [Official programmer's documentation for the Swiss Ephemeris by Astrodienst AG](https://www.astro.com/swisseph/swephprg.htm)
13
13
  [Official guide for the Swiss Ephemeris by Astrodienst AG](https://www.astro.com/ftp/swisseph/doc/swisseph.htm)
14
- [Sweph on Github](https://github.com/timotejroiko/sweph)
14
+ [Sweph on GitHub](https://github.com/timotejroiko/sweph)
15
15
  [Sweph on NPM](https://npmjs.com/package/sweph)
16
16
 
17
17
  ## Installation and Licensing
@@ -36,7 +36,7 @@ If you own a professional license for the Swiss Ephemeris, you may use any versi
36
36
 
37
37
  This library is version locked to the Swiss Ephemeris in addition to its own revisions. For example, version `2.10.1-1` corresponds to the Swiss Ephemeris version `2.10.1` and this library's revision `1`.
38
38
 
39
- Updates to this library will be released under new revisions, while updates to Swiss Ephemeris will be released under matching semver versions.
39
+ Updates to this library will be released under new revisions, while updates to Swiss Ephemeris will be released under matching SemVer versions.
40
40
 
41
41
  ## Documentation
42
42
 
@@ -61,20 +61,21 @@ For advanced usage, the following files can also be found:
61
61
 
62
62
  * astxxx folders - files for individual asteroids (600 years)
63
63
  * longfiles folder - files for individual asteroids (6000 years)
64
- * jplfiles folder - files for nasa's jpl ephemerides
64
+ * jplfiles folder - files for NASA's JPL ephemerides
65
65
  * sat folder - files for planetary moons
66
66
 
67
- More information can be found in the [Swiss Ephemeris files documentation](https://www.astro.com/ftp/swisseph/doc/swisseph.htm#_Toc58931065).
67
+ More information can be found in the [Swiss Ephemeris files documentation](https://www.astro.com/ftp/swisseph/doc/swisseph.htm).
68
68
 
69
69
  ## Contributing
70
70
 
71
- If you find any innacuracy or bug in this library, or if you find an update that is not yet included in this library, feel free to open an issue or a pull request.
71
+ If you find any inaccuracy or bug in this library, or if you find an upstream update that is not yet included in this library, feel free to open an issue or a pull request.
72
72
 
73
- ## Known Issues and Caveats
73
+ ## Limitations
74
74
 
75
- * Due to how the underlying C library operates, you may find that the `error` field returned by some functions will contain random data even if there is no actual error. This can happen when existing memory buffers are recycled therefore the user must always check the returned flag values as per the Swiss Ephemeris documentation.
76
- * While worker_threads are supported, the underlying C library is single threaded and its settings are global. Functions such as `set_ephe_path()` will affect the entire process, including worker_threads. While you can still use worker_threads as long as you dont change settings from other threads in the middle of calculations, true thread-safe multithreading can be achieved using child_process instead.
75
+ * While worker_threads are supported, the underlying C library is single threaded and contains process-wide settings. Functions such as `set_ephe_path()` or `set_sid_mode()` will affect the entire process, including all worker_threads. While you can still use worker_threads as long as you don't change settings from other threads in the middle of calculations, true thread-safe multithreading can only be achieved using child_process.
76
+
77
+ * This library is a C/C++ add-on designed for Node.JS only, it will not work in browsers, other JS engines or in any other environment that does not support native C/C++ add-ons. In order to install this library, the target system must have the necessary build tools installed, such as `python`, `make` and `gcc` on Linux, `xcode` on Mac, `visual c++` on Windows, and/or other equivalent solutions.
77
78
 
78
79
  ## Author
79
80
 
80
- Copyright © 2021, Timotej Valentin Rojko
81
+ Copyright © 2021-2022, Timotej Valentin Rojko
@@ -3072,7 +3072,7 @@ double CALL_CONV swe_refrac_extended(double inalt, double geoalt, double atpress
3072
3072
  y = N;
3073
3073
  }
3074
3074
  refr = D;
3075
- if( (inalt + refr < dip) ) {
3075
+ if (inalt + refr < dip) {
3076
3076
  if (dret != NULL) {
3077
3077
  dret[0]=inalt;
3078
3078
  dret[1]=inalt;
@@ -3161,10 +3161,10 @@ static double calc_dip(double geoalt, double atpress, double attemp, double laps
3161
3161
  {
3162
3162
  /* below formula is based on A. Thom, Megalithic lunar observations, 1973 (page 32).
3163
3163
  * conversion to metric has been done by
3164
- * V. Reijs, 2000, http://www.iol.ie/~geniet/eng/refract.htm
3164
+ * V. Reijs, 2000, http://www.archaeocosmology.org/eng/refract.htm#Sea
3165
3165
  */
3166
3166
  double krefr = (0.0342 + lapse_rate) / (0.154 * 0.0238);
3167
- double d = 1-1.8480*krefr*atpress/(273.16+attemp)/(273.16+attemp);
3167
+ double d = 1-1.8480*krefr*atpress/(273.15+attemp)/(273.15+attemp);
3168
3168
  /* return -0.03203*sqrt(geoalt)*sqrt(d); */
3169
3169
  /* double a = acos(1/(1+geoalt/EARTH_RADIUS));*/
3170
3170
  return -180.0/PI * acos(1 / (1 + geoalt / EARTH_RADIUS)) * sqrt(d);
@@ -3484,7 +3484,7 @@ next_try:
3484
3484
  * the function lun_eclipse_how().
3485
3485
  */
3486
3486
  dtstart = 0.1;
3487
- if (tjd < 2000000 || tjd > 2500000)
3487
+ if (tjd < 2100000 || tjd > 2500000) // was tjd < 2000000 until 26-aug-22
3488
3488
  dtstart = 5;
3489
3489
  dtdiv = 4;
3490
3490
  for (j = 0, dt = dtstart;
@@ -3748,8 +3748,8 @@ next_lun_ecl:
3748
3748
  */
3749
3749
  #define EULER 2.718281828459
3750
3750
  #define NMAG_ELEM (SE_VESTA + 1)
3751
- #define MAG_HILTON_2005 0
3752
3751
  #define MAG_MALLAMA_2018 1
3752
+ #define MAG_MOON_VREIJS 1
3753
3753
  /* Magnitudes according to:
3754
3754
  * - "Explanatory Supplement to the Astronomical Almanac" 1986.
3755
3755
  * Magnitudes for Mercury and Venus:
@@ -3897,42 +3897,27 @@ int32 CALL_CONV swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr, char
3897
3897
  fac *= fac;
3898
3898
  attr[4] = mag_elem[ipl][0] - 2.5 * log10(fac);
3899
3899
  } else if (ipl == SE_MOON) {
3900
+ #if MAG_MOON_VREIJS
3901
+ // double a=fabs(attr[0]);
3902
+ double a = attr[0];
3903
+ if (a<=147.1385465) {
3904
+ /* formula according to Allen, C.W., 1976, Astrophysical Quantities */
3905
+ attr[4] = -21.62 + 0.026 * fabs(a) + 0.000000004 * pow(a, 4);
3906
+ attr[4]+=5 * log10(lbr[2] * lbr2[2] * AUNIT / EARTH_RADIUS);
3907
+ } else {
3908
+ /* using the cube phase angle proposed by Samaha (Samaha, A.E.; Asaad,
3909
+ A. S. and Mikhail, J. S. (1969).
3910
+ Visibility of the New Moon, Bulletin of Observatory Helwan, 84), and VR
3911
+ adjusted the stitch phase (align Allen's and Samaha's magnitude)
3912
+ of 147.14degrees.
3913
+ */
3914
+ attr[4] = -4.5444 - (2.5 * log10(pow(180 - a, 3)));
3915
+ attr[4]+=5 * log10(lbr[2] * lbr2[2] * AUNIT / EARTH_RADIUS);
3916
+ }
3917
+ #else
3900
3918
  /* formula according to Allen, C.W., 1976, Astrophysical Quantities */
3901
- /*attr[4] = -21.62 + 5 * log10(384410497.8 / EARTH_RADIUS) / log10(10) + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4);*/
3902
- //attr[4] = -21.62 + 5 * log10(lbr[2] * AUNIT / EARTH_RADIUS) / log10(10) + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4);
3903
- attr[4] = -21.62 + 5 * log10(lbr[2] * AUNIT / EARTH_RADIUS) + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4);
3904
- #if 0
3905
- /* ratio apparent diameter : average diameter */
3906
- fac = attr[3] / (asin(pla_diam[SE_MOON] / 2.0 / 384400000.0) * 2 * RADTODEG);
3907
- /* distance sun - moon */
3908
- for (i = 0; i < 3; i++)
3909
- xxs[i] -= xx[i];
3910
- dsm = sqrt(square_sum(xxs));
3911
- /* account for phase and distance of moon: */
3912
- fac *= fac * attr[1];
3913
- /* account for distance of sun from moon: */
3914
- fac *= dsm * dsm;
3915
- attr[4] = mag_elem[ipl][0] - 2.5 * log10(fac);
3916
- #endif
3917
- /*printf("1 = %f, 2 = %f\n", mag, mag2);*/
3918
- #if MAG_HILTON_2005
3919
- } else if (ipl == SE_MERCURY) {
3920
- /* valid range is actually 2.1° < i < 169.5° */
3921
- double i100 = attr[0] / 100.0;
3922
- attr[4] = -0.60 + 4.98 * i100 - 4.88 * i100 * i100 + 3.02 * i100 * i100 * i100;
3923
- attr[4] += 5 * log10(lbr2[2] * lbr[2]);
3924
- if (attr[0] < 2.1 || attr[0] > 169.5)
3925
- sprintf(serr2, "magnitude value for Mercury at phase angle i=%.1f is bad; formula is valid only for 2.1 < i < 169.5", attr[0]);
3926
- } else if (ipl == SE_VENUS) {
3927
- double i100 = attr[0] / 100.0;
3928
- if (attr[0] < 163.6) /* actual valid range is 2.2° < i < 163.6° */
3929
- attr[4] = -4.47 + 1.03 * i100 + 0.57 * i100 * i100 + 0.13 * i100 * i100 * i100;
3930
- else /* actual valid range is 163.6° < i < 170.2° */
3931
- attr[4] = 0.98 - 1.02 * i100;
3932
- attr[4] += 5 * log10(lbr2[2] * lbr[2]);
3933
- if (attr[0] < 2.2 || attr[0] > 170.2)
3934
- sprintf(serr2, "magnitude value for Venus at phase angle i=%.1f is bad; formula is valid only for 2.2 < i < 170.2", attr[0]);
3935
- #endif
3919
+ attr[4] = -21.62 + 5 * log10(lbr[2] * lbr2[2] * AUNIT / EARTH_RADIUS) + 0.026 * fabs(attr[0]) + 0.000000004 * pow(attr[0], 4);
3920
+ #endif
3936
3921
  #if MAG_MALLAMA_2018
3937
3922
  // see: A. Mallama, J.Hilton,
3938
3923
  // "ComputingApparentPlanetaryMagnitudesforTheAstronomicalAlmanac" (2018)
@@ -4426,6 +4411,11 @@ int ncalc = 0;
4426
4411
  sprintf(serr, "location for swe_rise_trans() must be between %.0f and %.0f m above sea", SEI_ECL_GEOALT_MIN, SEI_ECL_GEOALT_MAX);
4427
4412
  return ERR;
4428
4413
  }
4414
+ // if horhgt == -100, set horhgt = dip of horizon, i.e. refracted height
4415
+ // of ocean if visible at horizon.
4416
+ if (horhgt == -100) {
4417
+ horhgt = 0.0001 + calc_dip(geopos[2], atpress, attemp, const_lapse_rate);
4418
+ }
4429
4419
  /*swi_set_tid_acc(tjd_ut, epheflag, 0, serr);*/
4430
4420
  /* function calls for Pluto with asteroid number 134340
4431
4421
  * are treated as calls for Pluto as main body SE_PLUTO */
@@ -4669,9 +4659,9 @@ nazalt++;
4669
4659
  aha = ah[1];
4670
4660
  } else {
4671
4661
  swe_azalt_rev(t, SE_HOR2EQU, geopos, ah, xc);
4672
- nazalt++;
4662
+ nazalt++;
4673
4663
  swe_azalt(t, SE_EQU2HOR, geopos, atpress, attemp, xc, ah);
4674
- nazalt++;
4664
+ nazalt++;
4675
4665
  ah[1] -= horhgt;
4676
4666
  ah[2] -= horhgt;
4677
4667
  aha = ah[2];
@@ -653,6 +653,10 @@ int CALL_CONV swe_houses_armc_ex2(
653
653
  h.sundec = ascmc[9];
654
654
  saved_sundec = h.sundec;
655
655
  }
656
+ if (h.sundec < -24 || h.sundec > 24) {
657
+ sprintf(serr, "House system I (Sunshine) needs valid Sun declination in ascmc[9]");
658
+ return ERR;
659
+ }
656
660
  }
657
661
  retc = CalcH(armc, geolat, eps, (char)hsys, &h);
658
662
  cusp[0] = 0;
@@ -820,7 +824,7 @@ static double apc_sector(int n, double ph, double e, double az)
820
824
  return dret;
821
825
  }
822
826
 
823
- char *CALL_CONV swe_house_name(int hsys)
827
+ const char *CALL_CONV swe_house_name(int hsys)
824
828
  {
825
829
  int h = hsys;
826
830
  if (h != 'i') h = toupper(h);