Commit Graph

2227 Commits

Author SHA1 Message Date
Don Cross
020942f1a8 Resolve cppcheck warnings about const variables. 2024-05-30 13:39:19 -04:00
Don Cross
67dd5dc691 Attempt to make GitHub Actions run the same python I told it to install.
It looks like I have been running an unintended version of Python
from GitHub Actions.  In Linux/Mac I used `python3`, and in Windows
I used `py`. It appears that I should be executing `python` in
all 3 operating systems.

This is an experiment to see if I can get everyone on the same page.
2024-05-30 12:57:43 -04:00
Don Cross
fbec9c73c7 Total guess - upgrade Python to resolve sin/cos problems? 2024-05-30 11:00:32 -04:00
Don Cross
4153488d13 Removed obsolete entries from .gitignore 2024-05-28 16:26:17 -04:00
Don Cross
20a8459447 C: Resolve cppcheck warnings about const pointers. 2024-05-27 21:12:45 -04:00
Don Cross
d2b7621f66 No longer use pylint - mypy works better for my needs. 2024-05-27 18:43:49 -04:00
Don Cross
bba1c9ecf1 Upgrade unit tests to use Python 3.9 2024-05-27 18:31:13 -04:00
Don Cross
9c5f98981a Some versions of Python do not allow hypot to have more than 2 arguments. 2024-05-27 18:01:44 -04:00
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
1c6a11c03d Merge branch 'tostt-patch-1' 2024-05-26 16:43:58 -04:00
Don Cross
898276e130 Update copyrights, move AstroTime notes to correct file, copyediting. 2024-05-26 16:30:43 -04:00
tostt
64415eba28 Date usage in README.md
I propose to add some helpful information so users can easily create correct Date objects, as the JavaScript Date class can be confusing. This class contains a timestamp (the number of milliseconds since Jan 1st 1970 at midnight), which is timezone-agnostic, but the methods to interact with this number do involve timezones.
2024-05-26 09:40:09 +02:00
Don Cross
61dc07020a Version : official release to test #330. v2.1.19 2023-12-14 12:48:22 -05:00
Don Cross
63ee6f5f14 Merge pull request #330 from vpctorr/master
Fix npm warnings
2023-12-14 12:33:02 -05:00
Victor
f60fe9dae2 Update package.json 2023-12-14 14:01:50 +01:00
Don Cross
21330a781a Merge branch 'vpctorr-patch-1' v2.1.18 2023-12-13 16:03:00 -05:00
Don Cross
6d6d6adb69 Version 2.1.18: Accepted PR #329.
Include TypeScript type definitions in the exported files.
This might be a fix for #294, but I'm not sure.
The only real way to test is to publish on npm and see what happens!
2023-12-13 16:00:30 -05:00
Victor
1736b62525 Add types field to package.json exports – fixes ts(7016) 2023-12-13 20:09:45 +01:00
Don Cross
e9f2be3b16 Fixed documentation typos regarding ECT. 2023-11-10 12:25:52 -05:00
Don Cross
a4ebd60031 Oops. Fixed bad path in yml. 2023-10-27 16:41:12 -04:00
Don Cross
b7f7615ec0 Moved GitHub Actions script logic into generate/commit_hook. 2023-10-27 16:37:52 -04:00
dependabot[bot]
06659d1e54 Bump browserify-sign from 4.2.1 to 4.2.2 in /generate
Bumps [browserify-sign](https://github.com/crypto-browserify/browserify-sign) from 4.2.1 to 4.2.2.
- [Changelog](https://github.com/browserify/browserify-sign/blob/main/CHANGELOG.md)
- [Commits](https://github.com/crypto-browserify/browserify-sign/compare/v4.2.1...v4.2.2)

---
updated-dependencies:
- dependency-name: browserify-sign
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-27 15:32:15 +00:00
Don Cross
1d19e211c3 Fixed #323 - checks time pointers for NULL.
Prevents crashes due to dereferencing NULL time pointers.
Passing in NULL for a `time` pointer will no longer cause
a crash in an Astronomy Engine function.

Wherever possible, a NULL time pointer will result in a
status code `ASTRO_INVALID_PARAMETER`.

`Astronomy_Horizon` has no way to report a status code,
so a null pointer causes it to return all NAN values.
Perhaps it should return a status code (considering for separate commit).

Thanks to [Steven Booth](https://github.com/sbooth) for suggesting this!
2023-10-23 19:50:01 -04:00
Don Cross
04a575c153 Merge pull request #321 from cosinekitty/dependabot/npm_and_yarn/generate/babel/traverse-7.23.2
Bump @babel/traverse from 7.12.13 to 7.23.2 in /generate
2023-10-16 20:00:03 -04:00
dependabot[bot]
940d273e57 Bump @babel/traverse from 7.12.13 to 7.23.2 in /generate
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.12.13 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-16 23:11:32 +00:00
Don Cross
2915cd9118 Improved contributor source editing experience by improved code generator markers.
I suddenly realized today that I could eliminate lots of red wavy
lines in the source editor when working on generate/template/astronomy.*
files, by tweaking the $ASTRO_... tokens to look like comments.
For some reason, I didn't think of doing this before now.
I was motivated by the Go language support, where the tokens were
breaking `go fmt`.
2023-10-04 21:03:21 -04:00
Don Cross
520a532531 Test Python demos in Windows also.
Before now, the Python demos were tested in Linux and Mac.
Now they are tested in the Windows environment also.
This will be helpful for any contributors who may wish
to use Windows as a development platform for the Python
version of Astronomy Engine.
2023-10-03 13:41:05 -04:00
Don Cross
871c26abde Enforce strict type checking in all Python demo programs.
Use mypy to check all Python demo programs.
Updated the demos to pass type checking.
There were a couple of small mistakes found, so this was worth the effort.
2023-10-03 11:49:04 -04:00
Don Cross
bbaf5bf544 Added Python demo: solar_eclipse.py
This demo calculates the next 10 solar eclipses that are
visible from a given location on the Earth, after a given date.
2023-10-03 11:17:32 -04:00
Don Cross
c7095c5038 Added Python demo ecliptic_of_date.
The demo program ecliptic_of_date.py shows how to
calculate the true ecliptic of date (ECT) angular coordinates
of the Sun, Moon, and planets for an observer somewhere on the Earth.
It calculates the equatorial of date (EQD) coordinates, then uses
a rotation matrix to convert the vector to ECT, then converts
the vector to spherical coordinates: latitude, longitude, and distance.
2023-10-02 16:36:56 -04:00
Don Cross
3cf4065126 Minor C code style suggestion from cppcheck. 2023-09-21 17:42:53 -04:00
Don Cross
9975edc81b Updated star database to HYG v 3.6.1. 2023-09-21 15:41:03 -04:00
Don Cross
f4405e390c Updated star database to HYG v 3.5.1.
This change affects internal unit testing only.
It does not affect developers who use Astronomy Engine.
Upgraded the HYG database used for verification of
constellation calculations to v 3.5.1.

See conversation at:
https://github.com/astronexus/HYG-Database/issues/21
2023-09-19 15:08:49 -04:00
Don Cross
054985606e Revert "Use _FORTIFY_SOURCE=3 to improve C/C++ code verification."
This reverts commit a7e747c100.
This broke the GitHub Actions automated tests, because they
are using gcc 11 (which does not support level 3 fortification),
and they already predefine another fortification level.

I realize this would also hinder other contributors who
are not using gcc 12. At least I tried it once on my own
system and didn't find any problems, which is nice.
2023-09-11 15:02:14 -04:00
Don Cross
a7e747c100 Use _FORTIFY_SOURCE=3 to improve C/C++ code verification. 2023-09-11 14:48:44 -04:00
Don Cross
056076b85a Merge pull request #316 from KJ7LNW/master
Support microsecond time resolution
2023-08-28 15:20:08 -04:00
Don Cross
82b531d210 Merge branch 'master' into master 2023-08-28 15:19:25 -04:00
Don Cross
4c1c31cf56 Merge branch 'microsecond' 2023-08-28 15:12:44 -04:00
Don Cross
c247250df7 C Windows: use GetSystemTimePreciseAsFileTime.
It turns out that GetSystemTimeAsFileTime only returns
time with millisecond resolution.
In order to get microsecond resolution in Astronomy_CurrentTime(),
I had to switch to GetSystemTimePreciseAsFileTime for Windows.

Example output from unit test:

C Test_AstroTime: PASS - realtime increment = 3.143e-07 seconds after 1 iterations.
2023-08-28 14:32:43 -04:00
Don Cross
dd0245cbf8 C: Astronomy_GetCurrentTime supports microsecond resolution.
This is a follow-up to work provided by:
Eric Wheeler, KJ7LNW <astronomy-git@z.ewheeler.org>

Before now, the C function Astronomy_GetCurrentTime returned
the current time from the system clock, but only with whole
second resolution. Now it supports microsecond resolution on
Linux/Unix, Mac OS, and Windows.

For unsupported platforms, a compiler error will occur
to indicate that microsecond resolution is not available.
However, it is possible to define one of the following two
preprocessor symbols to work around the compiler error:

1. ASTRONOMY_ENGINE_NO_CURRENT_TIME
   Excludes the function Astronomy_CurrentTime from the build.
   If your project does not need to obtain the current time,
   or your hardware platform does not provide current date
   and time in the first place, this is likely the better option.

2. ASTRONOMY_ENGINE_WHOLE_SECOND
   If your project does need to use the current date and time
   for astronomy calculations, and it can tolerate whole
   second resolution, this option provides a version of
   Astronomy_CurrentTime that uses a call to `time(NULL)`.

Notes:

- Added unit test to confirm at least millisecond resolution.
  Because these tests have to run on GitHub Actions cloud platform,
  and those systems can be heavily CPU-loaded, I want to be tolerant
  of resolution and avoid false failures.

- Added detection of Mac platform.

- Added preprocessor options documented above.

- On Windows, use ULARGE_INTEGER and eliminated one integer division.

- Added comments and developer documentation.

- Converted tabs to spaces in astronomy.c, for consistent code format.
2023-08-28 12:24:20 -04:00
Eric Wheeler
25367e2f38 Support microsecond time resolution
This patch adds support for microsecond time resolution on the UNIX and
WIN32 platforms.

Implementation details:

Previously, the `Astronomy_CurrentTime()` function used `time(NULL)` to
get the current time, thus providing 1-second resolution.  This patch
uses `gettimeofday()` for UNIX and `GetSystemTimeAsFileTime()` for WIN32
platforms.  If neither are supported, it will fall back to `time()` and
issue a #warning.  (Note that windows.h defines ARRAYSIZE, which may or
may not be compatible.  Thus, the internal define `ARRAYSIZE` is renamed
to `ASTRO_ARRAYSIZE`.)

The UNIX code was tested in Linux, and in arm-eabi-none under newlib.
The WIN32 code was tested using MinGW/64 under WINE.

Use case:

One-second resolution is enough in most cases.  However, there are cases
where higher resolutions are desirable.  For example:

We are using the astronomy.c library to control a mechanical rotor to
track celestial objects (planets, stars, and satellites).  The rotor
controller uses a PID controller with 100 tick/sec updates, and tracks
the velocity of the azimuth and elevation angles from the previous tick.
With 1-second resolution, the PID controller jerks and oscillates once
per second as it adjusts to the new position.  With at least
10-millisecond resolution (100/sec), it can calculate the per-tick
velocity change and track smoothly with far less jitter.

More information about the project:
	Source using astronomy.c:
	    https://github.com/KJ7NLL/space-ham

	Lego-controlled az/el:
	    https://youtu.be/vrlw4QPKMRY

	Lego-controlled telescope focus:
	    https://youtu.be/p-5dOQG95xg

	APID+SMC control algorithm:
		https://doi.org/10.1016/j.precisioneng.2022.01.006

Signed-off-by: Eric Wheeler, KJ7LNW <astronomy-git@z.ewheeler.org>
Tested-by: Zeke Wheeler, KJ7NLL <kj7nll@gmail.com>
2023-08-27 19:14:33 -07:00
Eric Wheeler
311a0cca59 Support microsecond time resolution
This patch adds support for microsecond time resolution on the UNIX and
WIN32 platforms.

Implementation details:

Previously, the `Astronomy_CurrentTime()` function used `time(NULL)` to
get the current time, thus providing 1-second resolution.  This patch
uses `gettimeofday()` for UNIX and `GetSystemTimeAsFileTime()` for WIN32
platforms.  If neither are supported, it will fall back to `time()` and
issue a #warning.  (Note that windows.h defines ARRAYSIZE, which may or
may not be compatible.  Thus, the internal define `ARRAYSIZE` is renamed
to `ASTRO_ARRAYSIZE`.)

The UNIX code was tested in Linux, and in arm-eabi-none under newlib.
The WIN32 code was tested using MinGW/64 under WINE.

Use case:

One-second resolution is enough in most cases.  However, there are cases
where higher resolutions are desirable.  For example:

We are using the astronomy.c library to control a mechanical rotor to
track celestial objects (planets, stars, and satellites).  The rotor
controller uses a PID controller with 100 tick/sec updates, and tracks
the velocity of the azimuth and elevation angles from the previous tick.
With 1-second resolution, the PID controller jerks and oscillates once
per second as it adjusts to the new position.  With at least
10-millisecond resolution (100/sec), it can calculate the per-tick
velocity change and track smoothly with far less jitter.

More information about the project:
	Source using astronomy.c:
	    https://github.com/KJ7NLL/space-ham

	Lego-controlled az/el:
	    https://youtu.be/vrlw4QPKMRY

	Lego-controlled telescope focus:
	    https://youtu.be/p-5dOQG95xg

	APID+SMC control algorithm:
		https://doi.org/10.1016/j.precisioneng.2022.01.006

Signed-off-by: Eric Wheeler, KJ7LNW <astronomy-git@z.ewheeler.org>
Tested-by: Zeke Wheeler, KJ7NLL <kj7nll@gmail.com>
2023-08-27 18:22:58 -07:00
Don Cross
8dc66a8610 Fixed search failure in moon_north_south.js demo.
It was possible for certain starting times to have a search
failure in this demo, because it could place more than
one zero-crossing of the function in the same time interval.
So now we iterate over an interval of 10 days at a time
until we find the solution.
2023-08-23 13:55:35 -04:00
Don Cross
4007023422 Forgot to include JPL Horizons batch data.
I wanted to record the exact settings I used
to generate the JPL Horizons data used to verify
my calculations of the Moon's extreme declinations.
2023-08-22 21:33:07 -04:00
Don Cross
cea0158558 Added JS demo: moon_north_south.
This demo shows how to search for the next time
the Moon reaches extreme ecliptic latitude or
extreme declination. In other words, it finds
when the Moon reaches the farthest north or south,
expressed in either ecliptic coordinates or equatorial
coordinates.

Both angles are measured using the Earth's equator of date.
2023-08-22 21:30:40 -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
7cf1a7eb7d Minor tweaks for cppcheck. Use const pointers for grav sim.
Slightly different cppcheck dev 2.11 behaviors have added
another warning that I don't care about. I don't want to
have to convert callback pointers to const, then cast them
to const.

However, it did find a couple of useful cases I fixed in
astronomy.c where GravSim parameters could be made const.
2023-06-19 12:37:39 -04:00
Don Cross
bb27adfdfa Update C# demo/test projects to dotnet core 7. 2023-06-18 21:04:33 -04:00
Don Cross
fda8426972 Another attempt to build altazsearch.cpp on Mac OS. 2023-06-18 17:44:02 -04:00