Skip to content

Generate a GRLevelX placefile from the NOAA AHPS river/stream level observations

License

Notifications You must be signed in to change notification settings

ktrue/ahps-placefile

Repository files navigation

ahps-placefile

GRLevelX placefile generator for AHPS data from NOAA-AHPS stream gauge levels

Purpose:

This script set gets AHPS data from water.noaa.gov and formats a placefile for GRLevelX software to display icons for stream gauge levels/alerts, and mouse-over popups with text for the current observation from the gauge.

One script is to run via cron to gather the data routinely (get-ahps-levels.php).

The ahps-placefile.php script is to be accessed by including the website URL in the GRLevelX placefile manager window. The ahps-placefile-alerts.php will display only gauges with alerts (Low Levels, Near Flood, Minor Flood, Moderate Flood, Major Flood).

Scripts:

get-ahps-levels.php

This script reads the GIS JSON data from https://mapservices.weather.noaa.gov/eventdriven/rest/services/water/ahps_riv_gauges/MapServer and creates the ahps-levels-inc.php file which contains the parsed and formatted gauge data for each gauge.

It should be run by cron every 15 minutes to keep the data current. Keep in mind that many gauges report only once per hour so loading more often won't result in 'new' data.

ahps-placefile.php

This script generates a GRLevelX placefile from the ahps-levels-inc.php file on demand by a GRLevel3 instance. It will return gauge icons with popup info for each guage within 250 miles of the current radar selected in GRLevel3. It requires the following file:

  • ahps-levels-inc.php (produced by get-ahps-levels.php for the current gauge data)

The script uses 1 icon file: ahps-icons-sm.png

If you run the script for debugging in a browser, add ?dpi=96&lat={latitude}&lon={longitude} to the ahps-placefile.php URL so it knows what to select for display.

Additional documentation is in each script for further modification convenience.

Installation

Change the date_default_timezone_set('America/Los_Angeles'); to your timezone in ahps-placefile.php, and ahps-placefile-alerts.php; and $ourTZ = 'America/Los_Angeles'; in get-ahps-levels.php to your timezone if needed.

Upload the following files in a directory under the document root of your website. (We used 'placefiles' in the examples below)

  • get-ahps-levels.php
  • ahps-placefile.php
  • ahps-placefile-alerts.php
  • ahps-icons-sm.png

Set up cron to run get-ahps-levels.php like:

*/15 * 1 * * * cd $HOME/public_html/placefiles;php -q get-ahps-levels.php > ahps-status.txt 2>&1

be sure to change the public_html/placefiles to the directory where you installed the scripts.

Run the script once (to generate data) by https://your.website.com/placefiles/get-ahps-levels.php

Then you can test the metar-placefile script by using your browser to go to https://your.website.com/placefiles/ahps-placefile.php?dpi=96&lat=37.0&lon=-122.0

If that returns a placefile, then add your placefile URL into the GRLevelX placefile manager window.

Sample ahps-placefile.php output:

; placefile generated by ahps-placefile.php V1.00 - 24-Jul-2023 - [email protected]
; Generated on Wed, 26 Jul 2023 13:34:06 +0000
;
Title: AHPS Observations - Wed, 26 Jul 2023 13:34:06 +0000 
Refresh: 7
Color: 255 255 255
Font: 1, 12, 1, Arial
IconFile: 1, 20, 20, 10, 10, "ahps-icons2-sm.png"
Threshold: 999

; generate AROC1 Pajaro River at Chittenden at 36.900231,-121.597722 at 24 miles SE 
Object: 36.900231,-121.597722
Threshold: 999
Icon: 0,0,000,1,5,"ID: AROC1 Pajaro River at Chittenden(CA)\n   (36.900231,-121.597722)\n----------------------------------------------------------\nTime: 24-Jul-2023 11:30pm UTC (23:30Z)\nStatus: No Flooding\nLevel:  2.36 ft\n\nACT Stage:  25.00 ft\nFLD Stage:  32.00 ft\nMOD Stage:  32.50 ft\nMAJ Stage:  33.10 ft\n----------------------------------------------------------"
End:

; generate ARRC1 Arroyo Seco (Monterey) at Greenfield at 36.237462,-121.481603 at 67 miles SSE 
Object: 36.237462,-121.481603
Threshold: 999
Icon: 0,0,000,1,5,"ID: ARRC1 Arroyo Seco (Monterey) at Greenfield(CA)\n   (36.237462,-121.481603)\n----------------------------------------------------------\nTime: 24-Jul-2023 11:15pm UTC (23:15Z)\nStatus: No Flooding\nLevel:  4.00 ft\n\nACT Stage:  13.00 ft\nFLD Stage:  n/a\nMOD Stage:  15.00 ft\nMAJ Stage:  n/a\n----------------------------------------------------------"
End:

Sample Display on GRLevel3

sample-output

Acknowledgements

Special thanks to Mike Davis, W1ARN of the National Weather Service, Nashville TN office for his testing/feedback during development.

About

Generate a GRLevelX placefile from the NOAA AHPS river/stream level observations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages