Skip to content

Instantly share code, notes, and snippets.

@lukecampbell
Created June 24, 2016 14:08
Show Gist options
  • Save lukecampbell/284df11efdaf8ab0643865e6e5d55424 to your computer and use it in GitHub Desktop.
Save lukecampbell/284df11efdaf8ab0643865e6e5d55424 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{"nbformat_minor": 0, "cells": [{"execution_count": 1, "cell_type": "code", "source": "keywords_file = 'https://raw.githubusercontent.com/ioos/compliance-checker/cbc67f9750abe220944accb5e02408cc4f5c977d/compliance_checker/cf/gcmd_contents.json'\nimport requests\n\nresponse = requests.get(keywords_file)\nkeywords = response.json()", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 3, "cell_type": "code", "source": "path = '/Users/lcampbell/Downloads/HRALBPH_2016-06-23.nc'\nfrom netCDF4 import Dataset\nnc = Dataset(path)", "outputs": [], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 4, "cell_type": "code", "source": "from cdftools import dap", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}, {"execution_count": 8, "cell_type": "code", "source": "valid_keywords = []\nfor v in dap.get_geophysical_variables(nc):\n standard_name = nc.variables[v].standard_name\n if standard_name not in keywords:\n continue\n gcmd_keywords = keywords[standard_name]\n valid_keywords.extend(gcmd_keywords)\n \nvalid_keywords ", "outputs": [{"execution_count": 8, "output_type": "execute_result", "data": {"text/plain": "[u'Oceans > Ocean Chemistry > Oxygen',\n u'Oceans > Ocean Chemistry > pH',\n u'Oceans > Salinity/Density > Salinity',\n u'Oceans > Sea Surface Topography > Sea Surface Height',\n u'Oceans > Ocean Chemistry > Oxygen',\n u'Oceans > Salinity/Density > Conductivity',\n u'Oceans > Ocean Temperature > Water Temperature']"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": 9, "cell_type": "code", "source": "', '.join(valid_keywords)", "outputs": [{"execution_count": 9, "output_type": "execute_result", "data": {"text/plain": "u'Oceans > Ocean Chemistry > Oxygen, Oceans > Ocean Chemistry > pH, Oceans > Salinity/Density > Salinity, Oceans > Sea Surface Topography > Sea Surface Height, Oceans > Ocean Chemistry > Oxygen, Oceans > Salinity/Density > Conductivity, Oceans > Ocean Temperature > Water Temperature'"}, "metadata": {}}], "metadata": {"collapsed": false, "trusted": true}}, {"execution_count": null, "cell_type": "code", "source": "", "outputs": [], "metadata": {"collapsed": true, "trusted": true}}], "nbformat": 4, "metadata": {"kernelspec": {"display_name": "Python 2", "name": "python2", "language": "python"}, "language_info": {"mimetype": "text/x-python", "nbconvert_exporter": "python", "version": "2.7.10", "name": "python", "file_extension": ".py", "pygments_lexer": "ipython2", "codemirror_mode": {"version": 2, "name": "ipython"}}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment