Commit Graph

293 Commits

Author SHA1 Message Date
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
4f80808008 JS: ObserverState
Implemented the JavaScript version of the ObserverState function.
2021-11-19 20:26:46 -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
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
029588da06 JavaScript: Calculate state vectors for barycentric/geocentric moon, EMB. 2021-11-14 00:37:52 -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
4e6cb282f5 Use original Pluto gravsim with finer time steps.
I'm getting much better accuracy sticking with my original
gravity simulator, just with smaller time increments, than
I was with the Runge-Kutta 4 method. The PlutoStateTable
gets a bit larger (51 state vectors instead of 41), but the
accuracy is so much higher.

Removed the Runge-Kutta code because I won't be going back to it.
2021-11-12 16:22:14 -05:00
Don Cross
a5fd814ba1 Finished single-source-of-truth for Pluto constants.
The Pluto gravity simulator constants now come from
a single source: pluto_gravsim.h. This will allow me
to experiment with the Pluto state table to get a better
compromise between size and accuracy.
2021-11-12 15:30:56 -05:00
Don Cross
3d899ab4f1 npm package 2.0.9 : security updates
These security updates do not affect users of Astronomy Engine.
They were flagged by Dependabot on GitHub to the steps
I use for building the TypeScript/JavaScript versions of
Astronomy Engine. The resulting code does not have any
external dependencies that need to be maintained.
2021-11-05 22:07:26 -04:00
Don Cross
c667fcf336 npm package version 2.0.8 2021-11-05 21:07:24 -04:00
Don Cross
3f788aaaee Fixed #126 - Added support for lunar libration.
There is now a Libration function in all 4 supported languages.
The returned structure contains libration angles in
ecliptic latitude and ecliptic longitude, along with
the Moon's ecliptic position and distance.
Also included is the Moon's apparent angular diameter.
2021-11-05 19:14:46 -04:00
Don Cross
296f23af76 Libration functions now calculate apparent angular diameter of the Moon.
All 4 languages have added a `diam_deg` field to the
structure returned by the Libration function.
It is the apparent angular diameter of the Moon as
seen from the center of the Earth, expressed in degrees.
2021-11-05 16:02:14 -04:00
Don Cross
eab9c275b9 Implemented lunar libration function for JavaScript. 2021-11-05 14:46:56 -04:00
Don Cross
adf65e1f1f Throw an exception for invalid refraction option.
In JavaScript and Python, throw an exception if provided
an invalid refraction option. Especially in JavaScript,
it was too easy to pass in a value like 'true', which did
not calculate refraction as expected.
2021-10-12 14:31:13 -04:00
Don Cross
42240288b0 JS SearchAltitude: improved documentation and parameter checking. 2021-09-23 10:43:20 -04:00
Don Cross
24571444d9 JS SearchAltitude implemented.
Refactored SearchRiseSet to create a new function
InternalSearchAltitude. SearchRiseSet calls InternalSearchAltitude,
and the new function SearchAltitude also cals InternalSearchAltitude.
This causes the code to be only a tiny big larger.
2021-09-22 19:45:33 -04:00
Don Cross
b32b2705ee Fixed JS doc formatting mistake.
The formatting of the JS documentation for class
GlobalSolarEclipseInformation was messed up in the
generated Markdown file. Fixed that issue in the
JS comments.

Bumping npm version to 2.0.6, to include recent
barycentric state and Earth gravity calculations.
2021-07-23 19:25:03 -04:00
Don Cross
a9479832dd JavaScript ObserverGravity function. 2021-07-19 17:27:33 -04:00
Don Cross
56b4852542 Documented the BaryState functions. 2021-07-14 20:28:15 -04:00
Don Cross
e398aa43a4 JS: Implemented BaryState function.
Ported the C version of BaryState to JavaScript.

