{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "\n# Making GRIB dataset CF-compatible\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from datetime import datetime, timedelta\nfrom opendrift.models.windblow import WindBlow" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Comparing / using two different wind datasets\n\nThe first dataset (UCAR) is a GRIB dataset served by Thredds as a netCDF dataset, but with GRIB attributes\n CF standard_name are added for identified surface variables (wind) with this method:\n https://opendrift.github.io/_modules/opendrift/readers.html#add_standard_name_for_surface_grib_variables\n This should be used with care, making sure that only surface (10m height) variables are used\n\nThe second dataset (PACIOOS) is a netCDF4 dataset served by Thredds with CF attributes\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "wind_datasets = [\n 'https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/GFS/Global_0p25deg/Best',\n 'https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd'\n ]\n\nsimulations = []\n\ntime = datetime.now() - timedelta(days=5)\nfor wind in wind_datasets:\n o = WindBlow(loglevel=20)\n o.add_readers_from_list(wind)\n o.seed_elements(lon=3, lat=60, time=time, number=10, radius=10000)\n o.run(duration=timedelta(hours=48))\n simulations.append(o)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Some differences are expected as datasets may origin from different runs\n\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], "source": [ "simulations[0].plot(compare=simulations[1:], lscale='i', legend=['GRIB converted', 'netCDF CF compatible'])" ] } ], "metadata": { "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.14.6" } }, "nbformat": 4, "nbformat_minor": 0 }