Moon Phase formula - updated

@mikeoday Hi, I am just trying to confirm your math here, and I am not getting a result that seems to align with the current moon phase.

At the time of this message, the UNIX epoch is 1711318000.
Running that through your simplified formula ((#DNOW#-583084344)/2551442802)%1
I get a value of 0.442194.
However, the moon’s phase from NASA’s site NASA SVS | Moon Phase and Libration, 2024 shows 99.86%.
This means the formula’s current value should be about 0.4993. This seems like a large error.

Am I interpreting the math incorrectly here? I thought this formula would return 0 for a new moon, and 0.5 for a full moon, which we are almost at.

1 Like

What do you get with the complex expression?

The simple formula is not that accurate at times ( although the error you got does seem quite large ).

You are right about 0.5 for full.

1 Like

The next full moon is at: 2024 Mar 25 07:00 UTC or UNIX: 1711350000

refer: https://aa.usno.navy.mil

Testing the expressions gives the following:

Top: #DNOW#
Mid: simple
Bot: complex

I’m not sure why you are getting different results.

Are you sure you are testing with the time in creator adjusted for the correct UTC/GMT ?

Also, the reference used for the expressions is the US Navy Observatory, which is the official source for astronomical data in the US ( not NASA ) - although the differences should not be that great.

And finally, although again, it does not explain the size of the error, the expressions have been determined by empirical means and have only been confirmed to be reasonably accurate at the 4 phases of the Moon. And the errors will be larger during the intermittent phases. But, your example is very close to full Moon so that particular source of error should be very small in this case.

2 Likes

Sure. The current unix epoch: 1711322358

Value output from the complex expression: 0.4447555

I’m testing this on python and I’ve converted your formula as follows.

In python, the expression time.time() provides the current unix epoch without local adjustments.

cTime = time.time()
moon_phase = (((cTime/2551442844-0.228535)
               +0.00591997*math.sin(cTime/5023359217+3.1705094)
               +0.017672776*math.sin(cTime/378923968-1.5388144)
               -0.0038844429*math.sin(cTime/437435791+2.0017235)
               -0.00041488*math.sin(cTime/138539900-1.236334))%1)

It could be the source of my issues, but I’m fairly certain I’ve interpreted your formula correctly. However if that’s not the case, your advice would be greatly appreciated!

2 Likes

Ok… I realize that time.time() does not get us to the correct order of magnitude. Your input is 1000 times larger than mine, since #DNOW# gives the current epoch to the nearest second.

What is the precise output of #DNOW# in terms of the unix epoch?

2 Likes

Yes, #DNOW# is in mSec not Sec. So, you will need to multiply time.time() by 1000 to get the same result.

3 Likes

Problem solved! Thanks for working through that. It’s great that we have a concise formula for the moon phase that only requires a unix timestamp, and outputs a very accurate result for many use cases.

In python, this one-liner does the trick:

moon_phase = ((time.time() - 583084.344) / 2551442.802) % 1

3 Likes

I love this Topic . Facer University Stuff. Great to see Masters at Work . Thank you very much . I think any of these Solutions are good for our Smart watches . I feel that if we really want something more accurate we need a Different instrument .
.
.
@mikeoday Sadly the Complex formulas above are not working for me today . They are way beyond me to debug . I think something has been mistranslated in The process of Copy and Paste due to formatting . I think the Formulas need Format protecting . Lucky have copies of the formulas from a few years ago that I have used on loads of faces. Thank You . I do find the New Facer Tag is out a bit by comparison but comes into line each new moon .
.
.
((((#DNOW#/2551442844-0.228535)+0.00591997*sin(#DNOW#/5023359217+3.1705094)+0.017672776*sin(#DNOW#/378923968-1.5388144)-0.0038844429*sin(#DNOW#/437435791+2.0017235)-0.00041488*sin(#DNOW#/138539900-1.236334))%1))

2 Likes

I converted the formulas above to hold up against the WFS moon phase wich reports 0 to 28 as Default. :rofl: :face_with_monocle:
.
.
formulas on wfs

1 Like

I use Time and Date for my Reference to check Sun and Moon stuff.
.
.

1 Like

I can’t immediately see the issue with the expression you have - other than the extra brackets around the outside, but I don’t know it that makes a difference. I’ll see if I can post the working formula with correct formatting tomorrow.

1 Like

Cool!

Other than not being as accurate as I would like, the problem was ( still is ?? ) that the Facer tag for Moon phase was / is timezone dependent. That is, if one changes the timezone for the phone/watch or PC, the reported Moon phase changes. Which is clearly wrong and introduces a large error depending on where one lives. It is as if local time is being used to determine Moon phase not UTC - as if the Phase of the Moon is somehow linked to one’s place on the Earth, not the same for everyone on Earth at the same time regardless of where they are. But I’ve not checked since the tags first came out, maybe that problem has been fixed now.

1 Like

Ha Ha . Yes I have pondered that one . The Data has to be given from some where . I have the Pleasure to live nearer the Greenwich Meridian than the Server in L.A. From a Visual point of view there must be a small difference to the New Moon .
Here is a Test the same as above for Facer showing off the new Tag . I personally Think that any of these Code Formulas are a Gift for sure . If we start talking about small differences it gets very silly . Although Facer gives us an updated Distance to the Moon we are not going to use that data to Navigate there . For me the Phase of the Moon is a Spiritual thing so plus or minus a few hours is totally Irrelevant . I see that the Table I posted is the same as there US Navy one . As with a lot of other astronomical stuff it must be set at GMT / UTC .
BTW sorry I put the extra () on the complex formula . Bit of a Habit of mine .
.
.

. .

3 Likes

Chips with everything!

1 Like

When Russel takes care of a topic :smile:

1 Like

I’m still only a few days into my Facer journey and haven’t yet committed to paying for the annual plan.
At the moment, my creations are primarily aimed at improving time readability “at a glance” (so I don’t have to keep putting my specs on!) and any other information/complication is there if I need it.
I was feeling enormously proud of myself when I added the moon phase option and then figured out that I could overlay that with an image of the full moon (at around 50% opacity) to achieve a more realistic effect. But, like others here, I now notice that the phase is slightly out and that bugs me.
Fortunately, the improvements have already been calculated by you folks.
So, is the improved formula something I can include while still playing around in the free version of Creator? Either way, any pointers towards the appropriate reading so I can learn how to do it, please?

2 Likes

@sirswampthing1 . Ha Ha . I think you are smitten . I have made Loads of thing in my life as I am a Maker . Some I am very proud of . One of my first watches included the Facer Stock Moon . I was so delighted and proud of myself . I published that one as well . I found it hard not to get emotional that there was someone else on the planet that had seen my creation on thier Watch Face . Now I crave thousands . I was in some way more honoured with the first as it was a bit Basic.
I got my first smartwatch for my 70th because I wanted a moon Phased Face . At that stage I did not relies I could make one myself . Like everything else in life I soon became dissatisfied with the 8 Image Phase and set about finding a way to do more settling on 28 . It is a strange number but give symmetry to the whole affair .
No you do not need to be a Pro to make a decent moon phase . I invite you to look at some of my work . I have represented the moon phase in many different ways . Learn to show us a link of what you are doing here . It does not have to be published and People on this Forum do not Copy your work . They will only use resources you post if it it obvious that is what you intended.

Ha Ha . You will see on this Face I did not even know how to make a Battery Gauge . You can imagine how proud I was . The shot was from a Favourite Holiday View.
.
.

5 Likes

I notice this Topic is now over 4 years old . What is remarkable is that none of it has become irrelevant or that Example Inspectable Faces have been Removed . Much earlier on in the Topic @GAUSS posted a face with a very nice way of representing the Moon phase . I myself have posted a Couple , Basic and Classic where two moons rotate behind a mask . That face was to Illustrate that Different formulas have small differences but all agree with each other at the New Moon . Good enough for Mortals I feel . I like the Idea of the moon standing alone without a mask and then you can have stuff orbiting it which is always fun .
Here are a Mask and Moons to play with . They are not perfect . If you need better I can work on them . I have this stuff all over the place .
I will post a Formula when I have checked it .
This is a KISS formula that I just tested .
For the rotation of the two moons set horizontal.

((#MOONAGEPERCENT#)*180)

.
.

.
.

4 Likes

Here is a Discs Mask . It is a Classic device as well used on a Lot of really expensive Watches . It additionally reflects how the Moon Phase might look in the Southern Hemisphere . Sadly it is not helping those who live on the Equator . Well you can not do it all . I wish I was that kind of Mathematician but I am not .
I normally Post 2D resources in WHITE but for new comers I feel it is polite to post them at #FAFAFA so it is not a Hide and seek exercise .
.
.


.
.

.
.
Here is a full face Mask .
.
.

4 Likes

Yes, I am smitten.
Your Telendos reminds me of the good old fashioned military issue and I have got ideas to create something similar to the watch worn by Ray Mears.
I have had a good look at the options available in the moon phase section of the Creator but I cannot see where/how to insert your more accurate formula?
Or is it a bit more than just entering the formula into a box somewhere?

1 Like