Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astral.AstralError: Sun never reaches 6 degrees below the horizon, at this location. #9

Open
exfizik opened this issue May 23, 2017 · 4 comments
Assignees

Comments

@exfizik
Copy link

exfizik commented May 23, 2017

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?

@matkoniecz
Copy link

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?

@exfizik
Copy link
Author

exfizik commented Nov 30, 2018

Sorry, not working on that project any more, can't follow up. You decide what to do with the issue.

@RichardSWheatley
Copy link

RichardSWheatley commented Feb 1, 2019

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.

@RichardSWheatley
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants