Local Radar - KMUX - GRLevel3

Saratoga-Weather.org

Weather station scripts - Buoy Data

They're free, but use at your own risk

The scripts in PHP and Perl referenced here are used in the operation of this weather station, and may be freely copied and used to support your station. Please note that you use these scripts at your own risk. No warranty is expressed or implied. I accept no liability for any damages that may ensue from their use.
You will need to configure them for your own particular station website.
RSS feed for Scripts Updates A RSS Feed is available to help keep you informed on updates to the scripts.

If you find one or more of the scripts useful to you, please consider making a small donation to help offset the routine expenses of operation of this website. Thanks for your kind support!

A Version History is available -- check back from time to time to see if there are updates to scripts you have downloaded earlier. Announcements of version updates and new scripts are made on WXForum.net and Weather-Watch forums as they become available.

This page was updated Thursday, 30-Apr-2009 10:21 AM

PHP Scripts (run on webserver)

These scripts have run on PHP 4.1.2, and PHP 4.4.1. I don't have access to PHP 3.x, so it is not known if they will work on versions below PHP 4.1.2. If you try them and they work (or not) on earlier versions of PHP, please send me a message at webmaster[at]saratoga-weather.org and let me know the results.

NDBC Buoy data mesomap PHP script

This PHP script will extract recent buoy data from the National Data Buoy Center (http://www.ndbc.noaa.gov/ )and display the data as rotating conditions on a mesomap graphic and/or create a table of the current temperature, wind, barometer and wave data. Here is a live example of the output:

Mesomap of nearby weather buoys

 Air Temperature   Water Temperature   Wind Direction @ Speed   Wind Gust Speed   Barometer   Barometer Trend   Wave Height   Wave Dominant Period 

54.0 °F 52.9 °F Wind from WSWWSW 4 mph 4 mph 30.03 in -0.01 in 2.6 ft 16 sec

53.6 °F n/a °F Wind from SWSW 9 mph 10 mph 30.04 in -0.02 in n/a ft n/a sec

53.8 °F 57.7 °F Wind from SWSW 6 mph 6 mph 30.04 in n/a in n/a ft n/a sec

54.1 °F 56.7 °F Wind from WNWWNW 2 mph 4 mph 30.02 in -0.03 in 3.0 ft 15 sec

71.1 °F 68.9 °F Wind from WSWWSW 21 mph 26 mph 29.96 in n/a in n/a ft n/a sec

n/a °F 57.6 °F n/a n/a mph n/a in n/a in n/a ft n/a sec

n/a °F 56.1 °F n/a n/a mph n/a in n/a in 3.6 ft 15 sec

62.4 °F n/a °F Wind from SS 14 mph 24 mph 29.97 in n/a in n/a ft n/a sec

62.8 °F 64.2 °F Wind from SWSW 8 mph 16 mph 30.01 in n/a in n/a ft n/a sec

63.5 °F 68.5 °F Wind from WW 11 mph 16 mph 30.01 in n/a in n/a ft n/a sec

58.5 °F 59.4 °F Wind from WW 4 mph 4 mph 30.02 in -0.03 in 2.6 ft 16 sec

60.4 °F 61.3 °F Wind from WW 10 mph 17 mph 30.02 in n/a in n/a ft n/a sec

68.4 °F 74.1 °F Wind from NWNW 11 mph 16 mph 29.98 in n/a in n/a ft n/a sec

60.8 °F n/a °F Wind from WSWWSW 7 mph 9 mph n/a in n/a in 2.6 ft 17 sec

57.0 °F 60.1 °F Wind from WSWWSW 11 mph n/a mph 30.01 in -0.03 in n/a ft n/a sec

64.0 °F 60.3 °F Wind from WW 7 mph 9 mph 30.02 in -0.03 in 3.0 ft 16 sec

56.8 °F 59.2 °F Wind from SWSW 11 mph n/a mph 30.02 in n/a in n/a ft n/a sec

59.7 °F n/a °F Wind from WSWWSW 4 mph n/a mph 30.01 in n/a in n/a ft n/a sec

n/a °F 60.4 °F n/a n/a mph n/a in n/a in n/a ft n/a sec

61.7 °F 64.4 °F Wind from WNWWNW 4 mph 7 mph 30.02 in -0.03 in 3.0 ft 15 sec

Point Arena, CA at 1650: Air:54.0°F, Wtr:52.9°F, WSW@4mph G 4, 30.03in, Wav:2.6ft Point Arena, CA at 1700: Air:53.6°F, Wtr:n/a°F, SW@9mph G 10, 30.04in, Wav:n/aft Arena Cove, CA at 1648: Air:53.8°F, Wtr:57.7°F, SW@6mph G 6, 30.04in, Wav:n/aft Bodega Bay at 1650: Air:54.1°F, Wtr:56.7°F, WNW@2mph G 4, 30.02in, Wav:3.0ft Port Chicago, CA at 1648: Air:71.1°F, Wtr:68.9°F, WSW@21mph G 26, 29.96in, Wav:n/aft Point Reyes, CA at 1648: Air:n/a°F, Wtr:57.6°F, n/ain, Wav:n/aft Point Reyes, CA at 1634: Air:n/a°F, Wtr:56.1°F, n/ain, Wav:3.6ft Tiburon Pier, SF Bay, CA at 1654: Air:62.4°F, Wtr:n/a°F, S@14mph G 24, 29.97in, Wav:n/aft Richmond, CA at 1648: Air:62.8°F, Wtr:64.2°F, SW@8mph G 16, 30.01in, Wav:n/aft Alameda, CA at 1648: Air:63.5°F, Wtr:68.5°F, W@11mph G 16, 30.01in, Wav:n/aft San Francisco, CA at 1650: Air:58.5°F, Wtr:59.4°F, W@4mph G 4, 30.02in, Wav:2.6ft San Francisco, CA at 1648: Air:60.4°F, Wtr:61.3°F, W@10mph G 17, 30.02in, Wav:n/aft Redwood City, CA at 1648: Air:68.4°F, Wtr:74.1°F, NW@11mph G 16, 29.98in, Wav:n/aft Half Moon Bay, CA at 1650: Air:60.8°F, Wtr:n/a°F, WSW@7mph G 9, n/ain, Wav:2.6ft MBM0 at 1612: Air:57.0°F, Wtr:60.1°F, WSW@11mph G n/a, 30.01in, Wav:n/aft Monterey, CA at 1650: Air:64.0°F, Wtr:60.3°F, W@7mph G 9, 30.02in, Wav:3.0ft MBM1 at 1556: Air:56.8°F, Wtr:59.2°F, SW@11mph G n/a, 30.02in, Wav:n/aft MBM2 at 1557: Air:59.7°F, Wtr:n/a°F, WSW@4mph G n/a, 30.01in, Wav:n/aft Monterey, CA at 1648: Air:n/a°F, Wtr:60.4°F, n/ain, Wav:n/aft Cape San Martin at 1650: Air:61.7°F, Wtr:64.4°F, WNW@4mph G 7, 30.02in, Wav:3.0ft

ID Name Time
PDT
Air
°F
Water
°F
Wind
mph
Gust
mph
Baro
in
Trend
in
Waves
ft
Period
Sec
46014 Point Arena, CA 1650 54.0 52.9 WSW Wind from WSW 4 4 30.03 -0.01 2.6 16
PTAC1 Point Arena, CA 1700 53.6 n/a SW Wind from SW 9 10 30.04 -0.02 n/a n/a
ANVC1 Arena Cove, CA 1648 53.8 57.7 SW Wind from SW 6 6 30.04 n/a n/a n/a
46013 Bodega Bay 1650 54.1 56.7 WNW Wind from WNW 2 4 30.02 -0.03 3.0 15
PCOC1 Port Chicago, CA 1648 71.1 68.9 WSW Wind from WSW 21 26 29.96 n/a n/a n/a
PRYC1 Point Reyes, CA 1648 n/a 57.6 n/a n/a n/a n/a n/a n/a
46214 Point Reyes, CA 1634 n/a 56.1 n/a n/a n/a n/a 3.6 15
TIBC1 Tiburon Pier, SF Bay, CA 1654 62.4 n/a S Wind from S 14 24 29.97 n/a n/a n/a
RCMC1 Richmond, CA 1648 62.8 64.2 SW Wind from SW 8 16 30.01 n/a n/a n/a
AAMC1 Alameda, CA 1648 63.5 68.5 W Wind from W 11 16 30.01 n/a n/a n/a
46026 San Francisco, CA 1650 58.5 59.4 W Wind from W 4 4 30.02 -0.03 2.6 16
FTPC1 San Francisco, CA 1648 60.4 61.3 W Wind from W 10 17 30.02 n/a n/a n/a
RTYC1 Redwood City, CA 1648 68.4 74.1 NW Wind from NW 11 16 29.98 n/a n/a n/a
46012 Half Moon Bay, CA 1650 60.8 n/a WSW Wind from WSW 7 9 n/a n/a 2.6 17
46091 MBM0 1612 57.0 60.1 WSW Wind from WSW 11 n/a 30.01 -0.03 n/a n/a
46042 Monterey, CA 1650 64.0 60.3 W Wind from W 7 9 30.02 -0.03 3.0 16
46092 MBM1 1556 56.8 59.2 SW Wind from SW 11 n/a 30.02 n/a n/a n/a
46093 MBM2 1557 59.7 n/a WSW Wind from WSW 4 n/a 30.01 n/a n/a n/a
MTYC1 Monterey, CA 1648 n/a 60.4 n/a n/a n/a n/a n/a n/a
46028 Cape San Martin 1650 61.7 64.4 WNW Wind from WNW 4 7 30.02 -0.03 3.0 15

The script has three parts: the buoy-data.php script itself, a text configuration file, and a JPG image of the map to display. Optionally, you can use a set of wind arrows to appear in the display. Included with the distribution file are sample configuration files, wind arrows, and associated graphics from the NDBC website. Be aware that some customization of the configuration file is REQUIRED, and you'll need to be familiar with using image hotspot coordinates to do the customization. More information on customization instructions and possibilities is contained in the buoy-data-readme.txt file in the distribution.

The script output is XHTML 1.0-Strict compliant (with version 1.05). The script also creates a CSS and a JavaScript required for the rotating condigions display. This script has been tested and works with IE V6-SP2, IE7, Firefox 1.0.5.4/2.0, Netscape 7.0 and Opera 8 browsers, and a PHP 4.2.1+ with GD 2.0 enabled. If the browser's JavaScript is not enabled, a small message will appear in the output, and the mesomap will display Air Temperature only. The following parameters are available on the buoy-data.php script:

inc=Y
If present, the script will not output surrounding HTML for the page returned. You should specify this if you invoke the script from within your webpage i.e.
<?php include("http://your.website/buoy-data.php?inc=Y"); ?>
Both Map and Table are returned by this parameter.
inc=CSS
If present, the script will just return the required in-line CSS for the mesomap display. You should specify this if you invoke the script from within the <head></head> section your webpage i.e.
<?php include("http://your.website/buoy-data.php?inc=CSS"); ?>
Only the CSS is returned by this parameter.
inc=MAP   (added in V1.02)
If present, the script will not output surrounding HTML for the page returned. You should specify this if you invoke the script from within your webpage i.e.
<?php include("http://your.website/buoy-data.php?inc=MAP"); ?>
Only the mesomap with rotating conditions is returned by this parameter.
inc=TABLE   (added in V1.02)
If present, the script will not output surrounding HTML for the page returned. You should specify this if you invoke the script from within your webpage i.e.
<?php include("http://your.website/buoy-data.php?inc=TABLE"); ?>
Only the buoy table is returned by this parameter.
units=E
(Default) Display temperature, wind, barometer and wave info in English units.
units=M
Display temperature, wind barometer and wave info in Metric units. .
cnv=Y
(default)-- convert wind speed m/s->kph and kts->mph
cnv=N
leave wind speed in m/s and kts
kts=N  (New in V1.10)
(default)-- leave wind speeds in units as set by units=M/E and cnv=Y/N
kts=Y  (New in V1.10)
force wind speed display to Knots

For webmaster help with debugging the setup/configuration of the script, the following parameters may also be used:

show=normal
(default) display normal mesomap graphic.
show=hotspots
display mesomap graphic with hotspots outlined in green to enable debugging of configuration file. Rest of page is displayed normally with rotating conditions and table of data..
show=map
display only the mesomap graphic image with hotspots outlined in green.
cfg=list
Include results of parsing the configuration file as HTML comments in the page. Useful to ensure the settings are correct in the configuration file.
cache=no   (added in V1.01)
Changes $refetchSeconds to 10 (to clear the cache file) .

Added in V1.12 was the ability to directly include the script and print the CSS, Map and Table in a simple manner. This method is recommended for PHP5 installations where allow_url_include is turned off.

In the <head></head> part of the including page, put:

<?php
 $doPrintBUOY = false;
 include("buoy-data.php");
 print $BUOY_CSS; 
 ?>

in the <body></body> part of the including page, put:

<?php print $BUOY_MAP; ?>
<?php print $BUOY_TABLE ?>

NDBC buoy data mesomap PHP .zip package V1.15[29-Apr-2009] : demo and download [ see version history ]
Download just the buoy-data.php script [V1.15 [29-Apr-2009]
Contributed graphics and configuration files are also available here and in the latest .zip file.

Weather Station Finder USA Weather Finder  ©2006-2007 Saratoga Weather.org   Privacy Statement
Radar/maps © Weather Underground. Used with permission.    Valid XHTML 1.0     Valid CSS
Never base important decisions that could result in harm to people or property on this weather information.