Page 1 of 3

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.

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 6:58 pm
by Flying Eye
mcrossley wrote: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:.
Yes, it's non obvious: I suspect we should start at the first moment we are prepared to declare a new moon, it's logical enough to presume to call that day one. Day two would follow after the completion of day one, or new moon plus the lunar day length for day one (it is lunar day length we need isn't it? not earth day length? <shrug>)

To make matters worse I just found the most wonderful set of icons for this, and there's 41 of the little devils in there, but that is going too far and I also don't see why 41 images work that much better than 30? So, nice as they are, perhaps we'd better let that set pass us by! :lol:

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 7:22 pm
by Flying Eye
mcrossley wrote: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.
I'm wanting to make it possible to show those images at about the right time for now. Cumulus would, in making a web tag, dictate the pace at which it's progressing through the sequence. So then the images reflect the output from your station as best they can and that is what I am trying to do. At present, I can roughly guess/deduce which 8 images to use out of the bunch and in time (as I learn more about it) that choice can and will be better made. However, far better to have the greater number of images to work with if that is possible, and I accept it may not be possible.

Now as to what you suggested; that sounds like making it even more complex, but I'd be happy to have a stab at modelling and rendering a set for that. How many do you envisage needing to suit your proposition?

Bearing in mind if it's not an automatically generated webtag then I have to have some means of changing the required image, some sort of script, that will need access to some file or other on the web page, and then I would have to retrieve an extra file every so often, read its content and set an image accordingly.

At present I just have Cumulus processing and sending one extra text file as it does it's normal web run. Using web tags I can simply include any extra data I need like that. Doing it externally, the program doing it would need to chose it's moment to do it's stuff.

Oh, and then the reading software (pagescraper plugin in Samurize) would have to grab it without there being a file lock on it too! Now maybe it's that I'm a novice but that's starting to sound pretty blooming complex! Of course I could be dead wrong about that, but that is just how it strikes me right now.

Re: Moon states - I'm stuck

Posted: Wed 21 Sep 2011 9:59 pm
by beteljuice

Code: Select all

<script  type="text/javascript">
pic_no = Math.floor(((parseInt(<#MoonPercent>) + 103) / 6.66) % 30 );
</script> 
Near enough :lol: (don't ask the beteljuice logic)
Returns 0 (Full Moon) => 29 (immediately before Full Moon) [15 = New Moon] or perhaps the other way around depending on Steves logic :lol:

Test:

Code: Select all

<script  type="text/javascript">
for(j= -100; j <= 100 ; j = j+2) {
  pic_no = Math.floor(((parseInt(j) + 103) / 6.66) % 30 ) 
  document.write(j + '% > ' + pic_no + '<br />');
}
</script>
Outputs:

-100% > 0
-98% > 0
-96% > 1
-94% > 1
-92% > 1
-90% > 1
-88% > 2
-86% > 2
-84% > 2
-82% > 3
-80% > 3
-78% > 3
-76% > 4
-74% > 4
-72% > 4
-70% > 4
-68% > 5
-66% > 5
-64% > 5
-62% > 6
-60% > 6
-58% > 6
-56% > 7
-54% > 7
-52% > 7
-50% > 7
-48% > 8
-46% > 8
-44% > 8
-42% > 9
-40% > 9
-38% > 9
-36% > 10
-34% > 10
-32% > 10
-30% > 10
-28% > 11
-26% > 11
-24% > 11
-22% > 12
-20% > 12
-18% > 12
-16% > 13
-14% > 13
-12% > 13
-10% > 13
-8% > 14
-6% > 14
-4% > 14
-2% > 15
0% > 15
2% > 15
4% > 16
6% > 16
8% > 16
10% > 16
12% > 17
14% > 17
16% > 17
18% > 18
20% > 18
22% > 18
24% > 19
26% > 19
28% > 19
30% > 19
32% > 20
34% > 20
36% > 20
38% > 21
40% > 21
42% > 21
44% > 22
46% > 22
48% > 22
50% > 22
52% > 23
54% > 23
56% > 23
58% > 24
60% > 24
62% > 24
64% > 25
66% > 25
68% > 25
70% > 25
72% > 26
74% > 26
76% > 26
78% > 27
80% > 27
82% > 27
84% > 28
86% > 28
88% > 28
90% > 28
92% > 29
94% > 29
96% > 29
98% > 0
100% > 0

Of course if you want a rough MoonDay number, just add 1 to the code output ;)

Re: Moon states - I'm stuck

Posted: Thu 22 Sep 2011 6:42 am
by Flying Eye
beteljuice wrote:

Code: Select all

<script  type="text/javascript">
pic_no = Math.floor(((parseInt(<#MoonPercent>) + 103) / 6.66) % 30 );
</script> 
Near enough :lol:
Oddly I got a lot of that "near enough" happen when I was playing too! :lol:
beteljuice wrote: (don't ask the beteljuice logic)
I see! :P
beteljuice wrote: Returns 0 (Full Moon) => 29 (immediately before Full Moon) [15 = New Moon] or perhaps the other way around depending on Steves logic :lol:
Glad I'm not the only one who had that thought cross their mind! :P
beteljuice wrote: Of course if you want a rough MoonDay number, just add 1 to the code output ;)

:clap: Scoundrel! :bash: I felt bad/gulilty/embarrassed when I had to stoop to doing that. :lol:

Thanks for that. Now I got to work out how to make that usable. Bear in mind I never used java or anything like it before, so I have no idea where to point it, or how to get the trigger pulled, but hey, I'm a graphics guy now, not a coder, so that's to be expected. 8-)

I know it's got to work on the output from Cumulus which would already reside on the web site. It's then got to insert the result either back into the file it found it in, or make a file of it's own, on the web site, either way it's got to be downloadable for the other tools I am using.

Then I got to find a way to grab that from the web site, and set up the right image. That last bit is fairly easy to sort out, but as for the rest of it I have no idea! Not even the most basic of concepts. :?

Re: Moon states - I'm stuck

Posted: Thu 22 Sep 2011 10:37 am
by beteljuice
I know it's got to work on the output from Cumulus which would already reside on the web site. It's then got to insert the result either back into the file it found it in, or make a file of it's own, on the web site, either way it's got to be downloadable for the other tools I am using.
This is not good !
I suspect the 'page scraper' would NOT see any image or text created by the JavaScript, and would only be able to see the js itself.

You need to 'scrape' the MoonDay number or image from one of the many sites that provide that sort of thing through a server-side script (eg. php). Some sites allow it, other frown upon scrapers.

If your server allows php, it would be better for you to get a freebie script that returns exactly what you want and scrape-your-own :lol:

It's been interesting though

BTW - Isn't a lunar month less than 30 days ...
... so all this code is ...... only any good for a 30 image selection :clap:

Re: Moon states - I'm stuck

Posted: Thu 22 Sep 2011 10:55 am
by steve
beteljuice wrote:You need to 'scrape' the MoonDay number or image from one of the many sites that provide that sort of thing
I did wonder why this wasn't the solution in the first place. It seemed rather perverse to me to be getting Cumulus to upload this 'moon day' number to a web site, to then scrape it off the web site to a desktop app, when the figure is already available on the web.

I'm also somewhat bemused by this repeated suggestion that it would all be much simpler if Cumulus had a <#moonday> web tag. If it's hard to arrive at this number in the first place, where am I expected to get it from?

Re: Moon states - I'm stuck

Posted: Thu 22 Sep 2011 11:02 am
by Flying Eye
beteljuice wrote:This is not good !
I do agree! :)
beteljuice wrote:I suspect the 'page scraper' would NOT see any image or text created by the JavaScript, and would only be able to see the js itself.
That was exactly my suspicion to start with. Hence my preferring a <#lunarday> webtag, as that would actually be able to work. 8-)
beteljuice wrote:You need to 'scrape' the MoonDay number or image from one of the many sites that provide that sort of thing through a server-side script (eg. php). Some sites allow it, other frown upon scrapers.
Lucky thing is, it's my site, and I'm being very lenient with myself ;)
beteljuice wrote:If your server allows php, it would be better for you to get a freebie script that returns exactly what you want and scrape-your-own :lol:
Well yes, that's what I am doing so far. :)
beteljuice wrote:It's been interesting though
Yeah, there were even some interesting philosophical bits in there that kept on cropping up! :?
beteljuice wrote:BTW - Isn't a lunar month less than 30 days ...
generally about 29 and a bit maximum from most reports I've read so far. Can go as low as - ugh, senior moment, can't remember. :lol:
beteljuice wrote:... so all this code is ...... only any good for a 30 image selection :clap:
That's fine in this case. :)

I'm thinking I may have to scrap the idea and take out the images and replace them with one of a pine cone and another of seaweed, and then I could just pretend the whole Zambretti business does not exist either! :roll:

Re: Moon states - I'm stuck

Posted: Thu 22 Sep 2011 11:04 am
by mcrossley
beteljuice wrote:BTW - Isn't a lunar month less than 30 days ...
... so all this code is ...... only any good for a 30 image selection :clap:
That is what I was trying to say, basing your images on the day of the lunation is not a good idea as the length of a lunation varies. What you have done is translate the 100% into a 'standard' 30 day range of images. My suggestion is to base the images on the percentage illumination in the first place!

Re: Moon states - I'm stuck

Posted: Thu 22 Sep 2011 11:15 am
by Flying Eye
steve wrote:
beteljuice wrote:You need to 'scrape' the MoonDay number or image from one of the many sites that provide that sort of thing
I did wonder why this wasn't the solution in the first place.
I've found lots of sites that tell you how you might calculate it, many that offer calendars and charts, some that want you to sign up for all sorts of doubtful things along the way of getting to the number. I've not yet seen one that just comes up with the number as a matter of routine. And while I don't mind scraping my own site, scraping that of another almost always ends up becoming broken as some will go to extraordinary lengths to dislike the practice.
steve wrote: It seemed rather perverse to me to be getting Cumulus to upload this 'moon day' number to a web site, to then scrape it off the web site to a desktop app, when the figure is already available on the web.
Samurize can use the plugin to scrape from the web, but can't scrape from the machine, so I was simply being practical and doing the only thing that actually worked, perverse or otherwise. :lol:
steve wrote:I'm also somewhat bemused by this repeated suggestion that it would all be much simpler if Cumulus had a <#moonday> web tag. If it's hard to arrive at this number in the first place, where am I expected to get it from?
I had this idea in my head that you might have it already to be drawing the moon image from Cumulus as you do. I had no idea you had no idea what the lunar day was, I guess I assumed you might need to know that to draw what you do, but I now suspect that has to be a bad assumption on my part. :?

Re: Moon states - I'm stuck

Posted: Thu 22 Sep 2011 11:21 am
by steve
Flying Eye wrote:I had this idea in my head that you might have it already to be drawing the moon image from Cumulus as you do. I had no idea you had no idea what the lunar day was, I guess I assumed you might need to know that to draw what you do, but I now suspect that has to be a bad assumption on my part. :?
The moon image which Cumulus provides is a third-party component; I put it on the form and it just works. I get the 'percent illuminated' figure from an astronomical functions library which doesn't have a function for lunar day.