Commit Graph

2245 Commits

Author SHA1 Message Date
Don Cross
7e89ca6cda Demo to confirm I understand galactic coordinates.
I wrote a quick Python program based on an original reference
paper defining the galactic orientation system.
It generates a rotation matrix from first principles
that matches one inside the NOVAS function equ2gal(),
within the expected 2.3 arcsecond difference between
ICRS and EQJ.

NOVAS equ2gal matrix:

   double ag[3][3] = {
      {-0.0548755604, +0.4941094279, -0.8676661490},
      {-0.8734370902, -0.4448296300, -0.1980763734},
      {-0.4838350155, +0.7469822445, +0.4559837762}};

This program's generated matrix:

    B1950 = 1949-12-31T22:09:21.346Z
     -0.0548624779711344   0.4941095946388765  -0.8676668813529025
     -0.8734572784246782  -0.4447938112296831  -0.1980677870294097
     -0.4838000529948520   0.7470034631630423   0.4559861124470794

Also added some JPL Horizons test data to confirm
conversion back and forth between EQJ and GAL, which
I will use for future tests.
2021-06-06 17:49:24 -04: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
1396367524 Made minified JS browser code a little smaller.
Decreased the minified browser code from 94115 bytes to 94098 bytes.
Eliminated unncessary braces, used ternaries instead of 'if', etc.
2021-05-18 21:54:03 -04:00
Don Cross
efc6e7bdf9 Fixed broken build caused by improper branch merge.
When I merged from calendar2 branch into master branch,
I forgot to run the unit tests locally and commit the
code generation changes it caused. This has been fixed.
2021-05-16 14:29:30 -04:00
Don Cross
3e420e9e32 Merge branch 'calendar2' 2021-05-16 14:05:00 -04:00
Don Cross
7db556046b Calendar demo: planet constellations. 2021-05-16 13:32:19 -04:00
Don Cross
d5fb13d35c I forgot to check in updated calendar output. 2021-05-16 13:18:00 -04:00
Don Cross
5afeab6b02 Calendar demo: Sun, Moon culmination. 2021-05-16 12:25:57 -04:00
Don Cross
d950eaaa55 Calendar demo: planet perihelion and aphelion. 2021-05-16 12:15:24 -04:00
Don Cross
d87a42446f Calendar demo: added lunar apogee and perigee. 2021-05-16 12:04:18 -04:00
Don Cross
c4c90c9c22 Cleaned up JavaScript code and made minified version a little bit smaller. 2021-05-15 21:52:20 -04:00
Don Cross
08247921b5 Calendar demo: include transits of Mercury and Venus. 2021-05-15 20:45:30 -04:00
Don Cross
3220fb030d Calendar demo: include local solar eclipse predictions. 2021-05-15 20:32:29 -04:00
Don Cross
51235fbffd Calendar demo: include lunar eclipse predictions. 2021-05-15 20:00:55 -04:00
Don Cross
eefcce91e0 Calendar demo: added comments for remaining tasks. No code changes. 2021-05-13 20:28:51 -04:00
Don Cross
37c35737af Calendar enumerator demo: find times when Venus appears brightest. 2021-05-13 20:22:44 -04:00
Don Cross
629317e9ff Calendar enumerator demo: max elongations of Mercury and Venus.
Added event enumerators for when Mercury and Venus appear
at the maximum angle from the Sun as seen from the Earth.
2021-05-13 20:06:39 -04:00
Don Cross
31b71ac97f Calendar enumerator: added planetary conjunctions and oppositions.
The calendar enumerator demo now includes inferior and superior
conjunctions of the inner planets (Mercury and Venus), along
with the conjunctions and oppositions of the outer planets
(Mars ... Pluto).
2021-05-13 19:32:03 -04:00
Don Cross
23eb42f951 Removed unnecessary and risky method EventCollator.Append().
Once a collator has been created, and a caller starts
enumerating events, it does not make sense to be able to add
another enumerator to the collator. So I removed EventCollator.Append().
It was just opening up the possibility of bugs for no good reason.

