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

calculate function uses hard coded "Official" rather than passed-in zenith #2

Closed
grumBit opened this issue Jun 10, 2016 · 3 comments
Closed
Assignees
Labels

Comments

@grumBit
Copy link

grumBit commented Jun 10, 2016

Hi Chris,

Thank you loads for the work porting the calculations to Swift, it's been very helpful!

In testing I found the sunset times for offical, civil, etc., were all the same. In Solar.swift on line 162, I noticed the calculate function was not using the passed-in zenith and was instead always using the "Official" zenith;

   let cosH = (cos(Zenith.Official.rawValue.degreesToRadians) - (sinDec * sin(latitude.degreesToRadians))) / (cosDec * cos(latitude.degreesToRadians))

This can be corrected with the following;

   let cosH = (cos(zenith.rawValue.degreesToRadians) - (sinDec * sin(latitude.degreesToRadians))) / (cosDec * cos(latitude.degreesToRadians))

Cheers, Graham.

@ceeK
Copy link
Owner

ceeK commented Jun 10, 2016

Hi Graham!

Oops! You're completely right. I'll put a fix in for this on the train this evening :)

@ceeK ceeK added the bug label Jun 10, 2016
@ceeK ceeK self-assigned this Jun 10, 2016
@grumBit
Copy link
Author

grumBit commented Jun 10, 2016

Nice one Chris. :)

My next effort is to reverse the algorithm so I can determine the zenith for a given date, time & place. Not sure my maths is up to it though!

Cheers, Graham.

ceeK added a commit that referenced this issue Jun 12, 2016
@ceeK
Copy link
Owner

ceeK commented Jun 12, 2016

Bit later than I expected, but I've just merged in the fix.

Good luck in the reversal! Feel free to send in a PR if you want to add it to Solar :)

@ceeK ceeK closed this as completed Jun 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants