Commit Graph

166 Commits

Author SHA1 Message Date
Don Cross
7c475fcada Expanded the fix for issue #347.
I tried more distant objects like Jupiter ... Neptune.
This revealed that at increasing distances, the convergence
threshold in inverse_terra needed to increased also.
So now I use 1 AU as a baseline, and scale up linearly
for more distant objects.
2024-05-27 17:07:30 -04:00
Don Cross
0309762a64 Fixed #347 - Relaxed convergence criteria for inverse_terra functions.
Asking the latitude and longitude directly beneath
the Sun causes inverse_terra not to converge, because the
convergence increment `W` never got below 1.48e-8, but the
convergence limit was 1.0e-8. I increased the limit to 2.0e-8
in all programming language versions.

I'm hoping that is a big enough tolerance for all cases now,
but I will do more testing to see if further fixes are required
for even more distant bodies than the Sun.
2024-05-27 16:20:45 -04:00
Don Cross
898276e130 Update copyrights, move AstroTime notes to correct file, copyediting. 2024-05-26 16:30:43 -04:00
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
5e2292dfa6 Kotlin: added metersAboveGround parameter to searchRiseSet. 2023-03-12 22:10:50 -04:00
Don Cross
de8521fa49 Kotlin: atmosphere function. 2023-03-12 14:34:14 -04:00
Don Cross
ce0acf6d44 Kotlin: support calendar dates for years -999999 to +999999.
Enhanced the Time class to correctly calculate calendar
dates for the year range -999999 to +999999.

Made unit tests in C, C#, and Kotlin all exercise
the full year range, for February 28 and March 1 in each year,
to make sure we cover before and after each potential leap day.
2023-02-26 12:54:57 -05:00
Don Cross
632d059972 Kotlin: implemented hourAngle function. 2023-02-12 18:13:36 -05:00
Don Cross
8bf48d0681 Slight relaxation of test tolerances.
Contributor @ris-tip ran into erroneous test failures
due to tiny floating point calculation differences.
I'm adjusting the thresholds slightly so his tests will pass.
2023-02-09 08:37:39 -05:00
Don Cross
667dcf5c9c Fixed #285 - added missing time parameter to docs.
The documentation was missing a mention of
the `time` parameter in the following TypeScript
functions:

* `Rotation_ECT_EQD`
* `Rotation_EQD_ECT`

Likewise, the `time` parameter was not documented in
the corresponding Kotlin functions:

* `rotationEctEqd`
* `rotationEqdEct`

These mistakes have been corrected.
2023-01-28 12:33:12 -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
1d57802470 Kotlin: implemented EQD/ECT rotations. 2022-12-06 21:12:31 -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
576eea2245 Unrolled loops from remaining nutation functions. 2022-12-04 21:30:22 -05:00
Don Cross
d3f36b942d Verify nutation angles are consistent across languages. 2022-12-04 14:20:44 -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
84621b4d33 Enable truncation of the IAU2000B nutation model.
Modified the code generator and source templates to allow
using fewer than 77 terms from the IAU2000B nutation model.
The number of terms causes calculations to be far slower than
I would  like, plus most of these terms provide far less than
one arcsecond of difference in the output.

I want to experiment with truncated versions of the series.

https://apps.dtic.mil/sti/pdfs/AD1112517.pdf
Page 4 in the above document references a shorter series
"NOD version 2" that has only 13 terms instead of 77 as used in IAU2000B.
I found that code and confirmed the 13 terms are the first 13
consecutive terms from the original 77.

This commit does not change the number of terms calculated;
it only enables doing so by changing a single #define in
generate/codegen.c.

Once I change the nutation model, I'm sure there will be multiple
tweaks to unit tests to get everything working again.
2022-12-03 21:29:59 -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
fe625c5956 Kotlin: added support for user-defined stars. 2022-11-22 19:29:15 -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
e31be80497 Kotlin: reworked rise/set to work in polar regions 2022-11-13 19:25:44 -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
275e3a7c79 Kotlin: added function planetOrbitalPeriod. 2022-11-01 19:16:32 -04:00
Don Cross
6f25a3db85 Astronomy Engine v2.1.7: eclipse obscuration
This is my second attempt to release eclipse obscuration.
I discovered there was a missing unit test for obscuration
for lunar eclipses in the Kotlin library. It has been added.
2022-10-20 19:13:47 -04:00
Don Cross
06b62887d2 Kotlin: obscuration for solar, lunar eclipses. 2022-10-20 17:31:21 -04:00
Don Cross
fde4c2c068 Kotlin: format dates for extreme year values. 2022-10-06 17:52:29 -04:00
Don Cross
dc59b55d92 Added more testing of rise/set foreward/backward searches. 2022-10-02 19:58:48 -04:00
Don Cross
6e2229603c Fixed wording, variable names in unit tests. 2022-10-02 12:33:20 -04:00
Don Cross
a3337348f5 Kotlin: better forward/reverse moon phase tests.
In the unit tests for searching forward and backward
for moon phases, in addition to new moons, also test
first quarter, full moon, and third quarter.

Verify that forward and backward searches work for
100 start times between a single pair of consecutive events.
2022-10-02 10:49:36 -04:00
Don Cross
b91b1d905f Python: Reverse chrono search for rise/set, hour angles.
The following Python functions now support searching
in forward or reverse chronological order:

    SearchRiseSet
    SearchAltitude
    SearchHourAngle

Made some minor performance improvements to the
other implementations: return sooner if we
go past time window.
2022-10-01 21:44:04 -04:00
Don Cross
c1759b081a Kotlin: Reverse chrono search for rise/set, hour angles.
The following Kotlin functions now support searching
in forward or reverse chronological order:

    searchRiseSet
    searchAltitude
    searchHourAngle
2022-10-01 11:26:03 -04:00
Don Cross
53b4b33958 Kotlin searchMoonPhase: allow searching backward in time.
Enhanced the Kotlin function searchMoonPhase
to allow searching forward in time when the `limitDays`
argument is positive, or backward in time when `limitDays`
is negative.

Added unit test "moon_reverse" to verify this new feature.
2022-09-26 22:07:47 -04:00
Don Cross
afd6f4835f Kotlin: reworked VSOP model selector as a function. 2022-09-10 16:20:03 -04:00
Ebrahim Byagowi
8ed7de7923 Resolve cyclic dependency of Body.vsopModel
Definition of vsopModel constant on Body enum items constructors
makes cyclic dependency with constants defined later in the code
and makes application crash when things are not initiated in the
correct order.

This fixes the issue by turning vsopModel into a property which
will have almost the same internal API for the rest of the code
and resolves crashes I'm getting when certain part of my app
is initiated sooner than usual.
2022-09-10 14:31:40 +04:30
Don Cross
b7979cb7a0 Light travel correction: improved documentation. 2022-06-01 19:25:48 -04:00
Don Cross
5e7162f08d GeoVector must return observation time.
Fixed 3 of the language implementations where I forgot
to make GeoVector return the observation time, not the
backdated time. This is important to preserve existing
behavior.
2022-05-31 21:26:03 -04:00
Don Cross
409451b3c2 Kotlin: light travel time correction. 2022-05-31 20:52:41 -04:00
Don Cross
f02658d63c More documentation fixes.
Corrected a mistake in the explanation of the
C function Astronomy_GravSimInit: the `bodyStates`
parameter is NOT barycentric -- it is relative to the
originBody parameter.

Python had improperly formatted documentation for
Time.FromTerrestrialTime parameter `tt`.

The Python markdown generator `pydown` did not
correctly handle links to compound symbols like
`#GravitySimulator.Update`. It also was trying
to link to `StateVector[]` instead of `StateVector`.

Removed unnecessary and unhelpful documentation
for C# internal class constructors. They do not appear
in the generated markdown documentation anyway.

Other minor wording revisions in the documentation.
2022-05-25 14:12:55 -04:00
Don Cross
4303137c0a PY gravsim: initial coding completed
Finished coding the Python version of the gravity simulator.
No unit tests have been written yet.
Cleaned up documentation in the other languages.
Made some functions static that did not need to be members.
2022-05-22 09:41:44 -04:00
Don Cross
26575066fc JS gravsim: work in progress.
Mostly coded, but unit tests not written yet.
2022-05-18 19:52:11 -04:00
Don Cross
f014d13910 C# gravsim: finished implementation.
Unit tests are complete and verified for the C# gravity simulator.
I found and fixed one bug in the GravitySimulator constructor.
2022-05-17 17:20:30 -04:00