.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/example_grib_cf.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_example_grib_cf.py: Making GRIB dataset CF-compatible ================================= .. GENERATED FROM PYTHON SOURCE LINES 6-10 .. code-block:: Python from datetime import datetime, timedelta from opendrift.models.windblow import WindBlow .. GENERATED FROM PYTHON SOURCE LINES 11-19 Comparing / using two different wind datasets The first dataset (UCAR) is a GRIB dataset served by Thredds as a netCDF dataset, but with GRIB attributes CF standard_name are added for identified surface variables (wind) with this method: https://opendrift.github.io/_modules/opendrift/readers.html#add_standard_name_for_surface_grib_variables This should be used with care, making sure that only surface (10m height) variables are used The second dataset (PACIOOS) is a netCDF4 dataset served by Thredds with CF attributes .. GENERATED FROM PYTHON SOURCE LINES 19-34 .. code-block:: Python wind_datasets = [ 'https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/GFS/Global_0p25deg/Best', 'https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd' ] simulations = [] time = datetime.now() - timedelta(days=5) for wind in wind_datasets: o = WindBlow(loglevel=20) o.add_readers_from_list(wind) o.seed_elements(lon=3, lat=60, time=time, number=10, radius=10000) o.run(duration=timedelta(hours=48)) simulations.append(o) .. rst-class:: sphx-glr-script-out .. code-block:: none 18:18:27 INFO opendrift:576: OpenDriftSimulation initialised (version 1.14.9 / v1.14.9-1-g9eceedb) 18:18:27 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers: 18:18:27 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000 18:18:27 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000 18:18:27 INFO opendrift:1847: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 18:18:27 INFO opendrift:1847: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 18:18:27 INFO opendrift:2144: 2026-03-13 18:18:27.240310 - step 1 of 48 - 10 active elements (0 deactivated) 18:18:27 INFO opendrift.readers:64: Opening file with xr.open_dataset 18:18:28 INFO opendrift.readers.reader_netCDF_CF_generic:340: Detected dimensions: {'time': ['time', 'time1', 'time2', 'time3'], 'x': 'lon', 'y': 'lat'} 18:18:28 INFO opendrift:2144: 2026-03-13 19:18:27.240310 - step 2 of 48 - 10 active elements (0 deactivated) 18:18:28 INFO opendrift:2144: 2026-03-13 20:18:27.240310 - step 3 of 48 - 10 active elements (0 deactivated) 18:18:28 INFO opendrift:2144: 2026-03-13 21:18:27.240310 - step 4 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-13 22:18:27.240310 - step 5 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-13 23:18:27.240310 - step 6 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 00:18:27.240310 - step 7 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 01:18:27.240310 - step 8 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 02:18:27.240310 - step 9 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 03:18:27.240310 - step 10 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 04:18:27.240310 - step 11 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 05:18:27.240310 - step 12 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 06:18:27.240310 - step 13 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 07:18:27.240310 - step 14 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 08:18:27.240310 - step 15 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 09:18:27.240310 - step 16 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 10:18:27.240310 - step 17 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 11:18:27.240310 - step 18 of 48 - 10 active elements (0 deactivated) 18:18:29 INFO opendrift:2144: 2026-03-14 12:18:27.240310 - step 19 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 13:18:27.240310 - step 20 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 14:18:27.240310 - step 21 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 15:18:27.240310 - step 22 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 16:18:27.240310 - step 23 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 17:18:27.240310 - step 24 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 18:18:27.240310 - step 25 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 19:18:27.240310 - step 26 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 20:18:27.240310 - step 27 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 21:18:27.240310 - step 28 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 22:18:27.240310 - step 29 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-14 23:18:27.240310 - step 30 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-15 00:18:27.240310 - step 31 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-15 01:18:27.240310 - step 32 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-15 02:18:27.240310 - step 33 of 48 - 10 active elements (0 deactivated) 18:18:30 INFO opendrift:2144: 2026-03-15 03:18:27.240310 - step 34 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 04:18:27.240310 - step 35 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 05:18:27.240310 - step 36 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 06:18:27.240310 - step 37 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 07:18:27.240310 - step 38 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 08:18:27.240310 - step 39 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 09:18:27.240310 - step 40 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 10:18:27.240310 - step 41 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 11:18:27.240310 - step 42 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 12:18:27.240310 - step 43 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 13:18:27.240310 - step 44 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 14:18:27.240310 - step 45 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 15:18:27.240310 - step 46 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 16:18:27.240310 - step 47 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:2144: 2026-03-15 17:18:27.240310 - step 48 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift:576: OpenDriftSimulation initialised (version 1.14.9 / v1.14.9-1-g9eceedb) 18:18:31 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers: 18:18:31 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000 18:18:31 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000 18:18:31 INFO opendrift:1847: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 18:18:31 INFO opendrift:1847: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous'])) 18:18:31 INFO opendrift:2144: 2026-03-13 18:18:27.240310 - step 1 of 48 - 10 active elements (0 deactivated) 18:18:31 INFO opendrift.readers:64: Opening file with xr.open_dataset 18:18:33 INFO opendrift.readers.reader_netCDF_CF_generic:340: Detected dimensions: {'time': 'time', 'x': 'longitude', 'y': 'latitude'} 18:18:33 INFO opendrift.readers.basereader:178: Variable x_wind will be rotated from eastward_wind 18:18:33 INFO opendrift.readers.basereader:178: Variable y_wind will be rotated from northward_wind 18:18:34 INFO opendrift:2144: 2026-03-13 19:18:27.240310 - step 2 of 48 - 10 active elements (0 deactivated) 18:18:34 INFO opendrift:2144: 2026-03-13 20:18:27.240310 - step 3 of 48 - 10 active elements (0 deactivated) 18:18:34 INFO opendrift:2144: 2026-03-13 21:18:27.240310 - step 4 of 48 - 10 active elements (0 deactivated) 18:18:34 INFO opendrift:2144: 2026-03-13 22:18:27.240310 - step 5 of 48 - 10 active elements (0 deactivated) 18:18:34 INFO opendrift:2144: 2026-03-13 23:18:27.240310 - step 6 of 48 - 10 active elements (0 deactivated) 18:18:34 INFO opendrift:2144: 2026-03-14 00:18:27.240310 - step 7 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 01:18:27.240310 - step 8 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 02:18:27.240310 - step 9 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 03:18:27.240310 - step 10 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 04:18:27.240310 - step 11 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 05:18:27.240310 - step 12 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 06:18:27.240310 - step 13 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 07:18:27.240310 - step 14 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 08:18:27.240310 - step 15 of 48 - 10 active elements (0 deactivated) 18:18:35 INFO opendrift:2144: 2026-03-14 09:18:27.240310 - step 16 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 10:18:27.240310 - step 17 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 11:18:27.240310 - step 18 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 12:18:27.240310 - step 19 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 13:18:27.240310 - step 20 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 14:18:27.240310 - step 21 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 15:18:27.240310 - step 22 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 16:18:27.240310 - step 23 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 17:18:27.240310 - step 24 of 48 - 10 active elements (0 deactivated) 18:18:36 INFO opendrift:2144: 2026-03-14 18:18:27.240310 - step 25 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-14 19:18:27.240310 - step 26 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-14 20:18:27.240310 - step 27 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-14 21:18:27.240310 - step 28 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-14 22:18:27.240310 - step 29 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-14 23:18:27.240310 - step 30 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-15 00:18:27.240310 - step 31 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-15 01:18:27.240310 - step 32 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-15 02:18:27.240310 - step 33 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-15 03:18:27.240310 - step 34 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-15 04:18:27.240310 - step 35 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-15 05:18:27.240310 - step 36 of 48 - 10 active elements (0 deactivated) 18:18:37 INFO opendrift:2144: 2026-03-15 06:18:27.240310 - step 37 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 07:18:27.240310 - step 38 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 08:18:27.240310 - step 39 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 09:18:27.240310 - step 40 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 10:18:27.240310 - step 41 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 11:18:27.240310 - step 42 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 12:18:27.240310 - step 43 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 13:18:27.240310 - step 44 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 14:18:27.240310 - step 45 of 48 - 10 active elements (0 deactivated) 18:18:38 INFO opendrift:2144: 2026-03-15 15:18:27.240310 - step 46 of 48 - 10 active elements (0 deactivated) 18:18:39 INFO opendrift:2144: 2026-03-15 16:18:27.240310 - step 47 of 48 - 10 active elements (0 deactivated) 18:18:39 INFO opendrift:2144: 2026-03-15 17:18:27.240310 - step 48 of 48 - 10 active elements (0 deactivated) .. GENERATED FROM PYTHON SOURCE LINES 35-36 Some differences are expected as datasets may origin from different runs .. GENERATED FROM PYTHON SOURCE LINES 36-37 .. code-block:: Python simulations[0].plot(compare=simulations[1:], lscale='i', legend=['GRIB converted', 'netCDF CF compatible']) .. image-sg:: /gallery/images/sphx_glr_example_grib_cf_001.png :alt: OpenDrift - WindBlow 2026-03-13 18:18 to 2026-03-15 18:18 UTC (49 steps) :srcset: /gallery/images/sphx_glr_example_grib_cf_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (,
) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 23.163 seconds) .. _sphx_glr_download_gallery_example_grib_cf.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: example_grib_cf.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: example_grib_cf.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: example_grib_cf.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_