Author Topic: OBSOLETE! Scripts to Display CDC Influenza Maps  (Read 12704 times)

0 Members and 1 Guest are viewing this topic.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
OBSOLETE! Scripts to Display CDC Influenza Maps
« on: November 23, 2013, 12:54:21 PM »
Since the flu season is upon us, this set of Saratoga template scripts displays current and past CDC Influenza Activity Maps.  There are two views, the Current Influenza Season which displays maps for the current and past weeks from 2007-2008 through the current Season and week, and Past Influenza Seasons which displays maps for all weeks from 2007-2008 though the most recent complete season.

There are four settings that require configuration: the page width, $divWidth; the image to show when a map is missing from the CDC archive, $missingImage; a flag to determine whether W3C validation is not desired, $invalidOK; and whether to use 'onclick' rather than 'onmouseover' to display new maps, $useOnClick.

I've included a 'missing-piece.jpg' to display when no image is found in the CDC archives for a given week, and I've added it to the 'ajax-images' directory on my site.  You can put it anywhere on your site so long as you include the correct path to the image.  This image will display when 'onerror' is encountered by the JavaScript code.  While all four major browsers currently support this image attribute, W3C's validation does not.  If you desire complete compliance with W3C's validator, set $invalidOK to 'false'.  Using this setting displays the 'alt=' text instead.

The maps are 1132px wide at native resolution.  This is the resolution at which the maps display in the Saratoga template 'widescreen' mode.  At this resolution the hyperlink to 'Larger Map in New Tab' is disabled, but it is active at all smaller resolutions.

When using 'onmouseover' by setting '$useOnClick = false' the map that is immediately displayed will often be the one beneath the dropdown menu's week that is clicked rather than the most recent map.  This is easily remedied by mousing over the desired season's map.  I, for one, get annoyed by repetitive mouse clicks, so I often use the mouseover option in my scripts.  You get to choose your preferred presentation.

I've tried to debug the map changeover to a new year in late December and early January, but this code might need refinement come year's end.  Hence the persistence of some commented out primitive debugging code.  I think the code to display a new map each Friday at 11AM Eastern Time of the most recent week's data is solid, but I'm not quite sure when the CDC posts the new map.  Their site just says 'each Friday'.

The CDC's 'FluView' has been evolving for the past several years, and they aren't nearly as sophisticated as the NWS when it comes to image consistency and thorough archiving of images.  Nevertheless they do deserve credit for compiling the data, creating the maps, and archiving them.

The main two scripts to reference in your menu system are 'wxflumap.php' for the current season and 'wxpastflumap.php' for past seasons.

Thanks to John Gillett for his suggestions and for helping to debug the scripts.

Edit 2014 Jan 14:  There were errors in the coding to determine the current flu season's year so that the years were wrong in several places.  These errors have been corrected in wxflumaps2.zip but bear in mind that only wxflumap.php and inc-flumap.php have changed.  All of the rest of the files are unchanged from the original zip distribution which is no longer available for obvious reasons.

Edit 2014 April 11:  Another error in the coding of the flu maps package has been unearthed.  The Past Flumaps were trying to access a current map in an archive because of a coding error involving the use of the wrong variable.  Also, the lack of parentheses in ternary operator statements could for some web hosts result in no current map display.  Both of these problems have been fixed in wxflumaps2a.zip

Edit 2014 Oct 3:  The start of Influenza season wasn't properly configured in these scripts.  Version 3 fixes this problem.

Edit2 2014 Oct 3:  The start of Influenza season is still not quite right.  Version 3a applies band aids, but only the next few weeks will tell the tale.

Edit 2014 Oct 14:  The first map of the 2014-2015 season has been up for a few days, and version 3a wasn't displaying it.  Version 3b displays it correctly.

Edit 2015 Jan 11:  There have been several problems with this script's displays over the past 3 weeks.  Version 4 attempts to correct them, but there will need to be some changes made to the past flu maps display as well.

Edit 2015 Jan 13:  Version4 didn't display the flu maps correctly again as of today.  Version 4a addresses this problem while the past flu maps haven't been addressed as yet.

Edit 2015 Jan 15:  Versions bombed out today.  Version 3b provides an interim fix for the 'week 53 produced when Jan 3 falls on Saturday' problem.

Edit 2015 Jan 16:  Version 5 contains FluMap and Past FluMap script revisions.  There were a number of factors that required rewriting the scripts, including maps through 2009 using a leading zero to identify maps from week 1 through week 9.  The CDC's map download isn't working today for this year's week 1 map, so I'm not sure what they are doing there.

Edit 2015 Jan 17:  The logic I developed for displaying the past FluMaps for seasons up to 2010 in the Past Maps wasn't carried over into the Current FluMaps script.  This only affects 'inc-flumaps.php' and is corrected in V5a.

Edit 2015 Jan 24:  Getting closer with version 5b.  They reverted to leading zeros in the map week names as of 2015!  Next week may see another change of two after which things should be stable for a while.

Edit 2015 Jan 30:  No surprise, there was a problem displaying this week's map.  Version 5c fixes it.

Edit 2015 Feb 11:  The Past Flumaps display for the 2014-2015 season would have failed next year without modification.  This version, 5D, is supposed to avoid that eventuality.

Edit 2015 May 22:  As anticipated, there are 'end-of-season' problems.  So far the logic that indicated the end of the current flu season has proven to be flawed.  Version 5E corrects this problem.

Edit 2015 May 29:  The last map, week 20, of the current season didn't display with 5E, as anticipated.  Version 5F appears to work correctly in displaying all maps.  As expected the 'Out of Season' message will reappear as this script's output next week.

Edit 2015 June 7:  With the end of the current flu season now past, I wanted to revise the past flu map script so that it would display the season just ended as well as all other prior seasons.  It turned out to be a messy problem, but Version 6 contains a past flu map script that does the trick.  I'm leaving Version 5f up as well because its past flu map script will see all prior seasons except the one just ended.

Edit 2017 May 26:  These scripts are now obsolete in view of the CDC's vastly improved presentation of past and present influenza seasons.  On my site I now just link to the CDC's flu map page.
« Last Edit: May 26, 2017, 10:52:02 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #1 on: December 08, 2013, 12:04:01 PM »
Thanks Jerry for another nice script.  =D>   As of today, Sunday, (12/8/13) the CDC has not updated the map through last Friday as yet. Perhaps not until Monday morning.

Jeff
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #2 on: December 08, 2013, 01:33:33 PM »
Thanks Jerry for another nice script.  =D>   As of today, Sunday, (12/8/13) the CDC has not updated the map through last Friday as yet. Perhaps not until Monday morning.

Jeff

Thanks for the kind words.  To answer your concern, the latest map was posted Friday, Dec. 6, Jeff.  Mouse over the prior years' week 48 and you'll see that the date progresses as you go back in time, until you see it jump back to Nov. 29 in 2008-2009.  A week ago Friday they posted week 47, and this past Friday they posted week 48.

Remember that the data for the prior week ending on Saturday is received by Tuesday the following week in order to be posted on Friday the following week.  Ergo we see week 48 ending on a week from yesterday (Saturday Nov. 30).

I hope my explanation doesn't just add to the confusion... :?
« Last Edit: October 03, 2014, 06:15:19 AM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #3 on: December 09, 2013, 07:43:21 AM »
Jerry,

Perfectly clear ...  \:D/

Jeff
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #4 on: January 12, 2014, 08:20:41 AM »
I finally checked the Flumaps this morning only to discover coding errors regarding the year after 2014 arrived.  These errors have been corrected in wxflumap2.zip attached to the first post above.  The original wxflumap.zip is no longer available.  I may need to revisit these scripts at the start of the 2014-2015 flu season to ensure they're working as intended.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #5 on: April 11, 2014, 08:28:50 PM »
A couple more bugs have emerged in the capable hands of John Gillett.  :-)

The Past Flumaps were trying to access a current map in an archive because of a coding error involving the use of the wrong variable.  Also, the lack of parentheses in ternary operator statements could for some web hosts result in no current map display.  Both of these problems have been fixed in wxflumaps2a.zip above.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline ed2kayak

  • Ed
  • Forecaster
  • *****
  • Posts: 613
  • Davis Vantage Pro2 w/12 hr FARS, solar/uv
    • Cumberland Valley Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #6 on: April 15, 2014, 09:56:43 PM »
Jerry,

Thanks for update!

Ed
Ed
CoCoRaHS PA-CD-6,  Weather Underground KPAMECHA7, CWOP DW5425

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #7 on: October 03, 2014, 06:12:09 AM »
This script was written after the 2013-2014 Influenza season had begun, and it didn't have a lock on the start of a new Influenza season.  It still doesn't, but the attached modified 'wxflumap3.zip' delays the map display until the first full week in October has passed.  Further modifications might be needed...

All previous versions have been removed.

Edit 3 Oct 2104 2:30pm CDT:  The scripts still may not be quite right for the start of the flu season.  Version 3a applies band aids, but might require further attention over the next couple of weeks.

Edit 14 Oct 2014:  The map for week 40 has been up for a few days, but version 3a isn't displaying it.  Version 3b displays it correctly.

Edit 10 Jan 2015:  This version has been deprecated...
« Last Edit: January 11, 2015, 10:00:22 AM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #8 on: January 11, 2015, 09:56:17 AM »
There have been several issues with this script over the past 3 weeks that have required some modifications.  I wasn't aware that on the years where January 3 is a Saturday there is a 'week 53' map produced before the 'week 1' map is made.  This version 4 correctly displays the week 53 maps this week, but because this version displays 'week 53' as 'week 1', I'm not sure what's going to happen next Friday when a new map appears.

This version 4 is very much an interim version that just deals with this year's problem by displaying the same maps for 'week 53' and 'week 1'.  I haven't addressed the problem yet in the past flumaps display.

