Commit Graph

333 Commits

Author SHA1 Message Date
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
8fa81d0fbc Fixed botched commit: didn't update Kotlin docs. 2022-11-14 13:40:10 -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
5e074d05aa Bumped version number to 2.1.10.
Not ready to tag yet, because I need to merge into
master branch first, to pick up the npm package
configuration change.
2022-11-14 08:15:23 -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
3679966931 Version 2.1.9: attempt fix for Deno/Node type info.
Updated the version number so I can create a new
npm package to test the pull request from @matheo
that should allow TypeScript types to be exported correctly.
2022-11-08 20:59:17 -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
c8af73e1e7 Fixed #256 - added orbital period functions. 2022-11-01 19:40:30 -04:00
Don Cross
23fd95a53f PY: Added PlanetOrbitalPeriod function. 2022-11-01 17:30:48 -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
232da2c319 Astronomy Engine 2.1.6: eclipse obscuration 2022-10-20 18:34:27 -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
a9eadee3f1 Fixed #250 - handle years outside 0000..9999. 2022-10-06 22:05:44 -04:00
Don Cross
1e95f0656b C, C#, Python: Support formatting calendar years -999999 to +999999. 2022-10-06 16:28:55 -04:00
Don Cross
409e490728 Python: No longer limited to years 0000..9999.
I ported the NOVAS C 3.1 functions julian_date and cal_date to Python,
and removed the dependence on the standard datetime class for calculating UT.
Now we can create Time objects for a much wider range of year values.

Simplified the julian_date formula in C and C#.

In the Python version, I had to account for a difference
in the way integer division works for negative numbers.
In Python, integer division always rounds down, not toward
zero like it does in C/C#. So I reworked the formulas to
avoid dividing a negative integer (month-14), dividing the
positive quantity (14-month) instead and toggling addition
of the term with subtraction of the term.

I use the reworked (14-month) version in C and C# for consistency.
Also, the formatting of the formula was wacky and didn't make sense,
so now it easier to read and understand.

The Python regex for parsing dates has been expanded to allow
years before 0 and after 9999.
Allow converting Python Time to string for years before 0 and after 9999.
2022-10-06 10:56:17 -04:00
Don Cross
4a56f18325 Astronomy Engine version 2.1.4 2022-10-02 22:07:23 -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
207b8e7f65 Removed incorrect comment in Python code. 2022-09-28 10:12:28 -04:00
Don Cross
3bed4a9bdc PY SearchMoonPhase: allow searching backward in time.
Enhanced the Python 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 21:08:37 -04:00
Don Cross
d21ce79976 Updated version number to 2.1.3. 2022-09-22 10:25:47 -04:00
Don Cross
e9cf2a0417 Python: changed true to True in documentation.
There were two places in the Python documentation
where I wrote `true` instead of `True` for the
boolean literal. These have been fixed.
2022-09-10 19:13:53 -04:00
Don Cross
f187bc3e22 Fixed mistake in Python enum for not correcting refraction.
GitHub user `hidp123` submitted the following pull request:
https://github.com/cosinekitty/astronomy/pull/240

The problem was I had documentation for the Python enum
`Refraction` where I incorrectly wrote `Refraction.None`
instead of the correct name `Refraction.Airless`.

The fix in the pull request was correct, but it was
applied to generated source code, so it did not correctly
update the template file or the online documentation.

This commit fixes the mistake in all the affected files.
2022-09-07 18:39:31 -04:00
Don Cross
e187707412 Patch version numbers using a Python program.
It turns out that "sed" does not work on Mac OS,
and I wasn't even trying to patch the version
numbers on Windows. I decided to write a Python
program for this task, so it will work identically
on all 3 operating systems.
2022-06-05 15:03:02 -04:00
Don Cross
1e9f1a7b05 Automatically patch version number.
Added a new file generate/version.txt that contains
the current Astronomy Engine version number.
Now when I run the build/test process, the version
number is patched in all the places it needs to
be changed to keep all the packages and documentation
up to date.

This means when I want to change the Astronomy Engine
version number, I just need to edit version.txt, then
execute the generate/run script.
2022-06-05 14:07:32 -04:00
Don Cross
2a1abad0d5 Better use of package badges/links.
Provide shield.io badges for pypi, npm, and nuget packages.
On the main README page, moved the badges into the supported
languages grid.
Added link and badge on each language documentation page.
2022-06-05 12:42:00 -04:00
Don Cross
476fb794c4 Fixed #217 - generic light travel correction.
Bumped version to 2.1.2.
2022-06-01 20:21:19 -04:00
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
9afbf0a67f Python: generalized light-travel correction. 2022-05-30 21:37:19 -04:00
Don Cross
b4f485eecc Bumped version to 2.1.1. 2022-05-25 21:37:10 -04:00
Don Cross
137fc5ce7b Python docs: better formatting of return values. 2022-05-25 17:23: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
9c65a27eb1 Improved documentation for gravity simulator.
Added mention of the gravity simulator in the topic
index sections of the markdown docs.
Slight wording changes here and there.
2022-05-23 21:54:00 -04:00
Don Cross
d28f5ecff3 PY gravsim: passes unit tests
The Python version of the GravitySimulator class
is now passing all unit tests. This completes
the initial coding. I still need to review
documentation across all the language implementations.
2022-05-22 21:16:58 -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
68f118587d PY gravim: work in progress.
Started implementation of the Python gravity simulator.
Updated the `pydown` markdown generator to include
class constructors `__init__` when they contain docstrings.
2022-05-21 23:23:29 -04:00
Don Cross
66eeb3e0a0 Python: Jupiter's moons returned by name
It makes more sense to report Jupiter's moons with
individually named structure fields rather than an array.
It reduces the overall code and documentation size,
and outside of unit testing, there are few cases
where iterating over an array of moons is more
lucid than using the names of the moons.

This is a breaking change, but hopefully very few
developers are using this function yet.
Fixing the breakage is very simple.

Also added operator overloads for adding and
subtracting StateVector, just like we already had
for Vector.
2022-05-05 12:39:39 -04:00
Don Cross
b93719146b Set version numbers to 2.1.0.
In anticipation of releasing the Kotlin version,
I set the version numbers for the following to 2.1.0:

    Kotlin
    Node.js / npm
    Python / pip

The intention is to keep matching releases of
Astronomy Engine at a common version number.
2022-04-26 15:58:27 -04:00
Don Cross
3ce32f8819 Kotlin: lunar libration. Fixes for other languages.
The existing lunar libration functions in the
other languages (C, C#, Python, JavaScript) were
calculating the Moon's ecliptic latitude and longitude
in radians, not degrees as intended. They have been fixed.

Implemented the libration function for Kotlin.
2022-04-22 16:36:14 -04:00
Don Cross
0d24433db3 Fixed #187 - Seasons() failed for distant years.
For years before 1582 or years after 3668, the Seasons functions
were unable to find many equinoxes and/or solstices.
The problem was that over time, the Earth's axis precesses
enough that the calendar dates of these events drifts outside
the fixed search ranges I had provided for them.

I expanded the search ranges so all season changes can be found
for a much wider range of years, as verified by unit tests:

    C/C++:      -2000..9999
    C#:             1..9999
    JavaScript: -2000..9999
    Python:         1..9999
    Kotlin:         1..9999

Note: C#, Python, and Kotlin currently do not allow
years values below +1. In fact, I discovered we were not
noticing when an invalid year was passed into the Kotlin code.
I updated that code to throw an exception when the year does
not match what was expected. It is disturbing that the
GregorianCalendar class silently ignores invalid years!

Constricted the search tolerance from 1 second to 0.01
seconds for the seasons search, to ensure more consistent
behavior.

Fixed a bug in the Kotlin search() function's
quadratic interpolation that was causing the convergence
to be slower than it should have been.
2022-04-08 16:51:09 -04:00
Don Cross
d7e86fae52 C#: Search cleanup, add InternalError exception.
Added an InternalError class to explicitly indicate
that an exception occurs due to an internal assertion
failure inside Astronomy Engine. Any InternalError
should be considered a bug in Astronomy Engine, not
a bug in calling code.

Upon reviewing the code for searching moon phases,
I discovered that there was inconsistent behavior
in SearchMoonPhase. It was sometimes returning null,
other times throwing an exception. Because the caller
passes in `limitDays`, it makes sense to simply
return `null` in any case where the search fails.
This is to support callers that intentionally want
to find whether or not a moon phase occurs in a given
small window of time.

Updated internal callers of SearchMoonPhase to throw
an InternalError when they know they should always
find an event.

Internal function FindSeasonChange did not check to
make sure SearchSunLongitude succeeded. There is no
known case where this failure happens, but if it did,
a null AstroTime would have been stored in SeasonsInfo.
It is better to fail early with an explicit InternalError.

Other miscellaneous C# code cleanup.

In the Python code, I found a couple of `raise Error`
that needed to be changed to `raise InternalError`.
2022-04-05 12:30:13 -04:00