WXforum.net

Web Weather => Weather Website PHP/AJAX scripting => Custom Website Templates => Topic started by: saratogaWX on January 06, 2021, 03:08:12 PM

Title: Saratoga Base-USA update-add animated GIF regional radar
Post by: saratogaWX on January 06, 2021, 03:08:12 PM
I found that https://aviationweather.gov/radar offered regional radar images similar to the ones that were available on radar.weather.gov before their 'makeover' in December, 2020.  I've created a new script (NWS-regional-radar-animate.php) to fetch/annotate/cache the selected image set and create an animated GIF.  Since the regions now used are somewhat different than the old region graphics used on radar.weather.gov, some other mods were made to USA-regional-maps-inc.php to support new region designations if needed.

Note that NWS-regional-radar-animate.php DOES NOT load Settings.php (to improve speed with some Plugins), so when you install,
be sure to check the internal settings to match your current site settings.. especially cache file directory and timezone.

At the same time, I've decided to deprecate (and mark for removal) the HAniS based wxnwsradar-*.php scripts as they no longer have source data to work with on radar.weather.gov.  A V2.00 of wxnwsradar.php will just display your selected regional radar GIF and a USA (CONUS) animated GIF.

The README file has additional details, and there's a PDF showing the old and new 'regions' for the NWS regional radars.

Update using the update tool (https://saratoga-weather.org/wxtemplates/updates.php) with query Base-USA, Plugin-*, 06-Jan-2021
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: CNYWeather on January 06, 2021, 03:15:41 PM
Hey Ken.

Trying to get the regional radar the image is blank and I get this on the end of the URL with the region blank.

.........../NWS-regional-radar-animate.php?region=

Here's my region settings:

Code: [Select]
$NWSregion = 'alb'; // see below $validRegions entries for valid regions to use
# Note: 2 letter old $NWSregion regions will be translated to 3 letter regions
#
# 'ak', 'hi', 'carib' sites are not displaying data on aviationweather.gov site
#
# Select radar type:
$NWStype = 'cref';  // ='rala' for 'Reference at low altitude'
#                   // ='cref' for 'Composite Reflectivity'
#                   // ='tops-18' for 'Echo Tops - 18dbz'
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: saratogaWX on January 06, 2021, 03:19:36 PM
Do you have in Settings.php
Code: [Select]
$SITE['NWSregion'] = 'alb'; .. if not, add that setting.

The USA-regional-maps-inc.php script will honor the $SITE['NWSregion'] setting.
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: CNYWeather on January 06, 2021, 03:25:44 PM
I didnt have $SITE['NWSregion'] in my settings. Added it and all set. THANK YOU!
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: gwwilk on January 06, 2021, 06:56:05 PM
Thanks, Ken!  Up and running on my website.

Your fine work is very much appreciated, as always. =D> \:D/ =D>
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: gwwilk on January 07, 2021, 11:23:43 AM
I've refrained from creating a universal-access script in order to avoid an inordinate number of accesses to the hosting site.  The NOAA/NWS gate-keepers have been known to retaliate...
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: saratogaWX on January 07, 2021, 02:36:42 PM
I've been able to adapt my old national/regional radar page to the new ones that Ken found.
Cannot get animated gifs out of their code but the static images work pretty good for now.
Thanks Ken for the discovery of the images.

http://vermilionweather.com/radarsnationalpage.php (http://vermilionweather.com/radarsnationalpage.php)
I've refrained from creating a universal-access script in order to avoid an inordinate number of accesses to the hosting site.  The NOAA/NWS gate-keepers have been known to retaliate...
The NWS-regional-radar-animate.php script was intended to be used to provide an animated GIF for display via a <img src=...> for a website.
The cache life of 600 seconds ensures that most accesses to the script will result in the cached GIF being returned.  When a cache expires, it will take 3-5 seconds to load the HTML and 15 images from aviationweather.gov, save the annotated individual GIFs and combine them to make a single animated GIF.  It should not run afoul of future NWS-imposed limits on accesses as it only uses 16 HTTPS queries to produce the animated GIF, and that happens only every 5 minutes.

Jerry's comment is very apt .. we need to be aware that the NWS is going to limit accesses (likely at 60/minute) from a single IP address as that will be done via their load balancer hardware .. they haven't engaged it yet, but are likely to engage it this spring.

So, I'd strongly recommend that you NOT try to create any more than two regional radar animated GIFs on your site using the script.  I did change the wxnwsradar.php script distributed in Base-USA to remove the (now defunct) HAniS animations from radar.weather.gov to use this simple code to display the selected regional radar and a CONUS radar as animated GIFS.

Code: [Select]
<div id="main-copy">
  <div align="center">
  <?php if(file_exists('NWS-regional-radar-animate.php')) { ?>
  <h2 align="center">Regional Radar Loop</h2>
  <img src="NWS-regional-radar-animate.php?region=<?php echo $SITE['NWSregion']; ?>" alt="Regional Radar" width="620"/> 
   
  <h2 align="center">USA (CONUS) Radar Loop</h2>
  <img src="NWS-regional-radar-animate.php?region=us" alt="USA (CONUS) Radar" width="620"/> 
  <?php } else { ?>
  <h2>The NWS Regional Radar Loop displays are not available.</h2>
  <p>The <i>NWS-regional-radar-animate.php</i> script was not found.</p>
  <?php ?>
   
  </div><!-- end align=center -->
</div><!-- end main-copy -->
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: JupiterJoe on January 09, 2021, 11:14:34 AM
Hi Ken,
The script is great, thank you, it works well and looks good.
I had one question. Is there a way to get the image to load after the Ajax starts loading? The site waits to update weather data until after that image loads. It’s no problem now, but I was thinking ahead if there was ever a problem with their site or whatever that it could hang the weather data until after that image loads. I hope this makes sense.
Thank you for any advice!

www.JupiterWX.com
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: gwwilk on January 09, 2021, 11:27:51 AM
Hi Ken,
The script is great, thank you, it works well and looks good.
I had one question. Is there a way to get the image to load after the Ajax starts loading? The site waits to update weather data until after that image loads. It’s no problem now, but I was thinking ahead if there was ever a problem with their site or whatever that it could hang the weather data until after that image loads. I hope this makes sense.
Thank you for any advice!

www.JupiterWX.com
I'll jump in here, Joe.  Your site's testtags.php loads immediately.  What delays a few seconds are the clientraw.txt updates.  I don't think this is a very high price to pay in order to have the regional radar on our dashboards.
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: saratogaWX on January 09, 2021, 11:50:45 AM
Hi Joe,
You might want to look at https://developer.mozilla.org/en-US/docs/Web/Performance/How_browsers_work for details about how the page is loaded and rendered in the browser.  One reason for the slower start to display updated weather data is due to the ajaxWDwx3.js AJAX script -- it is very much larger than the stock ajaxWDwx.js script, so takes longer to load/parse/execute (but is required to use the alt ajax-dashboard you are using).   There are several scripts that produce images on the page (and are invoked by <img> statements (the regional radar animation, cloud height, heaven-pie), but the browser loads images (along with CSS files) in parallel, generally 4 concurrent loads at a time.  Rendering of the page starts at the top of the HTML, and each JavaScript encountered has to be loaded/parsed/executed in the order it is seen.  The background CSS and image loads can take place then, but won't be fully 'revealed' until the page is fully processed.

I hope this helps...
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: JupiterJoe on January 09, 2021, 12:20:14 PM
Thank you.
Gwwilk, I wasn’t complaining, not even a little. I appreciate the work you do and I don’t think it’s a high price to pay at all. I was just curious if there was a way to change load order is all.


Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: saratogaWX on January 26, 2021, 05:09:39 PM
I've done a minor update to NWS-regional-radar-animate.php V1.02 to add error messages to the "Not Available" image to help in diagnosing issues.

Also.. looks like the aviationweather.gov site has started producing Hawaii, Alaska and Caribbean 'rala' images on 26-Jan-2021.
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: gwwilk on October 17, 2023, 02:51:57 PM
Sadly, the NWS Aviation Weather page (https://aviationweather.gov/) has been 'updated' by the NWS so the animated GIF regional radar is no longer functional.

Does anyone have a solution to this problem since NWS-regional-radar-animate.php (https://gwwilkins.org/NWS-regional-radar-animate.php) yields zilch?  There's a hole where this animated GIF used to be on my main page: https://www.gwwilkins.org
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: saratogaWX on October 17, 2023, 03:17:28 PM
Yes, aviationweather.gov implemented a new website design on 16-Oct-2023 and broke a bunch.  They aren't offering all that was available on the old site, and no more radar snapshot images to animate.

I suggest you use the USA-regional-maps-inc.php as a guide to replace the old animated image with the ones from radar.weather.gov.
Note that the WU IR satellite image is often flaky as their animated GIF production seems to stall-out frequently.
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: gwwilk on October 17, 2023, 03:24:18 PM
I found a substitute animation.  Check out my dashboard at https://www.gwwilkins.org  The reference is in my attribution to Monster Radar.

The change needed to be made in my index.php  It took me a while to find it because it has been years since I worked with it.  :oops:
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: rrrick8 on October 17, 2023, 07:21:07 PM
I found a substitute animation.  Check out my dashboard at https://www.gwwilkins.org  The reference is in my attribution to Monster Radar.

The change needed to be made in my index.php  It took me a while to find it because it has been years since I worked with it.  :oops:

Don't see it.
Title: Re: Saratoga Base-USA update-add animated GIF regional radar
Post by: gwwilk on October 17, 2023, 08:45:37 PM
Hmmm.  Interesting.  Try it now.