I found a bug in ASCOM.Astrometry.AstroUtils.AstroUtils.EventTimes method.
It doesn't return sunrise time events for latitude lat = 26.695512 and longitude lon = 100.03105 for the date of December 14, 2019 .
I could observe that changed 1% latitude works correctly. It works if you change the time zone.
I think it fails if the time is too close or is equal to 0:00.
Attached code example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ASCOM;
namespace testAscomSunsetRise
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
ASCOM.Astrometry.Transform.Transform apTransform = new ASCOM.Astrometry.Transform.Transform();
ASCOM.Astrometry.NOVAS.NOVAS31 apNOVAS = new ASCOM.Astrometry.NOVAS.NOVAS31();
ASCOM.Astrometry.AstroUtils.AstroUtils apUtil = new ASCOM.Astrometry.AstroUtils.AstroUtils();
System.Collections.ArrayList astroNight = new System.Collections.ArrayList();
System.Collections.ArrayList civilNight = new System.Collections.ArrayList();
System.Collections.ArrayList sunRiseSet = new System.Collections.ArrayList();
DateTime lastUpdate = DateTime.UtcNow;
double lat = 26.695512;
double lon = 100.03105;
civilNight = apUtil.EventTimes(ASCOM.Astrometry.EventType.CivilTwilight, lastUpdate.Day, lastUpdate.Month, lastUpdate.Year, lat, lon, 0);
astroNight = apUtil.EventTimes(ASCOM.Astrometry.EventType.AstronomicalTwilight, lastUpdate.Day, lastUpdate.Month, lastUpdate.Year, lat, lon, 0);
sunRiseSet = apUtil.EventTimes(ASCOM.Astrometry.EventType.SunRiseSunset, lastUpdate.Day, lastUpdate.Month, lastUpdate.Year, lat, lon, 0);
Console.WriteLine("Latitude: " + lat.ToString());
Console.WriteLine("Longitude:" + lon.ToString());
Console.WriteLine("Time" + lastUpdate.ToString());
Console.WriteLine("sunRiseSet cont :" + sunRiseSet.Count.ToString());
foreach (var e in sunRiseSet) Console.WriteLine("Array sunRiseSet:" + e.ToString());
Console.WriteLine("civilNignht cont :" + civilNight.Count.ToString());
foreach (var e in astroNight) Console.WriteLine("Array astro:" + e.ToString());
Console.WriteLine("astroNight cont :" + astroNight.Count.ToString());
DateTime objDateWoHour = lastUpdate.Date;
}
}
}
The output of the example with a bug and changing the latitude (1%).
C:\Users\Isilda\source\repos\testAscomSunsetRise\testAscomSunsetRise\bin\x86\Deb
ug>testAscomSunsetRise.exe
>
> Hello World!
> Latitude: 26,695512
> Longitude:100,03105
> Time14/12/2019 18:07:22
> sunRiseSet cont :4
> Array sunRiseSet:True
> Array sunRiseSet:0
> Array sunRiseSet:1
> Array sunRiseSet:10,4769542132567
> civilNignht cont :5
> Array astro:True
> Array astro:1
> Array astro:1
> Array astro:22,6261952111538
> Array astro:11,8566759109858
> astroNight cont :5
> C:\Users\Isilda\source\repos\testAscomSunsetRise\testAscomSunsetRise\bin\x86\Deb
> ug>testAscomSunsetRise.exe
> Hello World!
> Latitude: 26,96246712
> Longitude:100,03105
> Time14/12/2019 18:14:55
> sunRiseSet cont :5
> Array sunRiseSet:False
> Array sunRiseSet:1
> Array sunRiseSet:1
> Array sunRiseSet:0,00456997991677
> Array sunRiseSet:10,4673235217848
> civilNignht cont :5
> Array astro:True
> Array astro:1
> Array astro:1
> Array astro:22,632481231502
> Array astro:11,8504289094108
> astroNight cont :5