Page 1 of 6
Extreme Weather script(s)
Posted: Sat 22 Aug 2015 3:33 pm
by gluepack
This is a script that I was unaware of until a couple of days ago. It was from relayweather, although I could no longer find it on their website. I can't find any reference to it on the Cumulus forum so, apologies if it is referenced here.
Anyway, I was able to find a copy of the script and incorporated it into my website at...
http://jerbils.info/saratoga/wxextremes.php
There is a "gadget" script too but I haven't installed that.
As the scripts weren't visible at relayweather, I have made them available at my own site...
http://www.jerbils.info/worldextremes.zip
http://www.jerbils.info/worldextremesGadget.zip
I was a bit disappointed that there are only 7 places listed for my country of residence, Bulgaria. I assumed CWOP (which I contribute to) data would be used.
However, I made some mods to make the table length variable, in case the number of places returned was less than the specified max parameter.
To do that I inserted the lines
if($hiextremesLoc[1][$i] === null) break; - immediately prior to the ?> line, around line 274
if($loextremesLoc[1][$i] === null) break; - immediately prior to the ?> line, around line 306
and
if($precipextremesLoc[1][$i] === null) break; - immediately prior to the ?> line, around line 336
...perhaps it could be improved upon but it works
I'm not sure why I get no data for World and Northern Hemisphere. The rest seem to be ok. I have noticed on another site that specifying "world" fails to display any data too so perhaps there is a coding problem or perhaps NOAA have made some access changes.
Re: Extreme Weather script(s)
Posted: Sat 22 Aug 2015 7:53 pm
by PaulMy
Thank you for searching and posting. World and North Hemisphere seems to work for me, as do all the other included areas
http://www.komokaweather.com/komokaweat ... tremes.php.
Paul
Re: Extreme Weather script(s)
Posted: Sat 22 Aug 2015 8:30 pm
by gluepack
Thanks
I wondered whether it was a timeout problem. Those that do show data are almost instant, even after clearing cache, whereas World and Northern Hemisphere display nothing for 12 or 13 seconds before just displaying the surrounding text.
World on your site (for me) takes 20 seconds to display and Northern Hemisphere about 16 seconds initially.
Update: I tried using some code that was applied to a fopen() (the script uses file() but I hoped it would have the same effect) to set the default_socket_timeout and I set the refresh cache to 60 seconds and I managed to see results for World and Northern Hemisphere once for each (out of half a dozen attempts) but that was all so it may have just been coincidence.
Re: Extreme Weather script(s)
Posted: Sat 22 Aug 2015 11:30 pm
by beteljuice
I think I've found a small niggle ...
The number of stations (results) requested has no connection with the $stations var.
Code: Select all
/////////////////////////////////////////////////////////////////////////////
// Site to Parse
$siteSource = "http://www.ogimet.com/cgi-bin/gsynext?lang=en&state=$country&rank=20&ano=$year&mes=$month&day=$day&hora=$hour&Send=send";
/////////////////////////////////////////////////////////////////////////////
This means if you wanted to show more than 20 'results' (&rank=20) the extra data would never be called. In a similar way If you only want to display 15 (default $stations) you are requesting more records than you are displaying.
Fix (untested);
Code: Select all
/////////////////////////////////////////////////////////////////////////////
// Site to Parse
$siteSource = "http://www.ogimet.com/cgi-bin/gsynext?lang=en&state=$country&rank=$stations&ano=$year&mes=$month&day=$day&hora=$hour&Send=send";
/////////////////////////////////////////////////////////////////////////////
Re: Extreme Weather script(s)
Posted: Sun 23 Aug 2015 6:57 am
by gluepack
Well spotted.
I thought that might be something to do with the timeout but, having already tried much smaller numbers for $stations, reducing the number to 5 still resulted in nothing being displayed for World and Northern Hemisphere for me, following a pause of 15-16 seconds.
btw, just specifying,
http://www.ogimet.com/cgi-bin/gsynext in a browser, it takes 30 seconds to respond and lists (a default of) 30 stations for World ranking.
Re: Extreme Weather script(s)
Posted: Sun 23 Aug 2015 1:07 pm
by gluepack
I've updated mine to include all countries by populating the $extremesLocations and $extremesLocNames arrays with the appropriate codes and names.
The only problem I have found so far is that a request for Netherlands picks up both Netherlands and Netherlands Antilles because the code for the former is a subset of the latter. Invariably there are two words in similar circumstances so, for example, USA and UK have codes United+S and United+K whereas these two are Netherland and Netherlands+A (although, having said that, Niger and Nigeria work fine). I have emailed the site owner with details.
I added World, Europe and the two Hemispheres at the end but you can arrange them however you like.
Have placed the cache files in a sub-directory under cache.
If anyone is interested, pm me or, if there is much interest, I guess I could post the arrays here.
Re: Extreme Weather script(s)
Posted: Tue 25 Aug 2015 11:38 am
by pernaczy
gluepack wrote:I've updated mine to include all countries by populating the $extremesLocations and $extremesLocNames arrays with the appropriate codes and names.
If anyone is interested, pm me or, if there is much interest, I guess I could post the arrays here.
Thanks Jerry.
I've installed this script and it works:
http://www.pogoda-niesiolowice.kaszuby. ... nedane.php
Both 'World' and 'Northern Hemisphere' data are being displayed.
BTW. When entering Paul's site I can't see 'World' and 'Northern Hemisphere' data.
Piotr
Re: Extreme Weather script(s)
Posted: Tue 25 Aug 2015 12:40 pm
by gluepack
I'm sure it has to be a timeout issue because, yesterday, I actually got World and Northern Hemisphere data to display.
There are site settings in (my) php.ini but, in the script, my host says...
if you make adjustments to either max_execution_time, max_input_time or memory_limit, you risk getting your account suspended without any further warnings
The values appear to be high enough to not time out though. Mine goes to about 12-15 seconds.
The cache file usually shows text but cuts out before the location data.
When yours displays, how long is there between hitting enter and the data appearing?
Update: Well, that was a silly question, I can test it myself. World took 30 seconds at least. I think you must have a more lenient host.
Re: Extreme Weather script(s)
Posted: Tue 25 Aug 2015 1:22 pm
by PaulMy
Hi Piotr,
My World and Northern Hemisphere do come up in IE10 for me but it takes some time for the initial one. All my others are nearly instant. Your World and Northern Hemisphere come up but takes about 30 secs for each whereas the others are quicker..
Paul
Re: Extreme Weather script(s)
Posted: Tue 25 Aug 2015 1:52 pm
by gluepack
Well, I tried IE to see if it was browser oriented and they still both display after 14-15 seconds with no locations.
I also tried Opera and essentially the same thing although there was a delay each time of a few seconds before Opera responded to the request, then the 14-15 seconds.
btw, I refresh my cache files, if they are more than a minute old. It isn't as if it automatically refreshes the screen. I figure that you are rarely going to want to look at the data for the same country more than once in a reasonable time period and, at least for me, it is pretty unlikely that I will have many people in a day looking at the same location and forcing an update so it is pointless setting it to anything else.
Re: Extreme Weather script(s)
Posted: Tue 25 Aug 2015 4:30 pm
by pernaczy
Hi Paul,
Now it's OK. I can see your 'World' and 'Northern Hemisphere' data after 10-15 second (under Firefox). Jerry's data are still not visible.
Piotr
Re: Extreme Weather script(s)
Posted: Tue 25 Aug 2015 4:54 pm
by gluepack
Bear in mind that, if the site owner (or a visitor) has been able to access the data and the cache file duration is long, you may be able to access it speedily, within that timeframe.
Re: Extreme Weather script(s)
Posted: Wed 26 Aug 2015 1:31 pm
by ace2
I love these scripts and I've got them up and running
http://ace2weather.com/extremes.htm
But I'm finding sometimes the data is incomplete(Australia mainly and others)
It can be missing the rain or only have a few station listed...
Any ideas, I have changed the time zone to Australia, would that have anything to do with it??
Re: Extreme Weather script(s)
Posted: Wed 26 Aug 2015 2:13 pm
by gluepack
I assume you mean date_default_timezone_set('UTC');
Did you check it out with UTC before changing it (or have you rolled back to test it)?
Re: Extreme Weather script(s)
Posted: Wed 26 Aug 2015 2:18 pm
by gluepack
btw rain is missing on some and many places don't have 20 stations, that's why I added the code that I have in my opening post, in order to make the lists variable length.
However, I see what you mean about the missing data, I would try with UTC.
Update: Oh, of course, year month day and hour are passed to the source site so, presumably, no appropriate data exists as you are so far ahead. Look at your header for temp/rain, it shows your date and time but UTC.
Looking at the code for the source site, there is no parameter for timezone so you are stuck with specifying UTC.