Commit Graph

51 Commits

Author SHA1 Message Date
Don Cross
cc6a32bb98 Include the gravsim check in the unit tests.
I have gravsim_test.c to the point where it calculates a
standard deviation of error between TOP2013 and Astronomy Engine
for calculating the position of Pluto over 10 worst-case samples.
My baseline is now 0.205303 arcminutes of heliocentric position error.

For Runge-Kutta (or some other method) to be an improvement, it
has to beat that score without incurring significant extra work
or larger memory consumption.
2021-11-10 21:00:38 -05:00
Don Cross
1ccec1ffad Generate test data for converting GAL/EQJ.
Starting work on support for galatic coordinates.
Generate a test data file using calculations made
by the NOVAS function equ2gal(). Later I will use
this data to verify the conversion functions I
write for Astronomy Engine.
2021-06-06 13:46:22 -04:00
Don Cross
c5b05f84d9 More changes for GitHub actions.
The test build failed because diffcalc reported a small
discrepancy between the C and C# output.
So I made the threshold more lenient for now.
I want to come back later and figure out if I can get back
to exact agreement between C and C# code.

Told wget not to output rediculous progress bar stuff
that eats thousands of lines of log output.
2021-04-21 20:09:52 -04:00
Don Cross
cbcacc4b57 Improved agreement of precision among the 4 supported languages.
Before making these changes, I had the following discrepancies
between the calculations made by the different programming
language implementations of Astronomy Engine:

    C vs C#: 5.55112e-17, worst line number = 6
    C vs JS: 2.78533e-12, worst line number = 196936
    C vs PY: 1.52767e-12, worst line number = 159834

Now the results are:

    Diffing calculations: C vs C#
    ctest(Diff): Maximum numeric difference = 5.55112e-17, worst line number = 5

    Diffing calculations: C vs JS
    ctest(Diff): Maximum numeric difference = 1.02318e-12, worst line number = 133677

    Diffing calculations: C vs PY
    ctest(Diff): Maximum numeric difference = 5.68434e-14, worst line number = 49066

    Diffing calculations: JS vs PY
    ctest(Diff): Maximum numeric difference = 1.02318e-12, worst line number = 133677

Here is how I did this:

1. Use new constants HOUR2RAD, RAD2HOUR that directly convert between radians and sidereal hours.
   This reduces tiny roundoff errors in the conversions.

2. In VSOP longitude calculations, keep clamping the angular sum to
   the range [-2pi, +2pi], to prevent it from accumulating thousands
   of radians. This reduces the accumulated error in the final result
   before it is fed into trig functions.

The remaining discrepancies are largely because of an "azimuth amplification" effect:
When converting equatorial coordinates to horizontal coordinates, an object near
the zenith (or nadir) has an azimuth that is highly sensitive to the input
equatorial coordinates. A tiny change in right ascension (RA) can cause a much
larger change in azimuth.

I tracked down the RA discrepancy, and it is due to a different behavior
of the atan2 function in C and JavaScript. There are cases where the least
significant decimal digit is off by 1, as if due to a difference of opinion
about rounding policy.

My best thought is to go back and have a more nuanced diffcalc that
applies less strict tests for azimuth values than the other calculated values.
It seems like every other computed quantity is less sensitive, because solar
system bodies tend to stay away from "poles" of other angular coordinate
systems: their ecliptic latitudes and equatorial declinations are usually
reasonably close to zero. Therefore, right ascensions and ecliptic longitudes
are usually insensitive to changes in the cartesian coordinates they
are calculated from.
2021-04-18 21:15:17 -04:00
Don Cross
f879bc51a6 Skip Jupiter Moon model optimization if already calculated.
This will save a lot of time in my local unit tests, but
will verify it isn't broken when I push to GitHub.
2021-04-11 19:27:09 -04:00
Don Cross
43d05b25bd Jupiter Moons: stubbed the idea of a model optimizer.
I want to experiment with truncating the L1.2 series to
sacrifice some accuracy for smaller generated code.
To that end, I implemented the ability to save the
Jupiter moons model after loading it. I added a 'jmopt'
command to the 'generate' program that will do this
optimization. For now, it just loads the model and
saves it back to a different file. Then the code generator
loads from the saved file instead of the original.
This commit verifies that everything is still working,
before I start truncating the series.
2021-04-11 13:42:23 -04:00
Don Cross
427fb8ed3a Purged obsolete code from generate.c.
Now that I no longer need to generate Chebyshev models
or TOP2013 models for Pluto, I got rid of all the
code in generate.c that is no longer needed.
This whacked about 1000 lines of code.
2020-08-25 17:39:22 -04:00
Don Cross
34a5d48e9c TOP2013: Froze Pluto model at 24816 bytes.
Instead of randomly searching for a good Pluto model, just use
the one I have so far. If I find a better one, I will replace it
in the Git repo.
2020-07-04 20:02:13 -04:00
Don Cross
03cfecea39 Starting to work TOP2013 Pluto model into the build/test process.
Generating an embryonic TOP2013 Pluto model, along with the old
Chebyshev resampling model of Pluto, into the Linux and Windows
build processes.

The TOP2013 Pluto model isn't used for anything, and it isn't
optimized properly yet, but at least this helps validate my code
automatically as I go forward.
2020-07-03 15:19:21 -04:00
Don Cross
85892ec0dd Simplified TOP2013 validation test.
Always validate all planets.
Removed the option to validate a single planet.
2020-07-01 16:08:25 -04:00
Don Cross
f258c27ce5 Validate TOP2013 logic as part of automatic unit tests. 2020-07-01 14:33:39 -04:00
Don Cross
ff5ef2b3bb Starting to implement ValidateTop2013().
Adding infrastructure for loading TOP2013 models of planets
and calculating them. Will start with a unit test to verify
I'm calculating the formulas correctly.
2020-06-30 17:58:42 -04:00
Don Cross
60b69065b8 Factored out download logic into a bash function. Download TOP2013 data.
I'm starting to work on a replacement for Pluto calculations that
are not bounded in time. I'm trying the TOP2013 model that calculates
elliptic parameters of the outer planets Jupiter..Pluto.
I needed to download the 24MB file TOP2013.dat.
I already had redundant download logic for two files, and this was a third.
So I eliminated the redundancy and generalized the download logic
in the new bash function Download.
2020-06-30 14:03:27 -04:00
Don Cross
9cdaaa8761 Starting to work on planetary transit calculations.
Wrote stub C functions for finding transits.
Updated html files containing Espenak test data for Mercury, Venus.
Updated norm.py to convert the html files to easy-to-use text files.
2020-06-11 22:17:01 -04:00
Don Cross
75e26ccac2 Changed verbosity option from -d to more standard -v. 2020-05-26 11:58:02 -04:00
Don Cross
0787b88ddd Python unit tests are less verbose unless -d option is specified. 2020-05-26 11:14:12 -04:00
Don Cross
30a85407b4 JavaScript: Use Espenak/Meeus DeltaT function. 2020-05-15 18:42:12 -04:00
Don Cross
b7c59f6628 Include extrapolated DeltaT values for the years 2030..2200.
I had to increase certain error tolerances in the unit tests.
Reworked the unit tests to make more sense by waiting until
each language step is done to check against each other.
That way I can run a single language step independently.
2020-05-14 20:24:34 -04:00
Don Cross
822b92239f Increased time span of lunar eclipse data, and wrote pre-processor.
I found that lunar eclipse data is available for many centuries.
I downloaded the data for the years 1701..2200.
Wrote norm.py to extract and convert the parts I care about
into a format that will be much easier to parse in the unit
tests for all four languages.
Regenerate the normalized data from the 'run' script.
This way, I have documentation for where the data came from.
2020-05-12 12:19:22 -04:00
Don Cross
e803a65b4e More thorough constellation unit test for C code.
I'm using the HYG star database v3 from:
https://github.com/astronexus/HYG-Database

I compare the star constellations it reports against
what I calculate from the star RA/DEC it lists.
When I try this against all stars in the database, I
find 25 disagreements about which constellation contains
the star. Another person found 3 disagreements. See:

https://github.com/astronexus/HYG-Database/issues/21

For now, I'm testing only the stars brighter than mag 4.890,
which eliminates all the disagreements, and still gets me
over 1000 test cases.

