Commit Graph

2227 Commits

Author SHA1 Message Date
dependabot[bot]
67e1968329 Bump json5 from 2.2.0 to 2.2.3 in /generate
Bumps [json5](https://github.com/json5/json5) from 2.2.0 to 2.2.3.
- [Release notes](https://github.com/json5/json5/releases)
- [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md)
- [Commits](https://github.com/json5/json5/compare/v2.2.0...v2.2.3)

---
updated-dependencies:
- dependency-name: json5
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-01-07 05:23:00 +00:00
Don Cross
35c587c1bb Added link to functioning Moon Info calculator. 2022-12-30 15:36:24 -05:00
Don Cross
fd4090bd65 Added title 'Astronomy Engine' to README. 2022-12-26 14:20:58 -05:00
Don Cross
2c18257ea8 Updated Astronomy Engine logo. 2022-12-26 14:01:23 -05:00
Don Cross
1a4f842764 Updated Ecliptic to return ECL in all languages. v2.1.13 2022-12-10 19:35:42 -05:00
Don Cross
d4660de2a7 JS: Ecliptic function returns ECT instead of ECL. 2022-12-10 03:55:17 -05:00
Don Cross
47ce0ac34e C#: EquatorialToEcliptic now returns ECT instead of ECL. 2022-12-09 21:03:05 -05:00
Don Cross
f811b6f55b C: Ecliptic function returns ECT instead of ECL.
Now the C function Astronomy_Ecliptic returns ecliptic
coordinates in true equinox of date instead of the
J2000 mean equinox. I'm doing this because it is a
better fit for physical phenomena that ecliptic
coordinates are often used for. For example, lunar nodes,
eclipses, phase angles, and oppositions make more sense
with true latitude and longitude of date.

I will port these changes to the other languages also.
2022-12-09 20:00:52 -05:00
Don Cross
f959599497 Completed EQJ/ECT, ECT/EQJ rotations. 2022-12-09 13:12:42 -05:00
Don Cross
1864fa8539 Orientation nomenclature. C: EQJ/ECT rotations.
More work standardizing the nomenclature of the
orientation systems across all language documents.

Added C functions to calculate rotation matrices
for EQJ/ECT and ECT/EQJ.
2022-12-08 22:03:43 -05:00
Don Cross
281180db24 Use consistent descriptions of EQJ, ECL.
Use consistent wording for these two orientation systems:
EQJ = J2000 mean equator
ECL = J2000 mean ecliptic
2022-12-08 16:16:41 -05:00
Don Cross
b4c36e7188 Merge branch 'master' into ecliptic 2022-12-08 13:44:53 -05:00
Don Cross
30a9b0b757 Fixed warnings from gcc 12.2.
I'm taking gcc 12.2 for a test drive today.
It reports a few warnings that slipped through earlier versions.
None of the warnings concern me for actual code safety,
but I went ahead and resolved them to keep the build clean.

Also provide a hook for a CPP environment variable to override
the C++ compiler to use, instead of forcing g++.
2022-12-08 13:41:12 -05:00
Don Cross
dfbd268aa3 JS: Added rotation ECT/EQD. 2022-12-07 13:48:24 -05:00
Don Cross
2dd4fc1ab4 Python: rotations for ECT/EQD. 2022-12-07 13:03:38 -05:00
Don Cross
1d57802470 Kotlin: implemented EQD/ECT rotations. 2022-12-06 21:12:31 -05:00
Don Cross
78a850daac C# tests: verify EQD/ECT is inverse of ECT/EQD. 2022-12-06 20:09:24 -05:00
Don Cross
8fe8b028f8 Added EQD/ECT rotation functions to C# topic index. 2022-12-06 20:05:46 -05:00
Don Cross
f043ebc62b C#: added rotation matrix functions for EQD/ECT. 2022-12-06 18:36:47 -05:00
Don Cross
541e2774ef C# RotationTest cleanup. 2022-12-06 17:04:22 -05:00
Don Cross
62ba530272 Document new C functions: rotate EQD/ECT. 2022-12-06 15:19:13 -05:00
Don Cross
c102208e2b C: Rotation matrices for EQD/ECT.
Added new C functions to convert back and forth
between Equator of Date (EQD) and True Ecliptic of Date (ECT).
2022-12-06 15:09:00 -05:00
Don Cross
742ab4cbff Define ECT in documentation.
Define ECT = True Ecliptic of Date in the documentation.
I will soon convert the Ecliptic() functions to return ECT instead of
ECL, but I will retain ECL support via rotation matrix functions.
2022-12-06 13:36:47 -05:00
Don Cross
12e68a1931 Fixed warning issued by Microsoft C compiler.
Somehow gcc didn't warn me that a `void` function
was trying to return a `void` value. It makes sense
from a functional language "unit type" perspective,
but it wasn't intentional, and it is weird. Fixed it.
2022-12-05 22:10:51 -05:00
Don Cross
552c7a5557 EclipticGeoMoon uses true equinox of date in all languages.
Added EclipticGeoMoon as output to the temp/*_check.txt files as 'm' lines.
This ensures that all the languages calculate nearly identical values.

Optimized EclipticGeoMoon a little more by eliminating a redundant
call to mean_obliq.
2022-12-05 21:44:35 -05:00
Don Cross
2bdb25227e C EclipticGeoMoon: use true equinox of date.
Updated the C function Astronomy_EclipticGeoMoon to
correct ecliptic coordinates for nutation.
This means that the returned value is expressed in
true equinox of date instead of mean equinox of date.

This results in the moon_ecm test decreasing the max
longitude error from 24 arcseconds to 6 arcseconds.
EclipticGeoMoon is now about 40% slower, but it still
runs in about 0.4 microseconds per call.
2022-12-05 13:55:36 -05:00
Don Cross
b8d195cbca C moon_ecm: handle 360-degree wraparound. More checking. 2022-12-05 11:50:18 -05:00
Don Cross
6b8816b1b5 C tests: make excluded tests more obviously marked. 2022-12-05 11:37:19 -05:00
Don Cross
576eea2245 Unrolled loops from remaining nutation functions. 2022-12-04 21:30:22 -05:00
Don Cross
b9738d9661 C: Unrolled the truncated IAU2000B formula. 2022-12-04 20:56:15 -05:00
Don Cross
b8c0a1f0cc Python: hand-optmized nutation.
I bootstrapped based on the pretty good optimizations that
codegen did for the Python version of the (now truncated)
IAU2000B nutation formula. I will do the same for the other
nutation formulas.
2022-12-04 20:27:44 -05:00
Don Cross
700a834ffc Finally solved my download problems.
I realize now that the URLs I was using to download stuff
from GitHub Actions were redirects. So I need to use 'curl -L'
to follow the redirects. But I also removed the redirect by
using the ultimate URLs.
2022-12-04 19:42:05 -05:00
Don Cross
2154ae2bb6 Still flailing around trying to download a file.
All this stuff used to work, but suddenly is broken.
I just want to download a file!
Found a dubious hardcoded path online where wget.exe might be.
2022-12-04 17:49:54 -05:00
Don Cross
0f078a24ce Another try. Apparently curl isn't working. Use wget instead. 2022-12-04 17:40:23 -05:00
Don Cross
db90e39dfc Mirror Doxygen for Windows on GitHub for automated tests.
My GitHub actions automated tests kept failing today
because commit_hook.bat kept failing to download
the Doxygen zipped binaries for Windows.
So I have downloaded it myself and mirrored it in
my `ephemeris` repo where I keep other large files that
are only needed by Astronomy Engine tests, not end users.
Downloading from GitHub to a GitHub Actions worker
should be much more reliable (probably faster too).

Another advantage is the version will be stable,
so I don't have to keep fixing things every time they
make a change to Doxygen. It's good enough the way it is!
2022-12-04 17:18:21 -05:00
Don Cross
236e73bc18 Somehow missed checking in a change. 2022-12-04 17:04:33 -05:00
Don Cross
7445219794 Corrected diff of nutation angles on Windows. 2022-12-04 14:52:52 -05:00
Don Cross
d3f36b942d Verify nutation angles are consistent across languages. 2022-12-04 14:20:44 -05:00
Don Cross
a24da098de diffcalc: run all tests before pass/fail.
Instead of stopping at the first failure, diffcalc
scripts (Linux and Windows) will now continue to run
all tests before reporting pass/fail. This allows
fixing multiple issues all in one GitHub Actions pass.

Also fixed the immediate issue where I needed to
increase tolerances slightly, as a follow-up fix
for nutation formula changes.
2022-12-04 12:05:26 -05:00
Don Cross
15cb6ddc23 Fixed test breakage caused by nutation changes.
C# Test_EQD_HOR: EXCESSIVE HORIZONTAL ERROR:
diff_alt=6.750155989720952E-14, diff_az=8.526512829121202E-14
2022-12-04 11:25:58 -05:00
Don Cross
740a65d29b Windows: fixes for testing nutation changes. 2022-12-04 11:13:24 -05:00
Don Cross
8a153315cf Simplified and optimized nutation formula.
While trying to convert ecliptic coordinates from mean
equinox of date to true equinox of date, I ran into excessive
overhead from the IAU2000B nutation model. The fact that it
uses 77 trigonometric terms made the calculations a lot slower.

https://apps.dtic.mil/sti/pdfs/AD1112517.pdf
Page 4 in the above document mentions a shorter series
“NOD version 2” that has 13 terms instead of 77 as used in IAU2000B.
I had not noticed NOD2 before, because it appears only in
the FORTRAN version of NOVAS 3.x, not the C version.

After reading the FORTRAN code, I realized NOD2 is the same
as IAU2000B, only it keeps the first 13 of 77 terms.
The terms are already arranged in descending order of
significance, so it is easy to truncate the series.

Based on this discovery, I realized I could achieve all of
the required accuracy needed for Astronomy Engine by
keeping only the first 5 terms of the nutation series.
This tremendously speeds up nutation calculations while
sacrificing only a couple of arcseconds of accuracy.

It also makes the minified JavaScript code smaller:
Before: 119500 bytes.
After:  116653 bytes.

So that's what I did here. Most of the work was updating
unit tests for accepting slightly different calculation
results.

The nutation formula change did trigger detection of a
lurking bug in the inverse_terra functions, which convert
a geocentric vector into latitude, longitude, and elevation
(i.e. an Observer object). The Newton's Method loop in
this function was not always converging, resulting in
an infinite loop. I fixed that by increasing the
convergence threshold and throwing an exception
if the loop iterates more than 10 times.

I also fixed a couple of bugs in the `demotest` scripts.
2022-12-04 10:31:15 -05:00
Don Cross
b2b426096f Added C performance test for nutation.
SiderealTime called 14,609,700 times in 47.217 seconds
= 3.23 microseconds per call.
2022-12-03 21:40:20 -05:00
Don Cross
84621b4d33 Enable truncation of the IAU2000B nutation model.
Modified the code generator and source templates to allow
using fewer than 77 terms from the IAU2000B nutation model.
The number of terms causes calculations to be far slower than
I would  like, plus most of these terms provide far less than
one arcsecond of difference in the output.

I want to experiment with truncated versions of the series.

https://apps.dtic.mil/sti/pdfs/AD1112517.pdf
Page 4 in the above document references a shorter series
"NOD version 2" that has only 13 terms instead of 77 as used in IAU2000B.
I found that code and confirmed the 13 terms are the first 13
consecutive terms from the original 77.

This commit does not change the number of terms calculated;
it only enables doing so by changing a single #define in
generate/codegen.c.

Once I change the nutation model, I'm sure there will be multiple
tweaks to unit tests to get everything working again.
2022-12-03 21:29:59 -05:00
Don Cross
db24ae9332 C: Added comments. Error checking in SphereFromVector.
Astronomy_SphereFromVector was not checking its vector
argument for having a bad status. Now it does.

Added comments that clarify exactly what nutation and precession
functions do.
2022-12-03 16:30:55 -05:00
Don Cross
c29ec327f5 Measure the speed of EclipticGeoMoon.
Added a performance test to measure how fast
a call to EclipticGeoMoon is. Results:
Over 3 trials, mean time = 24.064 seconds.
Number of calls = 14,609,700.
Time per call = 1.647 microseconds.
That is faster than I thought!

Also replaced conditional compilation with a runtime flag
to indicate whether a test should be skipped by the "all"
command. This allows me to run performance tests without
hacking a #define in the code, plus it ensures that even
though I don't run the performance tests every time I change
Astronomy Engine, they at least compile without errors.
2022-12-03 13:38:22 -05:00
Don Cross
72634ea84b Removed test: C Ecliptic. No longer needed.
This was another test where I was trying to figure out
an apparent anomaly that was actually based on my
flawed assumption about why obliquity changes over time.
2022-12-01 13:51:42 -05:00
Don Cross
0ae8bf2bd3 C MoonEcliptic test: add error threshold checks. 2022-12-01 13:49:28 -05:00
Don Cross
a20f17bf8f Removed C MoonLatitudes test.
I don't need the MoonLatitudes test any more.
Its purpose was to investigate what I thought was an
ecliptic latitude discrepancy. Now I understand that
changes in obliquity are caused by changes in the ecliptic
plane, not the equatorial plane.
2022-12-01 13:34:09 -05:00
Don Cross
28a3505040 More C ecliptic latitude tests.
I'm still trying to understand a discrepancy
between ecliptic latitudes calculated in two
different equinoxes: mean equinox of date and
mean J2000 equinox. I keep thinking the two
latitude values should be the same, because they
are measured against an essentially unchanging
ecliptic plane. I understand that ecliptic longitudes
should change as the Earth's equator precesses
by 47 arcseconds per century.

Added new test MoonEcliptic(), that compares
JPL Horizons calculations of the Moon's ecliptic
coordinates relative to equator of date versus
Astronomy_EclipticGeoMoon():

C MoonEcliptic: PASS: count=73050, max lat=1.825 arcsec, max lon=23.462 arcsec.

It is so weird that the maximum latitude discrepancy is less than 2 arcseconds.

Updated MoonVector test to measure maximum errors in addition to RMS errors.
Display distance errors in kilometers instead of dimensionless units.

Defined constant JD_2000 so all my tests that
convert Julian Dates from JPL Horizons can share it.
2022-11-30 12:36:36 -05:00