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.

Latest postings about Saratoga-weather.org Weather PHP scripts on Twitter

follow Saratoga-Weather.org PHP script updates on Twitter

This page was updated Wednesday, 02-Sep-2009 9:22 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 

52.7 °F 53.2 °F Wind from SSESSE 27 mph 36 mph 30.00 in -0.06 in 15.7 ft 14 sec

52.0 °F n/a °F Wind from SSESSE 17 mph 22 mph 30.03 in -0.06 in n/a ft n/a sec

52.3 °F 52.7 °F Wind from ESEESE 13 mph 18 mph 30.06 in n/a in n/a ft n/a sec

52.7 °F 53.8 °F Wind from SSESSE 18 mph 25 mph 30.07 in -0.06 in 11.2 ft 16 sec

47.8 °F 54.0 °F Wind from SS 8 mph 10 mph 30.12 in -0.06 in n/a ft n/a sec

52.2 °F 52.2 °F Wind from SESE 10 mph 16 mph 30.11 in n/a in n/a ft n/a sec

n/a °F 51.8 °F n/a n/a mph n/a in n/a in 16.4 ft 17 sec

51.3 °F n/a °F Wind from SESE 6 mph 10 mph 30.12 in -0.06 in n/a ft n/a sec

51.6 °F 54.9 °F Wind from SSESSE 6 mph 11 mph 30.13 in -0.04 in n/a ft n/a sec

49.8 °F 56.3 °F Wind from SESE 11 mph 14 mph 30.12 in -0.05 in n/a ft n/a sec

52.9 °F 53.1 °F Wind from SS 13 mph 18 mph 30.12 in -0.05 in 11.2 ft 16 sec

51.3 °F 54.3 °F Wind from SSESSE 9 mph 10 mph 30.13 in -0.05 in n/a ft n/a sec

47.5 °F 55.8 °F Wind from ESEESE 5 mph 7 mph 30.13 in -0.05 in n/a ft n/a sec

52.5 °F n/a °F Wind from SSESSE 13 mph 18 mph n/a in n/a in 12.8 ft 17 sec

n/a °F 55.6 °F Wind from ESEESE 9 mph 11 mph 30.13 in -0.04 in 9.8 ft 17 sec

49.8 °F 53.4 °F Wind from ENEENE 9 mph n/a mph 30.14 in -0.04 in n/a ft n/a sec

52.9 °F n/a °F Wind from ESEESE 7 mph n/a mph 30.12 in -0.04 in n/a ft n/a sec

n/a °F 56.3 °F n/a n/a mph 30.14 in -0.06 in n/a ft n/a sec

55.2 °F 55.8 °F n/a 9 mph 30.13 in -0.05 in 8.5 ft 13 sec

Point Arena, CA at 0350: Air:52.7°F, Wtr:53.2°F, SSE@27mph G 36, 30.00in, Wav:15.7ft Point Arena, CA at 0400: Air:52.0°F, Wtr:n/a°F, SSE@17mph G 22, 30.03in, Wav:n/aft Arena Cove, CA at 0354: Air:52.3°F, Wtr:52.7°F, ESE@13mph G 18, 30.06in, Wav:n/aft Bodega Bay at 0350: Air:52.7°F, Wtr:53.8°F, SSE@18mph G 25, 30.07in, Wav:11.2ft Port Chicago, CA at 0400: Air:47.8°F, Wtr:54.0°F, S@8mph G 10, 30.12in, Wav:n/aft Point Reyes, CA at 0354: Air:52.2°F, Wtr:52.2°F, SE@10mph G 16, 30.11in, Wav:n/aft Point Reyes, CA at 0334: Air:n/a°F, Wtr:51.8°F, n/ain, Wav:16.4ft Tiburon Pier, SF Bay, CA at 0400: Air:51.3°F, Wtr:n/a°F, SE@6mph G 10, 30.12in, Wav:n/aft Richmond, CA at 0400: Air:51.6°F, Wtr:54.9°F, SSE@6mph G 11, 30.13in, Wav:n/aft Alameda, CA at 0400: Air:49.8°F, Wtr:56.3°F, SE@11mph G 14, 30.12in, Wav:n/aft San Francisco, CA at 0350: Air:52.9°F, Wtr:53.1°F, S@13mph G 18, 30.12in, Wav:11.2ft San Francisco, CA at 0400: Air:51.3°F, Wtr:54.3°F, SSE@9mph G 10, 30.13in, Wav:n/aft Redwood City, CA at 0400: Air:47.5°F, Wtr:55.8°F, ESE@5mph G 7, 30.13in, Wav:n/aft Half Moon Bay, CA at 0350: Air:52.5°F, Wtr:n/a°F, SSE@13mph G 18, n/ain, Wav:12.8ft MBM0 (46091) - no recent report available Monterey, CA at 0350: Air:n/a°F, Wtr:55.6°F, ESE@9mph G 11, 30.13in, Wav:9.8ft MBM1 at 0301: Air:49.8°F, Wtr:53.4°F, ENE@9mph G n/a, 30.14in, Wav:n/aft MBM2 at 0308: Air:52.9°F, Wtr:n/a°F, ESE@7mph G n/a, 30.12in, Wav:n/aft Monterey, CA at 0400: Air:n/a°F, Wtr:56.3°F, 30.14in, Wav:n/aft Cape San Martin at 0350: Air:55.2°F, Wtr:55.8°F, 30.13in, Wav:8.5ft

