WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Topic started by: CrondallWeather on November 21, 2021, 04:27:57 AM

Title: Relayweather World Weather Extremes Reporting Zero Data
Post by: CrondallWeather on November 21, 2021, 04:27:57 AM
Hi All,

After many years of working flawlessly I noticed this week that no data was now being found.

I've not made any changes and my source file is https://crondallweather.co.uk/worldextremes.php

Which is then producing the result in the attachment.

Looking at the script the source file for the data is

Code: [Select]
/////////////////////////////////////////////////////////////////////////////
// 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";
/////////////////////////////////////////////////////////////////////////////

Any help on the required tweaking would be great, as I can see that the data is still there on the ogimet.com site.

Many thanks

Neil
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: CrondallWeather on November 21, 2021, 11:18:12 AM
Just to add the raw data all appears to still be available on the site (see attachment)

Here's the link

http://www.ogimet.com/cgi-bin/gsynext?lang=en&state=United+K&rank=15&ano=2021&mes=11&day=21&hora=06&Send=send

So hopefully someone can point me to the tweaks I need to make

Many thanks

Neil


Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: saratogaWX on November 21, 2021, 05:00:42 PM
I don't have a fix for the original Relayweather script, but I do have a world extremes script using NOAA data:

https://saratoga-weather.org/scripts-NWSmisc.php#NWSEXTR
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: CrondallWeather on November 22, 2021, 08:31:43 AM
Ah, that's a shame, but thanks for checking Ken.

I'll download your new script now and have a play  [tup]

Thanks again

Neil
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: CrondallWeather on November 22, 2021, 12:05:42 PM
Hi Ken,

Working well for World, USA and also for my selection of "United Kingdom" as the country.

And apologies if this is obvious, as I've unsuccessfully tried a few things, but if I wanted to show more than one country is that also possible?

And is it possible to group countries, for example "Europe", to then show that as a separate set of data points also?

Many thanks

Neil

Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: saratogaWX on November 22, 2021, 12:35:39 PM
You can select multiple countries (or for the USA, states) one at a time by invoking the internal function scan_for() multiple times with different arguments and placing in different return variables.

So, for my https://saratoga-weather.org/wxextremes.php page, the following code is used:

Code: [Select]
<?php include_once('worldextremes.php');
print 
"<div class=\"story\">\n";
print 
"<h1>Weather Extremes for $reportDate</h1>\n";
print 
"<p>&nbsp;</p>\n";
gen_display('World'." (omitting $omittedCountry)",$worldhigh,$worldlow,$worldprecip);

gen_display('Canada',$countryhigh,$countrylow,$countryprecip);

gen_display('USA (lower 48)',$usahigh,$usalow,$usaprecip);

list(
$glhigh,$gllow,$glprecip) = scan_for($worldStations,'United States','AK',$tUOM,$rUOM);
gen_display('Alaska'."",$glhigh,$gllow,$glprecip);

gen_display('California',$statehigh,$statelow,$stateprecip);

list(
$glhigh,$gllow,$glprecip) = scan_for($worldStations,'United States','HI',$tUOM,$rUOM);
gen_display('Hawaii'."",$glhigh,$gllow,$glprecip);

print 
'<p><small><strong>Data from <a href="https://www.cpc.ncep.noaa.gov/products/cadb/">NOAA Climate Prediction Center</a>.  ';
print 
'worldextremes.php script by <a href="/scripts-NWSmisc.php#NWSEXTR">Saratoga-weather.org</a></strong></small><br/>'."\n";
print 
"Raw-data CSV file <a href=\"".gen_url($utcUse)."\">Download</a></p>\n";

print 
"</div>\n";

function 
gen_display($legend,$hightemp,$lowtemp,$precip) {
print "<h2>$legend</h2>\n";
print "<table style=\"border: none;\">\n";
print "<tr><td><span style=\"color: red\"><strong>High Temperature:</strong></span></td><td>$hightemp</td></tr>\n";
print "<tr><td><span style=\"color: blue\"><strong><br/>Low Temperature:</strong></span></td><td><br/>$lowtemp</td></tr>\n";
print "<tr><td><span style=\"color: green\"><strong><br/>Precipitation:</strong></span></td><td><br/>$precip</td></tr>\n";
print "</table>\n";
print "<p>&nbsp;</p>\n";
}
?>


You can run worldextremes.php?list on your site to see the current listing of countries and counts of observations available.
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: CrondallWeather on November 23, 2021, 07:51:29 AM
Thanks for your patience on this Ken, but I'm struggling to get the multiple country data to populate.

I've put in for example

Code: [Select]
list($glhigh,$gllow,$glprecip) = scan_for($worldStations,'Austria','Australia',$tUOM,$rUOM);
gen_display('Austria'."",$glhigh,$gllow,$glprecip);
gen_display('Australia',$glhigh,$gllow,$glprecip);

In order to show the data for Austria followed by Australia, but just blank data is appearing as you can see on the attachment.

Would really appreciate it if you could guide me a little further....

Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: saratogaWX on November 23, 2021, 10:12:23 AM
The call to scan_for() needs to be just a bit different:

Code: [Select]
list($glhigh,$gllow,$glprecip) = scan_for($worldStations,'Austria','',$tUOM,$rUOM);
gen_display('Austria'."",$glhigh,$gllow,$glprecip);
list($glhigh,$gllow,$glprecip) = scan_for($worldStations,'Australia','',$tUOM,$rUOM);
gen_display('Australia',$glhigh,$gllow,$glprecip);
The 3rd argument to the call is the abbreviation for a USA State name, otherwise it has to be '' for a country name.  Only one country name per call, with a corresponding gen_display() just after it.
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: CrondallWeather on November 24, 2021, 11:32:14 AM
Works like a dream - perfect  [tup]

Thanks ever so much Ken - really appreciated
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: 92merc on November 24, 2021, 12:38:34 PM
Texas airport must be having a malfunction.  It was NOT -31 2 days in a row.

Low Temperature:   
-31°F at Granbury Municipal Airport, TX
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: saratogaWX on November 24, 2021, 12:47:35 PM
Yep.. looks broken to me.

Add them to the worldextremes.php script ignore list
Code: [Select]
$ignoreStations = array('99KLRJ','99KWVI','99KGAD','99KGDJ');     // list of stn_id (field 0) to ignore for bogus data
and Mt. Washington shows up instead.
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: 92merc on November 24, 2021, 12:51:38 PM
Yep, that looks better.  Thanks.
Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: CrondallWeather on November 25, 2021, 03:42:28 AM
Ken, I wonder if a further refinement is possible?

Understand totally why we may wish to exclude Antarctica and Greenland from the World data, but a consequence of putting them into the $ignoreCountrys array, means that we can't then show that data as a separate country.

As far as I can tell to show, say Greenland, as a separate country I have to exclude it from the array.

Is there a way to have it included in the excluded array, and also be able to show it as a separate country?

Reason being is that the North and South extremities are interesting in their own right, but I also agree we don't always want them dominating the World cold extremes.

Many thanks

Neil

PS:
Don't worry if this is messing about as I'm very happy with the end result as it is :grin:
https://crondallweather.co.uk/latest-extreme-weather-conditions-from-the-uk-and-around-the-world/

Title: Re: Relayweather World Weather Extremes Reporting Zero Data
Post by: saratogaWX on November 25, 2021, 11:18:32 AM
Sure.. you can reset the $ignoreCountrys just before you scan_for('Antarctica'...) or 'Greenland')

Code: [Select]
$ignoreCountrys = array();
list($glhigh,$gllow,$glprecip) = scan_for($worldStations,'Antarctica','',$tUOM,$rUOM);
gen_display('Antarctica'."",$glhigh,$gllow,$glprecip);
list($glhigh,$gllow,$glprecip) = scan_for($worldStations,'Greenland','',$tUOM,$rUOM);
gen_display('Greenland',$glhigh,$gllow,$glprecip);

If you have more scan_for() after that, you can restore the original omit array by using
Code: [Select]
$ignoreCountrys = array('Antarctica','Greenland');