{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Coastal Ocean Wave Height Assessment\n", "\n", "\n", "This notebook is a follow-up from the [Sea Surface Height notebook](http://ioos.github.io/notebooks_demos/notebooks/2018-03-15-ssh-skillscore), here we use the same workflow to compare observations and models for sea waves height.\n", "\n", "We start with virtually the same configuration from before, except that now we changed the variable names to \"waves\" and the corresponding `standard_names` for waves.\n", "\n", "For more information regarding the workflow presented here see [SSH notebook](http://ioos.github.io/notebooks_demos/notebooks/2018-03-15-ssh-skillscore) and [Signell, Richard P.; Fernandes, Filipe; Wilcox, Kyle. 2016. \"Dynamic Reusable Workflows for Ocean Science.\" *J. Mar. Sci. Eng.* 4, no. 4: 68](http://dx.doi.org/10.3390/jmse4040068)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:23.944692Z", "start_time": "2017-10-27T19:00:23.932666Z" } }, "outputs": [], "source": [ "import warnings\n", "\n", "# Suppresing warnings for a \"pretty output.\"\n", "warnings.simplefilter('ignore')" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:24.015841Z", "start_time": "2017-10-27T19:00:23.952708Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Overwriting wave_config.yaml\n" ] } ], "source": [ "%%writefile wave_config.yaml\n", "\n", "date:\n", " start: 2018-2-28 00:00:00\n", " stop: 2018-3-10 00:00:00\n", "\n", "run_name: 'latest'\n", "\n", "region:\n", " bbox: [-71.20, 41.40, -69.20, 43.74]\n", " crs: 'urn:ogc:def:crs:OGC:1.3:CRS84'\n", "\n", "# try: sea_surface_wave_significant_height\n", "sos_name: 'waves'\n", "\n", "cf_names:\n", " - sea_surface_wave_significant_height\n", " - sea_surface_wind_wave_significant_height\n", "\n", "units: 'm'\n", "\n", "catalogs:\n", " - https://data.ioos.us/csw" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:27.643443Z", "start_time": "2017-10-27T19:00:24.024860Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Saving data inside directory /home/filipe/IOOS/notebooks_demos/notebooks/latest\n", "*********************** Run information ************************\n", "Run date: 2018-03-12 13:08:47\n", "Start: 2018-02-28 00:00:00\n", "Stop: 2018-03-10 00:00:00\n", "Bounding box: -71.20, 41.40,-69.20, 43.74\n" ] } ], "source": [ "import os\n", "import shutil\n", "from datetime import datetime\n", "from ioos_tools.ioos import parse_config\n", "\n", "config = parse_config('wave_config.yaml')\n", "\n", "save_dir = os.path.abspath(config['run_name'])\n", "if os.path.exists(save_dir):\n", " shutil.rmtree(save_dir)\n", "os.makedirs(save_dir)\n", "\n", "fmt = '{:*^64}'.format\n", "print(fmt('Saving data inside directory {}'.format(save_dir)))\n", "print(fmt(' Run information '))\n", "print('Run date: {:%Y-%m-%d %H:%M:%S}'.format(datetime.utcnow()))\n", "print('Start: {:%Y-%m-%d %H:%M:%S}'.format(config['date']['start']))\n", "print('Stop: {:%Y-%m-%d %H:%M:%S}'.format(config['date']['stop']))\n", "print('Bounding box: {0:3.2f}, {1:3.2f},'\n", " '{2:3.2f}, {3:3.2f}'.format(*config['region']['bbox']))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:27.779728Z", "start_time": "2017-10-27T19:00:27.695552Z" } }, "outputs": [], "source": [ "def make_filter(config):\n", " from owslib import fes\n", " from ioos_tools.ioos import fes_date_filter\n", " kw = dict(wildCard='*', escapeChar='\\\\',\n", " singleChar='?', propertyname='apiso:Subject')\n", "\n", " if len(config['cf_names']) > 1:\n", " or_filt = fes.Or([fes.PropertyIsLike(literal=('*%s*' % val), **kw)\n", " for val in config['cf_names']])\n", " else:\n", " or_filt = fes.PropertyIsLike(literal=('*%s*' % config['cf_names'][0]), **kw) \n", "\n", " not_filt = fes.Not([fes.PropertyIsLike(literal='GRIB-2', **kw)])\n", "\n", " begin, end = fes_date_filter(config['date']['start'],\n", " config['date']['stop'])\n", " bbox_crs = fes.BBox(config['region']['bbox'],\n", " crs=config['region']['crs'])\n", " filter_list = [fes.And([bbox_crs, begin, end, or_filt, not_filt])]\n", " return filter_list\n", "\n", "\n", "filter_list = make_filter(config)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:29.681714Z", "start_time": "2017-10-27T19:00:27.786743Z" }, "code_folding": [], "scrolled": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "********************* Catalog information **********************\n", "URL: https://data.ioos.us/csw\n", "Number of datasets available: 12\n", "Directional wave and sea surface temperature measurements collected in situ by Datawell Mark 3 directional buoy located near LOWER COOK INLET, AK from 2016/12/16 00:00:00 to 2018/03/11 18:09:42.\n", "NECOFS GOM3 Wave - Northeast US - Latest Forecast\n", "BIO WW III Latest Forecasts/EastCoast.nc\n", "BIO WW III Latest Forecasts/GulfOfMaine.nc\n", "BIO WW III Latest Forecasts/NorthAtlantic.nc\n", "Coupled Northwest Atlantic Prediction System (CNAPS)\n", "Directional wave and sea surface temperature measurements collected in situ by Datawell Mark 3 directional buoy located near ASTORIA CANYON, OR from 2017/08/03 18:00:00 to 2018/03/11 17:57:11.\n", "Directional wave and sea surface temperature measurements collected in situ by Datawell Mark 3 directional buoy located near CAPE COD BAY, MA from 2017/10/05 20:00:00 to 2018/03/11 18:01:09.\n", "Directional wave and sea surface temperature measurements collected in situ by Datawell Mark 3 directional buoy located near CLATSOP SPIT, OR from 2018/02/07 22:00:00 to 2018/03/11 18:00:33.\n", "Directional wave and sea surface temperature measurements collected in situ by Datawell Mark 3 directional buoy located near GRAYS HARBOR, WA from 2017/06/29 16:00:00 to 2018/03/11 18:00:29.\n", "Directional wave and sea surface temperature measurements collected in situ by Datawell Mark 3 directional buoy located near JEFFREYS LEDGE, NH from 2017/01/31 18:00:00 to 2018/03/11 18:08:17.\n", "Directional wave and sea surface temperature measurements collected in situ by Datawell Mark 3 directional buoy located near LAKESIDE, OR from 2017/03/31 23:00:00 to 2018/03/11 17:30:56.\n", "***************************** DAP ******************************\n", "http://thredds.cdip.ucsd.edu/thredds/dodsC/cdip/realtime/036p1_rt.nc.html\n", "http://thredds.cdip.ucsd.edu/thredds/dodsC/cdip/realtime/160p1_rt.nc.html\n", "http://thredds.cdip.ucsd.edu/thredds/dodsC/cdip/realtime/162p1_rt.nc.html\n", "http://thredds.cdip.ucsd.edu/thredds/dodsC/cdip/realtime/179p1_rt.nc.html\n", "http://thredds.cdip.ucsd.edu/thredds/dodsC/cdip/realtime/204p1_rt.nc.html\n", "http://thredds.cdip.ucsd.edu/thredds/dodsC/cdip/realtime/221p1_rt.nc.html\n", "http://thredds.cdip.ucsd.edu/thredds/dodsC/cdip/realtime/231p1_rt.nc.html\n", "http://thredds.secoora.org/thredds/dodsC/SECOORA_NCSU_CNAPS.nc.html\n", "http://www.neracoos.org/thredds/dodsC/WW3/EastCoast.nc.html\n", "http://www.neracoos.org/thredds/dodsC/WW3/GulfOfMaine.nc.html\n", "http://www.neracoos.org/thredds/dodsC/WW3/NorthAtlantic.nc.html\n", "http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_WAVE_FORECAST.nc.html\n", "\n", "\n" ] } ], "source": [ "from ioos_tools.ioos import service_urls, get_csw_records\n", "from owslib.csw import CatalogueServiceWeb\n", "\n", "\n", "dap_urls = []\n", "print(fmt(' Catalog information '))\n", "for endpoint in config['catalogs']:\n", " print('URL: {}'.format(endpoint))\n", " try:\n", " csw = CatalogueServiceWeb(endpoint, timeout=120)\n", " except Exception as e:\n", " print('{}'.format(e))\n", " continue\n", " csw = get_csw_records(csw, filter_list, esn='full')\n", " OPeNDAP = service_urls(csw.records, identifier='OPeNDAP:OPeNDAP')\n", " odp = service_urls(csw.records, identifier='urn:x-esri:specification:ServiceType:odp:url')\n", " dap = OPeNDAP + odp\n", " dap_urls.extend(dap)\n", "\n", " print('Number of datasets available: {}'.format(len(csw.records.keys())))\n", "\n", " for rec, item in csw.records.items():\n", " print('{}'.format(item.title))\n", " if dap:\n", " print(fmt(' DAP '))\n", " for url in dap:\n", " print('{}.html'.format(url))\n", " print('\\n')\n", "\n", "# Get only unique endpoints.\n", "dap_urls = list(set(dap_urls))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:36.030018Z", "start_time": "2017-10-27T19:00:29.692737Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "************************* Filtered DAP *************************\n", "http://www.neracoos.org/thredds/dodsC/WW3/GulfOfMaine.nc.html\n", "http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_WAVE_FORECAST.nc.html\n", "http://www.neracoos.org/thredds/dodsC/WW3/EastCoast.nc.html\n", "http://thredds.secoora.org/thredds/dodsC/SECOORA_NCSU_CNAPS.nc.html\n", "http://www.neracoos.org/thredds/dodsC/WW3/NorthAtlantic.nc.html\n" ] } ], "source": [ "from ioos_tools.ioos import is_station\n", "\n", "non_stations = []\n", "for url in dap_urls:\n", " try:\n", " if not is_station(url):\n", " non_stations.append(url)\n", " except (RuntimeError, OSError, IOError) as e:\n", " print('Could not access URL {}. {!r}'.format(url, e))\n", "\n", "dap_urls = non_stations\n", "\n", "print(fmt(' Filtered DAP '))\n", "for url in dap_urls:\n", " print('{}.html'.format(url))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:39.322918Z", "start_time": "2017-10-27T19:00:36.038034Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "******************* NDBC Collector offerings *******************\n", "National Data Buoy Center SOS: 1017 offerings\n" ] } ], "source": [ "from pyoos.collectors.ndbc.ndbc_sos import NdbcSos\n", "\n", "collector_ndbc = NdbcSos()\n", "\n", "collector_ndbc.set_bbox(config['region']['bbox'])\n", "collector_ndbc.end_time = config['date']['stop']\n", "collector_ndbc.start_time = config['date']['start']\n", "collector_ndbc.variables = [config['sos_name']]\n", "\n", "ofrs = collector_ndbc.server.offerings\n", "title = collector_ndbc.server.identification.title\n", "print(fmt(' NDBC Collector offerings '))\n", "print('{}: {} offerings'.format(title, len(ofrs)))" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "ExecuteTime": { "end_time": "2017-10-27T19:00:42.837283Z", "start_time": "2017-10-27T19:00:39.328931Z" } }, "outputs": [ { "data": { "text/html": [ "
\n", " | depth | \n", "lat | \n", "lon | \n", "sensor | \n", "station_name | \n", "
---|---|---|---|---|---|
station_code | \n", "\n", " | \n", " | \n", " | \n", " | \n", " |
44007 | \n", "None | \n", "43.525 | \n", "-70.141 | \n", "urn:ioos:sensor:wmo:44007::wpm1 | \n", "PORTLAND - 12 NM Southeast of Portland,ME | \n", "
44013 | \n", "None | \n", "42.346 | \n", "-70.651 | \n", "urn:ioos:sensor:wmo:44013::wpm1 | \n", "BOSTON 16 NM East of Boston, MA | \n", "
44020 | \n", "None | \n", "41.439 | \n", "-70.186 | \n", "urn:ioos:sensor:wmo:44020::wpm1 | \n", "NANTUCKET SOUND | \n", "
44029 | \n", "None | \n", "42.523 | \n", "-70.566 | \n", "urn:ioos:sensor:wmo:44029::summarywav1 | \n", "Buoy A01 - Massachusetts Bay | \n", "
44030 | \n", "None | \n", "43.181 | \n", "-70.428 | \n", "urn:ioos:sensor:wmo:44030::summarywav1 | \n", "Buoy B01 - Western Maine Shelf | \n", "
44032 | \n", "None | \n", "43.716 | \n", "-69.355 | \n", "urn:ioos:sensor:wmo:44032::summarywav1 | \n", "Buoy E01 - Central Maine Shelf | \n", "
44090 | \n", "None | \n", "41.840 | \n", "-70.329 | \n", "urn:ioos:sensor:wmo:44090::summarywav1 | \n", "Cape Cod Bay, MA (221) | \n", "
44098 | \n", "None | \n", "42.798 | \n", "-70.168 | \n", "urn:ioos:sensor:wmo:44098::summarywav1 | \n", "Jeffrey's Ledge, NH (160) | \n", "