Commit Graph

2245 Commits

Author SHA1 Message Date
Don Cross
df518aeb84 Implemented C# RotationAxis. Improved C RotationAxis docs. 2021-11-30 22:12:34 -05:00
Don Cross
62dae5d893 Eliminated C constants MIN_BODY, MAX_BODY.
I don't think it's a good idea to imply that the body constants
are always going to be consecutive, or that it makes sense to
iterate over them. The caller needs to understand the body enough
to know which operations are allowed and which aren't.

So I removed the constants MIN_BODY and MAX_BODY.
2021-11-30 20:54:22 -05:00
Don Cross
afc472be77 C RotationAxis: added rotation model for the Earth.
This model uses the existing precession and nutation models
to calculate the north pole vector. Then it converts the vector
to equatorial coordinates.
2021-11-30 19:59:44 -05:00
Don Cross
55a2e8fd3b C RotationAxis: added code and test data for Pluto. 2021-11-29 21:19:18 -05:00
Don Cross
ad0611755a C RotationAxis: added Jupiter ... Neptune. 2021-11-29 21:08:44 -05:00
Don Cross
318fc416af C RotationAxis: Added Venus and Mars. 2021-11-29 20:49:00 -05:00
Don Cross
20ff46bb27 C RotationAxis: calculate north pole vector.
Calculate the vector that points in the direction
of the body's north pole.
The unit test now checks for excessive angle
between the expected north pole vector and the
calculated north pole vector.
2021-11-28 21:51:47 -05:00
Don Cross
ec35f21827 Starting body rotation axis calculation.
I'm starting to implement formulas from the IAU 2015 report:
https://astropedia.astrogeology.usgs.gov/download/Docs/WGCCRE/WGCCRE2015reprint.pdf

This is a work in progress. The unit test is partially finished.
The C function Astronomy_RotationAxis() works only for the Sun and Mercury.
I want to also return a rotation matrix that reports the rotating
frame in a way more suited to graphics work. I will add this to
the type astro_axis_t later.
2021-11-28 20:44:57 -05:00
Don Cross
f0be3be9a0 Document and data files for planet rotation axes.
I am starting to work on calculation of the north pole
axes of various solar system bodies. Here I include a reference
source document, along with some test data, all described by
the README.md file.
2021-11-26 20:24:19 -05:00
Don Cross
4c59d93015 Added another state vector sanity check.
Compare state vectors with the initial states used
to integrate the DE405 ephemeris.
This is just yet another confidence check that calculations
are correct.
2021-11-25 21:26:35 -05:00
Don Cross
f95316c113 Fixes for the Windows build process. 2021-11-24 21:33:06 -05:00
Don Cross
36a8370f4d Tell GitHub Actions to install doxygen, xsltproc.
These tools are needed for generating documentation
for the C version of Astronomy Engine.
This is an attempt to fix the current CI build failure.
2021-11-24 20:03:57 -05:00
Don Cross
d1d34d5254 Enable generation of C documentation by default.
When building Astronomy Engine for publication,
I was disabling generation of C documentation by default,
because I used to have issues getting deterministic output
in the CI tests (GitHub Actions). Now I have reason to believe
it will work reliably, so I am turning on C docs generation
by default.

If this fails the CI test, I will have to make the CI test
explicitly disable this step until I figure out how to fix it.
Otherwise (and preferably) the CI test will ensure that the
published C documentation is always up to date, and will fail
the build if there are any issues generating the docs.

I also had forgotten to enable installing dependencies for
my custom tool `hydrogen` in the Windows build. I added a fix
for that.
2021-11-24 19:37:13 -05:00
Don Cross
91341df4a0 Moved website/tutorials to separate branch.
For now, I'm keeping beta/unfinished website and tutorial stuff
outside the master branch to reduce confusion for newcomers.
It will stay in the `tutorials` branch for any ongoing development.
If we finish it and make it ready for public use, then I will
bring it back into `master`.

