Grid

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

o = OceanDrift(loglevel=20)  # Set loglevel to 0 for debug information

# Norkyst
reader_norkyst = reader_netCDF_CF_generic.Reader(o.test_data_folder() + '16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc')

o.add_reader(reader_norkyst)
#o.set_config('environment:fallback:land_binary_mask', 0)
o.set_config('drift:vertical_mixing', False)

Out:

13:43:50 INFO    opendrift.models.basemodel: OpenDriftSimulation initialised (version 1.7.1 / v1.7.1-87-g074c1d2)
13:43:50 INFO    opendrift.readers.reader_netCDF_CF_generic: Opening dataset: /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc

Seeding some particles

lons = np.linspace(3.5, 5.0, 100)
lats = np.linspace(60, 61, 100)
lons, lats = np.meshgrid(lons, lats)
lons = lons.ravel()
lats = lats.ravel()
o.seed_elements(lons, lats, radius=0, number=10000,
                time=reader_norkyst.start_time)

Running model

o.run(steps=60*2, time_step=1800, time_step_output=1800)

Out:

13:43:50 INFO    opendrift.models.basemodel: Fallback values will be used for the following variables which have no readers:
13:43:50 INFO    opendrift.models.basemodel:    x_wind: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    y_wind: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    upward_sea_water_velocity: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    ocean_vertical_diffusivity: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    sea_surface_wave_significant_height: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    surface_downward_x_stress: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    surface_downward_y_stress: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    turbulent_kinetic_energy: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    turbulent_generic_length_scale: 0.000000
13:43:50 INFO    opendrift.models.basemodel:    sea_floor_depth_below_sea_level: 10000.000000
13:43:50 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:43:50 INFO    opendrift_landmask_data.mask: locking landmask for generation..
13:43:50 INFO    opendrift_landmask_data.mask: decompressing memmap landmask to /tmp/landmask/mask.dat..
13:44:00 INFO    opendrift_landmask_data.mask: landmask generated
13:44:04 INFO    opendrift.models.basemodel: Using existing reader for land_binary_mask
13:44:04 INFO    opendrift.models.basemodel: Moving 469 out of 10000 points from land to water
13:44:05 INFO    opendrift.models.basemodel: 2015-11-16 00:00:00 - step 1 of 120 - 10000 active elements (0 deactivated)
13:44:05 INFO    opendrift.models.basemodel: 2015-11-16 00:30:00 - step 2 of 120 - 10000 active elements (0 deactivated)
13:44:05 INFO    opendrift.models.basemodel: 2015-11-16 01:00:00 - step 3 of 120 - 9751 active elements (249 deactivated)
13:44:05 INFO    opendrift.models.basemodel: 2015-11-16 01:30:00 - step 4 of 120 - 9591 active elements (409 deactivated)
13:44:05 INFO    opendrift.models.basemodel: 2015-11-16 02:00:00 - step 5 of 120 - 9497 active elements (503 deactivated)
13:44:05 INFO    opendrift.models.basemodel: 2015-11-16 02:30:00 - step 6 of 120 - 9438 active elements (562 deactivated)
13:44:05 INFO    opendrift.models.basemodel: 2015-11-16 03:00:00 - step 7 of 120 - 9379 active elements (621 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 03:30:00 - step 8 of 120 - 9345 active elements (655 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 04:00:00 - step 9 of 120 - 9300 active elements (700 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 04:30:00 - step 10 of 120 - 9273 active elements (727 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 05:00:00 - step 11 of 120 - 9242 active elements (758 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 05:30:00 - step 12 of 120 - 9216 active elements (784 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 06:00:00 - step 13 of 120 - 9196 active elements (804 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 06:30:00 - step 14 of 120 - 9167 active elements (833 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 07:00:00 - step 15 of 120 - 9151 active elements (849 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 07:30:00 - step 16 of 120 - 9126 active elements (874 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 08:00:00 - step 17 of 120 - 9102 active elements (898 deactivated)
13:44:06 INFO    opendrift.models.basemodel: 2015-11-16 08:30:00 - step 18 of 120 - 9081 active elements (919 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 09:00:00 - step 19 of 120 - 9045 active elements (955 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 09:30:00 - step 20 of 120 - 9022 active elements (978 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 10:00:00 - step 21 of 120 - 8990 active elements (1010 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 10:30:00 - step 22 of 120 - 8961 active elements (1039 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 11:00:00 - step 23 of 120 - 8939 active elements (1061 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 11:30:00 - step 24 of 120 - 8916 active elements (1084 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 12:00:00 - step 25 of 120 - 8893 active elements (1107 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 12:30:00 - step 26 of 120 - 8863 active elements (1137 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 13:00:00 - step 27 of 120 - 8830 active elements (1170 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 13:30:00 - step 28 of 120 - 8793 active elements (1207 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 14:00:00 - step 29 of 120 - 8774 active elements (1226 deactivated)
13:44:07 INFO    opendrift.models.basemodel: 2015-11-16 14:30:00 - step 30 of 120 - 8756 active elements (1244 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 15:00:00 - step 31 of 120 - 8737 active elements (1263 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 15:30:00 - step 32 of 120 - 8728 active elements (1272 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 16:00:00 - step 33 of 120 - 8707 active elements (1293 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 16:30:00 - step 34 of 120 - 8687 active elements (1313 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 17:00:00 - step 35 of 120 - 8666 active elements (1334 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 17:30:00 - step 36 of 120 - 8658 active elements (1342 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 18:00:00 - step 37 of 120 - 8637 active elements (1363 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 18:30:00 - step 38 of 120 - 8619 active elements (1381 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 19:00:00 - step 39 of 120 - 8596 active elements (1404 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 19:30:00 - step 40 of 120 - 8568 active elements (1432 deactivated)
13:44:08 INFO    opendrift.models.basemodel: 2015-11-16 20:00:00 - step 41 of 120 - 8550 active elements (1450 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-16 20:30:00 - step 42 of 120 - 8528 active elements (1472 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-16 21:00:00 - step 43 of 120 - 8480 active elements (1520 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-16 21:30:00 - step 44 of 120 - 8441 active elements (1559 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-16 22:00:00 - step 45 of 120 - 8417 active elements (1583 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-16 22:30:00 - step 46 of 120 - 8395 active elements (1605 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-16 23:00:00 - step 47 of 120 - 8377 active elements (1623 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-16 23:30:00 - step 48 of 120 - 8355 active elements (1645 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-17 00:00:00 - step 49 of 120 - 8335 active elements (1665 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-17 00:30:00 - step 50 of 120 - 8316 active elements (1684 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-17 01:00:00 - step 51 of 120 - 8299 active elements (1701 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-17 01:30:00 - step 52 of 120 - 8275 active elements (1725 deactivated)
13:44:09 INFO    opendrift.models.basemodel: 2015-11-17 02:00:00 - step 53 of 120 - 8254 active elements (1746 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 02:30:00 - step 54 of 120 - 8228 active elements (1772 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 03:00:00 - step 55 of 120 - 8199 active elements (1801 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 03:30:00 - step 56 of 120 - 8171 active elements (1829 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 04:00:00 - step 57 of 120 - 8156 active elements (1844 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 04:30:00 - step 58 of 120 - 8144 active elements (1856 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 05:00:00 - step 59 of 120 - 8130 active elements (1870 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 05:30:00 - step 60 of 120 - 8117 active elements (1883 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 06:00:00 - step 61 of 120 - 8100 active elements (1900 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 06:30:00 - step 62 of 120 - 8086 active elements (1914 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 07:00:00 - step 63 of 120 - 8069 active elements (1931 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 07:30:00 - step 64 of 120 - 8052 active elements (1948 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 08:00:00 - step 65 of 120 - 8021 active elements (1979 deactivated)
13:44:10 INFO    opendrift.models.basemodel: 2015-11-17 08:30:00 - step 66 of 120 - 7992 active elements (2008 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 09:00:00 - step 67 of 120 - 7969 active elements (2031 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 09:30:00 - step 68 of 120 - 7957 active elements (2043 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 10:00:00 - step 69 of 120 - 7946 active elements (2054 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 10:30:00 - step 70 of 120 - 7929 active elements (2071 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 11:00:00 - step 71 of 120 - 7916 active elements (2084 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 11:30:00 - step 72 of 120 - 7894 active elements (2106 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 12:00:00 - step 73 of 120 - 7883 active elements (2117 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 12:30:00 - step 74 of 120 - 7875 active elements (2125 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 13:00:00 - step 75 of 120 - 7866 active elements (2134 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 13:30:00 - step 76 of 120 - 7864 active elements (2136 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 14:00:00 - step 77 of 120 - 7861 active elements (2139 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 14:30:00 - step 78 of 120 - 7853 active elements (2147 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 15:00:00 - step 79 of 120 - 7844 active elements (2156 deactivated)
13:44:11 INFO    opendrift.models.basemodel: 2015-11-17 15:30:00 - step 80 of 120 - 7839 active elements (2161 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 16:00:00 - step 81 of 120 - 7831 active elements (2169 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 16:30:00 - step 82 of 120 - 7820 active elements (2180 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 17:00:00 - step 83 of 120 - 7816 active elements (2184 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 17:30:00 - step 84 of 120 - 7812 active elements (2188 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 18:00:00 - step 85 of 120 - 7811 active elements (2189 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 18:30:00 - step 86 of 120 - 7809 active elements (2191 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 19:00:00 - step 87 of 120 - 7805 active elements (2195 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 19:30:00 - step 88 of 120 - 7800 active elements (2200 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 20:00:00 - step 89 of 120 - 7789 active elements (2211 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 20:30:00 - step 90 of 120 - 7777 active elements (2223 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 21:00:00 - step 91 of 120 - 7766 active elements (2234 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 21:30:00 - step 92 of 120 - 7760 active elements (2240 deactivated)
13:44:12 INFO    opendrift.models.basemodel: 2015-11-17 22:00:00 - step 93 of 120 - 7754 active elements (2246 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-17 22:30:00 - step 94 of 120 - 7746 active elements (2254 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-17 23:00:00 - step 95 of 120 - 7743 active elements (2257 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-17 23:30:00 - step 96 of 120 - 7731 active elements (2269 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 00:00:00 - step 97 of 120 - 7722 active elements (2278 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 00:30:00 - step 98 of 120 - 7715 active elements (2285 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 01:00:00 - step 99 of 120 - 7711 active elements (2289 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 01:30:00 - step 100 of 120 - 7702 active elements (2298 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 02:00:00 - step 101 of 120 - 7696 active elements (2304 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 02:30:00 - step 102 of 120 - 7692 active elements (2308 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 03:00:00 - step 103 of 120 - 7687 active elements (2313 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 03:30:00 - step 104 of 120 - 7683 active elements (2317 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 04:00:00 - step 105 of 120 - 7673 active elements (2327 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 04:30:00 - step 106 of 120 - 7670 active elements (2330 deactivated)
13:44:13 INFO    opendrift.models.basemodel: 2015-11-18 05:00:00 - step 107 of 120 - 7670 active elements (2330 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 05:30:00 - step 108 of 120 - 7670 active elements (2330 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 06:00:00 - step 109 of 120 - 7670 active elements (2330 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 06:30:00 - step 110 of 120 - 7669 active elements (2331 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 07:00:00 - step 111 of 120 - 7669 active elements (2331 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 07:30:00 - step 112 of 120 - 7668 active elements (2332 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 08:00:00 - step 113 of 120 - 7667 active elements (2333 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 08:30:00 - step 114 of 120 - 7666 active elements (2334 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 09:00:00 - step 115 of 120 - 7665 active elements (2335 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 09:30:00 - step 116 of 120 - 7662 active elements (2338 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 10:00:00 - step 117 of 120 - 7661 active elements (2339 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 10:30:00 - step 118 of 120 - 7660 active elements (2340 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 11:00:00 - step 119 of 120 - 7658 active elements (2342 deactivated)
13:44:14 INFO    opendrift.models.basemodel: 2015-11-18 11:30:00 - step 120 of 120 - 7658 active elements (2342 deactivated)

Print and plot results

print(o)
o.animation(fast=False, corners=[3.5, 5.5, 59.9, 61.2])

Out:

===========================
--------------------
Reader performance:
--------------------
/root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc
 0:00:03.3  total
 0:00:00.0  preparing
 0:00:00.6  reading
 0:00:00.3  interpolation
 0:00:00.0  interpolation_time
 0:00:02.6  rotating vectors
 0:00:00.0  masking
--------------------
global_landmask
 0:00:00.2  total
 0:00:00.0  preparing
 0:00:00.2  reading
 0:00:00.0  masking
--------------------
Performance:
   26.1 total time
    0.4 configuration
   14.9 preparing main loop
     13.7 making dynamical landmask
      0.1 moving elements to ocean
      4.9 readers
        0.3 global_landmask
        0.7 postprocessing
    9.6 main loop
        3.5 /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc
      0.5 updating elements
    1.1 cleaning up
--------------------
===========================
Model:  OceanDrift     (OpenDrift version 1.7.1)
        7651 active Lagrangian3DArray particles  (2349 deactivated, 0 scheduled)
-------------------
Environment variables:
  -----
  x_sea_water_velocity
  y_sea_water_velocity
     1) /root/project/tests/test_data/16Nov2015_NorKyst_z_surface/norkyst800_subset_16Nov2015.nc
  -----
  land_binary_mask
     1) global_landmask
  -----
Readers not added for the following variables:
  ocean_vertical_diffusivity
  sea_floor_depth_below_sea_level
  sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment
  sea_surface_wave_period_at_variance_spectral_density_maximum
  sea_surface_wave_significant_height
  sea_surface_wave_stokes_drift_x_velocity
  sea_surface_wave_stokes_drift_y_velocity
  surface_downward_x_stress
  surface_downward_y_stress
  turbulent_generic_length_scale
  turbulent_kinetic_energy
  upward_sea_water_velocity
  x_wind
  y_wind

Time:
        Start: 2015-11-16 00:00:00
        Present: 2015-11-18 12:00:00
        Calculation steps: 120 * 0:30:00 - total time: 2 days, 12:00:00
        Output steps: 121 * 0:30:00
===========================

13:44:35 INFO    opendrift.models.basemodel: Saving animation to /root/project/docs/source/gallery/animations/example_grid_0.gif...
13:44:35 INFO    opendrift.models.basemodel: Making animated gif...
MovieWriter imagemagick unavailable; using Pillow instead.
../_images/example_grid_0.gif

Total running time of the script: ( 2 minutes 41.088 seconds)

Gallery generated by Sphinx-Gallery