Also, now I'm verifying ephemeris file and star database
checksums whether or not they have just been downloaded.
The idea is to catch corruption or unexpected changes
each time I run the unit test.
2020-05-02 15:10:10 -04:00
Don Cross
3bb740fd1c Fixed #62 - Automatically update copyright year range. 2020-04-30 15:12:14 -04:00
Don Cross
07201afe0a Generate planet perihelion/aphelion test data from NOVAS.
Created my own unit test data from NOVAS for planet apsides.
Handle oddities with Neptune's orbit as a special case.
Removed hacks in ctest.c.
2020-01-04 07:05:43 -05:00
Don Cross
3ffc77caa6 C# demo: more work getting set up. 2019-12-23 11:36:55 -05:00
Don Cross
7bff374d57 Starting to add support for generating C# code.
Decided to move call to makedoc script from run script.
It was confusing that it was hidden inside unit_test_js,
especially because it invokes the code generator for
all supported languages.
2019-10-10 14:56:49 -04:00
Don Cross
6c398251ef Added call to csharp unit test from 'run' script. 2019-10-09 20:38:10 -04:00
Don Cross
5db8a91404 Verifying that I can build dotnet core 2.2 programs in Travis CI. 2019-10-09 20:28:46 -04:00
Don Cross
91aafeaba7 Starting to add Python demo programs.
Created skeleton test harness for validating the demo programs.
Created stub moonphase.py.
Copied correct demo program outputs from nodejs; will tweak as needed.
Call the Python demo test harness from the 'run' script.
2019-07-26 16:49:48 -04:00
Don Cross
410cf99a5e Display the "All Tests Passed" ASCII art from a text file. 2019-07-09 20:38:54 -04:00
Don Cross
7c8722acad Print ASCII art "All Tests Passed" on success.
It's nice to have a clear signal that I can read across the room
that everything was successful.  If I don't see this, I know
something went wrong.
2019-07-02 14:12:19 -04:00
Don Cross
b5ebc4a645 Added python unit test. 2019-06-23 19:52:16 -04:00
Don Cross
d476465b6d Actually test moonphase.js and moonphase.c. Test after generating code. 2019-06-13 21:38:27 -04:00
Don Cross
58fa90a0bf Reworked tests of C examples.
Moved test files into separate test directory (cleaner).
Make C and nodejs 'position' tests generate identical output.
2019-06-13 21:04:45 -04:00
Don Cross
4061aa6b58 Added nodejs example 'positions.js'.
Unit test the calculations and fail if output deviates.
2019-06-13 20:37:43 -04:00
Don Cross
fb09678d4f Verify that demo C programs build. Validate positions.c output.
I could also validate moonphase.c output if only I modified it
to accept an optional date and time parameter.
2019-06-11 21:05:44 -04:00
Don Cross
bf3c7a45c4 Fixed bug in checking for planet model files. 2019-06-04 17:50:36 -04:00
Don Cross
c343998098 Automatically detect whether planet models need to be generated.
Skip the time-consuming generation of planet models unless one
or more of the required files is missing.
This will cause the planet models to always be exercised by
Travis CI, but most of the time in my own development, they will
be skipped.  This is a good compromise now that the code is very stable.
2019-06-04 17:30:18 -04:00
Don Cross
f057996cda Implemented "fast" option for skipping regeneration of planet models. 2019-06-04 17:19:56 -04:00
Don Cross
2a0bd80469 Got timeout in Travis CI retrying download. Decrease timeout to 9 seconds. 2019-05-27 20:03:32 -04:00
Don Cross
6615e3b9f8 Starting to unit test astronomy.c.
Beginnings of a unit test for the C version of Astronomy Engine.
Currently verifies that Astro_MakeTime() is working correctly.
2019-05-16 16:18:03 -04:00
Don Cross
296367bd63 Attempt at fixing occasional ephemeris download error in Travis CI.
I will need to wait until I see the error happen, and confirm
that the retry logic fixes it, before I mark the bug fixed.
2019-05-09 20:40:25 -04:00
Don Cross
fa609fa6a0 Separated generating planet models and generating source code.
This allows me to very quickly and easily test changes that don't
affect the planet models or how code is generated.
2019-04-18 13:45:40 -04:00
Don Cross
e2d85e7bfb Added separate unit_test script. 2019-04-18 13:14:33 -04:00
Don Cross
0e757dfc0d Skip 6 days (instead of 1) to find next moon quarter.
This should help find the next quarter slightly more efficiently
because it will provide a more accurate estimate of the next quarter.
2019-04-18 13:05:29 -04:00
Don Cross
d00e40341b Added test of ecliptic longitude formula.
Using moon phase test data, exercised the calculation of
ecliptic longitude of the Sun and Moon at indicated times.
Compared the actual difference in longitude with 90*phase degrees,
where phase is 0 for new moon, 1 for first quarter, 2 for full,
3 for third quarter. The results always agree within 1 arcminute
(just barely).

Added this to the unit test.

Will come back and add unit tests for the phase searcher once
I implement it.
2019-04-17 05:03:47 -04:00
Don Cross
db6a7d3258 Curl needs -L option to follow redirects to download from GitHub. 2019-04-16 13:57:08 -04:00
Don Cross
a3f2495b59 Hosting DE405 ephemeris file on my own GitHub account.
I kept having trouble with Travis CI timing out trying
to download the DE405 ephmeris file from its official ftp site,
so I'm mirroring it on my own GitHub account.
Hopefully this makes the download smoother.
2019-04-16 12:40:14 -04:00
Don Cross
51cff29dd9 Figured out the JPL Horizons refraction formula.
I found some online resources that helped me track down the
formula for the refraction model used in the JPL Horizons
online tool. Now the JavaScript library allows 4 different
refraction options in Astronomy.Horizon():

false    :  no refraction
'novas'  :  use the NOVAS C 3.1 algorithm.
'jplhor' :  JPL Horizons algorithm, clamped beyond 1 degree below horizon.
'sae'    :  same as 'jplhor', only without clamping.

Now passes the jplcheck unit test without filtering out objects below the horizon!

Always compile the C code when executing the script './run'.
2019-04-13 22:00:20 -04:00
Don Cross
eaf6f3f7d6 JPL Horizons checker now working for astrometric equatorial coords.
Still need to resolve errors in apparent equatorial and horizontal coords.
2019-04-12 16:39:23 -04:00
Don Cross
390e0692d7 Added JavaScript unit test. 2019-04-09 13:34:56 -04:00
Don Cross
1e0527e2cf Generating VSOP output files. 2019-04-08 22:25:38 -04:00