Sun incorrectly reported to stay below horizon
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
astral |
In Progress
|
High
|
Simon Kennedy |
Bug Description
At my location the run is incorrectly reported to stay below the horizon, something that doesn't happen here:
AstralError Traceback (most recent call last)
<ipython-
----> 1 l.sun(local=True)
/usr/lib/
707 date = datetime.
708
--> 709 sun = self.astral.
710
711 if local:
/usr/lib/
1510 """
1511
-> 1512 dawn = self.dawn_utc(date, latitude, longitude)
1513 sunrise = self.sunrise_
1514 noon = self.solar_
/usr/lib/
1547 return self._calc_
1548 except Exception as ex:
-> 1549 raise AstralError(('Sun remains below the horizon on this day, '
1550 'at this location.'))
1551
AstralError: Sun remains below the horizon on this day, at this location.
If I patch the _calc_time method to re-raise the exception, I get this:
...
/usr/lib/
2326 solarDec = self._sun_
2327
-> 2328 hourangle = self._hour_
2329 if direction == SUN_SETTING:
2330 hourangle = -hourangle
/usr/lib/
2299 h = (n / d) - t
2300
-> 2301 HA = acos(h)
2302 return HA
2303
ValueError: math domain error
It only happens on solar_depression of 18. Code snippet:
import astral
a = astral.
l = a['Ghent,Belgium']
l.solar_depression = 18
l.sun(local=True)
Changed in astral: | |
status: | New → Triaged |
importance: | Undecided → High |
assignee: | nobody → Simon Kennedy (sffjunkie) |
Changed in astral: | |
status: | Triaged → In Progress |
That there is an error is correct but not for the reason given in the message. It is occurring for a depression of 18 degrees because the sun never reaches that far below the horizon.