Commit Graph

1683 Commits

Author SHA1 Message Date
Don Cross
25cba04356 Added pylint to unit tests. Fixed warnings. 2021-09-25 19:51:48 -04:00
Don Cross
6d4cb068c5 Implemented C# function SearchAltitude. 2021-09-23 15:44:06 -04:00
Don Cross
d3621e7206 Implemented Python function SearchAltitude. 2021-09-23 14:27:56 -04:00
Don Cross
4b64ceeb0d Implemented C function Astronomy_SearchAltitude. 2021-09-23 11:57:44 -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
0038bbbc39 Started JS Twilight unit test.
This is the beginning of adding support for calculating
civil, nautical, and astronomical twilight (dawn/dusk).
Just added the stubbed unit test without the call in place
for the new function that will be added: SearchAltitude.
2021-09-22 17:24:21 -04:00
Don Cross
e03289a8cc Fixed #120 - google-closure-compiler now works on Raspberry Pi.
Worked around an issue where the npm package google-closure-compiler
assumes the current architecture is Intel x64.
This caused a broken install on the Raspberry Pi.
Detect non-Intel architecture and fall back to installing
only the Java version of the Closure compiler.
2021-09-18 21:56:02 -04:00
Don Cross
57177a506e Resolved security issue CVE-2021-23343.
The following security issue was reported by
Dependabot for the code generator script:

https://github.com/advisories/GHSA-hj48-42vr-x3v9

The issue was that the npm package path-parse 1.0.6
had a regex denial-of-service attack.
I have updated to use path-parse 1.0.7.

The user-facing Astronomy Engine library has no external
dependencies, so there is no need for most users to
be concerned with this change. The only affected component
was the internal code generator used to produce the
distributed source files, which is only run on my own
machine and the GitHub CI hook when I push a new change.

I verified that this update has no effect on the generated code.
2021-08-12 10:10:27 -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
aa2eb01dbf Python ObserverGravity function. 2021-07-19 22:09:49 -04:00
Don Cross
a9479832dd JavaScript ObserverGravity function. 2021-07-19 17:27:33 -04:00
Don Cross
1e53f09630 C# ObserverGravity function. 2021-07-19 17:09:08 -04:00
Don Cross
37084a156d C Earth gravity calculation.
Implemented the C function Astronomy_ObserverGravity.
It implements the WGS 84 Ellipsoidal Gravity Formula,
yielding the effective observed gravitational acceleration
at a location on or above the Earth's surface.
Wrote a demo program that also serves as a unit test.
I verified a few of the calculations, so the file
demo/c/test/gravity_correct.txt also serves as correct
unit test output.
2021-07-19 14:23:27 -04:00
Don Cross
827e083e34 Implemented Python aberration unit test. 2021-07-14 20:09:28 -04:00
Don Cross
bd29e67663 Implemented C# AberrationTest. 2021-07-13 22:00:01 -04:00
Don Cross
0d23d46f74 Implemented Python function BaryState. 2021-07-13 20:43:50 -04:00
Don Cross
0ee6b22279 C# BaryState implemented. 2021-07-12 22:23:14 -04:00
Don Cross
e2e21f5681 Ported AberrationTest from C to JS.
The aberration unit test that relies on barycentric
velocity calculation for the Earth's geocenter
has been ported from C to JS and shows identical results.
2021-07-11 20:41:27 -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
5de0979f7c C: successful validation of aberration correction.
I updated the C aberration unit test to use the barycentric
velocity of the Earth to adjust the apparent position of
a star. This brought the error compared to JPL Horizons
data down from 20.5+ arcseconds to less than 0.4 arcseconds.
Success!
2021-07-11 16:34:03 -04:00
Don Cross
d1ce2674fc C: Added GM constants for remaining planets. 2021-07-11 15:26:10 -04:00
Don Cross
8e9e0efd96 C BaryState: finished unit test.
Astronomy_BaryState() is working, with varying degrees
of accuracy for the different supported bodies.
2021-07-10 20:57:58 -04:00
Don Cross
22002ab9ce C BaryState: first version, test in progress.
Implemented the C function Astronomy_BaryState().
Used JPL Horizons to generate some test data.
Started work on the C unit test for BaryState,
but it is not yet finished. This is just a good
checkpoint for this work in progress.
2021-07-10 19:34:14 -04:00
Don Cross
b005bdef5a Starting to implement generalized aberration.
I realize some use cases require adjustments for
stellar aberration. The existing aberration adjustments
are only supplied for calculating planet positions.
Some users will benefit from being able to add/subtract
aberration corrections to arbitrary vectors, including
for star positions.

I have added some JPL Horizons test data to help
validate the aberration functionality I'm about to add.
I created the beginning of a unit test in ctest.c,
but currently there is no aberration correction
implemented, so the test has no error threshold.
2021-07-09 20:31:23 -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
6060a36b09 C#: Implemented VectorObserver. 2021-06-21 18:47:08 -04:00
Don Cross
90f5ea367e JS: Implemented VectorObserver. 2021-06-21 16:45:59 -04:00
Don Cross
7b543249b1 Implemented C version of VectorObserver. 2021-06-21 15:34:56 -04:00
Don Cross
72030c5bcf Python _inverse_terra uses Newton's Method.
Instead of the hack call to Search(), the latitude
solver now uses Newton's Method directly. This
significantly speeds up the code, and is more elegant.
2021-06-20 21:19:15 -04:00
Don Cross
829328a1d2 PY VectorObserver: stricter latitude tolerance.
Added more exhaustive testing of VectorObserver.
I found a few cases where the height calculation
was off by more than 5 millimeters.

In the VectorObserver function, require the latitude solver
to keep iterating until the error is less than one billionth
of a degree. Now the height error is always within 1 mm.
2021-06-20 12:04:21 -04:00
Don Cross
2aa26aba78 Python: implemented VectorObserver function.
I already had the function ObserverVector that converts geographic
coordinates (latitude, longitude, elevation) to an equatorial-of-date
(EQD) vector.

Now I'm in the process of adding the inverse function VectorObserver
that calculates geographic coordinates from an EQD vector.
This commit implements VectorObserver in Python.
The other languages will follow in future commits.

The motivation was from the following request:
https://github.com/cosinekitty/geocalc/issues/1
The goal is to find the near-intersection between two different lines
of sight from two different observers on the Earth's surface.
Added a demo program triangulate.py that solves this problem.
2021-06-20 10:57:12 -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
f8b449bbbe Ported GAL/EQJ conversion to C#.
The C# version of Astronomy Engine can create rotation
matrices to convert between equatorial J2000 (EQJ)
and galactic (GAL) orientations.
2021-06-08 21:59:36 -04:00
Don Cross
3e870d6a99 Updated Windows build for testing galactic coordinates. 2021-06-08 16:40:36 -04:00
Don Cross
63a196edb9 Updated instructions for JPL Horizons galactic data. 2021-06-07 21:04:16 -04:00
Don Cross
31e7511f89 C EQJ/GAL: test using JPL Horizons data.
I added this test, but unfortunately I could not figure
out how to make JPL Horizons generate equatorial and galactic
coordinates using the same aberration model. This appears
to introduce an extra 22 arcseconds of error.
2021-06-07 21:01:37 -04:00
Don Cross
21000df4db C: Verify GAL/EQJ rotation is inverse of EQJ/GAL.
Added a sanity check in the unit tests that the functions
Astronomy_Rotation_EQJ_GAL and Astronomy_Rotation_GAL_EQJ
return matrices that really are inverses of each other.
2021-06-06 22:00:07 -04:00
Don Cross
c46a316464 C functions for galactic coordinates.
Added the following C functions:

Astronomy_Rotation_EQJ_GAL
Astronomy_Rotation_GAL_EQJ

These return rotation matrices to convert between
the galactic and J2000 equatorial orientation systems.
2021-06-06 21:32:56 -04:00
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
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
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
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
d45bb771ac Python: Replaced LongitudeFromSun with more general PairLongitude. 2021-04-24 21:55:54 -04:00