Skip to main content

Wrapper for the NOAA National Data Buoy Center

Project description

Buoyant is a Python wrapper for grabbing buoy data from the National Buoy Data Center. It parses XML from a NBDC endpoint. This data source isn’t fully documented, so there’s no guarantee of its stability.

The NBDC provides a list and a map of active buoys.

Hello buoy example:

from buoyant import Buoy

# construct the Buoy object with the station ID
# It's an alphanumeric code. If its numeric, an integer works fine.
station = Buoy(13010)

station.name
# 'Soul'
# Yes, that buoy is really named Soul.

More examples:

from buoyant import Buoy

station = Buoy('lndc1')

station.wind_speed
# 9.9

station.units['wind_speed']
# 'kt'

station.lon
# -23.14

station.coords
# (20.43, -23.14)

# Get the time the measurements were made.
station.datetime
# datetime.datetime(2014, 12, 15, 20, 50, tzinfo=<UTC>)

# Not all stations report all data.
station.wave_height
# raises AttributeError

# Fetches new data. This isn't very useful, since the buoys update only every hour or so
station.refresh()

Images

Some buoys have cameras! If the buoy doesn’t have an active camera, a placeholder image provided by the NBDC will be returned.

station = Buoy(41009)

station.image_url
# 'http://www.ndbc.noaa.gov/images/buoycam/Z14C_2014_11_01_2200.jpg'

# Save image as a file 'out.jpg'
station.write_image('out.jpg')

# Get raw image as a BytesIO object (see https://docs.python.org/2/library/io.html)
station.image
# <_io.BytesIO object>

station.url
# 'http://www.ndbc.noaa.gov/station_page.php?station=41009'

Measurement metadata

The occassional buoy reports metadata about its measurements. The Buoy object has a meta attribute with this data, if any.

# Buoy in the Frying Pan Shoals, NC
frying_pan = Buoy(41013)

frying_pan.pressure
# 30.1

frying_pan.meta['pressure']
# {'tendency': 'steady'}

No data

Sometimes buoys don’t have recent data. You’ll be able to tell two ways. First, the Buoy object won’t have many attributes. Second, there will be a message. It will say ‘No data’.

station = Buoy('ANRN6')
station.message
# 'No data'

Measurements included

Any measurements reported in the NBDC’s XML api are included in a Buoy object. Read about the meaning of the different measurements.

Measurements often included (the text in parentheses is the one used on the NBDC’s measurement descriptions page):

  • air_temp (ATMP)

  • average_period (APD)

  • dominant_period (DPD)

  • mean_wave_direction (Spectral wave direction)

  • water_temp (WTMP)

  • wave_height (WVHT)

  • wind_direction (WDIR)

  • wind_gust (GST)

  • wind_speed (WSPD)

  • datetime

  • dewpoint (DEWP)

  • lat (latitude)

  • lon (longitude)

  • pressure (PRES)

Water quality data isn’t included in the XML data source. Neither is the elevation of the station or the location of the instruments relative to the station.

XML

Get the raw XML, if you like XML for some reason. Maybe the package is missing something? If so, submit an issue or pull request!

soul = Buoy('13010')
soul.xml
'''<?xml version="1.0" encoding="UTF-8"?>
<observation id="13010" name="Soul" lat="-0.01" lon="0.00">
  <datetime>2014-12-16T02:00:00UTC</datetime>
  <winddir uom="degT">190</winddir>
  <windspeed uom="kt">9.9</windspeed>
  <airtemp uom="F">78.8</airtemp>
  </observation>'''

Compatibility

Buoyant is compatible with Python 2 and 3.

License

Buoyant is licensed under the GPL.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buoyant-0.5.2.tar.gz (7.6 kB view details)

Uploaded Source

Built Distribution

buoyant-0.5.2--py2.py3-none-any.whl (10.9 kB view details)

Uploaded

File details

Details for the file buoyant-0.5.2.tar.gz.

File metadata

  • Download URL: buoyant-0.5.2.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for buoyant-0.5.2.tar.gz
Algorithm Hash digest
SHA256 8825742fec7048e77ca88cd2d8851ef2adad19ba38ca19927ad9b6d0325783b9
MD5 465054a64622880c7cdf17f4ef755dc0
BLAKE2b-256 0de5d421443b85476b046510eee78f8a8aebc6e7335cca00cf4deaf671fd1166

See more details on using hashes here.

File details

Details for the file buoyant-0.5.2--py2.py3-none-any.whl.

File metadata

  • Download URL: buoyant-0.5.2--py2.py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags:
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/39.2.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/3.6.5

File hashes

Hashes for buoyant-0.5.2--py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e899b436d92301cddaf7be245a00bd926084d94c53ffc0449feffde671bdcdc2
MD5 a3fa2f38e46aa96ad790759e30f26058
BLAKE2b-256 1482a702df669dac3603960c9b9028719a14a04fe03ff071d4e5983c6979534f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page