NEW ! - IMPROVED, Low Carbon, Eco friendly, nut free, self healingOK Ver #3 now available ...Currently being "field tested" and evaluated - available from link on first post or
from hereHumungous amount of beteljuice logic to store "this" server day and "tomorrow" (when available) server day historic temp data from NOAA.
As well as identifying correct parts of report to 'scrape', it will also try to 'heal' any missing data / data lines.
This is a bit confusing because NOAA say "report for (date) ..." then refers relatively to the report
created date (eg. yesterday, today, tomorrow).
In the case where local server day has rolled over, but report
created date has not - the references are incorrect.
Further - there is at least one location where for eight hours or more each day there are two lines of data completely missing (and of course one of them is what we want)
All far too lengthy to explain fully in a meaningful way - but if you're interested see the real life example below of two consecutive reports, one of which has incomplete data, and how the program handles the situation ...
A report just after 00:00 local .. (but still being 'published' for 8 hours plus)
Local Server Time NOW: Friday
5th of July 2019
07:24:52
AM CDT, America/Mexico_City - UTC -05:00
CLIMATE REPORT
NATIONAL WEATHER SERVICE NASHVILLE TN
12:10 AM CDT FRI
JUL 5 2019
...
...THE NASHVILLE CLIMATE SUMMARY FOR
JULY 4 2019...
[program decides: recDay: 4, serverDay: 5, Tomorrow: 6, Use second block]...
[1st block]WEATHER ITEM OBSERVED TIME RECORD YEAR NORMAL DEPARTURE
VALUE (LST) VALUE VALUE FROM
NORMAL
...............................................................
TEMPERATURE (F)
YESTERDAY
[program decides: correct, day(4) not wanted] MAXIMUM 91 1214 PM 103 2012 89 2
MINIMUM 71 302 AM 55 1968 69 2
AVERAGE 81 79 2
...
[2nd block] THE NASHVILLE CLIMATE NORMALS FOR TODAY
[program decides: correct, day(5) already stored, but checked for any missing values] NORMAL RECORD YEAR
MAXIMUM TEMPERATURE (F) 89 104 2012
MINIMUM TEMPERATURE (F) 69 54 1968
[program decides: NO genuine Tomorrow day(6) Data Available, only Ring NOAA upto once per hour] Now a report
09:00 local that has problems ... (still being 'published' upto 17:00 local - 8hrs)
Local Server Time NOW: Friday
5th of July 2019
10:48:49
AM CDT, America/Mexico_City - UTC -05:00
CLIMATE REPORT
NATIONAL WEATHER SERVICE NASHVILLE TN
9:22 AM CDT FRI
JUL 5 2019
...THE NASHVILLE CLIMATE SUMMARY FOR
JULY 5 2019
VALID AS OF
0900 AM LOCAL TIME.
[program decides: recDay: 5, serverDay: 5, Tomorrow: 6, Use first block]...
[1st block]
TEMPERATURE (F)
TODAY
[program decides: correct, day(5) already stored, but checked for any missing values][ALL MAXIMUM TEMP DATA MISSING !!] MINIMUM 72 512 AM 54 1968 69 3
[ALL AVERAGE TEMP DATA MISSING !!] PRECIPITATION (IN)
TODAY 0.00 3.33 1950 0.12 -0.12
[program decides: use stored day(5) in cache-file]...
[2nd block]THE NASHVILLE CLIMATE NORMALS FOR TOMORROW
[program decides: correct, day(6) store in cache-file] NORMAL RECORD YEAR
MAXIMUM TEMPERATURE (F) 89 105 2012
MINIMUM TEMPERATURE (F) 69 54 1972
[program decides: Now we have complete data for day(5), day(6) stored in cache-file, - don't Ring NOAA until day(6) (when we look for day7 data)]It's pretty much impossible to second guess all the possible NOAA responses to report errors, but hopefully in the majority of cases this prog allows for upto 48 hours of NOAA 'failure' as long as your site has a visitor in the morning and one at night
For those already using this prog noaarec.php is a direct compatible replacement.
noaarecdat.
.php on your server is now redundant and may be deleted.
New noaarecdat
.txt will be created / maintained.