Commit Graph

2227 Commits

Author SHA1 Message Date
Don Cross
1c5ef57ad0 Measure iterations/call for SearchRelativeLongitude.
Confirmed that Mercury is taking 19 iterations/call on average,
and Mars is taking about 10 iterations/call.
The other planets average 6 iterations/call.
2019-04-25 21:13:45 -04:00
Don Cross
43e214c6f5 Check git status before doing anything else. 2019-04-25 18:03:21 -04:00
Don Cross
af8c2e294f Added checks of longitude calculations in Windows. 2019-04-25 18:01:28 -04:00
Don Cross
3f2d8416d8 Fixed #32 - Warning-as-error in Windows build.
Compiler does not understand that there is no need for
a switch default because the enclosing switch statement
has already guarded against that.  Changed to ternary
operator to make compiler warning go away.
2019-04-25 17:01:28 -04:00
Don Cross
66f90ddb44 Fixed #26 - Sanity check interval between alternating opposition/conjunction events.
Check to make sure we did not skip over an event.
Complicated by the high orbital eccentricities of Mercury and Mars.
2019-04-25 11:38:06 -04:00
Don Cross
1150f615de Added verification of conjunctions and oppositions to unit_test.
Still need to verify that there is a consistent interval between
consecutive events.

Mercury is taking way too long to converge.
Mars is kind of slow too.
Need to improve the efficiency of SearchRelativeLongitude!
2019-04-25 11:10:05 -04:00
Don Cross
d87bb7eb09 More testing of finding oppositions and conjunctions. 2019-04-25 10:48:41 -04:00
Don Cross
3aa5ff00d7 Ecliptic longitude tests now run on Windows. 2019-04-24 21:37:54 -04:00
Don Cross
9f246a169e Helper script to pre-check before pushing. 2019-04-24 21:11:32 -04:00
Don Cross
c845dc7cbf Successfully calculating opposition of superior planets.
Using relative heliocentric ecliptic longitude of the Earth
and the other planet. Home in on when both planets have the
same longitude (the difference is 0).
2019-04-24 21:06:34 -04:00
Don Cross
509a7bb0bf Factored out code for longitude offset normalization.
Makes code a tiny bit smaller, and I will re-use for finding
conjunctions and oppositions.
2019-04-24 15:38:36 -04:00
Don Cross
1491d7f075 Forgot to push generated code. 2019-04-24 15:24:16 -04:00
Don Cross
eaea81c828 Minor cleanup in Astronomy.Seasons().
I was passing a parameter 'ndays' that was never used.
Always search for over a window 4 days wide.
2019-04-24 15:04:51 -04:00
Don Cross
d4b3595dc6 Trying to switch over to travis-ci.org 2019-04-24 14:31:41 -04:00
Don Cross
0910df7c12 Added seasons_test to Windows run.bat 2019-04-23 21:12:02 -04:00
Don Cross
ee8f7b1063 Fixed #7 - Calculating equinoxes and solstices to within 1.7 minutes.
Added correction for light travel time from the Sun.
Now my equinox and solstice calculations are within 1.7 minutes
of established values.
2019-04-23 20:54:39 -04:00
Don Cross
b1fed4e459 Finding solstices and equinoxes, but with approx 8 minute error.
For some reason, all my calculations are about 8 minutes earlier
than predictions from the test data. I suspect this is because
of light travel time from the Sun (equivalently, aberration).
2019-04-23 20:39:50 -04:00
Don Cross
b3ff85df86 Added solstice/equinox test data.
The data also includes perihelions and aphelions, which I might add later.
2019-04-23 17:44:56 -04:00
Don Cross
dd761773d5 Starting to work on calculating equinoxes and solstices.
Added new function Astronomy.SunPosition().
It is supposed to return ecliptic coordinates of date for the Sun
as seen from the center of the Earth.

The values look reasonable but I need to test them.
Will use the Sun's longitude in the return value from SunPosition()
to determine solstices and equinoxes.
2019-04-23 16:00:51 -04:00
Don Cross
bd44c31de5 Updated Windows run.bat to match Linux run script.
Added rise_set_test to the Windows version of the unit test.
2019-04-23 14:46:47 -04:00
Don Cross
50988c9ab2 Simplified sidereal_time() and callers -- always calculate GAST.
All callers of sidereal_time ended up needing it for apparent time,
not mean time. So I simplified the code so it no longer has extra
stuff for calculating GMST.
2019-04-23 13:59:53 -04:00
Don Cross
0af0a8ec67 Fixed #24 - No need to correct for light travel for the Sun.
Astronomy.GeoVector no longer iterates to try to correct light
travel time for the apparent position of the Sun. The Sun's
heliocentric coordinates are always (0,0,0), so there is no need
to do that.
2019-04-23 13:35:18 -04:00
Don Cross
e56842755d Added iteration safety limit in Search(). Defaults to 20.
Search limit can be adjusted in options passed into Search().
After 20 iterations, we should have divided the search
region by a factor of more than a million.  If quadratic
interpolation can't finish the job at that point, something
is really wrong.
2019-04-23 07:37:52 -04:00
Don Cross
47c9d2b801 Fixed #25 - Boosted rise/set search efficiency by 25%.
Allow caller to pass in pre-evaluated endpoints to begin the search.
This eliminates 2 function calls per search, reducing the
average from 8 calls/search down to 6 calls/search.

I think this is about as good of performance as I'm going to get.
2019-04-22 21:32:43 -04:00
Don Cross
1f49f7222f Having a "max slope" was flawed... lower slope is worse!
The smaller the slope magnitude |df/dt| is, the larger
the uncertainty in dt. That means we are better off using
an estimated value for the slope each time than underestimating
the time error like we were doing.

