Note
Go to the end to download the full example code.
Making GRIB dataset CF-compatible
from datetime import datetime, timedelta
from opendrift.models.windblow import WindBlow
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:
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
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)
14:33:06 INFO opendrift:569: OpenDriftSimulation initialised (version 1.14.9 / v1.14.9-78-ged5dc51)
14:33:06 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers:
14:33:06 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000
14:33:06 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000
14:33:06 INFO opendrift:1914: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
14:33:06 INFO opendrift:1914: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
14:33:06 INFO opendrift:2211: 2026-06-18 14:33:06.065521 - step 1 of 48 - 10 active elements (0 deactivated)
14:33:06 INFO opendrift.readers:67: Opening file with xr.open_dataset
14:33:07 INFO opendrift.readers.reader_netCDF_CF_generic:340: Detected dimensions: {'time': ['time', 'time1', 'time2', 'time3'], 'x': 'lon', 'y': 'lat'}
14:33:07 INFO opendrift.readers.basereader:178: Variable x_wind will be rotated from eastward_wind
14:33:07 INFO opendrift.readers.basereader:178: Variable y_wind will be rotated from northward_wind
14:33:07 INFO opendrift:2211: 2026-06-18 15:33:06.065521 - step 2 of 48 - 10 active elements (0 deactivated)
14:33:07 INFO opendrift:2211: 2026-06-18 16:33:06.065521 - step 3 of 48 - 10 active elements (0 deactivated)
14:33:07 INFO opendrift:2211: 2026-06-18 17:33:06.065521 - step 4 of 48 - 10 active elements (0 deactivated)
14:33:07 INFO opendrift:2211: 2026-06-18 18:33:06.065521 - step 5 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-18 19:33:06.065521 - step 6 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-18 20:33:06.065521 - step 7 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-18 21:33:06.065521 - step 8 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-18 22:33:06.065521 - step 9 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-18 23:33:06.065521 - step 10 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-19 00:33:06.065521 - step 11 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-19 01:33:06.065521 - step 12 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-19 02:33:06.065521 - step 13 of 48 - 10 active elements (0 deactivated)
14:33:08 INFO opendrift:2211: 2026-06-19 03:33:06.065521 - step 14 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 04:33:06.065521 - step 15 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 05:33:06.065521 - step 16 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 06:33:06.065521 - step 17 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 07:33:06.065521 - step 18 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 08:33:06.065521 - step 19 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 09:33:06.065521 - step 20 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 10:33:06.065521 - step 21 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 11:33:06.065521 - step 22 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 12:33:06.065521 - step 23 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 13:33:06.065521 - step 24 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 14:33:06.065521 - step 25 of 48 - 10 active elements (0 deactivated)
14:33:09 INFO opendrift:2211: 2026-06-19 15:33:06.065521 - step 26 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 16:33:06.065521 - step 27 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 17:33:06.065521 - step 28 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 18:33:06.065521 - step 29 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 19:33:06.065521 - step 30 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 20:33:06.065521 - step 31 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 21:33:06.065521 - step 32 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 22:33:06.065521 - step 33 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-19 23:33:06.065521 - step 34 of 48 - 10 active elements (0 deactivated)
14:33:10 WARNING opendrift.readers.basereader.structured:324: Data block from https://thredds.ucar.edu/thredds/dodsC/grib/NCEP/GFS/Global_0p25deg/Best not large enough to cover element positions within timestep. Buffer size (12) must be increased. See `Variables.set_buffer_size`.
14:33:10 INFO opendrift:2211: 2026-06-20 00:33:06.065521 - step 35 of 48 - 10 active elements (0 deactivated)
14:33:10 INFO opendrift:2211: 2026-06-20 01:33:06.065521 - step 36 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 02:33:06.065521 - step 37 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 03:33:06.065521 - step 38 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 04:33:06.065521 - step 39 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 05:33:06.065521 - step 40 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 06:33:06.065521 - step 41 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 07:33:06.065521 - step 42 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 08:33:06.065521 - step 43 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 09:33:06.065521 - step 44 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 10:33:06.065521 - step 45 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 11:33:06.065521 - step 46 of 48 - 10 active elements (0 deactivated)
14:33:11 INFO opendrift:2211: 2026-06-20 12:33:06.065521 - step 47 of 48 - 10 active elements (0 deactivated)
14:33:12 INFO opendrift:2211: 2026-06-20 13:33:06.065521 - step 48 of 48 - 10 active elements (0 deactivated)
14:33:12 INFO opendrift:569: OpenDriftSimulation initialised (version 1.14.9 / v1.14.9-78-ged5dc51)
14:33:12 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers:
14:33:12 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000
14:33:12 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000
14:33:12 INFO opendrift:1914: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
14:33:12 INFO opendrift:1914: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
14:33:12 INFO opendrift:2211: 2026-06-18 14:33:06.065521 - step 1 of 48 - 10 active elements (0 deactivated)
14:33:12 INFO opendrift.readers:67: Opening file with xr.open_dataset
14:33:14 INFO opendrift.readers.reader_netCDF_CF_generic:340: Detected dimensions: {'time': 'time', 'x': 'longitude', 'y': 'latitude'}
14:33:14 INFO opendrift.readers.basereader:178: Variable x_wind will be rotated from eastward_wind
14:33:14 INFO opendrift.readers.basereader:178: Variable y_wind will be rotated from northward_wind
14:33:14 INFO opendrift:2211: 2026-06-18 15:33:06.065521 - step 2 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 16:33:06.065521 - step 3 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 17:33:06.065521 - step 4 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 18:33:06.065521 - step 5 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 19:33:06.065521 - step 6 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 20:33:06.065521 - step 7 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 21:33:06.065521 - step 8 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 22:33:06.065521 - step 9 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-18 23:33:06.065521 - step 10 of 48 - 10 active elements (0 deactivated)
14:33:15 INFO opendrift:2211: 2026-06-19 00:33:06.065521 - step 11 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 01:33:06.065521 - step 12 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 02:33:06.065521 - step 13 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 03:33:06.065521 - step 14 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 04:33:06.065521 - step 15 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 05:33:06.065521 - step 16 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 06:33:06.065521 - step 17 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 07:33:06.065521 - step 18 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 08:33:06.065521 - step 19 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 09:33:06.065521 - step 20 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 10:33:06.065521 - step 21 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 11:33:06.065521 - step 22 of 48 - 10 active elements (0 deactivated)
14:33:16 INFO opendrift:2211: 2026-06-19 12:33:06.065521 - step 23 of 48 - 10 active elements (0 deactivated)
14:33:17 INFO opendrift:2211: 2026-06-19 13:33:06.065521 - step 24 of 48 - 10 active elements (0 deactivated)
14:33:17 INFO opendrift:2211: 2026-06-19 14:33:06.065521 - step 25 of 48 - 10 active elements (0 deactivated)
14:33:17 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:17 INFO opendrift:2211: 2026-06-19 15:33:06.065521 - step 26 of 48 - 10 active elements (0 deactivated)
14:33:17 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:17 INFO opendrift:2211: 2026-06-19 16:33:06.065521 - step 27 of 48 - 10 active elements (0 deactivated)
14:33:17 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:17 INFO opendrift:2211: 2026-06-19 17:33:06.065521 - step 28 of 48 - 10 active elements (0 deactivated)
14:33:17 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:17 INFO opendrift:2211: 2026-06-19 18:33:06.065521 - step 29 of 48 - 10 active elements (0 deactivated)
14:33:18 INFO opendrift:2211: 2026-06-19 19:33:06.065521 - step 30 of 48 - 10 active elements (0 deactivated)
14:33:18 INFO opendrift:2211: 2026-06-19 20:33:06.065521 - step 31 of 48 - 10 active elements (0 deactivated)
14:33:18 INFO opendrift:2211: 2026-06-19 21:33:06.065521 - step 32 of 48 - 10 active elements (0 deactivated)
14:33:18 INFO opendrift:2211: 2026-06-19 22:33:06.065521 - step 33 of 48 - 10 active elements (0 deactivated)
14:33:18 INFO opendrift:2211: 2026-06-19 23:33:06.065521 - step 34 of 48 - 10 active elements (0 deactivated)
14:33:18 INFO opendrift:2211: 2026-06-20 00:33:06.065521 - step 35 of 48 - 10 active elements (0 deactivated)
14:33:18 INFO opendrift:2211: 2026-06-20 01:33:06.065521 - step 36 of 48 - 10 active elements (0 deactivated)
14:33:18 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:18 INFO opendrift:2211: 2026-06-20 02:33:06.065521 - step 37 of 48 - 10 active elements (0 deactivated)
14:33:18 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:18 INFO opendrift:2211: 2026-06-20 03:33:06.065521 - step 38 of 48 - 10 active elements (0 deactivated)
14:33:19 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:19 INFO opendrift:2211: 2026-06-20 04:33:06.065521 - step 39 of 48 - 10 active elements (0 deactivated)
14:33:19 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:19 INFO opendrift:2211: 2026-06-20 05:33:06.065521 - step 40 of 48 - 10 active elements (0 deactivated)
14:33:19 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:19 INFO opendrift:2211: 2026-06-20 06:33:06.065521 - step 41 of 48 - 10 active elements (0 deactivated)
14:33:19 INFO opendrift:2211: 2026-06-20 07:33:06.065521 - step 42 of 48 - 10 active elements (0 deactivated)
14:33:19 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:19 INFO opendrift:2211: 2026-06-20 08:33:06.065521 - step 43 of 48 - 10 active elements (0 deactivated)
14:33:19 WARNING opendrift.readers.basereader.structured:324: Data block from https://pae-paha.pacioos.hawaii.edu/thredds/dodsC/ncep_global/NCEP_Global_Atmospheric_Model_best.ncd not large enough to cover element positions within timestep. Buffer size (7) must be increased. See `Variables.set_buffer_size`.
14:33:19 INFO opendrift:2211: 2026-06-20 09:33:06.065521 - step 44 of 48 - 10 active elements (0 deactivated)
14:33:20 INFO opendrift:2211: 2026-06-20 10:33:06.065521 - step 45 of 48 - 10 active elements (0 deactivated)
14:33:20 INFO opendrift:2211: 2026-06-20 11:33:06.065521 - step 46 of 48 - 10 active elements (0 deactivated)
14:33:20 INFO opendrift:2211: 2026-06-20 12:33:06.065521 - step 47 of 48 - 10 active elements (0 deactivated)
14:33:20 INFO opendrift:2211: 2026-06-20 13:33:06.065521 - step 48 of 48 - 10 active elements (0 deactivated)
Some differences are expected as datasets may origin from different runs
simulations[0].plot(compare=simulations[1:], lscale='i', legend=['GRIB converted', 'netCDF CF compatible'])

(<GeoAxes: title={'center': 'OpenDrift - WindBlow\n2026-06-18 14:33 to 2026-06-20 14:33 UTC (49 steps)'}>, <Figure size 1100x1092.88 with 1 Axes>)
Total running time of the script: (0 minutes 26.525 seconds)