Edit 2014 Jan 13:  Version4 removed due to errors in display as of today.
« Last Edit: January 13, 2015, 09:50:40 AM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #9 on: January 13, 2015, 09:49:48 AM »
This is still a work in progress.  :-( The current maps in version 4 didn't display correctly today,  #-o so the Version 4a corrects this problem.  More updates are probably on the way as we work our way to the end of this week.  I have as yet to address the past flumaps script.  Version4 has been deleted from the previous post.

Edit 15 Jan 2015:  Version 4a bombed out today.  Use the old Version 3b until I can fix the 'week 53 produced when Jan 3 is a Saturday' problem.

Edit 24 Jan 2015:  Version 3b will NOT display 2015's maps.  Use Version 5b in the first post instead.
« Last Edit: January 24, 2015, 04:31:59 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #10 on: January 15, 2015, 12:09:59 PM »
Jerry,

You're making good progress. Thanks for the updates and devoted time. Much appreciated !!!  =D>

Jeff
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #11 on: January 16, 2015, 02:03:39 PM »
Unfortunately Version 4a bombed out totally today! :sad:

As an interim fix, use the old Version 3b attached.  I'm working, albeit making slow progress, on fixing up the 'week 53 when Jan 3 falls on Saturday' problem.

Edit 2015 Jan 16:  Version 3b removed in favor of Version 5 below.
« Last Edit: January 17, 2015, 02:58:02 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #12 on: January 16, 2015, 03:18:15 PM »
Switched to Version 3b ...

Jeff
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #13 on: January 17, 2015, 03:05:40 PM »
Version 5 contains FluMap and Past FluMap script revisions.  There were a number of factors that required major rewriting of the scripts, including the CDC using a leading zero to identify maps from week 1 through week 9 up until 2010 as well as problems with weeks 53, 1, and 2.

The CDC's map download isn't working today for this year's week 1 map, so I'm not sure what they are doing there.  Another slight revision may be needed once this map appears for download.

Here are the links to my Current Flumaps and my Past FluMaps pages.

Edit 2015 Jan 17:  The logic I developed for displaying the past FluMaps for seasons up to 2010 in the Past Maps wasn't carried over into the Current FluMaps script.  This only affects 'inc-flumaps.php' and is corrected in V5a.

Edit 2015 Jan 24:  Version 5a has been supplanted by 5b because the CDC has reverted to leading zeros in the week numbers as of 2015.

Edit 2015 Jan 30:  Version 5c in the top post fixes the display of today's week 3 map.  Hopefully no further modifications will need to be made (this year anyway).
« Last Edit: January 30, 2015, 05:28:30 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #14 on: January 17, 2015, 03:41:23 PM »
Jerry,

Updated to Version "5". Thanks.

Jeff
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #15 on: January 17, 2015, 03:52:23 PM »
Jerry,

Updated to Version "5". Thanks.

Jeff
I don't think you updated all six scripts, Jeff.  You are missing past maps that should be there.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Breezy

  • Indian Trail Weather
  • Forecaster
  • *****
  • Posts: 325
    • Indian Trail Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #16 on: January 17, 2015, 03:56:52 PM »
It's on the server. Any settings that I need to make?
Jeff

W7-64, Intel Z170A 16 GB RAM
Davis VP2 Plus, Davis Soil Moisture/Temp Sensors, Laser Snow Depth Sensor LR4/Fluke 414D

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #17 on: January 17, 2015, 05:03:09 PM »
It's on the server. Any settings that I need to make?
All's well now,  Jeff. Must have been a cache issue on the server.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 560
    • Up Country Maui Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #18 on: January 18, 2015, 12:00:09 AM »
Hi Jerry,

I was just checking out your flu site and noticed that when I selected either week 1 and week 2 for 2015, above the map shows up as week 1 and week 2 for 2014.  Don't know if the map is correct or not for either for 2014 or 1015 for those two week for those years.

Another tweak, maybe??

I have not implemented this page yet.

Regards,

--Stan Y.
   Maui, Hawaii



Stan Y. - KH6HHG - Maui, Hawaii
 --- Blitzortung ID: 993
 --- FlightRadar24 ID: F-PHOG1

WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
Webcam: Axis 211

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #19 on: January 18, 2015, 12:20:10 AM »
There aren't any maps that are downloadable for those weeks as yet, Stan.  Hence I've omitted the links.  The last link is 2013-2014 for weeks 1 & 2.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Silversword

  • --Stan Y.
  • Forecaster
  • *****
  • Posts: 560
    • Up Country Maui Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #20 on: January 18, 2015, 12:42:43 AM »
Hi Jerry,

That explains the issue.

If/when time permits I will try to set one up on my site.

Thanks for your contributions for this project.

Regards,

--Stan Y.
   Maui, Hawaii
Stan Y. - KH6HHG - Maui, Hawaii
 --- Blitzortung ID: 993
 --- FlightRadar24 ID: F-PHOG1

WDL 6.05
MS Windows 7 Pro
Dell Optiplex GX280-Intel Pentium 4 CPU 3.00GHz, 4 GB RAM
Davis Vantage Pro 2+ Wireless
Webcam: Axis 211

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #21 on: January 18, 2015, 12:52:36 AM »
The logic I developed for displaying the past FluMaps for seasons up to 2010 in the Past Maps wasn't carried over into the Current FluMaps script.  This only affects 'inc-flumaps.php' and is corrected in V5a in the first post above.
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline Gregal

  • Member
  • *
  • Posts: 13
    • Hilltop Inspiration
Re: Scripts to Display CDC Influenza Maps
« Reply #22 on: January 18, 2015, 08:13:29 AM »
Ditto what Stan Y said, I am seeing the same thing as well as when I check SE Lincoln Site I am see the same thing.  See attached screen shot.

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #23 on: January 18, 2015, 08:57:35 AM »
Those maps aren't downloadable right now for some reason.  Week 1 wasn't available when I revised the script Friday, and it still isn't.  The 'Downloadable Version' link for week 1 isn't functioning right now, and I can't find it in the archive.

Once the CDC has things working again, and hopefully they will, I'll revise the script to include the 2014-2015 Weeks 1-20.  There are other ways I could indicate the unavailability of the map(s), and I will if the CDC continues to withhold the 2015 maps, but I doubt they will.  If they withhold the maps from public distribution, the entire 'FluMap' exercise becomes pointless.  The information used to generate the maps comes from thousands of individuals and institutions who have every right to use the maps as they see fit, e.g. in presentations and on their web sites.  These are public not proprietary documents.
« Last Edit: January 18, 2015, 09:06:00 AM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Scripts to Display CDC Influenza Maps
« Reply #24 on: January 24, 2015, 04:27:32 PM »
Version 5b in the first post above displays the current and past year maps.  The CDC reverted to leading zeros in the week number as of 2015.  Yesterday the 2015 week 2 map was rotated 90° clockwise, but it's oriented correctly now.
Regards, Jerry Wilkins
gwwilk@gmail.com

 

anything