This also simplifies the code, and does not make it very
much slower.
2019-04-22 21:25:45 -04:00
Don Cross
358fb819a7 Improved search efficiency by guessing around QuadInterp root guess. 2019-04-22 16:22:41 -04:00
Don Cross
09fd5b1be1 Added a little test for Chebyshev stuff.
I learned by debugging the code that the Chebyshev approximation
does not exactly reproduce the endpoints like I thought. It does so
for the x values indicated by Alpha[1][...].
2019-04-22 14:34:41 -04:00
Don Cross
48006112db Search: wrap the function with another to increment call count.
This just makes the code cleaner, and I'm about to pass the
wrapper function to a Chebyshev interpolator, so it will be
even more handy then.
2019-04-22 11:04:27 -04:00
Don Cross
a30d904b84 Improvements to Search().
Now pass in max slope of function to be searched, expressed
in units/day. By seeing how far the function is from zero,
we can deduce whether we are within the specified time tolerance
of finding the event.

Use a simplified refraction model in the rise/set search so that
the function is better fit by parabolas. Assume constant refraction
instead of variable refraction, because it only matters near the horizon
anyway. Use a canned value of +34 minutes, which creates close fit with
test data.
2019-04-22 10:43:59 -04:00
Don Cross
dbe968691c Minor search improvements, but still seems like much better is possible. 2019-04-21 22:21:17 -04:00
Don Cross
c21d8a2345 Benchmark down to 66576 samples from 90720.
It is an improvement, but feels like much better should be possible.
2019-04-21 22:09:38 -04:00
Don Cross
0ea4432e4d First attempt speeding Search using quadratic interpolation.
The results are slightly better, but not nearly what I had hoped.
Going to try some other things.
2019-04-21 21:10:10 -04:00
Don Cross
954a00f6a0 Performance metrics: tally calls to Search.
Now I can see that rise_set_test is causing Search to sample
the altitude function 18 times per call.
2019-04-21 10:48:07 -04:00
Don Cross
043a05b78e Starting to add some simple performance metrics for Search function.
I am interested in optimizing the Search function.
Right now it is a very simple binary search that keeps breaking
an interval in half to narrow in on the time of where the supplied
function ascends through zero.  I know this can be made much better,
and this is important because the function calls are very expensive
in some cases.

So this commit adds the beginning of some simple metrics tracking
where unit test code can retrieve the number of times Search
sampled the function it is trying to find the ascending root for.
2019-04-21 10:34:31 -04:00
Don Cross
c1d8970873 Updated comments, renamed gmst variable to gast. 2019-04-21 10:10:49 -04:00
Don Cross
690a71ecf2 Replaced rise/set test data to have less extreme latitudes.
Latitudes within the arctic/antarctic circles cause too much
hassle because of horizon-grazing that makes it hard for
two different programs to agree on when (or even whether)
a rise or set took place.
2019-04-20 23:23:17 -04:00
Don Cross
8c2118ed67 Fixed #23 - Crazy behavior in refraction formula
The refraction formula went nuts near altitude angle -5.11 degrees.
We were taking the tangent of a value that zoomed toward infinity
near that value, causing essentially random numbers without any
upper bound to their size. Just like JPL Horizons, truncate any
angle more than 1 degree below the horizon, only I have a linear
taper down to 0 refraction as the altitude angle approaches -90.
I did not want any chance of creating an altitude less than -90.

Removed unit tests for the Sun at latitude -80 degrees.
It is too easy for my code to behave differently from another
calculator, because tiny changes in atmospheric modeling can
cause disagreement about whether there even is a sunset/sunrise.
This is because for observers so close to the pole, the Sun
sometimes barely dips below the horizon and then comes back
up for less than an hour.
2019-04-20 23:00:02 -04:00
Don Cross
9de4451468 Reworked rise/set algorithm based on culm/bottom bounding.
This is the first time it has passed the unit test,
although the unit test is just exercising whether the predictions
occur in the right order. I will need to add check for how accurate
the predictions are.
2019-04-20 19:12:29 -04:00
Don Cross
f465ac2d0a Turned off the rise/set test for now; I need to fix that code.
I will rework the rise/set algorithm to use min/max altitude events.
The result will be much more efficient, and will handle special
cases near the poles better.
2019-04-19 22:06:28 -04:00
Don Cross
d10f7e4bcb Can now search for time of object's highest/lowest altitude.
This will help me create a better algorithm for rise/set,
plus the culmination is one of the things I wanted for its own sake.
2019-04-19 22:03:55 -04:00
Don Cross
5965a43cc0 rise_test_test.js logs which body,lat,lon it is working on. 2019-04-19 13:37:33 -04:00
Don Cross
e3dc71952c Starting to implement rise/set search, but not working yet. 2019-04-18 21:32:06 -04:00
Don Cross
23e43ec9af Converted raw html rise/set data files to a format easier to process. 2019-04-18 16:07:43 -04:00
Don Cross
6413a24094 Run.bat now builds code before proceeding. 2019-04-18 14:40:40 -04:00
Don Cross
0c5415a1f5 Added batch file to rebuild generate.exe on Windows. 2019-04-18 14:34:14 -04:00
Don Cross
77c149519b Trying again with verify_clean script.
Git seems to return different exit codes on every system I try.
So now I'm just looking at whether 'git status --porcelain'
emits any text or not, without paying any attention to its exit code.
2019-04-18 14:01:56 -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
da07dda836 Fixed #21 - Travis CI - Verify generated code matches what was checked in.
Very simply, use git command to confirm there were no unexpected
modifications. In particular, if the checked in generated source
doesn't match what got written by the generate program, this will
fail the Travis CI build.
2019-04-18 12:43:58 -04:00