Commit Graph

2227 Commits

Author SHA1 Message Date
Don Cross
890fcf8d3e Fix build problem for altazsearch.cpp on Mac.
The following build error occurred in Mac OS:

Compiling altazsearch.cpp
clang: error: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Werror,-Wdeprecated]

Added options to explicitly perform mixed C/C++ programming.
2023-06-18 17:05:07 -04:00
Don Cross
33de407723 Added C++ demo for alt/az window search.
See the following discussion for context:

https://github.com/cosinekitty/astronomy/discussions/308

Added a demo program that shows how to search for when
a body enters a window defined in terms of an observer's
horizontal frame of reference, given a range of altitudes
and a range of azimuths.
2023-06-18 16:14:52 -04:00
Don Cross
9495e4e45f Fixed warning in top2013.c: unnecessary variable assignment.
The newer version of cppcheck reported that I was assigning
a value to a variable that was never used before another
assignment occurred. Fixed this to eliminate the warning.
2023-06-16 21:19:17 -04:00
Don Cross
e3fc95a2fb Use fixed version of star data in Windows build. 2023-04-10 21:35:30 -04:00
Don Cross
04afcf6e91 Handle another update to hygdata_v3.csv.
The star database changed again, which causes my hash check
to fail. This time I locked on to the specific commit of the
file, so my build process won't break if it is changed again.
2023-04-10 19:56:14 -04:00
dependabot[bot]
37f7d9f4b3 Bump xml2js from 0.4.19 to 0.5.0 in /generate/hydrogen
Bumps [xml2js](https://github.com/Leonidas-from-XIV/node-xml2js) from 0.4.19 to 0.5.0.
- [Release notes](https://github.com/Leonidas-from-XIV/node-xml2js/releases)
- [Commits](https://github.com/Leonidas-from-XIV/node-xml2js/compare/0.4.19...0.5.0)

---
updated-dependencies:
- dependency-name: xml2js
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-10 21:54:38 +00:00
Don Cross
5faccc9920 cppcheck: verify more source files. 2023-03-26 06:59:27 -04:00
Don Cross
69311b3ccf Adjusted cppcheck options and fixed more warnings. 2023-03-26 06:47:09 -04:00
Don Cross
37a0c44c9b Fixed uninitialized struct in C tests. 2023-03-25 15:34:03 -04:00
Don Cross
501c19015b Run cppcheck. Fixed errors in C code found by cppcheck. 2023-03-25 14:46:42 -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
f424bc14b5 Fixed bug in camera.js demo: incorrect angle for sunlit side of Moon. 2023-03-24 22:00:45 -04:00
Don Cross
da900c6793 Fixed C# camera demo bug: incorrect sunlit angle of Moon. 2023-03-24 21:55:07 -04:00
Don Cross
591ad2b11a Fixed bug in demo: camera.c
The camera demos all have a bug where I was calculating
the angle of the sunlit side of the Moon incorrectly.
The arguments to atan2 were backwards.
Added test data for Florida, New Zealand, and Canada
that are backed up by photographic evidence and
my first-hand observation.
2023-03-24 21:46:41 -04:00
Don Cross
0bd0df2cfa Use updated version of star database.
The star database file hygdata_v3.csv has been updated.
Updated the expected checksum for it.

Reworked the downloader to check for checksum disagreement.
If checksum doesn't match, delete the file and download,
then try the checksum again.
This change will automatically fix obsolete files that have already
been downloaded on contributor's development systems.
2023-03-22 15:05:00 -04:00
Don Cross
d3a2596e4c Exclude Any type from Python documentation.
Now that we use Python type hints, I discovered that
Python 3.11.2 includes the placeholder type `Any`
in the metadata reflected by `importlib`.
In order to generate consistent documentation with
older versions of Python, I exclude `Any` if it is present.

This change affects only the documentation and has
no effect on the Astronomy Engine package itself.
2023-03-22 12:23:10 -04:00
Don Cross
bd2db6a380 Version 2.1.17: add metersAboveGround parameter to SearchRiseSet. v2.1.17 2023-03-13 21:40:01 -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
8c55fbad79 JS: Added metersAboveGround parameter to SearchRiseSet. 2023-03-13 13:06:37 -04:00
Don Cross
66cd0147b5 JS: Added Atmosphere function. 2023-03-13 09:54:54 -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
09016badda C#: use my own hypot function internally. 2023-03-12 12:16:24 -04:00
Don Cross
6c3a7ab753 C#: Atmosphere, metersAboveGround in SearchRiseSet. 2023-03-12 11:17:47 -04:00
Don Cross
7bb9d02053 C#: Atmosphere function. 2023-03-11 20:23:20 -05:00
Don Cross
cdd75c7810 C SearchRiseSetEx: moved metersAboveGround parameter to end.
Because I plan on adding metersAboveGround as a parameter
that defaults to 0.0 in the other languages, and I want
the language implementations to be reasonably consistent,
I moved the metersAboveGround parameter to the end of
the parameter list for the C version of SearchRiseSetEx.
2023-03-11 18:50:57 -05:00
Don Cross
9a0151d9d4 C: Added unit tests for Atmosphere function. 2023-03-06 14:15:30 -05:00
Don Cross
c275922c0e C: rise/set now corrects for height above ground.
I realized I had to rework the RiseSetEx function so that
it accepts a height above ground level, rather than a generic
altitude angle correction, because atmospheric effects are
important both for the horizon dip angle and for the amount
of refraction at ground level.

The atmosphere calculations were interesting enough that
I made them public as a new function Astronomy_Atmosphere.
This returns the idealized temperature, pressure, and relative
density of air at the given elevation above/below sea level.
2023-03-05 22:05:40 -05:00
Don Cross
cc7d9f5bc9 C: Implemented horizon dip calculation for observer above ground.
This is the first step toward calculating body rise/set times
for an observer that is significantly above the ground.
It figures out the angular correction of the horizon
using both parallax and refractive correction of a light
ray from the horizon to the observer's eye.
2023-03-05 13:56:26 -05:00
Don Cross
543ffa358a Version 2.1.16 v2.1.16 2023-02-26 18:02:18 -05:00
Don Cross
1de31cf21f C#: Implemented Observer.ToString(). 2023-02-26 17:08:07 -05:00
Don Cross
2fcaf27995 Python: verify several thousand calendar dates. 2023-02-26 13:17:21 -05: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
16727b85c8 C: force use of 64-bit integers in calendar functions.
The C functions for calculating calendar dates used the
type `long` to perform calculations that require 64-bit
integers. However, in some C compilers, `long` is still
32 bits. This caused a failure in Windows for extreme
year values. So I now use the type `int64_t` to explicitly
require a 64-bit integer.
2023-02-26 10:31:27 -05:00
Don Cross
7e196a3c17 Fixed Windows batch files ignoring negative integer failure codes.
In many of my Windows batch files, I used the following
construct to detect failures:

    do_something
    if errorlevel 1 (
        echo.An error occurred in do_something
        exit /b 1
    )

I discovered that it is possible for a Windows program
to exit with a negative integer error code.
This causes the above construct to miss the failure
and the batch file blithely continues.

So I have replaced that construct with

    do_something || (
        echo.An error occurred in do_something
        exit /b 1
    )

This way, if the command exits with any nonzero error,
we correctly detect it as a failure.
2023-02-26 10:26:42 -05: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
e7d48c6ea7 C#: Fixed bugs with calendar dates with extreme year values.
Fixed problems converting AstroTime to calendar dates and back.
Also expose struct CalendarDateTime to outside callers,
for convenience dealing with Gregorian calendar dates.
2023-02-25 20:23:41 -05:00
Don Cross
1ac4ab2dba C: Fixed more problems with calendar date calculations.
With more rigorous testing, I discovered more bugs
in the C functions for converting calendar dates
to times and vice versa.

Astronomy_UtcFromTime():
When the year went before -4714, the value of the variable
`djd` went negative, causing the typecast `(long)djd` to
round toward zero instead of taking the true floor.
Changed this to `(long)floor(djd)`.

Astronomy_MakeTime():
Reworked the logic so that none of the integer divisions
involve negative values over the year range -999999..+999999.
2023-02-25 18:18:42 -05:00
Don Cross
7e17705801 PY: Fixed calendar calculations for extreme year values. 2023-02-25 14:20:55 -05:00
Don Cross
f537974530 C: Fixed bugs in Astronomy_UtcFromTime for extreme year values.
Addressed limitations of the logic I copied from NOVAS cal_date().
Its formulas did not work for years much before -12000 due to
integer division going negative. I figured out how to make the
formulas work for plus or minus 1 million years from the present era.
2023-02-24 20:31:55 -05:00
Don Cross
88a94b860f C#: Convert times and vectors to/from strings.
Implemented and added tests for the following methods:

    AstroTime.TryParse()
    AstroVector.TryParse()

I still need to implement StateVector.TryParse().

Fixed a bug in CalendarDateTime: the NOVAS cal_date
function worked well, except when years go below
somewhere near -12000. Then the formulas start making
negative numbers, which messes up the calculation
of the month and day.

So to fix this, I figured out that any multiple of
400 years added to any calendar date gives the exact
same calendar date. And 400 years always has the exact
same number of days in it: 146097.

Because one million years = 400 * 2500 years, I can
add 2500*146097 days at the front of the formula
and subtract 1000000 years at the back, and everything
works for the entire range of years plus or minus
one million years from the present.

Because my date format allows for no more than a 6-digit
decimal year, this is perfectly adequate.
2023-02-24 19:49:12 -05:00
Don Cross
f3c211fadb C#: Added StateVector.ToString(). 2023-02-23 22:31:47 -05:00
Don Cross
410708e8b3 C#: Added AstroVector.ToString() function. 2023-02-23 22:06:12 -05:00
Don Cross
4ab4b0bb6e Fixed #259 - JS documentation is usable for CorrectLightTravel function.
Replace the abstract class with a parameter of function type.
This allows the documentation to fully explain how to use
`CorrectLightTravel` without having to look at the code.
2023-02-23 18:01:51 -05:00
Don Cross
d321ed695c Version 2.1.15: Python type hints. v2.1.15 2023-02-21 17:24:25 -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
8963ef9b1a Python docs: show arrow character instead of -> for return types. 2023-02-21 14:19:44 -05:00
Don Cross
102e7e7dc7 Python docs: better formatting of type hints in function signatures. 2023-02-21 14:07:55 -05:00