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)
15:50:09 INFO opendrift:569: OpenDriftSimulation initialised (version 1.14.11 / v1.14.12-32-g22db1c0)
15:50:09 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers:
15:50:09 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000
15:50:09 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000
15:50:09 INFO opendrift:1921: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
15:50:09 INFO opendrift:1921: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
15:50:09 INFO opendrift:2237: 2026-09-30 15:50:08.867451 - step 1 of 48 - 10 active elements (0 deactivated)
15:50:09 INFO opendrift.readers:67: Opening file with xr.open_dataset
15:50:10 INFO opendrift.readers.reader_netCDF_CF_generic:340: Detected dimensions: {'time': ['time', 'time1', 'time2', 'time3'], 'x': 'lon', 'y': 'lat'}
15:50:10 INFO opendrift.readers.basereader:175: Variable x_wind will be rotated from eastward_wind
15:50:10 INFO opendrift.readers.basereader:175: Variable y_wind will be rotated from northward_wind
15:50:10 INFO opendrift:2237: 2026-09-30 16:50:08.867451 - step 2 of 48 - 10 active elements (0 deactivated)
15:50:10 INFO opendrift:2237: 2026-09-30 17:50:08.867451 - step 3 of 48 - 10 active elements (0 deactivated)
15:50:10 INFO opendrift:2237: 2026-09-30 18:50:08.867451 - step 4 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-09-30 19:50:08.867451 - step 5 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-09-30 20:50:08.867451 - step 6 of 48 - 10 active elements (0 deactivated)
15:50:11 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`.
15:50:11 INFO opendrift:2237: 2026-09-30 21:50:08.867451 - step 7 of 48 - 10 active elements (0 deactivated)
15:50:11 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`.
15:50:11 INFO opendrift:2237: 2026-09-30 22:50:08.867451 - step 8 of 48 - 10 active elements (0 deactivated)
15:50:11 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`.
15:50:11 INFO opendrift:2237: 2026-09-30 23:50:08.867451 - step 9 of 48 - 10 active elements (0 deactivated)
15:50:11 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`.
15:50:11 INFO opendrift:2237: 2026-10-01 00:50:08.867451 - step 10 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-10-01 01:50:08.867451 - step 11 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-10-01 02:50:08.867451 - step 12 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-10-01 03:50:08.867451 - step 13 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-10-01 04:50:08.867451 - step 14 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-10-01 05:50:08.867451 - step 15 of 48 - 10 active elements (0 deactivated)
15:50:11 INFO opendrift:2237: 2026-10-01 06:50:08.867451 - step 16 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 07:50:08.867451 - step 17 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 08:50:08.867451 - step 18 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 09:50:08.867451 - step 19 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 10:50:08.867451 - step 20 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 11:50:08.867451 - step 21 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 12:50:08.867451 - step 22 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 13:50:08.867451 - step 23 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 14:50:08.867451 - step 24 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 15:50:08.867451 - step 25 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 16:50:08.867451 - step 26 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 17:50:08.867451 - step 27 of 48 - 10 active elements (0 deactivated)
15:50:12 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`.
15:50:12 INFO opendrift:2237: 2026-10-01 18:50:08.867451 - step 28 of 48 - 10 active elements (0 deactivated)
15:50:12 INFO opendrift:2237: 2026-10-01 19:50:08.867451 - step 29 of 48 - 10 active elements (0 deactivated)
15:50:12 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`.
15:50:12 INFO opendrift:2237: 2026-10-01 20:50:08.867451 - step 30 of 48 - 10 active elements (0 deactivated)
15:50:12 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`.
15:50:12 INFO opendrift:2237: 2026-10-01 21:50:08.867451 - step 31 of 48 - 10 active elements (0 deactivated)
15:50:13 INFO opendrift:2237: 2026-10-01 22:50:08.867451 - step 32 of 48 - 10 active elements (0 deactivated)
15:50:13 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`.
15:50:13 INFO opendrift:2237: 2026-10-01 23:50:08.867451 - step 33 of 48 - 10 active elements (0 deactivated)
15:50:13 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`.
15:50:13 INFO opendrift:2237: 2026-10-02 00:50:08.867451 - step 34 of 48 - 10 active elements (0 deactivated)
15:50:13 INFO opendrift:2237: 2026-10-02 01:50:08.867451 - step 35 of 48 - 10 active elements (0 deactivated)
15:50:13 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`.
15:50:13 INFO opendrift:2237: 2026-10-02 02:50:08.867451 - step 36 of 48 - 10 active elements (0 deactivated)
15:50:13 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`.
15:50:13 INFO opendrift:2237: 2026-10-02 03:50:08.867451 - step 37 of 48 - 10 active elements (0 deactivated)
15:50:13 INFO opendrift:2237: 2026-10-02 04:50:08.867451 - step 38 of 48 - 10 active elements (0 deactivated)
15:50:13 INFO opendrift:2237: 2026-10-02 05:50:08.867451 - step 39 of 48 - 10 active elements (0 deactivated)
15:50:13 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`.
15:50:13 INFO opendrift:2237: 2026-10-02 06:50:08.867451 - step 40 of 48 - 10 active elements (0 deactivated)
15:50:13 INFO opendrift:2237: 2026-10-02 07:50:08.867451 - step 41 of 48 - 10 active elements (0 deactivated)
15:50:13 INFO opendrift:2237: 2026-10-02 08:50:08.867451 - step 42 of 48 - 10 active elements (0 deactivated)
15:50:13 INFO opendrift:2237: 2026-10-02 09:50:08.867451 - step 43 of 48 - 10 active elements (0 deactivated)
15:50:14 INFO opendrift:2237: 2026-10-02 10:50:08.867451 - step 44 of 48 - 10 active elements (0 deactivated)
15:50:14 INFO opendrift:2237: 2026-10-02 11:50:08.867451 - step 45 of 48 - 10 active elements (0 deactivated)
15:50:14 INFO opendrift:2237: 2026-10-02 12:50:08.867451 - step 46 of 48 - 10 active elements (0 deactivated)
15:50:14 INFO opendrift:2237: 2026-10-02 13:50:08.867451 - step 47 of 48 - 10 active elements (0 deactivated)
15:50:14 INFO opendrift:2237: 2026-10-02 14:50:08.867451 - step 48 of 48 - 10 active elements (0 deactivated)
15:50:14 INFO opendrift:569: OpenDriftSimulation initialised (version 1.14.11 / v1.14.12-32-g22db1c0)
15:50:14 INFO opendrift.models.basemodel.environment:227: Fallback values will be used for the following variables which have no readers:
15:50:14 INFO opendrift.models.basemodel.environment:230: x_wind: 0.000000
15:50:14 INFO opendrift.models.basemodel.environment:230: y_wind: 0.000000
15:50:14 INFO opendrift:1921: Storing previous values of element property lon because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
15:50:14 INFO opendrift:1921: Storing previous values of element property lat because of condition (('general:coastline_action', 'in', ['stranding', 'previous']), 'or', ('general:seafloor_action', 'in', ['previous']))
15:50:14 INFO opendrift:2237: 2026-09-30 15:50:08.867451 - step 1 of 48 - 10 active elements (0 deactivated)
15:50:14 INFO opendrift.readers:67: Opening file with xr.open_dataset
15:50:16 INFO opendrift.readers.reader_netCDF_CF_generic:340: Detected dimensions: {'time': 'time', 'x': 'longitude', 'y': 'latitude'}
15:50:16 INFO opendrift.readers.basereader:175: Variable x_wind will be rotated from eastward_wind
15:50:16 INFO opendrift.readers.basereader:175: Variable y_wind will be rotated from northward_wind
15:50:17 INFO opendrift:2237: 2026-09-30 16:50:08.867451 - step 2 of 48 - 10 active elements (0 deactivated)
15:50:17 INFO opendrift:2237: 2026-09-30 17:50:08.867451 - step 3 of 48 - 10 active elements (0 deactivated)
15:50:17 INFO opendrift:2237: 2026-09-30 18:50:08.867451 - step 4 of 48 - 10 active elements (0 deactivated)
15:50:17 INFO opendrift:2237: 2026-09-30 19:50:08.867451 - step 5 of 48 - 10 active elements (0 deactivated)
15:50:17 INFO opendrift:2237: 2026-09-30 20:50:08.867451 - step 6 of 48 - 10 active elements (0 deactivated)
15:50: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`.
15:50:17 INFO opendrift:2237: 2026-09-30 21:50:08.867451 - step 7 of 48 - 10 active elements (0 deactivated)
15:50: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`.
15:50:17 INFO opendrift:2237: 2026-09-30 22:50:08.867451 - step 8 of 48 - 10 active elements (0 deactivated)
15:50: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`.
15:50:17 INFO opendrift:2237: 2026-09-30 23:50:08.867451 - step 9 of 48 - 10 active elements (0 deactivated)
15:50: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`.
15:50:17 INFO opendrift:2237: 2026-10-01 00:50:08.867451 - step 10 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 01:50:08.867451 - step 11 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 02:50:08.867451 - step 12 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 03:50:08.867451 - step 13 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 04:50:08.867451 - step 14 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 05:50:08.867451 - step 15 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 06:50:08.867451 - step 16 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 07:50:08.867451 - step 17 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 08:50:08.867451 - step 18 of 48 - 10 active elements (0 deactivated)
15:50:18 INFO opendrift:2237: 2026-10-01 09:50:08.867451 - step 19 of 48 - 10 active elements (0 deactivated)
15:50:19 INFO opendrift:2237: 2026-10-01 10:50:08.867451 - step 20 of 48 - 10 active elements (0 deactivated)
15:50:19 INFO opendrift:2237: 2026-10-01 11:50:08.867451 - step 21 of 48 - 10 active elements (0 deactivated)
15:50:19 INFO opendrift:2237: 2026-10-01 12:50:08.867451 - step 22 of 48 - 10 active elements (0 deactivated)
15:50:19 INFO opendrift:2237: 2026-10-01 13:50:08.867451 - step 23 of 48 - 10 active elements (0 deactivated)
15:50:19 INFO opendrift:2237: 2026-10-01 14:50:08.867451 - step 24 of 48 - 10 active elements (0 deactivated)
15:50:19 INFO opendrift:2237: 2026-10-01 15:50:08.867451 - step 25 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 16:50:08.867451 - step 26 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 17:50:08.867451 - step 27 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 18:50:08.867451 - step 28 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 19:50:08.867451 - step 29 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 20:50:08.867451 - step 30 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 21:50:08.867451 - step 31 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 22:50:08.867451 - step 32 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-01 23:50:08.867451 - step 33 of 48 - 10 active elements (0 deactivated)
15:50:20 INFO opendrift:2237: 2026-10-02 00:50:08.867451 - step 34 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 01:50:08.867451 - step 35 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 02:50:08.867451 - step 36 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 03:50:08.867451 - step 37 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 04:50:08.867451 - step 38 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 05:50:08.867451 - step 39 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 06:50:08.867451 - step 40 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 07:50:08.867451 - step 41 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 08:50:08.867451 - step 42 of 48 - 10 active elements (0 deactivated)
15:50:21 INFO opendrift:2237: 2026-10-02 09:50:08.867451 - step 43 of 48 - 10 active elements (0 deactivated)
15:50:22 INFO opendrift:2237: 2026-10-02 10:50:08.867451 - step 44 of 48 - 10 active elements (0 deactivated)
15:50:22 INFO opendrift:2237: 2026-10-02 11:50:08.867451 - step 45 of 48 - 10 active elements (0 deactivated)
15:50:22 INFO opendrift:2237: 2026-10-02 12:50:08.867451 - step 46 of 48 - 10 active elements (0 deactivated)
15:50:22 INFO opendrift:2237: 2026-10-02 13:50:08.867451 - step 47 of 48 - 10 active elements (0 deactivated)
15:50:22 INFO opendrift:2237: 2026-10-02 14:50:08.867451 - 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-09-30 15:50 to 2026-10-02 15:50 UTC (49 steps)'}>, <Figure size 797.888x1100 with 1 Axes>)
Total running time of the script: (0 minutes 26.486 seconds)