astral
astral copied to clipboard
astral.AstralError: Sun never reaches 6 degrees below the horizon, at this location.
I started getting this error about a week ago (getting close to summer solistice I'm guessing) for a location that's fairly up north, but nowhere near the pole - lat,lon = 62.55,-129.52. I've traced it back to the following code:
def _hour_angle(self, latitude, declination, depression):
# arg values: 62.54999923706055, 21.466634091977532, 96
latitude_rad = radians(latitude)
declination_rad = radians(declination)
depression_rad = radians(depression)
n = cos(depression_rad)
d = cos(latitude_rad) * cos(declination_rad)
t = tan(latitude_rad) * tan(declination_rad)
h = (n / d) - t # h: -1.0006730127306969 <- out of range for acos
HA = acos(h) # Exception here.
return HA
I'm not sure how to handle this. Is astral not supposed to work in my case?
fairly up north, but nowhere near the pole
Have you checked whatever it is enough toward north that "Sun never reaches 6 degrees below the horizon, at this location" is true?
Sorry, not working on that project any more, can't follow up. You decide what to do with the issue.
Did you check each step in the equation? The cos function is returning a negative value for depression_rad. Most calculators will not do that.
Try checking that out before continuing.
@exfizik one thing to note is that when using python cosine, it does return negative values and you should check for that.
n = cos(depression_rad)
look at your example and remember that 1 - sqrt(1-pow(sin(depression_rad), 2))) is the same as cos(depression_rad). Not as cool looking but it might give you a better answer.