Updated the `makedoc` script to gracefully skip steps
involving tutorials or website if they are absent.

Also, we were not installing packages needed for `hydrogen`
to generate C documentation. This broke document generation
on freshly-cloned repos.
2021-11-24 19:17:29 -05:00
Don Cross
523b91fde2 Fixed JavaScript unit tests for Windows.
I noticed on a freshly-cloned Astronomy Engine on Windows,
I started getting JavaScript test failures. The problem was the
script generate/test.js had an inconsistent way of reading text
from files and splitting it into lines. Some of the tests
did not account for \r\n line endings in Windows text files.

So I created a unified approach: a new function ReadLines
that works correctly for Linux and Windows, regardless
of the variant line endings.

This may not work on Mac OS, but I don't have an easy
way of testing that myself. But at least now I can fix
issues like that in one place.
2021-11-24 08:30:54 -05:00
Don Cross
04cd457122 Deleted obsolete GitHub Pages control files. 2021-11-23 21:31:37 -05:00
Don Cross
aa334a0067 Moved code generation directories beneath 'generate'.
I'm trying to make it easier for first-time visitors to
this project to find the source code and documentation
to get started quickly. Moved directories that are only
used by contributors (mostly myself) out of the root
and into the 'generate' directory where they are less
distracting.
2021-11-23 21:23:54 -05:00
Don Cross
eb91d20c4e Directly link to source directory, out of genererate directory. 2021-11-23 20:52:09 -05:00
Don Cross
5ec6070c7c Deleted distracting directory that is not important for end users. 2021-11-23 20:51:42 -05:00
Don Cross
d02039c78f Trying to make it easier for newcomers to find the code.
I'm concerned that a first-time visitor to the Astronomy Engine
repo on GitHub will get lost. I made it more obvious where to
quickly find the source code needed for a given language.
2021-11-23 20:43:17 -05:00
Don Cross
cec908e52c Fixed #137 - more carefully scale SSB errors.
The reason SSB vector errors were larger than other bodies
is because the Sun/Barycenter relationship does not have
position and velocity vectors of a "typical" size.
The distance of a planet from the SSB is fairly constant,
and the speed a planet travels is fairly constant.
Therefore, comparing errors by dividing by the magnitude
of the correct vector usually makes sense for scaling.
But for the barycentric Sun (or the heliocentric SSB),
the magnitude of the vectors can become arbitrarily small,
nearly zero in fact, resulting in surprisingly large ratios.

I compensated for this in all the tests by adding a new rule.
When the error thresholds r_thresh and v_thresh are negative,
it is a flag that indicates they are absolute, not relative.
In other words, r_thresh < 0 indicates that abs(r_thresh) is
the maximum number of astronomical units allowed in position
errors, and v_thresh < 0 specifies maximum AU/day.

This results in more consistent numbers that give confidence
the errors are indeed very small and not worth worrying about.
2021-11-20 21:51:08 -05:00
Don Cross
6b744edd71 Completed implementation of ObserverState.
Fixed a few lingering issues in the documentation of
the C# version of the ObserverState function.
This completes the implementation across all 4 languages.