Client code should decide up front what kind of events it wants
to enumerate and provide a complete list of enumerators.
Then it may use FindFirst/FindNext as many times as it wants
and everything will just work.
2021-05-12 20:36:32 -04:00
Don Cross
953ffef7a8 Calendar demo: added a moon quarter enumerator.
Added MoonQuarterEnumerator, which finds new moon, first quarter,
full moon, and third quarter events.
Changed the calendar start date to May 2021, so it is
more relevant to the time I'm testing it.
2021-05-12 19:54:09 -04:00
Don Cross
04ebd129dd Calendar demo now includes seasons. Also goes for 10 years instead of 1.
Generate solstices and equinoxes in the calendar event enumerator.
Generate 10 years of data instead of 1, to better test the seasons.
2021-05-12 19:37:34 -04:00
Don Cross
03f4e91bb9 Rough demo for how calendar enumerator will work.
This is an example of how multiple enumerators can be combined
into an EventCollator. The collator does the minimum amount
of work to keep searching for one event at a time, while always
emitting them in chronological order.
2021-05-12 19:00:21 -04:00
Don Cross
bba5b0b616 Calendar demo: apparently I don't need astronomy.d.ts for this to work. 2021-05-10 16:37:40 -04:00
Don Cross
398e8115c7 Added the new calendar demo to the JavaScript self-tests. 2021-05-09 21:00:54 -04:00
Don Cross
f299d15fd9 Starting to figure out how to make an Astronomy Engine demo in TypeScript. 2021-05-09 20:57:13 -04:00
Don Cross
1f2444c891 Starting to create a calendar event enumeration demo. 2021-05-09 18:11:00 -04:00
Don Cross
a57f8fc98e Made minified JS browser code a little smaller.
Decreased the minified browser code from 94918 bytes to 94221 bytes.
Did this by using a more efficient encoding of the IAU2000B nutation model:
instead of making {nals:[_], cls:[_]} objects, make lists of lists [[_], [_]].
2021-05-09 15:33:16 -04:00
Don Cross
d414bdda06 Fixed a few security vulnerabilities in the developer tools.
Ran 'npm audit fix' to resolve some security vulnerabilities
in the developer tools in the 'generate' directory.
None of the vulnerabilities affect the npm package
astronomy-engine, because it has no external dependencies.
The risk was only to developers who run the code generation
tools, not end users. Even then, the risk is minimal because
these tools run with well-defined inputs that are not subject
to external tampering.
2021-05-07 20:03:53 -04:00
Don Cross
b81a96cbdc Fixed #100 - Demo of searching for constellation change.
Added Python demo constellation.py that shows how to search
for when a body crosses the border between two constellations.
2021-04-30 20:00:52 -04:00
Don Cross
c7a48093c0 Fixed #101 - Added Python example of searching for lunar angle events with other bodies.
Finished the script demos/python/lunar_angles.py
that shows how to search for times when the Moon and other
solar system bodies reach apparent ecliptic longitude separations
as seen from the Earth.

This is also a good demo of how to perform a custom search
for events using Astronomy Engine. This is the same technique
used internally by Astronomy Engine to search for lunar phases,
eclipses, solstices, etc.
2021-04-28 12:29:01 -04:00
Don Cross
7ef9f71810 Work in progress: Python demo of searching for pair longitudes.
Started work on a Python demo for finding when the moon
reaches relative longitudes with other solar system bodies
that are multiples of 30 degrees. It is not finished yet,
but getting close.

Added operator overloads for the Python Time class so
that times can be compared against each other.
This makes it easier to sort a list of times, for example.
2021-04-27 22:08:24 -04:00
Don Cross
a8a3342a2f Added script pairlon.py to graph the behavior of PairLongitude functions.
This script will help me figure out how to tune the search algorithm
I'm about to write for searching for times that a pair of bodies
reach a given relative apparent ecliptic longitude.
2021-04-26 14:00:40 -04:00
Don Cross
d45bb771ac Python: Replaced LongitudeFromSun with more general PairLongitude. 2021-04-24 21:55:54 -04:00
Don Cross
a53e83d4af JS: Replaced LongitudeFromSun with more general PairLongitude. 2021-04-24 21:36:47 -04:00
Don Cross
2cf6419792 C#: Replaced LongitudeFromSun with more general PairLongitude. 2021-04-24 21:18:03 -04:00
Don Cross
a74e89bd24 Added C function Astronomy_PairLongitude.
This function is a generalization of Astronomy_LongitudeFromSun,
which it replaces. It calculates the relative ecliptic longitude of one body
with respect to another body, as seen from the Earth.

