Page 1 of 2

Weather Synopsis

Posted: Fri Nov 20, 2009 10:31 pm
by cbhiii
With the aid of some Javascript and the many variety of [variables] available on Meteohub. I was able to create a text weather synopsis of the day for my station.

Check out the top box on my weather page to read it: http://weather.huffman.info

I've attached the html text file code I used to create the text if someone is interested. Let me know what you think.

Cheers! [file name=synopsis.txt size=3820]http://www.meteohub.de/joomla/images/fb ... nopsis.txt[/file]

Re:Weather Synopsis

Posted: Fri Nov 20, 2009 10:45 pm
by rune
I really like it and see huge potential in this script. Thanks for sharing!

Re:Weather Synopsis

Posted: Fri Nov 20, 2009 11:01 pm
by cbhiii
I agree. This is my first draft and I'm sure I'll be tweaking it now and then over the next few weeks.

Especially when it comes to detecting the cloudy or partly cloudy skies. Right now I'm kind of guessing based on amount of daylight in the SOL sensor and the time of day. We'll see what happens. :)

Re:Weather Synopsis

Posted: Sat Nov 21, 2009 12:08 am
by rune
Great. Please keep on sharing, I'm sure your code will be popular :-)

Re:Weather Synopsis

Posted: Sat Nov 21, 2009 3:42 am
by cbhiii
Updated text file with some bug fixes. [file name=synopsis-d67d4a3dbbbbe163849b394682118f47.txt size=4173]http://www.meteohub.de/joomla/images/fb ... 118f47.txt[/file]

Re:Weather Synopsis

Posted: Sat Nov 21, 2009 5:49 pm
by WS Grave
Very nice script Chuck.
I'm using it on my site, but had to tweak a little bit to get it working. But still, very nice work.
I'm missing the "cloud" message, because I don't have a solar sensor anymore.

The "else" part wasn't working for me (don't know why), but I added the remaining directions manually (still have to add the 3 letter directions, but it is working). Also I could leave the mph :)):

Code: Select all

// wind
						var wtxt="";var b="";var c="";
						var wd="[last15m_wind0_maindir_en:-]";
						var wn=(Math.round([last15m_wind0_speed_mph:-]));
						if (wn<1){b="windstil. ";}
						if (wn>=1 && wn<=3){b="een lichte wind ";}
						if (wn>=4 && wn<=7){b="een lichte bries ";}
						if (wn>=8 && wn<=12){b="een zachte bries ";}
						if (wn>=13 && wn<=17){b="een matige wind ";}
						if (wn>=18 && wn<=24){b="een frisse wind ";}
						if (wn>=25 && wn<=30){b="een sterke wind ";}
						if (wn>=31 && wn<=38){b="een bijna stormachtige wind ";}
						if (wn>=39 && wn<=46){b="een stormachtige wind ";}
						if (wn>0 && wd=="N"){c="uit het noorden. ";}
						if (wn>0 && wd=="S"){c="uit het zuiden. ";}
						if (wn>0 && wd=="E"){c="uit het oosten. ";}
						if (wn>0 && wd=="W"){c="uit het westen. ";}
						if (wn>0 && wd=="SE"){c="uit het zuidoosten. ";}
						if (wn>0 && wd=="SW"){c="uit het zuidwesten. ";}	
						if (wn>0 && wd=="NW"){c="uit het noordwesten. ";}	
						if (wn>0 && wd=="NE"){c="uit het noordoosten. ";}						
						document.write(b,c);

Re:Weather Synopsis

Posted: Sat Nov 21, 2009 6:13 pm
by cbhiii
Nice!

You can also get rid of var wtxt=""; as I decided not to use that variable. The code does need a bit of clean up, but it's too early for that.

In the interest of time I only did the four main wind directions and left the rest, but I will probably go back and do those in the future. ;)

I was also tweaking some things last night too, so some of the code is even different from what I posted. I'm excited to see what it looks like in a few weeks after I keep playing with it. :laugh:

Glad people are trying it out.

Re:Weather Synopsis

Posted: Sun Nov 22, 2009 8:19 pm
by bensca
Hi,
your script is great! I think about it, to install it on my homepage. Small interposed question for understanding. How is the trend value calculated?
For example [last15m_th0_temp_trend]. Is the average of the last 15 minutes compared with the current? But this don“t work with the last24h value, because I would get -1 at night and +1 during the day. So how does it work?

Sorry for my bad English :blush:

Re:Weather Synopsis

Posted: Sun Nov 22, 2009 8:36 pm
by cbhiii
You should use "last24h" for all trend variables. This was an error on my part. Use "last24h" and it should work fine.

Re:Weather Synopsis

Posted: Sun Nov 22, 2009 8:46 pm
by bensca
Yes, but how is this value calculated?

Re:Weather Synopsis

Posted: Sun Nov 22, 2009 8:50 pm
by cbhiii
I do not know the algorithm. This is either from the weather station unit or the Meteohub software.

Re:Weather Synopsis

Posted: Sun Nov 22, 2009 8:54 pm
by bensca
Does the value -1 (last24h) mean that it is now colder than the same time yesturday? Or does it mean that it is currently colder than the average temperature of the last 24 hours.

Re:Weather Synopsis

Posted: Sun Nov 22, 2009 9:07 pm
by cbhiii
It is not looking at the value from yesterday, but I don't know how it decides the temp trend.

Re:Weather Synopsis

Posted: Sun Nov 22, 2009 9:31 pm
by bensca
ok, thanks. Perhaps Boris can give his comment to it :)

Re:Weather Synopsis

Posted: Mon Nov 23, 2009 12:48 am
by cbhiii
Yeah, I would like Boris to comment, because I'm using "Last24h" now and the temps are falling, but the trend says rising (1). The "last60m" reading appears to be correct now.

Boris?