Fixed an issue in both the C and JS unit tests:
the JPL Horizons data is given in terms of TT, not UT.
2021-07-11 19:40:27 -04:00
Don Cross
c77e5a5845 Publishing npm version 2.0.5. 2021-06-22 14:02:58 -04:00
Don Cross
a28aa5c3d9 One more documentation fix for JavaScript. 2021-06-21 21:20:05 -04:00
Don Cross
95960a962a Documentation fixes for JavaScript. 2021-06-21 20:56:38 -04:00
Don Cross
8abda4ea30 Documentation fixes for VectorObserver functions. 2021-06-21 20:23:33 -04:00
Don Cross
90f5ea367e JS: Implemented VectorObserver. 2021-06-21 16:45:59 -04:00
Don Cross
52fb59b32e Python: Implemented EQJ/GAL conversions.
Ported conversion to/from galactic coordinates to Python.
Added unit test for new Python code.
Updated documentation for all 4 supported languages.
Fixed mistakes in JavaScript function documentation.
2021-06-10 20:48:11 -04:00
Don Cross
15988c87df Ported GAL/EQJ conversion to JavaScript. 2021-06-09 21:11:30 -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
c4c90c9c22 Cleaned up JavaScript code and made minified version a little bit smaller. 2021-05-15 21:52:20 -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
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
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
6b01510b33 Fixed #99 - Export the AngleBetween function for outside callers. 2021-04-16 20:18:25 -04:00
Don Cross
90a9f56375 Bumped npm package version to 2.0.4. 2021-04-15 21:00:40 -04:00
Don Cross
1e2763af63 Finished defining Jupiter moon radii constants.
Now there are constants for the mean radii of Jupiter's
four major moons available in the C, C#, Python, and JavaScript
versions of Astronomy Engine.

Clarified that these are all mean radii.

Fixed some lingering "//" comments in the C code
(I want to keep ANSI C code as portable as possible.)
2021-04-15 13:20:55 -04:00
Don Cross
a3734bc60b Fixed #105 - Added functions to calculate a time object from TT.
Now callers can create time objects from either UT (UT1/UTC civil time)
or ephemeris/dynamical Terrestrial Time (TT). The new TT functions
numerically solve to find the UT that produces the given TT based
on the Delta-T value at that UT. This is always a very fast
numerical convergence, because TT and UT are almost perfectly
linear over brief time windows.
2021-04-14 19:42:03 -04:00
Don Cross
ef42841592 PY: Finished implementation of JupiterMoons function. 2021-04-14 06:41:24 -04:00
Don Cross
4f7a6e69cb C#: Implemented calculation of Jupiter's moons. 2021-04-13 11:45:03 -04:00
Don Cross
a6b1963291 Decreased minified JS size from 98382 to 94490 bytes.
I increased the error tolerance slightly for the Jupiter moons model.
This shrank the model tables significantly, giving me some more
breathing room to stay under 100K download size.
2021-04-12 20:53:42 -04:00
Don Cross
7f26aa7c20 JS: Decreased minified browser code from 98413 to 98382 bytes.
I don't like how close I am to my 100K target size, now
that I'm calculating Jupiter's moons.
Simplified the spin() function so its minified code is smaller.
I will look for other things I can shrink too.
2021-04-12 19:27:45 -04:00
Don Cross
a0d88f2f00 JS: Added documentation for JupiterMoons function and return type. 2021-04-12 16:57:22 -04:00
Don Cross
d64a46d5e1 JS: Implemented calculation of Jupiter moons. 2021-04-12 16:19:33 -04:00
Don Cross
9b67e7f3f9 Starting development for calculating Jupiter's moons.
I am starting the process of implementing calculation
of Jupiter's four largest moons: Io, Europa, Ganymede, Callisto.
This commit just contains constant declarations for the
equatorial, polar, and volumetric mean radii of Jupiter.

The positions of the moons will be related to the center
of Jupiter and be expressed in Jupiter equatorial radius units,
so I felt it would be good to give users a way to convert to
kilometers, which can in turn be converted to AU.
2021-04-04 20:52:31 -04:00
Don Cross
6f943d9ea4 Fixed some minor documentation mistakes. JS: Export DEG2RAD, RAD2DEG. 2021-04-01 14:08:56 -04:00
Don Cross
786afdd4eb Fixed broken link to KM_PER_AU in JavaScript documentation. 2021-03-31 22:42:50 -04:00
Don Cross
c3c8ffeb0f Finished documenting ObserverVector() in topic indexes. 2021-03-31 21:49:35 -04:00
Don Cross
cfb8714da4 JS: Added unit test and documentation for ObserverVector.
Also made time parameters to rotation matrix functions be of
type FlexibleDateTime, and internally convert them to AstroTime.
This should be the policy of all exposed functions in the
JavaScript version of Astronomy Engine.

Exposed KM_PER_AU to outside callers.
2021-03-31 19:07:00 -04:00
Don Cross
085d285ef0 Refactored all the nutation and precession functions.
Use a private enumerated type to select which direction
the precession and nutation is to be done:
- from date to J2000
- from J2000 to date

Normalize the order of parameters to be consistent
between precession() and nutation(), and across languages.
Pass in AstroTime instead of a pair of floating point TT
values (one of which had to be 0).

Added TypeScript version of ObserverVector(),
but it has not yet been documented or tested.
2021-03-31 12:09:11 -04:00