From 10b54af0072399dab5405cec7581d15945f82017 Mon Sep 17 00:00:00 2001 From: Mathew Biddle Date: Fri, 3 Sep 2021 11:28:19 -0400 Subject: [PATCH] adding ioos models catalog notebook --- .../2020-02-28-IOOS-models.ipynb | 209 ++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 jupyterbook/content/Code Gallery/data_access_notebooks/2020-02-28-IOOS-models.ipynb diff --git a/jupyterbook/content/Code Gallery/data_access_notebooks/2020-02-28-IOOS-models.ipynb b/jupyterbook/content/Code Gallery/data_access_notebooks/2020-02-28-IOOS-models.ipynb new file mode 100644 index 00000000..216384bc --- /dev/null +++ b/jupyterbook/content/Code Gallery/data_access_notebooks/2020-02-28-IOOS-models.ipynb @@ -0,0 +1,209 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# IOOS models: how to find model data in the catalog\n", + "\n", + "This is the third post on the series “IOOS Ocean Models IOOS.”" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "code_folding": [] + }, + "outputs": [], + "source": [ + "models = {\n", + " \"DOPPIO\": {\n", + " \"RA\": \"MARACOOS\",\n", + " \"url\": \"http://tds.marine.rutgers.edu/thredds/dodsC/roms/doppio/2017_da/avg/Averages_Best\",\n", + " \"var\": {\"standard_name\": \"sea_water_potential_temperature\"},\n", + " },\n", + " \"NYHOPS\": {\n", + " \"RA\": \"MARACOOS\",\n", + " \"url\": \"http://colossus.dl.stevens-tech.edu:8080/thredds/dodsC/latest/Complete_gcmplt.nc\",\n", + " \"var\": {\"standard_name\": \"sea_water_temperature\"},\n", + " },\n", + " \"NECOFS-GOM3\": {\n", + " \"RA\": \"NERACOOS\",\n", + " \"url\": \"http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_GOM3_FORECAST.nc\",\n", + " \"var\": {\"standard_name\": \"sea_water_potential_temperature\"},\n", + " },\n", + " \"NECOFS-MASSBAY\": {\n", + " \"RA\": \"NERACOOS\",\n", + " \"url\": \"http://www.smast.umassd.edu:8080/thredds/dodsC/FVCOM/NECOFS/Forecasts/NECOFS_FVCOM_OCEAN_MASSBAY_FORECAST.nc\",\n", + " \"var\": {\"standard_name\": \"sea_water_potential_temperature\"},\n", + " },\n", + " \"CNAPS\": {\n", + " \"RA\": \"SECOORA\",\n", + " \"url\": \"http://thredds.secoora.org/thredds/dodsC/SECOORA_NCSU_CNAPS.nc\",\n", + " \"var\": {\"standard_name\": \"sea_water_potential_temperature\"},\n", + " },\n", + " \"CMOP-SELFE\": {\n", + " \"RA\": \"NANOOS\",\n", + " \"url\": \"http://amb6400b.stccmop.org:8080/thredds/dodsC/model_data/forecast\",\n", + " \"var\": {\"standard_name\": \"average_sea_water_temperature\"},\n", + " },\n", + " \"OSU-ROMS\": {\n", + " \"RA\": \"NANOOS\",\n", + " \"url\": \"http://ona.coas.oregonstate.edu:8080/thredds/dodsC/NANOOS/OCOS\",\n", + " \"var\": {\"standard_name\": \"sea_water_potential_temperature\"},\n", + " },\n", + " \"Hawaii-ROMS\": {\n", + " \"RA\": \"PacIOOS\",\n", + " \"url\": \"http://oos.soest.hawaii.edu/thredds/dodsC/hioos/roms_forec/hiig/ROMS_Hawaii_Regional_Ocean_Model_best.ncd\",\n", + " \"var\": {\"standard_name\": \"sea_water_potential_temperature\"},\n", + " },\n", + " \"WCOFS\": {\n", + " \"url\": \"http://opendap.co-ops.nos.noaa.gov/thredds/dodsC/WCOFS/fmrc/Aggregated_7_day_WCOFS_Fields_Forecast_best.ncd\",\n", + " \"var\": {\"standard_name\": \"sea_water_temperature\"},\n", + " },\n", + " \"WestCoastUCSC\": {\n", + " \"url\": \"http://oceanmodeling.pmc.ucsc.edu:8080/thredds/dodsC/ccsra_2016a_phys_agg_zlevs/fmrc/CCSRA_2016a_Phys_ROMS_z-level_(depth)_Aggregation_best.ncd\",\n", + " \"var\": {\"long_name\": \"potential temperature\"},\n", + " },\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from owslib import fes\n", + "\n", + "\n", + "cf_names = set([list(model[\"var\"].values())[0] for model in models.values()])\n", + "\n", + "kw = dict(\n", + " wildCard=\"*\",\n", + " escapeChar=\"\\\\\",\n", + " singleChar=\"?\",\n", + " propertyname=\"apiso:Subject\",\n", + ")\n", + "\n", + "or_filt = fes.Or(\n", + " [\n", + " fes.PropertyIsLike(literal=(\"*{val}*\"), **kw)\n", + " for val in cf_names\n", + " ]\n", + ")" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "from datetime import datetime\n", + "from ioos_tools.ioos import fes_date_filter\n", + "\n", + "\n", + "start = datetime(2020, 1, 1)\n", + "stop = datetime(2020, 1, 8)\n", + "\n", + "begin, end = fes_date_filter(start, stop)" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "bbox = [-145, 20, -45, 50]\n", + "crs = \"urn:ogc:def:crs:OGC:1.3:CRS84\"\n", + "\n", + "\n", + "bbox_crs = fes.BBox(bbox, crs=crs)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [], + "source": [ + "filter_list = [\n", + " fes.And(\n", + " [\n", + " bbox_crs,\n", + " begin,\n", + " end,\n", + " or_filt,\n", + " ]\n", + " )\n", + "]" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [], + "source": [ + "from owslib.csw import CatalogueServiceWeb\n", + "from ioos_tools.ioos import get_csw_records\n", + "\n", + "\n", + "endpoint = \"https://data.ioos.us/csw\"\n", + "csw = CatalogueServiceWeb(endpoint, timeout=120)\n", + "csw = get_csw_records(csw, filter_list, esn=\"full\")" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "OrderedDict()\n" + ] + } + ], + "source": [ + "print(csw.records)" + ] + } + ], + "metadata": { + "_draft": { + "nbviewer_url": "https://gist.github.com/082ff31d26e85767e2bdcb622fb753b4" + }, + "gist": { + "data": { + "description": "2018-04-21-horizontal-slices", + "public": true + }, + "id": "082ff31d26e85767e2bdcb622fb753b4" + }, + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.1" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +}