Author Topic: NWS CPC USA Extremes Script Update...  (Read 1940 times)

0 Members and 1 Guest are viewing this topic.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2361
    • SouthEast Lincoln, NE Weather
Re: NWS CPC USA Extremes Script Update...
« Reply #25 on: April 01, 2020, 06:13:39 AM »
This script is Ken True's, and I'm not capable of fixing it.  Therefore I'm going to abandon it for now.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline mth

  • Member
  • *
  • Posts: 38
    • Relay, Maryland Weather
Michael Holden
Relay, Maryland Weather Station
http://www.relayweather.com
Davis Vantage Pro 2  -  Model 6153
 


Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8114
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS CPC USA Extremes Script Update...
« Reply #27 on: April 01, 2020, 11:58:16 AM »
I'll take a look at alternative sourcing for the data for the usaextremes and stateextremes scripts since I seem to have adopted them...

Looks like the https://www.cpc.ncep.noaa.gov/products/cadb/ will be the new source, but I have to write some shim code to get the new file and use the .CSV format instead of fixed-width text for the scripts.  The raw .csv files are available via https, but.. they have year/month/day as part of the directory structure and filenames, so just a bit more tricky than the old fixed URL.

I'm on it :)
« Last Edit: April 01, 2020, 01:23:12 PM by saratogaWX »
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 949
    • Southern Maryland Weather
Re: NWS CPC USA Extremes Script Update...
« Reply #28 on: April 02, 2020, 10:59:01 AM »
I have re-written the existing script to grab those numbers for now. you can see it on my page... I'm sure Ken will have something alot nicer then what i have done but at least it is a temporary fix...

https://somdweather.com/somd_usaextremes3.php

« Last Edit: April 02, 2020, 01:13:43 PM by SoMDWx »
Jim Wyman
Southern Maryland Weather
http://somdweather.com
http://scit.somdweather.com

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8114
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS CPC USA Extremes Script Update...
« Reply #29 on: April 04, 2020, 01:52:39 PM »
I've done a rewrite of usaextremes.php (including the function of stateextremes.php) as a new worldextremes.php (V5.00 - 04-Apr-2020).

The expanded script now uses the CSV files from https://www.cpc.ncep.noaa.gov/products/cadb/ which includes worldwide data.
A small caveat however, the data is NOT WELL PROOFED so you can get some max/min temperatures for a station showing >25C differences.
The script already filters out >40C differences (configurable).

Now the following variables are returned:
Quote
$omittedCountry (text list of countries excluded from $world high/low/precip scans)
Note: the setting $ignoreCountrys is the array of country names to to exclude
$worldhigh
$worldlow
$worldprecip

$selectedCountry (setting: country name for selected country high/low/precip)
Note: run http://your.site.com/worldextremes.php?list to see the list of country names to use
$countryhigh
$countrylow
$countryprecip

$usahigh (Note: for lower-48 USA states)
$usalow (Note: for lower-48 USA states)
$usaprecip (Note: for lower-48 USA states)

$selectedState (setting: USA state 2-character name abbreviation in settings area)
$selectState (a copy of $selectedState for compatibility with old stateextremes.php)
$statehigh
$statelow
$stateprecip

$reportDate (nicely formatted date of the report)
$stateReportDate (a copy of $reportDate for compatibility with old stateextremes.php)

To replace the usaextremes.php (and stateextremes.php) just use include_once("worldextremes.php") and comment out/remove the include for stateextremes.php.

See the docs at https://saratoga-weather.org/scripts-NWSmisc.php#NWSEXTR which has the download link for the script.

Many thanks to Jim (SoMDWx) for his assistance with this script!  =D>  \:D/

Best regards,
Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SoMDWx

  • Forecaster
  • *****
  • Posts: 949
    • Southern Maryland Weather
Re: NWS CPC USA Extremes Script Update...
« Reply #30 on: April 04, 2020, 02:05:57 PM »
Thanks Ken! Awesome work as usual...:)
Jim Wyman
Southern Maryland Weather
http://somdweather.com
http://scit.somdweather.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2361
    • SouthEast Lincoln, NE Weather
Re: NWS CPC USA Extremes Script Update...
« Reply #31 on: April 04, 2020, 06:33:39 PM »
 [tup]
Much appreciated, Ken!
 =D>
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline colonieweather

  • Contributor
  • ***
  • Posts: 118
    • Colonie Weather Online
Re: NWS CPC USA Extremes Script Update...
« Reply #32 on: April 05, 2020, 09:58:22 AM »
Thank you Ken.  The work you do is much appreciated!
Davis Vantage Pro 2 Plus
WeatherLink v6.0.5
colonieweatheronline.com
Wx Underground - KNYCOLON3
APRS/CWOP - EW0288

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8114
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS CPC USA Extremes Script Update...
« Reply #33 on: April 05, 2020, 10:57:03 AM »
You are all welcome!  I did a slight update to V5.01-05-Apr-2020 today.  Iddaly noted that the array_key_first() function I'd used is a PHP7+ only function.  The V5.01 script replaces that with PHP5+ calls to array_keys()/array_pop() so the script should work on all versions of PHP from 5.x up.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2361
    • SouthEast Lincoln, NE Weather
Re: NWS CPC USA Extremes Script Update...
« Reply #34 on: April 05, 2020, 11:31:50 AM »
Thanks, Ken!  My testing site bombed out while my web site and my localhost worked.  Now my testing site works with v5.1!  I obviously haven't updated my Debian server to a PHP 7.x version.
« Last Edit: April 05, 2020, 11:33:57 AM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline lddaly

  • Forecaster
  • *****
  • Posts: 485
Re: NWS CPC USA Extremes Script Update...
« Reply #35 on: April 05, 2020, 09:16:55 PM »
You are all welcome!  I did a slight update to V5.01-05-Apr-2020 today.  Iddaly noted that the array_key_first() function I'd used is a PHP7+ only function.  The V5.01 script replaces that with PHP5+ calls to array_keys()/array_pop() so the script should work on all versions of PHP from 5.x up.

Thank you, Ken! Works perfectly. [tup] https://www.planoweather.com/wxextremes.php

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8114
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS CPC USA Extremes Script Update...
« Reply #36 on: June 25, 2020, 08:43:59 PM »
A slight update to V5.02 - 25-Jun-2020.  The CPC added a station_id column to the CSV file (drat).

Download from the script page and recustomize as needed.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PSJohn

  • Senior Contributor
  • ****
  • Posts: 155
    • DesertWeather.com
Re: NWS CPC USA Extremes Script Update...
« Reply #37 on: June 26, 2020, 12:25:12 AM »
Thanks for the update Ken.
Has anyone notice the frequent data error from this one site:

   High Temp:   124F at Le Mars Municipal Airport, IA


Anyway to exclude this?
John Slama
Palm Springs, California
Davis Vantage Pro 2, FARS

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8114
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS CPC USA Extremes Script Update...
« Reply #38 on: June 26, 2020, 11:17:35 AM »
Just updated to 5.03 -- it now has a $ignoreStations array to select a stn_id to ignore for bogus data.  I've added in the Le Mars one as the initial one to ignore.
Download 5.03 from the script page and customize as needed.

I do wish the CPC would screen/sanity check those reports.  50C/124F for a High in Iowa for several days running???
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline SteveFitz1

  • Forecaster
  • *****
  • Posts: 410
    • Tyler Texas Weather
Re: NWS CPC USA Extremes Script Update...
« Reply #39 on: June 26, 2020, 12:02:31 PM »
I do wish the CPC would screen/sanity check those reports.  50C/124F for a High in Iowa for several days running???

And -17C/1F for a low at Camp David, MD (99KRSP) this morning is quite a stretch as well.

Steve

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8114
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS CPC USA Extremes Script Update...
« Reply #40 on: June 26, 2020, 12:07:11 PM »
Yes, I just saw (and fixed that) .. they were reporting the same temp for min/max (now the script rejects it).
Also removed the Alaska entries from the Lower 48 Min/Max display.
Download again for the update (version hasn't changed).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8114
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: NWS CPC USA Extremes Script Update...
« Reply #41 on: June 26, 2020, 12:10:49 PM »
I thought y'all might be interested in the code I use on my wxextremes.php page in the <div id="main-copy">...</div> on a copy of wxnewpage.php put
Code: [Select]
<?php include_once('worldextremes.php');
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";

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";
}
?>


Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline PSJohn

  • Senior Contributor
  • ****
  • Posts: 155
    • DesertWeather.com
Re: NWS CPC USA Extremes Script Update...
« Reply #42 on: July 30, 2020, 05:23:45 PM »
Seems that they don't make thermometers that go beyond 118 in the Middle East!  :grin: I see that often as the World Extreme.

 [ You are not allowed to view attachments ]
« Last Edit: July 30, 2020, 05:26:02 PM by PSJohn »
John Slama
Palm Springs, California
Davis Vantage Pro 2, FARS

 

anything