Commit Graph

2245 Commits

Author SHA1 Message Date
Don Cross
e5c9e0d7b4 TOP2013: Removed code that prevented diffing Pluto data between the languages. 2020-07-08 15:52:26 -04:00
Don Cross
03609b2825 TOP2013: Ported new Pluto model to Python. 2020-07-08 15:42:52 -04:00
Don Cross
8b2880a925 TOP2013: Ported to JavaScript. 2020-07-08 14:35:19 -04:00
Don Cross
e9b72ac12a Eliminated obsolete time limit checking for Pluto in C# unit test.
Now that I have switched to TOP2013 for calculating Pluto's
position in the C# code, there is no need for the unit test
to handle errors for out-of-bound time coordinate.
2020-07-08 11:40:22 -04:00
Don Cross
91709e29f2 Minor cleanup of Earth radius constants in JavaScript code. 2020-07-08 11:39:46 -04:00
Don Cross
765902c542 TOP2013: Ported new Pluto model to C# code.
Also corrected code generator to output term coefficients
in scientific notation. In the C code, it was dropping signficant
digits by outputting in fixed point notation.
2020-07-08 11:10:02 -04:00
Don Cross
a198b9e59e TOP2013: Re-tightened error tolerances for Pluto. 2020-07-07 16:56:34 -04:00
Don Cross
b31c0185df TOP2013: greatly decrease waviness in Pluto curve.
The high-frequency wobble in the Pluto position function was bothering me.
Decreased the arcminute error threshold from 1.0 to 0.5, resulting
in a much larger model, but a lot less ripple:

   547 [    78   140    94   115    21    99]
2020-07-07 15:38:39 -04:00
Don Cross
220ce1d74e TOP2013: Fixed problem with Pluto apsides.
The truncated TOP2013 series creates higher frequency
oscillations in the heliocentric distance of Pluto
that confused the apsides algorithm the same way Neptune did.
So I changed the special-case Neptune logic to work for both
Neptune and Pluto.
2020-07-06 19:41:28 -04:00
Don Cross
eea481231d plot_pluto should regenerate astronomy.c before building ctest. 2020-07-06 16:13:39 -04:00
Don Cross
28749fd671 Wrote scripts to plot Pluto distance, comparing NOVAS vs TOP2013.
The data plot confirms there is some kind of high-frequency error
that causes excessive local minima/maxima that fools the apside
finder.
2020-07-06 14:47:07 -04:00
Don Cross
d89b9a19d5 C: Replaced Chebyshev with TOP2013 for Pluto calculations.
Now the C version of Astronomy Engine is using the TOP2013 model
of Pluto instead of resampled Chebyshev polynomials.

I added temporary hacks to ignore differences for Pluto between
C output and output from Python, JavaScript, and C#.
I will remove these after all four languages are using TOP2013.
See the variable ToleratePlutoErrors in ctest.c.

ctest.c DiffLine function now understands that longitude-like
angles (right ascension and azimuth) can wrap around, and to tolerate
very small angular differences that happen to straddle the wraparound
value. I should have done this a long time ago, but it never caused
problems before now.

C PlanetApsis has a serious problem with Pluto that I didn't expect.
I need to investigate and understand this before porting to other
languages. For now, I hack around it using ToleratePlutoErrors.
2020-07-06 13:47:05 -04:00
Don Cross
852681b225 TOP2013: NudgeSearch shuffles the order of each delta value also.
This is another way to explore possible solutions in a random order
so that we don't keep going in the same directions each time.

Found a better solution:

   219 [    27    63    61    58     6     4]
2020-07-05 21:13:22 -04:00
Don Cross
07887d30b8 TOP2013: NudgeSearch randomly shuffles the order it searches the coordinates. 2020-07-05 20:19:17 -04:00
Don Cross
ab815498af TOP2013: found a better Pluto model.
224 [    27    73    56    58     6     4]

