suncalc icon indicating copy to clipboard operation
suncalc copied to clipboard

Add getRiseAndSetAtSolarAngle method

Open MatthiasKunnen opened this issue 6 years ago • 8 comments

I have a use case where I need to get the time on which the sun will be at multiple angles. Since these altitudes are unknown I can't really name them. Therefore I've added the getRiseAndSetAtSolarAngle method.

The method can be seen as a shortcut to addTime followed by getTimes that does not pollute the times array. It saves a method call and does not calculate any other times when it doesn't need to.

MatthiasKunnen avatar Jun 26 '19 02:06 MatthiasKunnen

@mourner, are you accepting PRs at the moment?

MatthiasKunnen avatar Jul 26 '19 02:07 MatthiasKunnen

Sorry for not reviewing this in time — I got swamped by other commitments and have fallen behind on this project. :( Closing as the PR is superseded by #137, which is more accurate and complete.

mourner avatar Dec 27 '19 14:12 mourner

@mourner, that issue seems to address a different issue. #137 changes the height of the observer. This PR allows passing of the angle of the sun you want to know the sun rise and sun set time of. Am I incorrect and does #137 provide a way to do this?

MatthiasKunnen avatar Feb 02 '20 22:02 MatthiasKunnen

Ah apologies, I misread the description — reopening.

mourner avatar Feb 03 '20 09:02 mourner

The name might be confusing indeed. What do you think about getTimesAtAngle?

MatthiasKunnen avatar Feb 03 '20 11:02 MatthiasKunnen

@mourner, I've made some additions:

  • Rename the method to be more intuiitive
  • Add elevation parameter as was added to getTimes
  • Accounted for atmospheric refraction It's not 100% correct. I tried using the astroRefraction function but that seems to be off by a a few seconds. I'll add a commit to showcase this

MatthiasKunnen avatar Feb 08 '20 04:02 MatthiasKunnen

This saved me some time, thank you for sharing your solution @MatthiasKunnen !

gtim avatar Jan 21 '22 12:01 gtim

published a new version which include this as https://github.com/Hypnos3/suncalc3

Hypnos3 avatar Mar 13 '22 21:03 Hypnos3