Commit Graph

175 Commits

Author SHA1 Message Date
Don Cross
63ed3746b2 Misc fixes for Raspberry Pi 4 build.
On the Raspberry Pi 4, using latest versions of cppcheck
and pylint, a few more minor fixes were needed for eliminating
warnings.

Also had to soften a tolerance for the Kotlin unit tests.
2023-06-19 16:28:34 -04:00
Don Cross
9ab7767a57 Document camera demos and include image to explain the angles. 2023-03-25 11:40:02 -04:00
Don Cross
0be053325a Fixed bug in camera.py demo: incorrect angle for sunlit side of Moon. 2023-03-24 22:06:45 -04:00
Don Cross
c85881c25b Python: added metersAboveGround parameter to SearchRiseSet. 2023-03-13 20:42:46 -04:00
Don Cross
6c59d14bd4 Python: added Atmosphere function. 2023-03-13 16:16:53 -04:00
Don Cross
503538da12 PY: Fixed calendar/time conversion functions for extreme year values.
Applying the same recent fixes to C and C# to the Python code.

I'm also changing my philosophy of representing times.
From now on, they will be truncated to the floor millisecond,
not rounded to the nearest millisecond. This means we don't reach
another calendar date until we have had 60 full seconds after
the last minute. Otherwise there is too much nasty logic for
rounding up calendar dates. I will follow suit across all languages.
2023-02-25 22:37:58 -05:00
Don Cross
7e17705801 PY: Fixed calendar calculations for extreme year values. 2023-02-25 14:20:55 -05:00
Don Cross
b686b6185c Escalated mypy to use --strict option.
Use --strict in mypy to perform maximum type checking.
Fixed the remaining errors.
2023-02-21 15:34:52 -05:00
Don Cross
513d1f0f17 Python: reordered things to reduce forward type declarations. 2023-02-21 13:17:43 -05:00
Don Cross
cd8f9e9f4c Improved Python table for Jupiter moon models.
Updated the code generator so the Python version of
the Jupiter moon tables has better type checking
and is easier to understand.
2023-02-21 12:17:35 -05:00
Don Cross
23b45dd075 Improved Pluto state table in Python code.
The generated code for the Pluto state table in Python
now uses a class `_pstate` for better type checking.
It also makes the code easier to understand.
Moved class _TerseVector higher in the source file to
reduce the need for quoted forward type declarations.
2023-02-21 10:56:05 -05:00
Don Cross
a530069e99 Improved Python VSOP table generation.
The VSOP table generator for Python now is now
better type-checked using classes and tuples.
This also makes the code easier to understand.
2023-02-21 10:12:45 -05:00
Don Cross
f849c11258 Require type hints for all Python functions.
I added the mypy option `--disallow-untyped-defs` to fail
any function lacking complete type hints.
Then I fixed all the resulting errors.

I ended up changing the Python code generator to create
some tuple types instead of list, because it is possible
to write stricter type checks that way. This was in
the Pluto and Jupiter Moon tables.
I still should come back and do the same thing for the VSOP tables.

The type checking revealed a couple of places where I wasn't
checking for a search failure. I fixed those too.
2023-02-20 20:04:10 -05:00
ris-tlp
66c3ebbc33 Fix PR reviews 2023-02-18 15:45:06 -05:00
ris-tlp
43be952eb2 Python: Type Hints Integration - 6 2023-02-18 03:58:01 -05:00
ris-tlp
e7f8f2b8e2 Python: Type Hints Integration - 5 2023-02-18 03:26:35 -05:00
ris-tlp
0d4c438c2b Python: Type Hints Integration - 4 2023-02-18 02:46:04 -05:00
ris-tlp
d055cb9fe8 Python: Type Hints Integration - 3 2023-02-16 01:12:09 -05:00
ris-tlp
92d266fc3a Python: Type Hints Integration - 2 2023-02-15 02:07:43 -05:00
ris-tlp
6bb781146b Python: Type Hints Integration - 1 2023-02-13 22:56:10 -05:00
Don Cross
d73d271a4f Fixed pydown to understand imported symbols.
In order to import typing.Union into the module namespace,
I had to fix pydown to recognize Union as a defined symbol.
2023-02-13 13:19:13 -05:00
ris-tlp
4ea28c6d88 Python: Few typehints for initial review 2023-02-13 02:11:37 -05:00
Don Cross
42c352f918 PY: true solar time demo 2023-02-12 16:28:37 -05:00
Don Cross
9e98d0fb17 PY: Implemented HourAngle function. 2023-02-12 16:20:33 -05:00
Don Cross
341a4bbaec Fixed overly general exception in Python code.
Pylint discovered that I was raising Exception,
which was overly general. I didn't mean to do that;
it was supposed to be my custom exception type
astronomy.Error instead. So I fixed that case.

There were also some deprecated settings in the
pylint configuration file, so I fixed those too.
2023-02-07 14:27:06 -05:00
Don Cross
4256903060 Fixed #280 - corrected typo in documentation. 2023-01-23 17:50:13 -05:00
Don Cross
62192357ba Updated copyrights for 2023.
Windows build process now updates copyright
years just like the Linux build process does.
Ran it to update the copyright years for 2023.
2023-01-07 17:13:07 -05:00
Don Cross
1a4f842764 Updated Ecliptic to return ECL in all languages. 2022-12-10 19:35:42 -05:00
Don Cross
f959599497 Completed EQJ/ECT, ECT/EQJ rotations. 2022-12-09 13:12:42 -05:00
Don Cross
281180db24 Use consistent descriptions of EQJ, ECL.
Use consistent wording for these two orientation systems:
EQJ = J2000 mean equator
ECL = J2000 mean ecliptic
2022-12-08 16:16:41 -05:00
Don Cross
2dd4fc1ab4 Python: rotations for ECT/EQD. 2022-12-07 13:03:38 -05:00
Don Cross
552c7a5557 EclipticGeoMoon uses true equinox of date in all languages.
Added EclipticGeoMoon as output to the temp/*_check.txt files as 'm' lines.
This ensures that all the languages calculate nearly identical values.

Optimized EclipticGeoMoon a little more by eliminating a redundant
call to mean_obliq.
2022-12-05 21:44:35 -05:00
Don Cross
b9738d9661 C: Unrolled the truncated IAU2000B formula. 2022-12-04 20:56:15 -05:00
Don Cross
8a153315cf Simplified and optimized nutation formula.
While trying to convert ecliptic coordinates from mean
equinox of date to true equinox of date, I ran into excessive
overhead from the IAU2000B nutation model. The fact that it
uses 77 trigonometric terms made the calculations a lot slower.

https://apps.dtic.mil/sti/pdfs/AD1112517.pdf
Page 4 in the above document mentions a shorter series
“NOD version 2” that has 13 terms instead of 77 as used in IAU2000B.
I had not noticed NOD2 before, because it appears only in
the FORTRAN version of NOVAS 3.x, not the C version.

After reading the FORTRAN code, I realized NOD2 is the same
as IAU2000B, only it keeps the first 13 of 77 terms.
The terms are already arranged in descending order of
significance, so it is easy to truncate the series.

Based on this discovery, I realized I could achieve all of
the required accuracy needed for Astronomy Engine by
keeping only the first 5 terms of the nutation series.
This tremendously speeds up nutation calculations while
sacrificing only a couple of arcseconds of accuracy.

It also makes the minified JavaScript code smaller:
Before: 119500 bytes.
After:  116653 bytes.

So that's what I did here. Most of the work was updating
unit tests for accepting slightly different calculation
results.

The nutation formula change did trigger detection of a
lurking bug in the inverse_terra functions, which convert
a geocentric vector into latitude, longitude, and elevation
(i.e. an Observer object). The Newton's Method loop in
this function was not always converging, resulting in
an infinite loop. I fixed that by increasing the
convergence threshold and throwing an exception
if the loop iterates more than 10 times.

I also fixed a couple of bugs in the `demotest` scripts.
2022-12-04 10:31:15 -05:00
Don Cross
53b735a941 Fixed misspelled "ecliptic" in documentation. 2022-11-28 11:57:36 -05:00
Don Cross
5087e4df28 More documentation fixes for rise/set, altitude. 2022-11-27 13:56:51 -05:00
Don Cross
e12d2e88c6 Updated docs: SearchRiseSet, SearchAltitude.
The documentation for SearchRiseSet and SearchAltitude needed
clarification about refraction and the part of the body solved
for (center versus limb). The JavaScript version was especially
lacking compared to documentation for the other languages.

Also documented SearchAltitude's limitations; it does not
work at or near maximum/minimum altitude.

Mention that user-defined stars are allowed for
SearchRiseSet, SearchAltitude, and SearchHourAngle.

Fixed a couple places where the Kotlin documentation had
broken links to other functions.
2022-11-27 12:42:48 -05:00
Don Cross
1725c77c9f Fixed doc typos. JS HelioState user-defined stars.
I had a copy-n-paste typo in the `dec` parameters
for all of the DefineStar functions. Fixed it.

The TypeScript version of HelioState did not handle
user-defined stars. Added support there.
2022-11-23 12:01:34 -05:00
Don Cross
098eb3ac7a Optimized HelioDistance for user-defined stars.
Because we instantly know the heliocentric
distance of a user-defined star, there is no
need to convert it into a vector and then take
the length of the vector.
All of the HelioDistance functions now return
the distance directly, as an optimization.

Also, I decided it didn't make sense to have a
default definition for user-defined stars.
If the caller doesn't define a star, it should
be treated as an invalid body.
2022-11-23 11:16:56 -05:00
Don Cross
79f6eac8eb HelioState functions support user-defined stars. 2022-11-23 09:21:56 -05:00
Don Cross
7b7a306baf Python: Find rise/set/culm of user-defined stars.
Added Python support for user-defined stars.
Defined new StateVector methods: Position and Velocity.
Defined division operator: Vector / float.
Bumped version number to 2.1.12.
2022-11-22 21:42:02 -05:00
Don Cross
351e997a2f Merge branch 'riseset_poles'
Fixed issues with finding rise/set events near the
Earth's poles. Avoid assumptions that rise/set is
tied to hour angles.
2022-11-14 12:05:20 -05:00
Don Cross
d9d955a651 Altitude search: better parameter checking.
Made sure all the altitude search functions
verify that the geographic latitude and target altitude
are valid numbers in the range [-90, +90].

Reworked the C version of the code to be clearer:
eliminated goofy ALTDIFF macro, split out max
altitude derivative into its own function MaxAltitudeSlope,
just like the other language implementations do.

Minor rewording of comments in MaxAltitudeSlope functions.

Python InvalidBodyError now includes the invalid body
in the diagnostic message.
2022-11-14 11:04:46 -05:00
Don Cross
1b52e91394 Python: overhauled altitude search 2022-11-13 22:17:06 -05:00
Don Cross
4602f619d3 C: Rise/set that works near the poles!
This is a whole new algorithm that efficiently finds
all rise/set events, even near the poles.
It uses a recursive bisection search that limits
recursion depth by knowing the maximum possible
|da/dt| = change in altitude with respect to time.
2022-11-12 21:40:20 -05:00
Don Cross
5eca7d7760 CodeQL tweaks and fixes.
Updated CodeQL config to ignore source templates,
because they are not syntactically valid source code.
Ignore other stuff that is irrelevant to published
code quality.

Made various fixes based on helpful CodeQL analysis.
2022-11-07 15:31:05 -05:00
Don Cross
23fd95a53f PY: Added PlanetOrbitalPeriod function. 2022-11-01 17:30:48 -04:00
Don Cross
393f134c49 PY: solar eclipse obscuration
Also fixed missing improvements to C# PlanetShadow().
2022-10-20 12:32:11 -04:00
Don Cross
a90edfed0d PY: lunar eclipse obscuration 2022-10-19 20:44:22 -04:00
Don Cross
1e95f0656b C, C#, Python: Support formatting calendar years -999999 to +999999. 2022-10-06 16:28:55 -04:00