ObserverState calculates the position vector of a point
on the surface of the Earth, and the velocity vector
of that point, both relative to the center of the Earth.
2021-11-19 22:15:02 -05:00
Don Cross
c91fe513c1 PY ObserverState
Implemented the Python version of the ObserverState function.
2021-11-19 21:40:22 -05:00
Don Cross
3c3a41326c Made C#, JS, PY state tests consistent with C.
In the C unit test for barystate, heliostate, and topostate,
I had switched from checking absolute differences to relative
differences. I forgot to do that in the other 3 languages
until now. They are all working consistently in how they
measure calculation errors.
2021-11-19 20:53:40 -05:00
Don Cross
4f80808008 JS: ObserverState
Implemented the JavaScript version of the ObserverState function.
2021-11-19 20:26:46 -05:00
Don Cross
7e2b0a73eb C# ObserverState
Implemented the C# version of the ObserverState function.
This returns the geocentric position and velocity for
a point on the Earth's surface at a given time.
2021-11-19 17:30:52 -05:00
Don Cross
1d9a90af2d C barystate: Reworked internal data structure.
Made the internal data structure for the C version of barystate
use named fields in a struct for Sun...Neptune, instead of
an array. This makes the C code look more like the other 3
language implementations. I am going to experiment with adding
more bodies to see if it helps accuracy, and this makes the
code easier to modify for that experiment.
2021-11-18 10:40:42 -05:00
Don Cross
05911a698f C StateVectorDiff: measure relative errors.
Instead of measuring absolute state vector position/velocity
errors, measure them relatively by dividing by the magnitude
of the scalar length of the correct vectors. This gives a better
feel for how much error each calculation contains.

In the process, I discovered that the barycentric Sun calculation
is off by more than 1 percent, which is surprising and deserves
more attention. I wonder if including the inner planets would
make it more accurate?
2021-11-17 21:25:40 -05:00
Don Cross
4741bf3bed C ObserverState: added unit test.
The unit test uses two JPL Horizons data sets: the center of
the Earth as seen from the surface of the Earth, and the
Earth/Moon Barycenter (EMB) as seen from the surface of the Earth.
2021-11-17 20:31:22 -05:00
Don Cross
684775acac Python heliostate/barystate use common code. 2021-11-16 20:30:16 -05:00
Don Cross
6e698fdb8d JS heliostate/barystate share common code. 2021-11-16 20:18:29 -05:00
Don Cross
1746747769 C# barystate/heliostate tests use common code. 2021-11-16 20:12:23 -05:00
Don Cross
f7a46490ce Refactored C heliostate, barystate tests.
Simplified the C unit tests for barystate and heliostate
so they use common code for parsing the JPL Horizons
data files. The only thing really different about them
is which function is called to compare against the state
vectors in the files. Pass in a pointer to a context.
Right now the context just contains a pointer to a function
to call, but later it may contain other parameters if needed.
2021-11-16 19:18:29 -05:00
Don Cross
f4e40e764a Implemented C ObserverState, but not yet tested.
I am starting to work on a function to find the position
and velocity vectors for an observer on the surface of the Earth.
I created the C function Astronomy_ObserverState(), but I don't
yet have a unit test for it.
2021-11-16 19:14:40 -05:00
Don Cross
9537296347 Added missing supported bodies to Python HelioState docs. 2021-11-15 21:14:40 -05:00
Don Cross
5c989be20c PY HelioState: calculates heliocentric position and velocity.
This is the Python version of a new function HelioState to
calculate heliocentric state vectors (position and velocity).
2021-11-15 20:37:09 -05:00
Don Cross
f16dcea487 JS HelioState: calculates heliocentric position and velocity.
This is the JavaScript version of a new function HelioState to
calculate heliocentric state vectors (position and velocity).
2021-11-15 20:10:11 -05:00
Don Cross
295221339c C# HelioState: calculates heliocentric position and velocity.
This is the C# version of a new function HelioState to
calculate heliocentric state vectors (position and velocity).
2021-11-15 19:37:26 -05:00
Don Cross
b2101c6cfe C HelioState: calculates heliocentric position and velocity.
This is the C version of a new function HelioState to
calculate heliocentric state vectors (position and velocity).
2021-11-15 14:31:48 -05:00
Don Cross
19f157e71c Full support for geocentric and barycentric EMB.
Now the Python version of Astronomy Engine supports calculating
the Earth/Moon Barycenter (EMB) state vector (position and velocity)
relative to the Earth's center (geocentric) or relative
to the Solar System Barycenter (SSB).