ID Name Time
PST
Air
°F
Water
°F
Wind
mph
Gust
mph
Baro
in
Trend
in
Waves
ft
Period
Sec
46014 Point Arena, CA 0350 52.7 53.2 SSE Wind from SSE 27 36 30.00 -0.06 15.7 14
PTAC1 Point Arena, CA 0400 52.0 n/a SSE Wind from SSE 17 22 30.03 -0.06 n/a n/a
ANVC1 Arena Cove, CA 0354 52.3 52.7 ESE Wind from ESE 13 18 30.06 n/a n/a n/a
46013 Bodega Bay 0350 52.7 53.8 SSE Wind from SSE 18 25 30.07 -0.06 11.2 16
PCOC1 Port Chicago, CA 0400 47.8 54.0 S Wind from S 8 10 30.12 -0.06 n/a n/a
PRYC1 Point Reyes, CA 0354 52.2 52.2 SE Wind from SE 10 16 30.11 n/a n/a n/a
46214 Point Reyes, CA 0334 n/a 51.8 n/a n/a n/a n/a 16.4 17
TIBC1 Tiburon Pier, SF Bay, CA 0400 51.3 n/a SE Wind from SE 6 10 30.12 -0.06 n/a n/a
RCMC1 Richmond, CA 0400 51.6 54.9 SSE Wind from SSE 6 11 30.13 -0.04 n/a n/a
AAMC1 Alameda, CA 0400 49.8 56.3 SE Wind from SE 11 14 30.12 -0.05 n/a n/a
46026 San Francisco, CA 0350 52.9 53.1 S Wind from S 13 18 30.12 -0.05 11.2 16
FTPC1 San Francisco, CA 0400 51.3 54.3 SSE Wind from SSE 9 10 30.13 -0.05 n/a n/a
RTYC1 Redwood City, CA 0400 47.5 55.8 ESE Wind from ESE 5 7 30.13 -0.05 n/a n/a
46012 Half Moon Bay, CA 0350 52.5 n/a SSE Wind from SSE 13 18 n/a n/a 12.8 17
46091 MBM0 No recent reports.
46042 Monterey, CA 0350 n/a 55.6 ESE Wind from ESE 9 11 30.13 -0.04 9.8 17
46092 MBM1 0301 49.8 53.4 ENE Wind from ENE 9 n/a 30.14 -0.04 n/a n/a
46093 MBM2 0308 52.9 n/a ESE Wind from ESE 7 n/a 30.12 -0.04 n/a n/a
MTYC1 Monterey, CA 0400 n/a 56.3 n/a n/a 30.14 -0.06 n/a n/a
46028 Cape San Martin 0350 55.2 55.8 n/a 9 30.13 -0.05 8.5 13

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.