Ensemble

from datetime import timedelta
import numpy as np
from opendrift.models.oceandrift import OceanDrift
from opendrift.readers import reader_netCDF_CF_generic

Drift simulation using 30 member ensemble wind data from MEPS model of MET Norway

o = OceanDrift(loglevel=20)
o.set_config('drift:vertical_mixing', False)
r = reader_netCDF_CF_generic.Reader('https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc')
o.add_reader(r)

o.seed_elements(lat=60, lon=4.9, time=r.start_time,
                radius=1000, number=10000)

o.run(duration=timedelta(hours=50), time_step=1800, time_step_output=3600)

Out:

13:44:19 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)
13:44:19 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: https://thredds.met.no/thredds/dodsC/mepslatest/meps_lagged_6_h_latest_2_5km_latest.nc
13:44:20 INFO    opendrift.models.basemodel: Fallback values will be used for the following variables which have no readers:
13:44:20 INFO    opendrift.models.basemodel:    x_sea_water_velocity: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    y_sea_water_velocity: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    upward_sea_water_velocity: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    ocean_vertical_diffusivity: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    sea_surface_wave_significant_height: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    surface_downward_x_stress: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    surface_downward_y_stress: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    turbulent_kinetic_energy: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    turbulent_generic_length_scale: 0.000000
13:44:20 INFO    opendrift.models.basemodel:    sea_floor_depth_below_sea_level: 10000.000000
13:44:20 INFO    opendrift.models.basemodel: Adding a dynamical landmask with max. priority based on assumed maximum speed of 1 m/s. Adding a customised landmask may be faster...
13:44:24 INFO    opendrift.models.basemodel: Using existing reader for land_binary_mask
13:44:24 INFO    opendrift.models.basemodel: All points are in ocean
13:44:24 INFO    opendrift.models.basemodel: 2021-09-24 11:00:00 - step 1 of 100 - 10000 active elements (0 deactivated)
13:44:25 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:25 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:25 INFO    opendrift.models.basemodel: 2021-09-24 11:30:00 - step 2 of 100 - 10000 active elements (0 deactivated)
13:44:25 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:25 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:25 INFO    opendrift.models.basemodel: 2021-09-24 12:00:00 - step 3 of 100 - 10000 active elements (0 deactivated)
13:44:25 INFO    opendrift.models.basemodel: 2021-09-24 12:30:00 - step 4 of 100 - 10000 active elements (0 deactivated)
13:44:26 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:26 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:26 INFO    opendrift.models.basemodel: 2021-09-24 13:00:00 - step 5 of 100 - 10000 active elements (0 deactivated)
13:44:26 INFO    opendrift.models.basemodel: 2021-09-24 13:30:00 - step 6 of 100 - 10000 active elements (0 deactivated)
13:44:27 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:27 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:27 INFO    opendrift.models.basemodel: 2021-09-24 14:00:00 - step 7 of 100 - 9999 active elements (1 deactivated)
13:44:27 INFO    opendrift.models.basemodel: 2021-09-24 14:30:00 - step 8 of 100 - 9999 active elements (1 deactivated)
13:44:27 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:27 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:27 INFO    opendrift.models.basemodel: 2021-09-24 15:00:00 - step 9 of 100 - 9997 active elements (3 deactivated)
13:44:28 INFO    opendrift.models.basemodel: 2021-09-24 15:30:00 - step 10 of 100 - 9983 active elements (17 deactivated)
13:44:28 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:28 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:28 INFO    opendrift.models.basemodel: 2021-09-24 16:00:00 - step 11 of 100 - 9952 active elements (48 deactivated)
13:44:28 INFO    opendrift.models.basemodel: 2021-09-24 16:30:00 - step 12 of 100 - 9875 active elements (125 deactivated)
13:44:29 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:29 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:29 INFO    opendrift.models.basemodel: 2021-09-24 17:00:00 - step 13 of 100 - 9697 active elements (303 deactivated)
13:44:29 INFO    opendrift.models.basemodel: 2021-09-24 17:30:00 - step 14 of 100 - 9408 active elements (592 deactivated)
13:44:30 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:30 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:30 INFO    opendrift.models.basemodel: 2021-09-24 18:00:00 - step 15 of 100 - 8911 active elements (1089 deactivated)
13:44:30 INFO    opendrift.models.basemodel: 2021-09-24 18:30:00 - step 16 of 100 - 8232 active elements (1768 deactivated)
13:44:30 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:30 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:30 INFO    opendrift.models.basemodel: 2021-09-24 19:00:00 - step 17 of 100 - 7351 active elements (2649 deactivated)
13:44:30 INFO    opendrift.models.basemodel: 2021-09-24 19:30:00 - step 18 of 100 - 6427 active elements (3573 deactivated)
13:44:31 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:31 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:31 INFO    opendrift.models.basemodel: 2021-09-24 20:00:00 - step 19 of 100 - 5584 active elements (4416 deactivated)
13:44:31 INFO    opendrift.models.basemodel: 2021-09-24 20:30:00 - step 20 of 100 - 4950 active elements (5050 deactivated)
13:44:32 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:32 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:32 INFO    opendrift.models.basemodel: 2021-09-24 21:00:00 - step 21 of 100 - 4352 active elements (5648 deactivated)
13:44:32 INFO    opendrift.models.basemodel: 2021-09-24 21:30:00 - step 22 of 100 - 3811 active elements (6189 deactivated)
13:44:32 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:32 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:32 INFO    opendrift.models.basemodel: 2021-09-24 22:00:00 - step 23 of 100 - 3341 active elements (6659 deactivated)
13:44:32 INFO    opendrift.models.basemodel: 2021-09-24 22:30:00 - step 24 of 100 - 2821 active elements (7179 deactivated)
13:44:33 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:33 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:33 INFO    opendrift.models.basemodel: 2021-09-24 23:00:00 - step 25 of 100 - 2262 active elements (7738 deactivated)
13:44:33 INFO    opendrift.models.basemodel: 2021-09-24 23:30:00 - step 26 of 100 - 1705 active elements (8295 deactivated)
13:44:33 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:33 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:33 INFO    opendrift.models.basemodel: 2021-09-25 00:00:00 - step 27 of 100 - 1296 active elements (8704 deactivated)
13:44:33 INFO    opendrift.models.basemodel: 2021-09-25 00:30:00 - step 28 of 100 - 973 active elements (9027 deactivated)
13:44:34 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:34 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:34 INFO    opendrift.models.basemodel: 2021-09-25 01:00:00 - step 29 of 100 - 757 active elements (9243 deactivated)
13:44:34 INFO    opendrift.models.basemodel: 2021-09-25 01:30:00 - step 30 of 100 - 616 active elements (9384 deactivated)
13:44:35 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:35 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:35 INFO    opendrift.models.basemodel: 2021-09-25 02:00:00 - step 31 of 100 - 528 active elements (9472 deactivated)
13:44:35 INFO    opendrift.models.basemodel: 2021-09-25 02:30:00 - step 32 of 100 - 483 active elements (9517 deactivated)
13:44:36 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:36 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:36 INFO    opendrift.models.basemodel: 2021-09-25 03:00:00 - step 33 of 100 - 435 active elements (9565 deactivated)
13:44:36 INFO    opendrift.models.basemodel: 2021-09-25 03:30:00 - step 34 of 100 - 415 active elements (9585 deactivated)
13:44:37 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:37 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:38 INFO    opendrift.models.basemodel: 2021-09-25 04:00:00 - step 35 of 100 - 404 active elements (9596 deactivated)
13:44:38 INFO    opendrift.models.basemodel: 2021-09-25 04:30:00 - step 36 of 100 - 397 active elements (9603 deactivated)
13:44:38 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:38 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:38 INFO    opendrift.models.basemodel: 2021-09-25 05:00:00 - step 37 of 100 - 393 active elements (9607 deactivated)
13:44:39 INFO    opendrift.models.basemodel: 2021-09-25 05:30:00 - step 38 of 100 - 389 active elements (9611 deactivated)
13:44:40 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:40 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:40 INFO    opendrift.models.basemodel: 2021-09-25 06:00:00 - step 39 of 100 - 388 active elements (9612 deactivated)
13:44:40 INFO    opendrift.models.basemodel: 2021-09-25 06:30:00 - step 40 of 100 - 386 active elements (9614 deactivated)
13:44:41 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:41 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:41 INFO    opendrift.models.basemodel: 2021-09-25 07:00:00 - step 41 of 100 - 386 active elements (9614 deactivated)
13:44:41 INFO    opendrift.models.basemodel: 2021-09-25 07:30:00 - step 42 of 100 - 384 active elements (9616 deactivated)
13:44:42 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:42 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:42 INFO    opendrift.models.basemodel: 2021-09-25 08:00:00 - step 43 of 100 - 380 active elements (9620 deactivated)
13:44:42 INFO    opendrift.models.basemodel: 2021-09-25 08:30:00 - step 44 of 100 - 378 active elements (9622 deactivated)
13:44:43 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:43 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:43 INFO    opendrift.models.basemodel: 2021-09-25 09:00:00 - step 45 of 100 - 378 active elements (9622 deactivated)
13:44:43 INFO    opendrift.models.basemodel: 2021-09-25 09:30:00 - step 46 of 100 - 377 active elements (9623 deactivated)
13:44:44 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:44 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:44 INFO    opendrift.models.basemodel: 2021-09-25 10:00:00 - step 47 of 100 - 375 active elements (9625 deactivated)
13:44:44 INFO    opendrift.models.basemodel: 2021-09-25 10:30:00 - step 48 of 100 - 375 active elements (9625 deactivated)
13:44:45 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:45 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:45 INFO    opendrift.models.basemodel: 2021-09-25 11:00:00 - step 49 of 100 - 373 active elements (9627 deactivated)
13:44:45 INFO    opendrift.models.basemodel: 2021-09-25 11:30:00 - step 50 of 100 - 371 active elements (9629 deactivated)
13:44:47 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:47 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:47 INFO    opendrift.models.basemodel: 2021-09-25 12:00:00 - step 51 of 100 - 370 active elements (9630 deactivated)
13:44:47 INFO    opendrift.models.basemodel: 2021-09-25 12:30:00 - step 52 of 100 - 370 active elements (9630 deactivated)
13:44:48 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:48 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:48 INFO    opendrift.models.basemodel: 2021-09-25 13:00:00 - step 53 of 100 - 370 active elements (9630 deactivated)
13:44:48 INFO    opendrift.models.basemodel: 2021-09-25 13:30:00 - step 54 of 100 - 367 active elements (9633 deactivated)
13:44:50 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:50 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:50 INFO    opendrift.models.basemodel: 2021-09-25 14:00:00 - step 55 of 100 - 358 active elements (9642 deactivated)
13:44:50 INFO    opendrift.models.basemodel: 2021-09-25 14:30:00 - step 56 of 100 - 340 active elements (9660 deactivated)
13:44:51 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:51 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:51 INFO    opendrift.models.basemodel: 2021-09-25 15:00:00 - step 57 of 100 - 304 active elements (9696 deactivated)
13:44:51 INFO    opendrift.models.basemodel: 2021-09-25 15:30:00 - step 58 of 100 - 267 active elements (9733 deactivated)
13:44:52 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:52 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:52 INFO    opendrift.models.basemodel: 2021-09-25 16:00:00 - step 59 of 100 - 215 active elements (9785 deactivated)
13:44:52 INFO    opendrift.models.basemodel: 2021-09-25 16:30:00 - step 60 of 100 - 162 active elements (9838 deactivated)
13:44:54 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:54 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:54 INFO    opendrift.models.basemodel: 2021-09-25 17:00:00 - step 61 of 100 - 120 active elements (9880 deactivated)
13:44:54 INFO    opendrift.models.basemodel: 2021-09-25 17:30:00 - step 62 of 100 - 85 active elements (9915 deactivated)
13:44:55 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:55 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:55 INFO    opendrift.models.basemodel: 2021-09-25 18:00:00 - step 63 of 100 - 63 active elements (9937 deactivated)
13:44:55 INFO    opendrift.models.basemodel: 2021-09-25 18:30:00 - step 64 of 100 - 52 active elements (9948 deactivated)
13:44:56 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:56 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:56 INFO    opendrift.models.basemodel: 2021-09-25 19:00:00 - step 65 of 100 - 41 active elements (9959 deactivated)
13:44:56 INFO    opendrift.models.basemodel: 2021-09-25 19:30:00 - step 66 of 100 - 29 active elements (9971 deactivated)
13:44:57 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:57 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:57 INFO    opendrift.models.basemodel: 2021-09-25 20:00:00 - step 67 of 100 - 19 active elements (9981 deactivated)
13:44:57 INFO    opendrift.models.basemodel: 2021-09-25 20:30:00 - step 68 of 100 - 12 active elements (9988 deactivated)
13:44:58 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:58 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:58 INFO    opendrift.models.basemodel: 2021-09-25 21:00:00 - step 69 of 100 - 9 active elements (9991 deactivated)
13:44:58 INFO    opendrift.models.basemodel: 2021-09-25 21:30:00 - step 70 of 100 - 7 active elements (9993 deactivated)
13:44:59 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:59 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:44:59 INFO    opendrift.models.basemodel: 2021-09-25 22:00:00 - step 71 of 100 - 2 active elements (9998 deactivated)
13:44:59 INFO    opendrift.models.basemodel: 2021-09-25 22:30:00 - step 72 of 100 - 1 active elements (9999 deactivated)
13:45:00 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:00 WARNING opendrift.readers.interpolation.structured: Ensemble data currently not extrapolated towards seafloor
13:45:00 INFO    opendrift.models.basemodel: 2021-09-25 23:00:00 - step 73 of 100 - 1 active elements (9999 deactivated)
13:45:00 WARNING opendrift.models.basemodel: The simulation stopped before requested end time was reached.
13:45:00 INFO    opendrift.models.basemodel: ========================
13:45:00 INFO    opendrift.models.basemodel: End of simulation:
13:45:00 INFO    opendrift.models.basemodel: No more active or scheduled elements, quitting.
13:45:00 INFO    opendrift.models.basemodel: Traceback (most recent call last):
  File "/root/project/opendrift/models/basemodel.py", line 2473, in run
    raise ValueError('No more active or scheduled elements, quitting.')
ValueError: No more active or scheduled elements, quitting.

13:45:00 INFO    opendrift.models.basemodel: 'The simulation stopped before requested end time was reached.'

13:45:00 INFO    opendrift.models.basemodel: ========================

Ensemble members are recycled among the 10000 particles

ensemble_number = np.remainder(np.arange(o.num_elements_total()), len(r.realizations)) + 1
o.animation(fast=True, color=ensemble_number, legend=['Member ' + str(i) for i in r.realizations], colorbar=False)

Out:

13:45:02 WARNING opendrift.models.basemodel: Plotting fast. This will make your plots less accurate.
13:45:04 INFO    opendrift.models.basemodel: Saving animation to /root/project/docs/source/gallery/animations/example_ensemble_0.gif...
13:45:04 INFO    opendrift.models.basemodel: Making animated gif...
MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_ensemble_0.gif

Total running time of the script: ( 1 minutes 3.946 seconds)

Gallery generated by Sphinx-Gallery