This completes support for this feature across C, C#, JavaScript, and Python.
2021-11-14 11:54:57 -05:00
Don Cross
68b2235c0b Removed extraneous newlines from C# test output. 2021-11-14 10:02:44 -05:00
Don Cross
926eae349a C demos allow getting observer from environment.
The function ParseArgs (used by many of the C demo programs)
now allows an alternative command line usage. If the '-e'
option is specified, it looks for the environment variable setting:

ASTRONOMY_ENGINE_OBSERVER='latitude longitude'

This form allows the demo programs to be configured for a given site.
2021-11-14 09:53:45 -05:00
Don Cross
029588da06 JavaScript: Calculate state vectors for barycentric/geocentric moon, EMB. 2021-11-14 00:37:52 -05:00
Don Cross
e4f9e68630 C#: Calculate state vectors for barycentric/geocentric moon, EMB. 2021-11-13 23:29:07 -05:00
Don Cross
64785cecf4 C version calculates geocentric and barycentric EMB.
Now the C version of Astronomy Engine supports calculating
the Earth/Moon Barycenter (EMB) state vector (position and velocity)
relative to the Earth's center (geocentric) or relative
to the Solar System Barycenter (SSB).

Astronomy_BaryState() now supports body == BODY_EMB.

Added a new function Astronomy_GeoEmbState() to calculate
the geocentric state for the EMB.

Both have been verified using test data generated by JPL Horizons.
2021-11-13 20:58:42 -05:00
Don Cross
3ad637f225 Implemented C function Astronomy_GeoMoonState.
I wanted to test the geocentric Moon state vector I
calculate for the sake of the Moon state relative to
the Solar System Barycenter (SSB). Because the geocentric
portion has such a small magnitude, I decided to go ahead
and expose GeoMoonState as part of the API, and create
a test for it specifically. I used JPL Horizons to generate
the test file GeoMoon.txt.
2021-11-13 20:12:55 -05:00
Don Cross
9869fd8bfc C BaryState: Calculate Moon's barycentric position and velocity vectors.
The C function Astronomy_BaryState() now supports BODY_MOON.
Because of the complexity of the CalcMoon() function, I ended
up calculating two positions close together in time, and
using dr/dt to estimate the velocity vector.
2021-11-13 19:34:13 -05:00
Don Cross
71cb92df08 Calculate barycentric state of Pluto.
The BaryState function did not support Pluto before.
Refactored the code so that the internal CalcPluto function
returns both the position and velocity, and its caller
can select from heliocentric or barycentric coordinates.
HelioVector asks for heliocentric coordinates and keeps
only the position vector. BaryState asks for barycentric
coordinates and returns both position and velocity.

I added test data for Pluto generated by JPL Horizons.
It turns out the Pluto system barycenter is the best fit
for TOP2013, presumably because Charon causes Pluto to
wobble quite a bit.

I also generated JPL Horizons test data for the Moon
and the Earth/Moon barycenter, anticipating that I will
support calculating their barycentric state vectors soon.

I had to increase the enforced size limit for minified
JavaScript from 100000 bytes to 120000 bytes.
I guess this is like raising the "debt ceiling".

Fixed a bug in Python unit tests: if "-v" verbose option
was specified, it was printing a summary line for every
single line of input, instead of a single summary after
processing the whole file, as was intended. This is one
of those Python whitespace indentation bugs!
2021-11-13 16:07:00 -05:00
Don Cross
0b96e2a2d7 Fixed Windows build: diffcalc C vs C#.
A slight difference (7.9e-17) in calculation now exists between
the C and C# horizontal angle calculations on Windows.
This is not surprising because the atan2() function is
known to return slightly different values on other
compilers/platforms. Adjusted the tolerance for this tiny
amount of roundoff discrepancy.
2021-11-13 09:13:41 -05:00
Don Cross
2fe8b8d8c0 Deleted log file original.txt 2021-11-12 19:44:56 -05:00