deformed-offering

Weather station scripts - Buoy Data

They're free, but use at your own risk

The scripts 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 weather 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 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 and saratogaWXPHP Twitter account as they become available.

This page was updated Friday, 31-Aug-2012 11:56 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 

55.0 °F 53.1 °F Wind from NNWNNW 16 mph 20 mph 29.96 in +0.00 in 4.6 ft 7 sec

55.4 °F 58.1 °F Wind from NWNW 2 mph 7 mph 29.95 in n/a in n/a ft n/a sec

57.0 °F 55.8 °F Wind from NWNW 18 mph 20 mph 29.92 in +0.00 in 5.2 ft 6 sec

69.4 °F 71.4 °F Wind from WW 14 mph 17 mph 29.87 in n/a in n/a ft n/a sec

59.4 °F 63.1 °F Wind from WNWWNW 7 mph 9 mph 29.92 in n/a in n/a ft n/a sec

n/a °F 60.8 °F n/a n/a mph n/a in n/a in 6.6 ft 7 sec

61.3 °F 67.1 °F Wind from SS 9 mph 10 mph 29.91 in n/a in n/a ft n/a sec

59.9 °F 72.9 °F Wind from WNWWNW 3 mph 6 mph 29.92 in n/a in n/a ft n/a sec

58.6 °F n/a °F Wind from NWNW 13 mph 16 mph n/a in n/a in 3.3 ft 7 sec

57.6 °F 64.9 °F Wind from NN 3 mph 5 mph 29.93 in n/a in n/a ft n/a sec

62.4 °F 75.7 °F Wind from NNWNNW 8 mph 9 mph 29.91 in n/a in n/a ft n/a sec

59.9 °F 63.0 °F Wind from NWNW 13 mph 16 mph 29.94 in +0.02 in 4.3 ft 7 sec

59.5 °F 63.1 °F Wind from NNWNNW 16 mph 18 mph 29.94 in +0.01 in 3.9 ft 7 sec

58.5 °F 65.8 °F Wind from WSWWSW 6 mph 9 mph 29.95 in n/a in n/a ft n/a sec

59.9 °F 61.5 °F Wind from NWNW 16 mph 20 mph 29.92 in +0.01 in 4.3 ft 8 sec

Point Arena, CA at 2150: Air:55.0°F, Wtr:53.1°F, NNW@16mph G 20, 29.96in, Wav:4.6ft Point Arena, CA (PTAC1) - no recent report available Arena Cove, CA at 2218: Air:55.4°F, Wtr:58.1°F, NW@2mph G 7, 29.95in, Wav:n/aft Bodega Bay at 2150: Air:57.0°F, Wtr:55.8°F, NW@18mph G 20, 29.92in, Wav:5.2ft Port Chicago, CA at 2218: Air:69.4°F, Wtr:71.4°F, W@14mph G 17, 29.87in, Wav:n/aft Point Reyes, CA at 2218: Air:59.4°F, Wtr:63.1°F, WNW@7mph G 9, 29.92in, Wav:n/aft Point Reyes, CA at 2156: Air:n/a°F, Wtr:60.8°F, n/ain, Wav:6.6ft Tiburon Pier, SF Bay, CA (TIBC1) - no recent report available Richmond, CA at 2218: Air:61.3°F, Wtr:67.1°F, S@9mph G 10, 29.91in, Wav:n/aft Alameda, CA at 2218: Air:59.9°F, Wtr:72.9°F, WNW@3mph G 6, 29.92in, Wav:n/aft San Francisco, CA at 2150: Air:58.6°F, Wtr:n/a°F, NW@13mph G 16, n/ain, Wav:3.3ft San Francisco, CA at 2218: Air:57.6°F, Wtr:64.9°F, N@3mph G 5, 29.93in, Wav:n/aft Redwood City, CA at 2218: Air:62.4°F, Wtr:75.7°F, NNW@8mph G 9, 29.91in, Wav:n/aft Half Moon Bay, CA at 2150: Air:59.9°F, Wtr:63.0°F, NW@13mph G 16, 29.94in, Wav:4.3ft MBM0 (46091) - no recent report available Monterey, CA at 2150: Air:59.5°F, Wtr:63.1°F, NNW@16mph G 18, 29.94in, Wav:3.9ft MBM1 (46092) - no recent report available MBM2 (46093) - no recent report available Monterey, CA at 2136: Air:58.5°F, Wtr:65.8°F, WSW@6mph G 9, 29.95in, Wav:n/aft Cape San Martin at 2150: Air:59.9°F, Wtr:61.5°F, NW@16mph G 20, 29.92in, Wav:4.3ft

ID Name Time
PDT
Air
°F
Water
°F
Wind
mph
Gust
mph
Baro
in
Trend
in
Waves
ft
Period
Sec
46014 Point Arena, CA 2150 55.0 53.1 NNW Wind from NNW 16 20 29.96 +0.00 4.6 7
PTAC1 Point Arena, CA No recent reports.
ANVC1 Arena Cove, CA 2218 55.4 58.1 NW Wind from NW 2 7 29.95 n/a n/a n/a
46013 Bodega Bay 2150 57.0 55.8 NW Wind from NW 18 20 29.92 +0.00 5.2 6
PCOC1 Port Chicago, CA 2218 69.4 71.4 W Wind from W 14 17 29.87 n/a n/a n/a
PRYC1 Point Reyes, CA 2218 59.4 63.1 WNW Wind from WNW 7 9 29.92 n/a n/a n/a
46214 Point Reyes, CA 2156 n/a 60.8 n/a n/a n/a n/a 6.6 7
TIBC1 Tiburon Pier, SF Bay, CA No recent reports.
RCMC1 Richmond, CA 2218 61.3 67.1 S Wind from S 9 10 29.91 n/a n/a n/a
AAMC1 Alameda, CA 2218 59.9 72.9 WNW Wind from WNW 3 6 29.92 n/a n/a n/a
46026 San Francisco, CA 2150 58.6 n/a NW Wind from NW 13 16 n/a n/a 3.3 7
FTPC1 San Francisco, CA 2218 57.6 64.9 N Wind from N 3 5 29.93 n/a n/a n/a
RTYC1 Redwood City, CA 2218 62.4 75.7 NNW Wind from NNW 8 9 29.91 n/a n/a n/a
46012 Half Moon Bay, CA 2150 59.9 63.0 NW Wind from NW 13 16 29.94 +0.02 4.3 7
46091 MBM0 No recent reports.
46042 Monterey, CA 2150 59.5 63.1 NNW Wind from NNW 16 18 29.94 +0.01 3.9 7
46092 MBM1 No recent reports.
46093 MBM2 No recent reports.
MTYC1 Monterey, CA 2136 58.5 65.8 WSW Wind from WSW 6 9 29.95 n/a n/a n/a
46028 Cape San Martin 2150 59.9 61.5 NW Wind from NW 16 20 29.92 +0.01 4.3 8

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 ?>

If you need to center the map and table on the page, don't use <center></center> or <div align="center></div> as it will cause the map display to offset from the background map. Instead use in the <body></body> part:

 <table width="99%">
<tr><td align="center">
<table width="100%">
<tr>
<td align="center">
<?php print $BUOY_MAP; ?>
</td>
</tr>
<tr>
<td align="left">
<?php print $BUOY_TABLE ?>
</td>
</tr>
</table>
</td></tr>
</table>

 

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

deformed-offering