Page 1 of 3

Moon states - I'm stuck

Posted: Wed 21 Sep 2011 12:42 pm
by Flying Eye
Hi all,

I'm stuck. I have a set of icons that cover the moon phase, they number 0-29, 0 being dark and 29 approaching dark again, with 15 as full moon.

I've seen a few sets that use that numbering and it makes sense after reading what they had to say about moon phases at wikipedia.

I need to find a way to get a number from 0-29 or 1-30 out of cumulus.

I'm using (Serious) Samurize to make an info panel on my desktop (yes, it does work on Win764 bitSP1!, installer has an issue but using vista SP2 compatability mode sorts the installer out.)

It looks like this so far:

Image

I can grab my data for it all from my website by using a Samurize plugin called page scraper, and it was all going pretty well until I hit this problem (well, that and the Zambretti descriptions).

I don't think there is a a webtag to produce the 0-29 or 1-30 number as far as I could discover.

Right now I don't code any more, and I'd quite like it to stay that way, as I seriously burned out on that stuff more than a decade ago.

What's the easiest way to get that 30 integer range I need?

It's so so with 8 icons used and named suitably, but it could be so much better if I could use the whole lot.

Ideas anyone?

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 12:51 pm
by steve
There's a web tag <#MoonPercent> which goes from -100 to +100 where -100 and +100 are both 'full moon', zero is 'new moon', and the sign indicates waxing (positive) or waning (negative), so you could map that range onto 0 to 29 with javascript. I'm sure beteljuice will be along in a minute with the code ;)

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:03 pm
by steve
I think the required conversion is (<#MoonPercent> + 100) * 29)/200

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:14 pm
by mcrossley
A first punt...


phaseNo = floor((<#MoonPercent>+100)/200*29);

Edit: cross posted with Steve :roll:

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:17 pm
by steve
Sorry - I think my formula is wrong; I've got 'full' and 'new' reversed. Um...

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:18 pm
by Flying Eye
steve wrote:I think the required conversion is (<#MoonPercent> + 100) * 29)/200
I guess <#moonday> where it chucks out a value between 1 and 30, is out of the question? :P

I would have imagined serving up the day the current moon is on might be a valid thing to want from a program dealing with moon phase, even if one was just wanting to know by way of it being a hobby. ;)

Would be a great addition in my view. :)

Then I could set about figuring out the mapping of zambretti to icons, which is a rather bigger ball of wax.

I'm using icons as I find ones I like for now, but eventually I'll probably make 3D models and do some rendering.

It's nice having an info bar handy at the screen top, or wherever suits you best really. Easy to spot sensor outages too! 8-)

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:21 pm
by Flying Eye
mcrossley wrote:A first punt...


phaseNo = floor((<#MoonPercent>+100)/200*29);

Edit: cross posted with Steve :roll:
OK, thanks, but what language is that first punt in? I mean I'd have to install and learn some new language for this wouldn't I? Cumulus and Samurize don't do math, and Samurize says it can take scripts, but I'd have to look into that. I'm not sure how I'd feed the result to pagescraper, so the script would have to work on a file somewhere or other. <shrug> :lol:

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:24 pm
by Flying Eye
steve wrote:Sorry - I think my formula is wrong; I've got 'full' and 'new' reversed. Um...
Hehe, I tried this most of this with a calculator morning, and it made my head hurt in the end! Never did get the right result either! :lol:

Not quite as easy as it looks at first glance is this one! :?

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:45 pm
by mcrossley
The code is in JavaScript for insertion into a web page.

The output is a value 0-29 (0=new, 7=1st Q, 14=full, 21=last Q, 29=new)

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 1:57 pm
by Flying Eye
mcrossley wrote:The code is in JavaScript for insertion into a web page.

The output is a value 0-29 (0=new, 7=1st Q, 14=full, 21=last Q, 29=new)
I need to ask a daft question - from what I read above this has 2 new moons in one lunation or synodic period? :o

Can that be right? :? I'm not expert enough to say, but it feels wrong at this point.

I've also now spotted a bug in the icon set, it's got image 15 as the full moon, even if I rename image 0 to become image 30 that's going to be off! I know that's somewhat another problem but it's probably worth a mention! :)
I could probably just nudge them all down by one and make 0 into 29, if you see what I mean.

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 2:41 pm
by Flying Eye
steve wrote:Sorry - I think my formula is wrong; I've got 'full' and 'new' reversed. Um...
I've just fallen in; what is needed is the day number in the cycle, what the numeric tags give us is the percentage of the disc visible. That would rise then fall. Calculating "proportionally in reverse" for the second half of the cycle being needed too!

Sadly the basic numbers do not really tell us how many days though the overall lunar cycle we are at. The numeric tags are reading 41 and -41.

Since they can vary in length, then just having the day number in each cycle's case would work best.

The full horror of it hit me when I just tried put this into a spreadsheet! :lol:

Given each cycle can vary, dare we safely assume each lunar day in that cycle are the same length for calculation purposes? We are just trying to get the right day here, nothing more closely accurate than that.

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 5:37 pm
by beteljuice
It's even more interesting than that !

There are many 'stand alone' bits of script that can give you your lunar day number.

Using Cumulus makes things a bit more interesting:

To consider -

-100 > 100, but -100 and 100 are the same !
You want to take it to a 'real' fraction (ie. 30 images = 3.33333333333333 ......... %)
An image 'period' will begin 1/2 period before the event and end immediately before 1/2 period after the event.

... BTW did we mention it was cyclic ?

I might be back ;)

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 6:12 pm
by mcrossley
and do you take the phase at midnight - start of the day, or end of the day, or mid-day, or mid-evening when perhaps most people will see the Moon :shock: A simple approximation can be obtained just using the cycles which repeat over 14 years (if you do not require great accuracy, or predict too far into the future or past which is the case here).

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 6:13 pm
by Flying Eye
beteljuice wrote:It's even more interesting than that !
[snip]
I might be back ;)
Hehe, that's the first time I ever witnessed any sort of doubt from you! :lol:

I've had some seriously daft fun with a spreadsheet this afternoon, I'm roughly in the right area, but I've had to make far too many guesses and broad assumptions, and even stooped to =ROUNDUP() a couple of times - but I only got within +/- 1 image numbers. Now that's all downright nasty! ;) Working it out from the data we already have is very tricky, and almost impossible to validate with any certainty.

The more I think of this the more I would like to see a <#moonday> web tag, because that would actually be useful in the same way the others are, however I'm not copping out, I'm perfectly happy to try and help reason out how one might get there! :) Having one of them would be a pretty darn neat feature just for it's own sake! :ugeek:

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 6:54 pm
by mcrossley
I'm not convinced that a <#moonday> tag will solve every thing, because the length of a lunation varies by a day or two. Better to create a series of images at set illumination percentages, and use the existing percentage tag. Otherwise things get slightly more complex.