Detecting daytime and nighttime
Posted: 11 Dec 2018, 16:51
Hello, I've been asked the simplest way to detect daytime and nighttime, for automatic research scripts.
Instead of looking at the current time, I think that it's better to check the altitude of the sun: when it's 15 degrees below the horizon then it's surely night.
A possible implementation would be: (remember to change the longitude/latitude of your observatory)
Instead of looking at the current time, I think that it's better to check the altitude of the sun: when it's 15 degrees below the horizon then it's surely night.
A possible implementation would be: (remember to change the longitude/latitude of your observatory)
Code: Select all
myLon = 12 ' positive if East
myLat = 44 ' North
al = SunAlt
if al < -15 then
print al; "= nighttime"
else
print al; "= daytime"
end if
sub SunAlt
ra,de = SunRaDec(JD)
az,al = EquatToAltaz(ra,de,myLon,myLat,JD)
return al
end sub