-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from jrleeman/NDBC_Service
Add NDBC simple web service
- Loading branch information
Showing
19 changed files
with
7,135 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.. _ndbc_examples: | ||
|
||
National Data Buoy Center (NDBC) | ||
-------------------------------- | ||
|
||
Examples of requesting data from the National Data Buoy Center latest and realtime | ||
data sources. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2018 Siphon Contributors. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
""" | ||
NDBC Buoy Meteorological Data Request | ||
===================================== | ||
The NDBC keeps a 45-day recent rolling file for each buoy. This examples shows how to access | ||
the basic meteorological data from a buoy and make a simple plot. | ||
""" | ||
|
||
import matplotlib.pyplot as plt | ||
|
||
from siphon.simplewebservice.ndbc import NDBC | ||
|
||
#################################################### | ||
# Get a pandas data frame of all of the observations, meteorological data is the default | ||
# observation set to query. | ||
df = NDBC.realtime_observations('41002') | ||
df.head() | ||
|
||
#################################################### | ||
# Let's make a simple time series plot to checkout what the data look like. | ||
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, figsize=(12, 10)) | ||
ax2b = ax2.twinx() | ||
|
||
# Pressure | ||
ax1.plot(df['time'], df['pressure'], color='black') | ||
ax1.set_ylabel('Pressure [hPa]') | ||
|
||
# Wind speed, gust, direction | ||
ax2.plot(df['time'], df['wind_speed'], color='tab:orange') | ||
ax2.plot(df['time'], df['wind_gust'], color='tab:olive', linestyle='--') | ||
ax2b.plot(df['time'], df['wind_direction'], color='tab:blue', linestyle='-') | ||
ax2.set_ylabel('Wind Speed [m/s]') | ||
ax2b.set_ylabel('Wind Direction') | ||
|
||
# Water temperature | ||
ax3.plot(df['time'], df['water_temperature'], color='tab:brown') | ||
ax3.set_ylabel('Water Temperature [degC]') | ||
|
||
plt.show() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) 2018 Siphon Contributors. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
""" | ||
NDBC Buoy Data Request (of any type) | ||
==================================== | ||
The NDBC keeps a 40-day recent rolling file for each buoy. This examples shows how to access | ||
the other types of data available for a buoy. | ||
""" | ||
|
||
from siphon.simplewebservice.ndbc import NDBC | ||
|
||
#################################################### | ||
# Request the types of data available from a given buoy. | ||
data_aval = NDBC.buoy_data_types('41002') | ||
print(data_aval) | ||
|
||
#################################################### | ||
# Get a pandas data frame of all of the observations, meteorological data is the default | ||
# observation set to query. | ||
df = NDBC.realtime_observations('41002', data_type='supl') | ||
df.head() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# Copyright (c) 2018 Siphon Contributors. | ||
# Distributed under the terms of the BSD 3-Clause License. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
""" | ||
NDBC Latest Data Request | ||
======================== | ||
This example shows how to use siphon's `simplewebswervice` support query the most recent | ||
observations from all of the NDBC buoys at once. | ||
""" | ||
|
||
import cartopy.crs as ccrs | ||
import cartopy.feature as cfeature | ||
import matplotlib.pyplot as plt | ||
|
||
from siphon.simplewebservice.ndbc import NDBC | ||
|
||
#################################################### | ||
# Get a pandas data frame of all of the observations | ||
df = NDBC.latest_observations() | ||
df.head() | ||
|
||
#################################################### | ||
# In this case I'm going to drop buoys that do not have water temperature measurements. | ||
df.dropna(subset=['water_temperature'], inplace=True) | ||
|
||
#################################################### | ||
# Let's make a simple plot of the buoy positions and color by water temperature | ||
proj = ccrs.LambertConformal(central_latitude=45., central_longitude=-100., | ||
standard_parallels=[30, 60]) | ||
|
||
fig = plt.figure(figsize=(17., 11.)) | ||
ax = plt.axes(projection=proj) | ||
ax.coastlines('50m', edgecolor='black') | ||
ax.add_feature(cfeature.OCEAN.with_scale('50m')) | ||
ax.add_feature(cfeature.LAND.with_scale('50m')) | ||
ax.set_extent([-85, -75, 25, 30], ccrs.PlateCarree()) | ||
|
||
ax.scatter(df['longitude'], df['latitude'], c=df['water_temperature'], | ||
transform=ccrs.PlateCarree()) | ||
|
||
plt.show() |
Oops, something went wrong.