janrg / MeeusSunMoon

JavaScript module to calculate times for sunrise, solar noon, and sunset, as well as moon phases based on "Astronomical Algorithms" by Jean Meeus
MIT License
31 stars 9 forks source link

Dawn and other times #3

Closed brettz9 closed 6 years ago

brettz9 commented 6 years ago

Hi Jan,

Another library I was using had the following additional items:

Would it be difficult to add these, in particular dawn?

janrg commented 6 years ago

I'll need to take a look but I imagine some of them will be fairly easy to add. I'll see when I have time but should be able to do this at the very latest in December. What I should definitely be able to add is civil, nautical, and astronomical dawn and dusk. (I imagine dawn and dusk in your list refer to astronomical dawn and dusk?). I'm not sure what nightEnd and night refer to in your list. goldenHour is a bit of a fuzzy concept and I don't think there'd be a particular benefit to add something like that in, as the times for sunrise and sunset should be sufficient to get an idea of when that is. For anything other than the 3 dawns and dusks I'd need an additional source of reliable and accurate data that I can test against. For nadir I could potentially just take it as exactly the midpoint between sunset and sunrise which should be reasonably accurate.

brettz9 commented 6 years ago

I was using suncalc with the times as described here: https://www.npmjs.com/package/suncalc#user-content-sunlight-times

I'm not very read up on the distinctions myself--my app was just surfacing what had been available (in suncalc) in addition to the times which had been of personal interest (sunrise, sunset, and noon as well as dawn).

janrg commented 6 years ago

I see, the page does explain how he uses the terms. dawn/dusk -> civil dawn/dusk nauticalDawn/nauticalDusk is clear night/nightEnd -> astronomical dusk/dawn For sunriseEnd and sunsetStarts (the lower edge of the sun touching the horizon) I don't think there would be much usefulness derived from addding them. Golden hour (which he essentially takes as the opposite of civil dawn/dusk, i.e. the sun being 6° above the horizon, I've already mentioned. So I'd narrow down this CR to adding the three dawns and dusks + potentially nadir, though for nadir I'll have to think a bit more about how to implement this (suncalc just uses 6 hours before dawn, which I'm not sure I'm happy with, but then its calculations are significantly less precise anyway) and if I can find a reliable reference for nadir times somewhere.

janrg commented 6 years ago

Implemented in https://github.com/janrg/MeeusSunMoon/releases/tag/v2.1.0

brettz9 commented 6 years ago

This looks great, thanks a lot!