Added a 'topinfo' command to generate.c for displaying
the above stats.
2020-07-05 19:39:55 -04:00
Don Cross
b6d0d4f8da TOP2013: The 'hunt' script found a better Pluto solution.
winner:   0.995872 arcmin :    227 [     27     62     61     65      8      4]
2020-07-05 18:57:03 -04:00
Don Cross
cb5f4fd998 TOP2013: found better solution using new script 'hunt'.
winner:   0.998305 arcmin :    228 [     37     63     60     58      6      4]

This script keeps running the ray search followed by the nudge search.
If it finds a better solution that the existing one, it replaces it.
Found the above solution after about 30 minutes.
2020-07-05 17:46:46 -04:00
Don Cross
ea989f53a2 TOP2013: Implemented NudgeSearch to make Pluto model even smaller.
0.993372 arcmin :    238 [     41     62     63     63      5      4]
2020-07-05 16:30:20 -04:00
Don Cross
a8ce5191b4 Improved term sorting by adjusting "millennia" value.
I realized that I still was telling the code to assume the
time coordinate never gets more than 0.2 millennia away from J2000.
But in fact, it is getting 0.5 millennia away. Fixed that, and
immediately found a smaller model that works.

OptimizeTop:    255 terms [     41     62     71     68      9      4]
2020-07-05 14:12:36 -04:00
Don Cross
6588e21d72 TOP2013: Relaxed required accuracy to 1 arcminute; some optimizations.
Relax apparent angular error threshold from 0.4 to 1.0 arcminutes.
No longer compare TOP2013 to NOVAS while optimizing.
Use worst-case distance between Earth and Pluto:
Pluto radius from Sun, minus Earth aphelion distance.

Sample 503 points intead of 293.
Measure 2 full orbits before J2000 and 2 full orbits after J2000.

Statistics for output/8.top :
OptimizeTop:    268 terms [     34     57     72     90      9      6]
2020-07-05 13:31:43 -04:00
Don Cross
53050bf939 TOP2013: Generating Pluto data tables in astronomy.c.
Nothing uses the tables yet. Still need to add the calculation code.
2020-07-04 23:02:14 -04:00
Don Cross
d226f3c11e Make Travis CI leave output/8.top alone. 2020-07-04 20:21:10 -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
0afc803b94 TOP2013: First draft of a random-ray search for small models. 2020-07-04 19:31:39 -04:00
Don Cross
3ce9f07c63 TOP2013: Implemented function for picking random 6D unit vectors.
Created functions for generating random unit vectors in
6-dimensional space. Will use this for trying different
directions along which to do a binary search between
truncated TOP2013 models that have acceptable error
and those which have unacceptable error. Will home in on
the smallest model that is within tolerable error.
2020-07-04 14:24:06 -04:00
Don Cross
c2785f9ae0 Updated comments that document binary search stats. 2020-07-03 23:01:58 -04:00
Don Cross
c3d1cdf465 TOP2013: Made measurements run twice as fast by recycling invariant calculations. 2020-07-03 22:59:24 -04:00
Don Cross
d3680c1f1d TOP2013: exploring how many terms I can truncate from the 6 formulas. 2020-07-03 22:13:05 -04:00
Don Cross
cb9e5e9107 TOP2013: added helper function to directly calculate rectangular coordinates.
Also optimized calculation of rotation matrix.
2020-07-03 20:37:24 -04:00
Don Cross
ac6a101607 TOP2013: Changed my mind. Will squash models by integer skip values.
Instead of calculating amplitudes and truncating based on them,
I realized when it comes right down to it, all I want to do
is truncate fewer or more terms from each formula until I find
a good compromise between size and accuracy. A term is either
included or excluded. Therefore the degree of freedom is discrete,
not continuous. There is no need to calculate a continuous value
to adjust something with only discrete options available.
2020-07-03 20:15:53 -04:00
Don Cross
f8be7797bf TOP2013: Incorporate the pruning amplitudes inside the contribution map itself.
This change allows me to automatically initialize the pruning amplitudes
to the largest possible value that won't cause any pruning.
It establishes a lower bound for pruning each of the 6 elliptical formulas.
2020-07-03 17:23:13 -04:00
Don Cross
acac092e03 TOP2013: TopSquash() never returns an error code, so made it return void. 2020-07-03 17:04:48 -04:00
Don Cross
c2eedd6e2c TOP2013: simplified data structure.
Eliminated a layer of abstraction from the data structure
for a TOP2013 model. Just represent a flat [6][13] array of series.
2020-07-03 16:59:27 -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
70faf02b4d TOP2013: Eliminated nseries_calc; it causes more trouble than it's worth.
It's more elegant to assume there are always 13 series,
even if many of them are empty of any terms.
The increased calculation time is negligible.
2020-07-03 14:41:46 -04:00
Don Cross
ab5df8fc5d TOP2013: Implemented "clone" and "squash" functions.
The TopCloneModel function makes a deep copy of a model,
allocating separate term arrays for the copy.

TopSquash uses a contribution map and an array of 6 amplitude thresholds
to pack down an original model into a cloned model.
2020-07-03 14:33:31 -04:00
Don Cross
e2f5d47cc9 Eliminated top_formula_t::nseries_total.
Because the series array size is fixed, there is no reason
to have an nseries_total field.
2020-07-03 12:47:45 -04:00
Don Cross
13c02dcfc9 TOP2013: Implemented "contrib map" idea.
The contrib map is an array of 6 sortable lists, one for each
elliptical formula. Each list contains a tuple (m, s, t)
where m = the magnitude of the contribution of a term,
and (s, t) are the indices of the term in the formula.
I sort the tuples in ascending order of magnitude.
This should allow me to efficiently eliminate terms from
each formula.

I will have to add an "ignore" flag for each term, because
eliminated terms will not generally be at the end of the list.
Before saving, I will need to compact the lists.
2020-07-02 22:05:12 -04:00
Don Cross
5679aace89 TOP2013: Starting to work on pruner/optimizer.
The first step is measuring the error between TOP2013 and NOVAS
over a range of time values and finding the maximum error in
worst-case parallax arcminutes as seen from the Earth.

Next I will be able to automate pruning the model to make
it as small as possible without exceeding our error tolerance.
2020-07-02 20:19:40 -04:00
Don Cross
5079896ad5 Ported validation of TOP2013 code to Windows run.bat. 2020-07-02 10:31:28 -04:00
Don Cross
9a11828265 Windows run.bat: factored out download logic as a subroutine.
Reduced the size of the Windows batch file 'run.bat' by factoring
out the logic for downloading an external file into a subroutine.
I had already done this in the Linux bash script 'run'.
2020-07-02 10:18:04 -04:00
Don Cross
3fef403834 Updated build for Windows to include TOP2013 code. 2020-07-01 22:32:06 -04:00
Don Cross
4306f09f92 More debug info about errors comparing JPL/TOP, NOVAS/TOP. 2020-07-01 22:15:52 -04:00
Don Cross
7132080e8f Compared JPL Horizons data with TOP2013. Very good fit.
This makes me think there is something wrong with how
I am calling NovasBodyPos(). I don't understand why the errors
are tiny fractions of arcminutes here, but up to 0.11 arcmin
compared to NOVAS.
2020-07-01 21:59:18 -04:00
Don Cross
1fe3bd222b Comparing TOP2013 calculations against NOVAS.
The error is larger than I expect, especially for Pluto:
0.11 arcmin max, measured heliocentrically.
2020-07-01 19:52:14 -04:00
Don Cross
61eef7531a TOP2013: Verified calculation of rectangular coordinates.
Ported the original FORTRAN code for converting elliptical
elements to ecliptic/equatorial rectangular coordinates.
Verified against the output of the original FORTRAN program.
The results include both position vectors and velocity vectors,
and all are identical to 10 places after the decimal.
2020-07-01 19:07:35 -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
460044df83 TOP2013: calculating correct elliptical elements. 2020-07-01 15:57:36 -04:00
Don Cross
f258c27ce5 Validate TOP2013 logic as part of automatic unit tests. 2020-07-01 14:33:39 -04:00
Don Cross
2259024404 Added self-diffing to verify we generate identical TOP2013 output as we loaded. 2020-07-01 13:24:20 -04:00