Closed ghost closed 10 years ago
@ironwallaby very sorry for a late response — crazy days! I love Forecast.io (and also work for Mapbox :)
Honestly I'm not sure how to go about this, since I don't understand the domain here very well and followed some online articles to implement it (which are extremely sparse when it comes to moon calculations). Maybe @mpetroff who contributed the angle calculations can chime in here.
Found this description of the fraction value:
The fraction illuminated is geocentric, that is, it is computed for a fictitious observer located at the center of the Earth.
The fraction applies both to
- the illuminated area of the Moon's apparent disk divided by the total area of the disk
- the illuminated portion of the Moon's apparent angular diameter divided by the total diameter, for the diameter that would intersect the Sun if extended.
Ha! Small world. :)
Based on that description, it looks like the fraction illuminated and the moon phase are related linearly (since the angle between the moon and sun is the primary concern here), so I'll run with the function I mentioned above until somebody shows me the error of my ways.
Thanks again!
Ok, figured it out — it's not linear, but I'll post a solution later today when I get back home :)
Pesky math. :p
I'll look forward to your solution!
OK, check this out :) fraction had a cosinal relation to phase.
Released 1.4.0 with phase
property (from 0
to 1
).
You're my hero. <3 (I thought it might. I guess I should just trust my gut.)
I'll get this integrated into my stuff shortly. Thanks a bunch!
Glad to be helpful. BTW, now that I'm at it, do you know why the Dark Sky app is only available in US/UK? I'd love to use it here in Kiev.
Yup—it comes down to the fact that we have global hour-by-hour data, but we only have minute-by-minute data for the US and UK. (They actually use completely different datasets: hour-by-hour is primarily based on numerical weather prediction models, while the minute-by-minute is based on our in-house projections of radar observations. Forecast can work off of either, but Dark Sky really needs the minute-by-minute data.)
The main reason that we're limited on the minute-by-minute front is because licensing raw radar data is expensive, especially in Europe. (In fact, the UK has among the cheaper data sets, and one of the largest markets, and even then we don't turn a profit there. France, for example, costs five times as much but has half the market, making it an order of magnitude too expensive for us.)
We're hoping that A) the EUMETNET gets it's act together and provides a radar composite of all the EU member states (which they promised us last year, but we're still waiting!), and B) that there's political will to make the data more open in order to promote innovation.
Until then, we're working on drastically improving our hour-by-hour forecasts in Europe to make up for it. :)
Hi there!
We use your excellent SunCalc library in Forecast and our weather API and love it. Thanks for your hard work!
I don't have a bug to report; just a question: what is the correct way to calculate the moon phase? (That is, I would like the percentage of the way through the current lunation cycle: 0%=new moon, 25%=first quarter moon, 50%=full moon, 75%=last quarter moon.)
I came up with the following function:
It's certainly simple, however, I'm not sure it's correct: I get the impression that the illuminated fraction of the lunar disk is a nonlinear value (due to the spherical shape of the moon), and thus treating it as a linear value above is flawed. (While it will return correct values at 0%, 25%, 50%, and 75%, I suspect it will be incorrect between those points. By how much, I'm not sure.)
My intuition is that I should simply be mapping the angle property (plus, perhaps, some offset) from 0..π to 0%..100%, but this doesn't seem to work. Am I misunderstanding that property?
Thanks for your help! Jay LaPorte