@johnmorrisdotca/wakusei-planets 0.17.2 → 0.20.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/NOTICE.md +8 -4
  3. package/README.md +9 -5
  4. package/dist/calendar.d.ts +119 -0
  5. package/dist/calendar.js +154 -0
  6. package/dist/clock.d.ts +244 -0
  7. package/dist/clock.js +326 -0
  8. package/dist/coordinates.d.ts +177 -0
  9. package/dist/coordinates.js +169 -0
  10. package/dist/data/lunar.d.ts +4 -0
  11. package/dist/data/lunar.js +548 -0
  12. package/dist/data/orbits.d.ts +5 -1
  13. package/dist/data/orbits.js +26 -26
  14. package/dist/data/pluto.d.ts +6 -0
  15. package/dist/data/pluto.js +29 -0
  16. package/dist/data/tables.d.ts +41 -0
  17. package/dist/data/tables.js +37 -0
  18. package/dist/data/vsop.d.ts +21 -0
  19. package/dist/data/vsop.js +27 -0
  20. package/dist/element.d.ts +5 -3
  21. package/dist/element.js +22 -9
  22. package/dist/ephemeris.d.ts +4 -16
  23. package/dist/ephemeris.js +76 -33
  24. package/dist/live.js +1 -1
  25. package/dist/mars.d.ts +41 -0
  26. package/dist/mars.js +52 -0
  27. package/dist/scales.d.ts +46 -0
  28. package/dist/scales.js +75 -0
  29. package/dist/sidereal.d.ts +66 -0
  30. package/dist/sidereal.js +88 -0
  31. package/dist/sky/engine.d.ts +46 -0
  32. package/dist/sky/engine.js +145 -0
  33. package/dist/sky/events.d.ts +37 -0
  34. package/dist/sky/events.js +133 -0
  35. package/dist/suncalc-legacy.d.ts +187 -0
  36. package/dist/suncalc-legacy.js +168 -0
  37. package/dist/suncalc.d.ts +209 -0
  38. package/dist/suncalc.js +173 -0
  39. package/dist/tables/all.d.ts +2 -0
  40. package/dist/tables/all.js +2 -0
  41. package/dist/tables/ceres.d.ts +1 -0
  42. package/dist/tables/ceres.js +57 -0
  43. package/dist/tables/dwarfs.d.ts +1 -0
  44. package/dist/tables/dwarfs.js +59 -0
  45. package/dist/theory.d.ts +20 -0
  46. package/dist/theory.js +98 -0
  47. package/dist/time.d.ts +6 -0
  48. package/dist/time.js +7 -0
  49. package/dist/version.d.ts +1 -1
  50. package/dist/version.js +1 -1
  51. package/dist/when.d.ts +16 -0
  52. package/dist/when.js +18 -0
  53. package/package.json +71 -5
package/CHANGELOG.md CHANGED
@@ -2,6 +2,41 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [0.20.0] - 2026-11-07
6
+
7
+ - **`/time` is the whole clock** (MODULES-538). The `julian` package's functions under the same names (`julian`, `toDate`, `toJulianDay`, `toMillisecondsInJulianDay`, `fromJulianDayAndMilliseconds`; julian truncates toward zero before 31 December 1969 and gives a day one too high, these floor); `julianCenturies`, `julianMillennia` and the epochs (`J2000_JD`, `J2000_MS`, `B1950_JD`); the Gregorian and Julian calendars (`toCalendar`, `fromCalendar`, `dayOfWeek`, `dayOfYear`, `daysInMonth`, `isLeapYear`, the switch of 1582, astronomical years, the whole range of a Date); time scales UTC, UT1, TAI, GPS, TT and TDB (`convertTimeScale`, `taiMinusUtc`, `deltaT`, `tdbMinusTt`) with the leap seconds from 1972; sidereal time (`greenwichMeanSiderealTime`, `greenwichApparentSiderealTime`, `localSiderealTime`, `equationOfTheEquinoxes`); and Mars time (`marsSolDate`, `coordinatedMarsTime`, `marsLocalMeanSolarTime`). Every function takes a `Date` or milliseconds, never changes a `Date` and throws on an invalid one. About 3 kB gzipped, no dependencies. Tests: Meeus's worked examples (chapters 7 and 12), the julian package and astronomy-engine as dev-only oracles, round trips over the years -5000 to 5000 and the ends of a Date, every pair of time scales from 1800 to 2200. EN/JA guide `docs/guides/time.md`.
8
+ - Add a reproducible, development-only accuracy comparison against JPL Horizons for wakusei, Astronomy Engine, Python solarsystem and SunCalc 2.1.2, with EN/JA tables, pinned dependencies, source provenance and frozen regression limits (MODULES-556). Astronomy Engine wins Earth and the four Galilean moons on the shared modern grid; no blanket superiority is claimed.
9
+ - **`/suncalc`: the Sun and Moon from a place, a drop-in for suncalc 2** (MODULES-535). `getPosition`, `getTimes`, `addTime`, `times`, `getMoonPosition`, `getMoonIllumination` and `getMoonTimes` with suncalc 2's names, arguments and results (degrees, azimuth from north, `utcOffset`, observer height, Moon transits), on this package's own VSOP87B Sun and ELP2000-82B Moon with precession, nutation, aberration, parallax and refraction. Sunrise and sunset are within 7 seconds of astronomy-engine and moonrise within 1 (suncalc is 13 and 5); the tests compare against suncalc 2.1.2, suncalc 1.9.0 and astronomy-engine as dev-only oracles. `/suncalc/legacy` has suncalc 1's conventions (radians, azimuth from south, invalid dates, `inUTC`) so only the import changes. Both are 10 kB gzipped: the Earth's VSOP87B series now has its own export (`VSOP_EARTH`) so a page needs one planet, and the two theories moved to `src/theory.ts`. EN/JA guide. Planets' rise and set, eclipses and suncalc3's extras are not here yet (MODULES-537).
10
+ - **The Moon is ELP2000-82B, within 2 arc-seconds of Horizons** (MODULES-528). The Moon was the largest terms of a short series and 0.21 degrees (760 arc-seconds) from Horizons; it is now the lunar solution ELP2000-82B (Chapront-Touzé and Chapront, IMCCE) cut to its 540 largest terms (of 37,872), in terrestrial time, with the constants fitted to JPL's DE200 folded in (`scripts/make-lunar-data.py`, `src/data/lunar.ts`; the core entry point grows from 39.3 to 44.7 kB gzipped). The worst of seven dates from 1900 to 2100 is 1.8 arc-seconds and the distance is within 0.8 km; the limit in `test/accuracy.test.ts` falls from 0.3 degrees to 0.0008. The phase, rise and set of the Moon follow from the better position.
11
+ - **The dwarf planets are fitted to Horizons** (MODULES-554, 557). Ceres was 9 degrees from Horizons in 1900 and 2 degrees in 2000, and Orcus, Haumea, Quaoar, Makemake, Gonggong, Eris and Sedna a few arc-minutes, because each was one ellipse of one epoch. Each is now a Chebyshev table from the solar system's barycentre (`scripts/make-dwarf-data.py`), with the Sun's twelve-year swing about the barycentre added back from the planets' masses; all eight are within 0.2 arc-seconds of Horizons on dates off the fit's grid (Ceres 1900 to 2100, the others 1800 to 2200). `test/accuracy.test.ts` holds each to a limit, `test/pluto.test.ts` checks the segment edges, and the tables load on demand (MODULES-557): `@johnmorrisdotca/wakusei-planets/tables/dwarfs` (about 5 kB gzipped), `/tables/ceres` (about 14 kB) and `/tables` for both register themselves, the web component imports them, and `heliocentric` without them still answers with the old elements, so the core entry point stays at 39.0 kB gzipped.
12
+ - **Pluto is fitted to Horizons** (MODULES-528). VSOP87 has no Pluto, and JPL's approximate elements were 39 arc-seconds from Horizons; a table of 20 Chebyshev segments of 20 years (1800 to 2200, `scripts/make-pluto-data.py`, `src/data/pluto.ts`) is 0.05 arc-seconds on the five reference dates and 0.15 at worst on samples held back from the fit. Pluto is no longer the loosest planet; Saturn and Uranus (3.7 and 3.8) are. The segments are fitted on their own, so the position can step by up to 0.15 arc-seconds where one ends (tested). The elements still answer outside 1800 to 2200. The remaining error is the Sun's yearly wobble about the system's centre of mass, 0.016 arc-seconds at Pluto's distance, which a polynomial of this size cannot follow. The core entry point grows from 35.1 to 39.0 kB gzipped.
13
+ - Add the pure `/coordinates` sub-path: spherical/Cartesian AU coordinates, mean ecliptic/equatorial rotations at J2000 or of date, and equatorial-of-date to horizontal directions. Explicit origins, frames and epochs, degree angles, EN/JA guides, Meeus known-answer tests and a 4 KiB gzip budget (MODULES-555).
14
+
15
+ ## 0.19.0 - 2026-11-07
16
+
17
+ The planets and the moons are where they are, and every body is checked against JPL Horizons (MODULES-528, 525, 522). 0.18.0 was never published: what it holds, the view gestures, is below and is in this release.
18
+
19
+ - **Mercury to Neptune are the VSOP87B series, in terrestrial time** (MODULES-528). Jupiter was 309 arc-seconds from Horizons and Saturn 545; they are 1.9 and 3.7 now, and every planet from Mercury to Neptune is within 4 arc-seconds on five dates from 1800 to 2050 (Mercury was 41, Mars 58, Uranus 79). The series (Bretagnon and Francou, IMCCE) is cut from 35,080 terms to the 991 that matter (`scripts/make-vsop-data.py`, `src/data/vsop.ts`), and the date is converted from UTC to terrestrial time first. The Earth is the Earth's centre now, not the Earth–Moon barycentre. Pluto, which VSOP87 does not have, stays on JPL's elements (39 arc-seconds). The cost is size: the core entry point goes from 21.6 to 35.1 kB gzipped.
20
+ - **`@johnmorrisdotca/wakusei-planets/time`**: Julian dates (`toJulianDate`, `fromJulianDate`, `modifiedJulianDate`), the Julian day and the milliseconds in it with no digit lost (`toJulianDay`, `toMillisecondsInJulianDay`, `fromJulianDayAndMilliseconds`), and the step from UTC to terrestrial time (`ttMinusUtc`, `toTerrestrialTime`): exact from 1972 from the leap seconds, delta T before (MODULES-538). 0.8 kB gzipped. Fed UTC, the same theory is off by up to 17.9 arc-seconds for Mercury, which is why the step is inside.
21
+ - **The planets' limits in `test/accuracy.test.ts` are tighter** (2.2 arc-seconds for Earth and Mars, 5.8 for Uranus), and `test/time.test.ts` checks the Julian dates against Meeus's examples and delta T against astronomy-engine from 1800 to 2005.
22
+
23
+ - **The moons of Saturn, Uranus, Neptune and Pluto were in the wrong place.** Mimas, Tethys, Dione, Rhea, Titan, Iapetus, Miranda, Ariel, Umbriel, Titania, Oberon, Triton and Nix were tens of degrees off (Titan 157, Dione 151) at every date, including the epoch the elements are for, and Phobos, Enceladus, Proteus and Hydra up to 21. The angles in JPL's Planetary Satellite Mean Elements do not reproduce Horizons' positions for these moons: for Dione the table gives a mean longitude of 328 degrees where Horizons' own elements give 177. Their orbits are fitted to Horizons' positions and velocities for 1950 to 2050 now (`scripts/make-moon-data.py`), each in its mean orbit plane. 21 of the 24 moons are within a degree of Horizons on every date from 1900 to 2100, and the worst is Nereid, an orbit with an eccentricity of 0.75, at 6 degrees. The Uranian moons also go round Uranus the other way from what the pole in the facts says, and Triton's orbit was reversed twice (its inclination and its rate); both are fixed by describing each orbit as going round anticlockwise about its own pole.
24
+ - **Phobos has an acceleration and Mimas and Tethys a swing.** `OrbitElements` has two optional terms for the mean longitude: `acc`, for Phobos, whose orbit is shrinking, and `wave`, for the Mimas–Tethys resonance, a swing of 43 degrees over 70 years that the fit found by itself.
25
+ - **`test/accuracy.test.ts` holds every planet, the Moon and every moon to a limit against Horizons** (`test/data/horizons.json`, from `scripts/fetch-horizons-reference.py`), on five dates from 1800 to 2050 for the planets and seven from 1900 to 2100 for the moons. It fails on the old orbit table. The numbers are in a new [Accuracy](docs/guides/accuracy.md) guide, in English and Japanese. When it was written the planets were within 1 arc-minute except Jupiter (5) and Saturn (9); the VSOP87 change above took them all within 4 arc-seconds.
26
+ - **A synchronous moon's spin takes its direction from the facts and its speed from the orbit** (`turnRate`), because the sign of an orbit's rate no longer says which way a moon goes round. The rotation test checks the rate.
27
+ - **The docs said moon positions were accurate to a few degrees.** That was true for Jupiter's moons and the Moon, not for the rest; the README, the guides and NOTICE.md say what was measured.
28
+ - **The npm keywords name every planet and what the package does** (MODULES-532): planet, mercury, venus, earth, uranus, neptune, pluto, dwarf-planets, heliocentric, orbit, orbits, rotation, space, celestial, nasa, jpl, 3d, javascript, browser, added to the 17 it had. A test keeps them lower case and free of astrology and other packages' names.
29
+
30
+ ## 0.18.0 - 2026-11-07 (never published; in 0.19.0)
31
+
32
+ The view gestures are the family's, on kazoku-ui 0.19 (MODULES-527).
33
+
34
+ - **kazoku-ui 0.15 to 0.19.** The wheel over a view moves it, and Shift with the wheel moves it sideways; Ctrl, Command or Alt with the wheel zooms about the pointer; the middle button or Space with a drag moves it; Shift with a drag rolls it. Before, a plain wheel zoomed, Alt did nothing and Shift turned the body.
35
+ - **A pan moves the picture by as many pixels as the controls say.** `setView` read `panX` and `panY` as half-widths of the picture, but the controls send CSS pixels, so any pan jumped the picture to its limit. They are pixels now. A page that calls `setView` with fractions of the width must send pixels.
36
+ - **`setView` takes `roll`**: the picture, with its rings, moons and orbits, turns clockwise about the line of sight, in both the line and the shaded looks.
37
+ - **The portrait builder's wheel is the family's too** (Manual layout): the wheel moves the view, Shift moves it sideways, Ctrl, Command or Alt zoom. Shift with the wheel no longer sizes a body; `[` and `]` do.
38
+ - `e2e/gestures.demo.ts` sends each gesture with real events and compares the pictures with what the controls report. It fails on the old element (a pan lands 80 to 260 pixels from where it should, a roll changes nothing).
39
+
5
40
  ## 0.17.2 - 2026-11-07
6
41
 
7
42
  Rings are drawn all the way round.
package/NOTICE.md CHANGED
@@ -7,16 +7,20 @@ Wakusei Planets is original work by John Morris, under the MIT licence in `LICEN
7
7
  No picture is used by the line and shaded looks: they are drawn from numbers.
8
8
 
9
9
  - **Sizes, flattening, axial tilt, poles and rotation**: the IAU Working Group on Cartographic Coordinates and Rotational Elements, B. A. Archinal et al. (2018), "Report of the IAU Working Group on Cartographic Coordinates and Rotational Elements: 2015", Celestial Mechanics and Dynamical Astronomy 130:22, and NASA's planetary and satellite fact sheets (https://nssdc.gsfc.nasa.gov/planetary/factsheet/, read 2026-11-02). Facts are not copyrightable; the values were typed from these sources.
10
- - **Planet positions**: JPL Solar System Dynamics, "Keplerian Elements for Approximate Positions of the Major Planets", Table 1, 1800 AD to 2050 AD (https://ssd.jpl.nasa.gov/planets/approx_pos.html, read 2026-11-02; Pluto from the same page's earlier edition). NASA/JPL content is not subject to copyright in the United States; credit: NASA/JPL-Caltech.
11
- - **Moons' orbits**: JPL Solar System Dynamics, "Planetary Satellite Mean Elements" (https://ssd.jpl.nasa.gov/sats/elem/, read 2026-11-02), made into `src/data/orbits.ts` by `scripts/make-moon-data.py`. Credit: NASA/JPL-Caltech; the elements are from R. A. Jacobson and colleagues' ephemerides cited on that page.
12
- - **The Moon's position**: the largest terms of the series in Jean Meeus, "Astronomical Algorithms" (2nd edition), chapter 47, written out here as numbers; the mean arguments are the standard ones.
10
+ - **Mercury to Neptune**: the VSOP87B series, P. Bretagnon and G. Francou (1988), "Planetary theories in rectangular and spherical variables: VSOP87 solutions", Astronomy and Astrophysics 202, 309, from the files of IMCCE, Observatoire de Paris (https://ftp.imcce.fr/pub/ephem/planets/vsop87/, read 2026-11-07), cut to 991 of 35,080 terms into `src/data/vsop.ts` by `scripts/make-vsop-data.py`. The files state their precision and ask to be cited; they carry no licence text, and the numbers are a published scientific table.
11
+ - **Time scales**: the leap seconds are IERS Bulletin C; delta T before 1972 is the polynomials of F. Espenak and J. Meeus (NASA, https://eclipse.gsfc.nasa.gov/SEhelp/deltatpoly2004.html), in `src/time.ts`.
12
+ - **Calendars, sidereal time and Mars time (`/time`)**: written here from J. Meeus, "Astronomical Algorithms" (2nd edition, chapters 7 and 12: the Julian day and the sidereal time), the Richards day-number algorithm for the calendars, M. Allison and M. McEwen, "A post-Pathfinder evaluation of aerocentric solar coordinates with improved timing recipes for Mars seasonal/diurnal climate studies", Planetary and Space Science 48, 215 (2000), and Meeus's two-term formula for TDB minus TT. The names of the Julian-date functions follow the `julian` package (MIT, Stepan Stolyarov), whose code is not used; `julian` 0.2.0 and astronomy-engine are development-time comparisons in `test/calendar.test.ts` only and are not shipped.
13
+ - **Pluto's position**: a Chebyshev table (`src/data/pluto.ts`, made by `scripts/make-pluto-data.py`) fitted to JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-07), 1800 to 2200; outside those years, and for its earlier edition, JPL Solar System Dynamics, "Keplerian Elements for Approximate Positions of the Major Planets", Table 1, 1800 AD to 2050 AD (https://ssd.jpl.nasa.gov/planets/approx_pos.html, read 2026-11-02; Pluto from the same page's earlier edition). NASA/JPL content is not subject to copyright in the United States; credit: NASA/JPL-Caltech.
14
+ - **Moons' orbits**: fitted to the positions and velocities of JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api, read 2026-11-07) for 1950 to 2050, by `scripts/make-moon-data.py`, which writes `src/data/orbits.ts`; the Moon's row, and the pole of each moon's reference plane, are from JPL Solar System Dynamics, "Planetary Satellite Mean Elements" (https://ssd.jpl.nasa.gov/sats/elem/, read 2026-11-02). The positions the accuracy test compares with are in `test/data/horizons.json`, fetched by `scripts/fetch-horizons-reference.py`. Credit: NASA/JPL-Caltech; the satellite ephemerides behind Horizons are R. A. Jacobson and colleagues' (the page names each).
15
+ - **The Moon's position**: the lunar solution ELP2000-82B, M. Chapront-Touzé and J. Chapront, "The lunar ephemeris ELP 2000", Astron. Astrophys. 124, 50 (1983) and "ELP 2000-85", Astron. Astrophys. 190, 342 (1988), from IMCCE, Observatoire de Paris (https://ftp.imcce.fr/pub/ephem/moon/elp82b/). Its 37,872 terms are cut to the 540 above 0.05 arc-seconds (`scripts/make-lunar-data.py`, `src/data/lunar.ts`) and written out as numbers, with the constants fitted to JPL's DE200 that the notice gives. IMCCE's files carry no licence text; they are published for use with the credit above (the same footing as VSOP87).
16
+ - **Sun and Moon times (`/suncalc`)**: written here from the standard methods: J. Meeus, "Astronomical Algorithms" (2nd edition, chapters 11, 12, 21, 22, 48), the IAU 1976 precession, the IAU 1980 nutation (its largest terms), Saemundsson's refraction formula, and the Naval Observatory's convention for the rise and set of the Moon and Sun. The names, arguments and results follow the public interface of suncalc (BSD-2-Clause, Copyright (c) Volodymyr Agafonkin; https://github.com/mourner/suncalc), whose code is not used. suncalc 1.9.0 and 2.1.2 and astronomy-engine (MIT) are development-time comparisons in `test/suncalc.test.ts` only and are not shipped.
13
17
  - **Mass and escape speed** (`JOURNEY_STOPS`): JPL "Planetary Satellite Physical Parameters" (https://ssd.jpl.nasa.gov/sats/phys_par/, read 2026-11-04) for the GM of the Earth, Mars through Pluto and the moons on that page; NASA's Sun, Mercury and Venus fact sheets (https://nssdc.gsfc.nasa.gov/planetary/factsheet/, read 2026-11-04) for those three GM values and the Sun's escape speed; JPL "Planetary Physical Parameters" (https://ssd.jpl.nasa.gov/planets/phys_par.html, read 2026-11-04) for the planets' escape speeds and for the masses of Ceres, Eris, Makemake and Haumea, turned into GM with the CODATA 2018 G that page names. A moon's escape speed is computed from its GM and the radius already in this package. Nereid, Orcus, Quaoar, Gonggong, Sedna, Vanth, Hiʻiaka, Namaka and Dysnomia are left blank: those pages do not print a mass.
14
18
 
15
19
  ## The dwarf planets
16
20
 
17
21
  Ceres, Orcus, Haumea, Quaoar, Makemake, Gonggong, Eris and Sedna (Pluto is with the planets) and the moons Vanth, Hiʻiaka, Namaka and Dysnomia. Values read on 2026-11-03.
18
22
 
19
- - **Where they are**: NASA/JPL Small-Body Database, osculating elements at JD 2461200.5 (https://ssd.jpl.nasa.gov/api/sbdb.api), run as a plain ellipse (`src/data/dwarf.ts`): good for a few years either side of June 2026, and Ceres, pulled by Jupiter, drifts most.
23
+ - **Where they are**: JPL Horizons (https://ssd.jpl.nasa.gov/api/horizons.api), fitted as Chebyshev tables from the solar system's barycentre (`scripts/make-dwarf-data.py`, `src/data/dwarfs.ts`), with the Sun's swing about the barycentre worked out from the planets' masses (IAU 2012 and JPL DE440 mass ratios): Ceres 1900 to 2100, the others 1800 to 2200, each within 0.2 arc-seconds of Horizons. Outside those years, NASA/JPL Small-Body Database osculating elements at JD 2461200.5 (https://ssd.jpl.nasa.gov/api/sbdb.api), run as a plain ellipse (`src/data/dwarf.ts`): good for a few years either side of June 2026.
20
24
  - **Sizes and spin**: Ceres (966.2 x 962.0 x 891.8 km) and its pole: Ermakov et al. 2017 (as listed in Wikipedia's Ceres article); its rotation: JPL SBDB (9.074170 h). Haumea: Ortiz et al. 2017, Nature 550:219 (semi-axes 1161 x 852 x 513 km), rotation 3.915341 h from Santos-Sanz et al. 2017, A&A 604:A95, pole from Kondratyev & Kornoukhov 2018, MNRAS 478:3159 (RA 282.6, Dec -13.0). Eris: radius 1163 km, Sicardy et al. 2011; it keeps one face to Dysnomia, so its rotation is Dysnomia's orbital period, Szakats et al. 2023, A&A 669:L3. Makemake: radius 715 km, Brown 2013; rotation 22.8266 h, Hromakina et al. 2019. Gonggong: radius 615 km and rotation 22.4 h, Kiss et al. 2019, Icarus. Quaoar: 1241.4 x 1093.0 x 1023.0 km and 17.6788 h, Margoti et al. 2026 and Pereira et al. 2023. Sedna: radius 453 km (Lellouch et al. 2013, TNOs are Cool IX, which allows far more) and 10.273 h, Gaudi et al. 2005. Orcus: radius 455 km, Brown & Butler 2018, rotation 13.188 h (JPL SBDB; 7 to 21 h in the literature). Wikipedia's articles on each body were the finding aid; the papers are the sources.
21
25
  - **Moons' orbits**: Dysnomia, Holler et al. 2021, Icarus 355:114130, Table 2 (arXiv 2009.13733). Hiʻiaka and Namaka, Ragozzine & Brown 2009, AJ 137:4766, Table 2 (osculating elements of 2008; the two moons pull on each other, so the position years later is rough). Vanth, Brown et al. 2010, AJ 139:2700, Table 2, solution 1 of two mirror solutions. Radii: Dysnomia 308 km (Brown & Butler 2023), Vanth 221 km (Sickafoose et al. 2018, occultation), Hiʻiaka and Namaka from the Haumea article's listed diameters (370 and 150 km). Weywot, Xiangliu and Makemake's moon S/2015 (136472) 1 are left out: no orbit with a published phase.
22
26
  - **Estimated, not measured** (the pictures say so only here): these bodies' poles are not measured, so each is drawn with its spin axis along its orbit's pole (Quaoar, Makemake, Gonggong, Sedna), along Dysnomia's orbit pole (Eris) or along the far end of Vanth's orbit pole, so that it spins forwards (Orcus). Hiʻiaka's and Namaka's spin is unknown and they are drawn still. Dysnomia and Vanth are assumed to keep one face to their planet. Every drawn feature on the line look of a dwarf planet except Ceres's Occator crater and Haumea's long axis is a generic crater, and so is each shaded (realistic) look: only the colour (from the published colour indices and albedos) and the sizes are from numbers. Ceres, Haumea and Dysnomia's shapes are from the sources above. Only Ceres has a painted look.
package/README.md CHANGED
@@ -13,9 +13,9 @@ A clean line drawing, a shaded realistic drawing, or a painted surface map, with
13
13
 
14
14
  <p align="center"><a href="https://johnmorrisdotca.github.io/wakusei-planets/"><strong>Open the demo →</strong></a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/embed.html">Embed page</a> · <a href="https://johnmorrisdotca.github.io/wakusei-planets/docs/">Docs</a></p>
15
15
 
16
- <p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.17.2/docs/images/hero-desk.png" width="640"></p>
16
+ <p align="center"><img alt="Jupiter and Saturn drawn in the realistic look, and Saturn as a line drawing" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.20.0/docs/images/hero-desk.png" width="640"></p>
17
17
 
18
- <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.17.2/docs/images/lineup-desk.png" width="640"></p>
18
+ <p align="center"><img alt="Every body at one scale, the Earth among them: each small body has a magnified picture joined by a line, and the Sun shows only its edge" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.20.0/docs/images/lineup-desk.png" width="640"></p>
19
19
 
20
20
  ## One minute
21
21
 
@@ -176,7 +176,7 @@ The pure side has no DOM: `BODIES`, `apparent(id, time)`, `system(planet, time)`
176
176
 
177
177
  ## The data
178
178
 
179
- Sizes, flattening, poles and rotation are the IAU's and NASA's; planet positions are JPL's approximate elements; the Moon's are Meeus's largest terms; the other moons are JPL's mean elements. Nothing is fetched at run time by the line and shaded looks, which use no pictures. See [NOTICE.md](NOTICE.md).
179
+ Sizes, flattening, poles and rotation are the IAU's and NASA's; Mercury to Neptune are VSOP87B, cut down, and Pluto is a table fitted to Horizons; the Moon's are the lunar solution ELP2000-82B cut down; the other moons are fitted to JPL Horizons' positions, and every body is tested against Horizons ([accuracy](docs/guides/accuracy.md)). Nothing is fetched at run time by the line and shaded looks, which use no pictures. See [NOTICE.md](NOTICE.md).
180
180
 
181
181
  ## Examples
182
182
 
@@ -273,7 +273,7 @@ A body that turns by itself and a moving sky, in HTML:
273
273
 
274
274
  ## The portrait builder
275
275
 
276
- <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.17.2/docs/images/portrait-family.png" width="640"></p>
276
+ <p align="center"><img alt="The Sun and the planets in an arc, painted, with their names, in the portrait builder" src="https://raw.githubusercontent.com/johnmorrisdotca/wakusei-planets/v0.20.0/docs/images/portrait-family.png" width="640"></p>
277
277
 
278
278
  [The portrait builder](https://johnmorrisdotca.github.io/wakusei-planets/portrait.html) puts any bodies in one picture: drag them, size them, turn them, order them front to back, arrange them in a row, an arc, a grid or at true orbit distance (true or readable sizes, a planet's moons round it in orbit order), light them from one direction, and take the code, a PNG or an SVG. The scene is kept in the address, and every body is drawn in one WebGL scene, so the page holds one WebGL context. [The portrait builder](docs/guides/portrait-builder.md) is its guide.
279
279
 
@@ -319,7 +319,11 @@ Each guide has a Japanese twin in [docs/guides/ja](docs/guides/ja/getting-starte
319
319
  | [The portrait builder](docs/guides/portrait-builder.md) | Many bodies in one picture |
320
320
  | [Looks and bodies](docs/guides/looks-and-bodies.md) | The looks and each body's entry point |
321
321
  | [Moons and time](docs/guides/moons-and-time.md) | The sky on a date, time that runs fast |
322
+ | [Accuracy](docs/guides/accuracy.md) | How far each body is from JPL Horizons |
322
323
  | [In your own three.js scene](docs/guides/in-your-own-scene.md) | `painter.make` |
324
+ | [Time](docs/guides/time.md) | Julian dates, calendars, time scales, sidereal time, Mars time |
325
+ | [The Sun and Moon from a place](docs/guides/suncalc.md) | Position, sunrise and sunset, Moon rise, set and phase; a drop-in for suncalc |
326
+ | [Coordinate conversions](docs/guides/coordinates.md) | Pure spherical, ecliptic, equatorial and horizontal coordinate conversions |
323
327
  | [TypeScript and Node](docs/guides/typescript-and-node.md) | Types and the pure side |
324
328
  | [How it works](docs/guides/how-it-works.md) | Where the numbers come from |
325
329
  | [Architecture](docs/guides/architecture.md) | How the layers fit |
@@ -334,7 +338,7 @@ import { BODIES } from "@johnmorrisdotca/wakusei-planets";
334
338
  BODIES.pluto.kind; // "dwarf-planet"
335
339
  ```
336
340
 
337
- - A fact with no source is left out, never guessed. Moon positions are JPL's mean elements and are accurate to a few degrees on the orbit, about the size of the moon on screen.
341
+ - A fact with no source is left out, never guessed. The Moon is within 2 arc-seconds of JPL Horizons, and the other moons' positions are fitted to it and are within a degree or two on the orbit for almost every moon, about the size of the moon on screen; [accuracy](docs/guides/accuracy.md) has each body's number.
338
342
  - `realistic` and `painted` are the photo maps (`painted` is the same maps, so an older page still works). `illustrated` is the shaded drawing from the numbers, and it is not a default. Venus, Saturn, Neptune and the Sun use Solar System Scope's maps (CC BY 4.0). Mercury uses the natural grey 8K map (Shady Tex and Solar System Scope, CC BY 4.0). Mars stays on the Viking mosaic, graded toward a butterscotch ochre, with the frost in Hellas toned to the basin and the polar ice left. Jupiter and Uranus use Nestaeric's maps (CC BY 4.0), and Saturn's poles use Nestaeric's caps (CC BY 4.0). The Earth and the Moon stay on their NASA maps until those have been compared. The rest are the public-domain maps in `NOTICE.md`.
339
343
  - A shaded look needs WebGL. Without it the line drawing is drawn.
340
344
  - Jupiter, Saturn, Uranus and Neptune have their rings drawn.
@@ -0,0 +1,119 @@
1
+ import { type When } from "./when.ts";
2
+ /**
3
+ * Which calendar: `gregorian` and `julian` are used for every year (the proleptic calendars), and `auto` follows history: the Julian calendar to 1582-10-04 and the Gregorian from 1582-10-15.
4
+ *
5
+ * @example
6
+ * ```ts
7
+ * import { type Calendar } from "@johnmorrisdotca/wakusei-planets/time";
8
+ *
9
+ * const calendar: Calendar = "auto";
10
+ * console.log(calendar);
11
+ * ```
12
+ */
13
+ export type Calendar = "gregorian" | "julian" | "auto";
14
+ /**
15
+ * A date and time of day. The year is astronomical (1 BCE is 0, 2 BCE is -1), the month is 1 to 12, the day starts at 1.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { toCalendar, type CivilTime } from "@johnmorrisdotca/wakusei-planets/time";
20
+ *
21
+ * const t: CivilTime = toCalendar(Date.UTC(1957, 9, 4, 19, 26, 24));
22
+ * console.log(t.year, t.month, t.day, t.hour);
23
+ * ```
24
+ */
25
+ export interface CivilTime {
26
+ year: number;
27
+ month: number;
28
+ day: number;
29
+ hour: number;
30
+ minute: number;
31
+ second: number;
32
+ millisecond: number;
33
+ }
34
+ /**
35
+ * Whether a year is a leap year.
36
+ * @param year - The astronomical year.
37
+ * @param calendar - `gregorian` (a century is a leap year only if divisible by 400), `julian` (every fourth year), or `auto` (the Julian rule to 1582, the Gregorian after).
38
+ * @returns `true` for a leap year.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { isLeapYear } from "@johnmorrisdotca/wakusei-planets/time";
43
+ *
44
+ * console.log(isLeapYear(1900), isLeapYear(1900, "julian"), isLeapYear(2000));
45
+ * ```
46
+ */
47
+ export declare function isLeapYear(year: number, calendar?: Calendar): boolean;
48
+ /**
49
+ * The number of days in a month; October 1582 has 21 in the `auto` calendar, the ten days of the switch being left out.
50
+ * @param year - The astronomical year.
51
+ * @param month - 1 to 12.
52
+ * @param calendar - `gregorian`, `julian` or `auto`.
53
+ * @returns The days in the month.
54
+ *
55
+ * @example
56
+ * ```ts
57
+ * import { daysInMonth } from "@johnmorrisdotca/wakusei-planets/time";
58
+ *
59
+ * console.log(daysInMonth(2024, 2), daysInMonth(1582, 10));
60
+ * ```
61
+ */
62
+ export declare function daysInMonth(year: number, month: number, calendar?: Calendar): number;
63
+ /**
64
+ * A moment as a date and time of day in UTC, in the Gregorian or the Julian calendar.
65
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
66
+ * @param calendar - `auto` (default: the calendar in use that day), `gregorian` or `julian` for every year.
67
+ * @returns The year (astronomical), month, day, hour, minute, second and millisecond.
68
+ *
69
+ * @example
70
+ * ```ts
71
+ * import { toCalendar } from "@johnmorrisdotca/wakusei-planets/time";
72
+ *
73
+ * console.log(toCalendar(Date.UTC(1582, 9, 15)), toCalendar(Date.UTC(1582, 9, 15), "julian").day);
74
+ * ```
75
+ */
76
+ export declare function toCalendar(when: When, calendar?: Calendar): CivilTime;
77
+ /**
78
+ * A date and time of day in UTC as a moment, in milliseconds since 1970. A day that does not exist (31 April, 29 February in a common year, or 5 to 14 October 1582 in the `auto` calendar) throws a `RangeError`.
79
+ * @param civil - The year (astronomical), and the month (1), day (1), hour, minute, second and millisecond (0) when left out.
80
+ * @param calendar - `auto` (default), `gregorian` or `julian`.
81
+ * @returns Milliseconds since 1970.
82
+ *
83
+ * @example
84
+ * ```ts
85
+ * import { fromCalendar } from "@johnmorrisdotca/wakusei-planets/time";
86
+ *
87
+ * console.log(fromCalendar({ year: 333, month: 1, day: 27, hour: 12 }, "julian"), new Date(fromCalendar({ year: 2000, month: 1, day: 1, hour: 12 })).toISOString());
88
+ * ```
89
+ */
90
+ export declare function fromCalendar(civil: {
91
+ year: number;
92
+ } & Partial<Omit<CivilTime, "year">>, calendar?: Calendar): number;
93
+ /**
94
+ * The day of the week of a moment in UTC: 0 Sunday to 6 Saturday.
95
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
96
+ * @returns 0 to 6.
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { dayOfWeek } from "@johnmorrisdotca/wakusei-planets/time";
101
+ *
102
+ * console.log(dayOfWeek(Date.UTC(1954, 5, 30)));
103
+ * ```
104
+ */
105
+ export declare function dayOfWeek(when: When): number;
106
+ /**
107
+ * The day of the year of a moment in UTC: 1 on 1 January.
108
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
109
+ * @param calendar - `auto` (default), `gregorian` or `julian`.
110
+ * @returns 1 to 366.
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * import { dayOfYear } from "@johnmorrisdotca/wakusei-planets/time";
115
+ *
116
+ * console.log(dayOfYear(Date.UTC(1978, 10, 14)), dayOfYear(Date.UTC(1988, 3, 22)));
117
+ * ```
118
+ */
119
+ export declare function dayOfYear(when: When, calendar?: Calendar): number;
@@ -0,0 +1,154 @@
1
+ // Calendars: the Gregorian and the Julian, the switch between them in October 1582, years before 1 CE (astronomical numbering, so the year 0 is 1 BCE), days of the week and of the year.
2
+ // Whole days are counted as integers, so a date goes to a moment and back without a digit lost and years from -271821 to 275760 (the range of a JavaScript `Date`) all work. Pure: no DOM, no three.js.
3
+ import { moment } from "./when.js";
4
+ const DAY_MS = 86_400_000;
5
+ /** The Julian day number (the day that begins at midnight) of 1970-01-01. */
6
+ const UNIX_DAY_NUMBER = 2_440_588;
7
+ /** The Julian day number of 1582-10-15, the first day of the Gregorian calendar. */
8
+ const REFORM_DAY_NUMBER = 2_299_161;
9
+ const floorMod = (a, b) => a - b * Math.floor(a / b);
10
+ function dayNumberOf(year, month, day, gregorian) {
11
+ const a = Math.floor((14 - month) / 12);
12
+ const y = year + 4800 - a;
13
+ const m = month + 12 * a - 3;
14
+ const base = day + Math.floor((153 * m + 2) / 5) + 365 * y + Math.floor(y / 4);
15
+ return gregorian ? base - Math.floor(y / 100) + Math.floor(y / 400) - 32045 : base - 32083;
16
+ }
17
+ function dateOfDayNumber(J, gregorian) {
18
+ const f = gregorian ? J + 1401 + Math.floor((Math.floor((4 * J + 274277) / 146097) * 3) / 4) - 38 : J + 1401;
19
+ const e = 4 * f + 3;
20
+ const g = Math.floor(floorMod(e, 1461) / 4);
21
+ const h = 5 * g + 2;
22
+ const day = Math.floor(floorMod(h, 153) / 5) + 1;
23
+ const month = ((Math.floor(h / 153) + 2) % 12) + 1;
24
+ return { year: Math.floor(e / 1461) - 4716 + Math.floor((14 - month) / 12), month, day };
25
+ }
26
+ /**
27
+ * Whether a year is a leap year.
28
+ * @param year - The astronomical year.
29
+ * @param calendar - `gregorian` (a century is a leap year only if divisible by 400), `julian` (every fourth year), or `auto` (the Julian rule to 1582, the Gregorian after).
30
+ * @returns `true` for a leap year.
31
+ *
32
+ * @example
33
+ * ```ts
34
+ * import { isLeapYear } from "@johnmorrisdotca/wakusei-planets/time";
35
+ *
36
+ * console.log(isLeapYear(1900), isLeapYear(1900, "julian"), isLeapYear(2000));
37
+ * ```
38
+ */
39
+ export function isLeapYear(year, calendar = "auto") {
40
+ if (!Number.isInteger(year))
41
+ throw new RangeError(`year must be a whole number, got ${year}`);
42
+ const gregorian = calendar === "gregorian" || (calendar === "auto" && year > 1582);
43
+ return floorMod(year, 4) === 0 && (!gregorian || floorMod(year, 100) !== 0 || floorMod(year, 400) === 0);
44
+ }
45
+ /**
46
+ * The number of days in a month; October 1582 has 21 in the `auto` calendar, the ten days of the switch being left out.
47
+ * @param year - The astronomical year.
48
+ * @param month - 1 to 12.
49
+ * @param calendar - `gregorian`, `julian` or `auto`.
50
+ * @returns The days in the month.
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { daysInMonth } from "@johnmorrisdotca/wakusei-planets/time";
55
+ *
56
+ * console.log(daysInMonth(2024, 2), daysInMonth(1582, 10));
57
+ * ```
58
+ */
59
+ export function daysInMonth(year, month, calendar = "auto") {
60
+ if (!Number.isInteger(month) || month < 1 || month > 12)
61
+ throw new RangeError(`month must be a whole number from 1 to 12, got ${month}`);
62
+ if (calendar === "auto" && year === 1582 && month === 10)
63
+ return 21;
64
+ if (month === 2)
65
+ return isLeapYear(year, calendar) ? 29 : 28;
66
+ return [4, 6, 9, 11].includes(month) ? 30 : 31;
67
+ }
68
+ /**
69
+ * A moment as a date and time of day in UTC, in the Gregorian or the Julian calendar.
70
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
71
+ * @param calendar - `auto` (default: the calendar in use that day), `gregorian` or `julian` for every year.
72
+ * @returns The year (astronomical), month, day, hour, minute, second and millisecond.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * import { toCalendar } from "@johnmorrisdotca/wakusei-planets/time";
77
+ *
78
+ * console.log(toCalendar(Date.UTC(1582, 9, 15)), toCalendar(Date.UTC(1582, 9, 15), "julian").day);
79
+ * ```
80
+ */
81
+ export function toCalendar(when, calendar = "auto") {
82
+ const ms = Math.floor(moment(when));
83
+ const dayNumber = Math.floor(ms / DAY_MS) + UNIX_DAY_NUMBER;
84
+ const inDay = floorMod(ms, DAY_MS);
85
+ const gregorian = calendar === "gregorian" || (calendar === "auto" && dayNumber >= REFORM_DAY_NUMBER);
86
+ const { year, month, day } = dateOfDayNumber(dayNumber, gregorian);
87
+ return { year, month, day, hour: Math.floor(inDay / 3_600_000), minute: Math.floor((inDay % 3_600_000) / 60_000), second: Math.floor((inDay % 60_000) / 1000), millisecond: inDay % 1000 };
88
+ }
89
+ /**
90
+ * A date and time of day in UTC as a moment, in milliseconds since 1970. A day that does not exist (31 April, 29 February in a common year, or 5 to 14 October 1582 in the `auto` calendar) throws a `RangeError`.
91
+ * @param civil - The year (astronomical), and the month (1), day (1), hour, minute, second and millisecond (0) when left out.
92
+ * @param calendar - `auto` (default), `gregorian` or `julian`.
93
+ * @returns Milliseconds since 1970.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * import { fromCalendar } from "@johnmorrisdotca/wakusei-planets/time";
98
+ *
99
+ * console.log(fromCalendar({ year: 333, month: 1, day: 27, hour: 12 }, "julian"), new Date(fromCalendar({ year: 2000, month: 1, day: 1, hour: 12 })).toISOString());
100
+ * ```
101
+ */
102
+ export function fromCalendar(civil, calendar = "auto") {
103
+ const { year, month = 1, day = 1, hour = 0, minute = 0, second = 0, millisecond = 0 } = civil;
104
+ for (const [name, value] of Object.entries({ year, month, day, hour, minute, second, millisecond }))
105
+ if (!Number.isInteger(value))
106
+ throw new RangeError(`${name} must be a whole number, got ${value}`);
107
+ if (hour < 0 || hour > 23 || minute < 0 || minute > 59 || second < 0 || second > 59 || millisecond < 0 || millisecond > 999)
108
+ throw new RangeError(`the time of day ${hour}:${minute}:${second}.${millisecond} does not exist`);
109
+ if (day < 1 || day > daysInMonth(year, month, calendar))
110
+ throw new RangeError(`${year}-${month}-${day} does not exist in the ${calendar} calendar`);
111
+ let gregorian = calendar === "gregorian";
112
+ if (calendar === "auto") {
113
+ const afterReform = year > 1582 || (year === 1582 && (month > 10 || (month === 10 && day >= 15)));
114
+ if (year === 1582 && month === 10 && day > 4 && day < 15)
115
+ throw new RangeError(`${year}-${month}-${day} does not exist: the calendar skipped 5 to 14 October 1582`);
116
+ gregorian = afterReform;
117
+ }
118
+ return (dayNumberOf(year, month, day, gregorian) - UNIX_DAY_NUMBER) * DAY_MS + hour * 3_600_000 + minute * 60_000 + second * 1000 + millisecond;
119
+ }
120
+ /**
121
+ * The day of the week of a moment in UTC: 0 Sunday to 6 Saturday.
122
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
123
+ * @returns 0 to 6.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * import { dayOfWeek } from "@johnmorrisdotca/wakusei-planets/time";
128
+ *
129
+ * console.log(dayOfWeek(Date.UTC(1954, 5, 30)));
130
+ * ```
131
+ */
132
+ export function dayOfWeek(when) {
133
+ return floorMod(Math.floor(moment(when) / DAY_MS) + 4, 7);
134
+ }
135
+ /**
136
+ * The day of the year of a moment in UTC: 1 on 1 January.
137
+ * @param when - A `Date` or milliseconds since 1970 (UTC).
138
+ * @param calendar - `auto` (default), `gregorian` or `julian`.
139
+ * @returns 1 to 366.
140
+ *
141
+ * @example
142
+ * ```ts
143
+ * import { dayOfYear } from "@johnmorrisdotca/wakusei-planets/time";
144
+ *
145
+ * console.log(dayOfYear(Date.UTC(1978, 10, 14)), dayOfYear(Date.UTC(1988, 3, 22)));
146
+ * ```
147
+ */
148
+ export function dayOfYear(when, calendar = "auto") {
149
+ const ms = moment(when);
150
+ const { year } = toCalendar(ms, calendar);
151
+ const dayNumber = Math.floor(ms / DAY_MS) + UNIX_DAY_NUMBER;
152
+ const gregorian = calendar === "gregorian" || (calendar === "auto" && year > 1582);
153
+ return dayNumber - dayNumberOf(year, 1, 1, gregorian) + 1;
154
+ }