After implementing the same function in C#, JavaScript,
and Python, I will come back and create a generalized
search algorithm to find the next time two bodies are
at a given apparent relative longitude. Even though this
is a generalization of SearchRelativeLongitude, I will have
to figure out a more general way of tuning the search.
2021-04-24 19:52:33 -04:00
Don Cross
4f23e85524 Fixed #108 - Fail the build if C function, #define, enum, or typedef lacks documentation. 2021-04-23 20:54:09 -04:00
Don Cross
95b45d427d Removed Travis CI, added GitHub actions badge. 2021-04-21 21:01:37 -04:00
Don Cross
56d08a7370 Less verbose JupiterMoonTruncate. 2021-04-21 20:36:16 -04:00
Don Cross
06fc6651f8 One more tweak to diffcalc error thresholds for GitHub Actions. 2021-04-21 20:32:58 -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
c23affd28c First attempt at doing a GitHub Actions test build for Astronomy Engine. 2021-04-21 19:40:42 -04:00
Don Cross
31ff4acc1e Experimenting with GitHub Actions as a replacement for Travis CI. 2021-04-21 19:27:30 -04:00
Don Cross
0e1f8dbdc2 Check all fgets() in C tests for partial line reads.
I ran into a problem recently that was confusing to debug.
It turned out that I was calling fgets() providing a line buffer
that was not long enough for all of the lines in the input file.
This caused the unread portion of the long line to appear as if
it were the beginning of another line, failing the test in
a weird way.

So I replaced all calls to fgets() in ctest.c with a new
wrapper function ReadLine(). It checks for this issue
and immediately aborts with a helpful diagnostic.
2021-04-21 13:34:04 -04:00
Don Cross
6d3f27cd4c Added diffcalc testing for Jupiter's moons: position and velocity vectors.
This test verifies that the calculations of Jupiter's moons
are consistent across C, C#, JavaScript, and Python.
2021-04-21 13:06:44 -04:00
Don Cross
ab32f548e8 Diffcalc: scale topocentric distances based on minimum distance to Earth. 2021-04-20 19:06:32 -04:00
Don Cross
932573ac2d More fixes needed for diffing calculations among languages.
It turns out different Node.js versions do math differently,
which caused a Travis CI build failure.

Scale topocentric distance the same way I scale heliocentric distance.
Adjusted diffcalc bash script and diffcalc.bat Windows batch file accordingly.

The differ now prints the final "score" so I'm less likely to make
a mistake spotting the correct maximum difference.

Removed unused variable in ctest.c DiffLine(): maxdiff.
2021-04-20 18:51:36 -04:00
Don Cross
1e2c24208c Fixed #103 - Scale body vector differences by orbital radius.
When comparing calculations of body vectors, scale
the size of the difference by the minimum orbital
radius (or typical radius in the case of the Solar
System Barycenter).

This concludes my investigations of discrepancies between
the various language calculations. I have done as much
as I can without implementing my own trig functions,
which is not worth the effort (or the loss of efficiency
in JavaScript).

Scaling the errors relative the measurement units reveals
that the discrepancies are reasonable for the 16-digit
precision one expects from 64-bit floating point numbers.
The worst case is C vs JavaScript, with a scaled error
of about 7.2e-15. I can live with that.
2021-04-20 17:23:29 -04:00
Don Cross
ce0290b7f6 diffcalc: Divide angular errors by their range of values.
A given amount of error in an angle measured in
sidereal hours is 15 times more important than the
same numeric error in an angle measured in degrees.
Scale angular errors by the range of values they
could take on. Longitude-like angles in degrees
have a range of 360, while latitude-like angles
range over 180 degrees (-90 to +90).

Split out separate Windows batch file diffcalc.bat,
just like I already split out bash script diffcalc.
2021-04-20 16:25:02 -04:00
Don Cross
ebade6c4c2 Updated Windows build to run diff checker with tolerance passed in.
Now that the Linux build process passes in a different
tolerance value for each of the diff checks, I updated
the Windows build accordingly.
2021-04-20 15:30:54 -04:00