Compare commits

..

6 Commits

Author SHA1 Message Date
Dianne Skoll
f2d1a21a4e Update docs. 2025-03-20 15:40:33 -04:00
Dianne Skoll
81a5241097 Add tests for soleq. 2025-03-20 11:53:11 -04:00
Dianne Skoll
eced4de4a2 Explicitly supply date. 2025-03-20 11:45:11 -04:00
Dianne Skoll
2c8fa39af0 Add tests for astronomical functions. 2025-03-20 11:38:18 -04:00
Dianne Skoll
6ac5e96260 Fix logic bug in astro. 2025-03-20 10:20:08 -04:00
Dianne Skoll
deda94a69e Comment and code cleanups. 2025-03-19 18:08:28 -04:00
7 changed files with 107 additions and 23 deletions

View File

@@ -10,6 +10,8 @@ CHANGES TO REMIND
- CODE CLEANUPS: remind: Some minor code cleanups with no user-visible effects.
- IMPROVEMENT: Add tests for the astronomical calculation functions.
- BUG FIX: remind: The %2 and %@ sequences would print "0:34am" for the
time 00:34, instead of the correct "12:34am". This has been fixed.

View File

@@ -33,7 +33,7 @@ EOF
remind -g "-i\$Latitude=\"$latitude\"" "-i\$Longitude=\"$longitude\"" -q -@2 - "$@" <<'EOF'
SET $AddBlankLines 0
FSET angle_to_direction(x) \
IIF(x > 348 && x <= 11, "North", \
IIF(x > 348 || x <= 11, "North", \
x > 11 && x <= 34, "North North-East", \
x > 34 && x <= 56, "North-East", \
x > 56 && x <= 79, "East North-East", \

View File

@@ -525,7 +525,7 @@ void HuntPhase(int startdate, int starttim, int phas, int *date, int *time)
/* Convert from Remind representation to year/mon/day */
FromDSE(utcd, &y, &m, &d);
/* Convert to a true Julian date */
jdorig = jtime(y, m, d, (utct / 60), (utct % 60), 0);
jdorig = jtime(y, m, d, (utct / 60), (utct % 60), 0);
jd = jdorig - 45.0;
nt1 = meanphase(jd, 0.0, &k1);
while(1) {
@@ -563,10 +563,11 @@ void HuntPhase(int startdate, int starttim, int phas, int *date, int *time)
Redistributions of this source code must retain this copyright notice.
*/
/* How many hours to search for moonrise / moonset on either side of
starting point */
/* How many hours to search for moonrise / moonset? We search
half a window on either side of the starting point */
#define MR_WINDOW 48
/* K1 tide cycle is 1.0027379 cycles per solar day */
#define K1 15*(PI/180)*1.0027379
#define remainder(x, y) ((x) - (y) * rint((x)/(y)))
@@ -735,7 +736,7 @@ static void test_moon_event(int k, double offset_days, struct MoonInfo *moon_inf
double lSideTime;
/* Get (local_sidereal_time - MR_WINDOW / 2) hours in radians. */
lSideTime = local_sidereal_time(offset_days, longitude) * 2 * PI / 360.0;
lSideTime = local_sidereal_time(offset_days, longitude) * PI / 180.0;
/* Calculate hour angle */
ha[0] = lSideTime - ra[0] + k*K1;
@@ -892,9 +893,11 @@ calculate_moonrise_moonset(double latitude, double longitude, time_t t,
}
}
/* Get next moonrise in minutes after midnight of BASEYR
/* Get next moonrise or moonset in minutes after midnight of BASEYR
starting from given DSE.
Returns 0 if no moonrise could be computes */
Returns 0 if no moonrise could be computed
If want_angle is true, then returns the azimuth of the event rather
than the time of the event */
#define ME_SEARCH_DAYS 180
static int GetMoonevent(int dse, int is_rise, int want_angle)

View File

@@ -1,13 +0,0 @@
SET $LatDeg 45
SET $LatMin 24
SET $LatSec 0
SET $LongDeg 75
SET $LongMin 39
SET $LongSec 0
SET $MinsFromUTC -300
SET $CalcUTC 0
MSG Dawn: [dawn()]
MSG Sunrise: [sunrise()]
MSG Sunset: [sunset()]
MSG Dusk: [dusk()]

93
tests/sunmoon.rem Normal file
View File

@@ -0,0 +1,93 @@
set $AddBlankLines 0
banner %
set d '2011-01-01'
set x adawn(d)
if x < 5:53 || x > 5:57
REM MSG adawn() is inaccurate! - [x]
endif
set x dawn(d)
if x < 7:06 || x > 7:10
REM MSG dawn() is inaccurate! - [x]
endif
set x sunrise(d)
if x < 7:40 || x > 7:44
REM MSG sunrise() is inaccurate! - [x]
endif
set x sunset(d)
if x < 16:28 || x > 16:32
REM MSG sunset() is inaccurate! - [x]
endif
set x dusk(d)
if x < 17:02 || x > 17:06
REM MSG dusk() is inaccurate! - [x]
endif
set x adusk(d)
if x < 18:15 || x > 18:19
REM MSG adusk() is inaccurate! - [x]
endif
set x moonrise(d)
if x < '2011-01-01@5:14' || x > '2011-01-01@5:18'
REM MSG moonrise() is inaccurate! - [x]
endif
set x moonset(d)
if x < '2011-01-01@13:59' || x > '2011-01-01@14:03'
REM MSG moonset() is inaccurate! - [x]
endif
set x moonphase(d, 0:00)
if x < 319 || x > 323
REM MSG moonphase() is inaccurate! - [x]
endif
set x moondatetime(0, d, 0:00)
if x < '2011-01-04@04:02' || x > '2011-01-04@04:06'
REM MSG moondatetime(0) is inaccurate! - [x]
endif
set x moondatetime(1, d, 0:00)
if x < '2011-01-12@06:31' || x > '2011-01-12@06:35'
REM MSG moondatetime(1) is inaccurate! - [x]
endif
set x moondatetime(2, d, 0:00)
if x < '2011-01-19@16:20' || x > '2011-01-19@16:24'
REM MSG moondatetime(2) is inaccurate! - [x]
endif
set x moondatetime(3, d, 0:00)
if x < '2011-01-26@07:57' || x > '2011-01-26@08:01'
REM MSG moondatetime(3) is inaccurate! - [x]
endif
set x soleq(0, 2011)
if x < '2011-03-20@19:18' || x > '2011-03-20@19:22'
REM MSG soleq(0) is inaccurate! - [x]
endif
set x soleq(1, 2011)
if x < '2011-06-21@13:14' || x > '2011-06-21@13:18'
REM MSG soleq(1) is inaccurate! - [x]
endif
set x soleq(2, 2011)
if x < '2011-09-23@05:02' || x > '2011-09-23@05:06'
REM MSG soleq(2) is inaccurate! - [x]
endif
set x soleq(3, 2011)
if x < '2011-12-22@00:28' || x > '2011-12-22@00:32'
REM MSG soleq(3) is inaccurate! - [x]
endif
if $NumTrig == 0
REM MSG All astronomical functions look OK
endif

View File

@@ -153,9 +153,7 @@ rm -f ../tests/purge_dir/*.rem.purged >> ../tests/test.out 2>&1
../src/remind -p ../tests/shade.rem 1 August 2009 | ../src/rem2ps -e -l -c3 >> ../tests/test.out 2>&1
../src/remind -pp ../tests/shade.rem 1 August 2009 | ../src/rem2ps -e -l -c3 >> ../tests/test.out 2>&1
# The sun tests can fail due to math roundoff error changing the times
# by a minute...
# ../src/remind -p12 ../tests/sun.rem 1 Jan 2011 >> ../tests/test.out 2>&1
TZ=America/Toronto ../src/remind ../tests/sunmoon.rem 1 Jan 2011 >> ../tests/test.out 2>&1
# Test -a vs -aa
../src/remind -q -a - 1 Jan 2012 9:00 <<'EOF' >> ../tests/test.out 2>&1

View File

@@ -22332,6 +22332,7 @@ grestore
showpage
%%Trailer
%%Pages: 1
All astronomical functions look OK
Reminders for Sunday, 1st January, 2012:
1