River runoff

import os
from datetime import datetime, timedelta
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.dates import DateFormatter
import opendrift
from opendrift.models.oceandrift import OceanDrift
from opendrift.readers import reader_oscillating


outfile = 'runoff.nc'  # Raw simulation output
histogram_file = 'runoff_histogram.nc'

First make a simulation with two seedings, marked by origin_marker

o = OceanDrift(loglevel=20)
o.set_config('drift:horizontal_diffusivity', 300)
o.set_config('general:coastline_action', 'previous')
t1 = datetime.now()
t2 = t1 + timedelta(hours=48)
reader_x = reader_oscillating.Reader('x_sea_water_velocity', period_seconds=3600*24,
                amplitude=1, zero_time=t1)
reader_y = reader_oscillating.Reader('y_sea_water_velocity', period_seconds=3600*72,
                amplitude=.5, zero_time=t2)
o.add_reader([reader_x, reader_y])
number = 25000
o.seed_elements(time=[t1, t2], lon=9.017931, lat=58.562702, number=number,
                origin_marker_name='River 1')  # River 1
o.seed_elements(time=[t1, t2], lon=8.824815, lat=58.425648, number=number,
                origin_marker_name='River 2')  # River 2
seed_times = o.elements_scheduled_time[0:number]

o.run(duration=timedelta(hours=48),
      time_step=1800, time_step_output=3600, outfile=outfile)
12:54:03 INFO    opendrift.models.basemodel:515: OpenDriftSimulation initialised (version 1.11.13 / v1.11.13-99-gd2132d3)
12:54:03 INFO    opendrift.models.basemodel.environment:218: Adding a dynamical landmask with max. priority based on assumed maximum speed of 2.0 m/s. Adding a customised landmask may be faster...
12:54:07 INFO    opendrift.models.basemodel.environment:245: Fallback values will be used for the following variables which have no readers:
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_height: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    x_wind: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    y_wind: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    upward_sea_water_velocity: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    ocean_vertical_diffusivity: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_significant_height: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_x_velocity: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_stokes_drift_y_velocity: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_period_at_variance_spectral_density_maximum: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wave_mean_period_from_variance_spectral_density_second_frequency_moment: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_to_direction: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_peak_period_from_variance_spectral_density: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_swell_wave_significant_height: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_to_direction: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_mean_period: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_surface_wind_wave_significant_height: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    surface_downward_x_stress: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    surface_downward_y_stress: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    turbulent_kinetic_energy: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    turbulent_generic_length_scale: 0.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    ocean_mixed_layer_thickness: 50.000000
12:54:07 INFO    opendrift.models.basemodel.environment:248:    sea_floor_depth_below_sea_level: 10000.000000
12:54:10 INFO    opendrift.models.basemodel:936: Using existing reader for land_binary_mask
12:54:10 INFO    opendrift.models.basemodel:947: All points are in ocean
12:54:10 INFO    opendrift.models.basemodel:2038: 2024-11-11 12:54:03.996710 - step 1 of 96 - 522 active elements (0 deactivated)
12:54:10 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:24:03.996710 - step 2 of 96 - 1042 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 13:54:03.996710 - step 3 of 96 - 1564 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:24:03.996710 - step 4 of 96 - 2084 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 14:54:03.996710 - step 5 of 96 - 2606 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:24:03.996710 - step 6 of 96 - 3126 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 15:54:03.996710 - step 7 of 96 - 3646 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:24:03.996710 - step 8 of 96 - 4168 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 16:54:03.996710 - step 9 of 96 - 4688 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:24:03.996710 - step 10 of 96 - 5210 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 17:54:03.996710 - step 11 of 96 - 5730 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 18:24:03.996710 - step 12 of 96 - 6250 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 18:54:03.996710 - step 13 of 96 - 6772 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 19:24:03.996710 - step 14 of 96 - 7292 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 19:54:03.996710 - step 15 of 96 - 7814 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 20:24:03.996710 - step 16 of 96 - 8334 active elements (0 deactivated)
12:54:12 INFO    opendrift.models.basemodel:2038: 2024-11-11 20:54:03.996710 - step 17 of 96 - 8854 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-11 21:24:03.996710 - step 18 of 96 - 9376 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-11 21:54:03.996710 - step 19 of 96 - 9896 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-11 22:24:03.996710 - step 20 of 96 - 10418 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-11 22:54:03.996710 - step 21 of 96 - 10938 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-11 23:24:03.996710 - step 22 of 96 - 11458 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-11 23:54:03.996710 - step 23 of 96 - 11980 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 00:24:03.996710 - step 24 of 96 - 12500 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 00:54:03.996710 - step 25 of 96 - 13022 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 01:24:03.996710 - step 26 of 96 - 13542 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 01:54:03.996710 - step 27 of 96 - 14062 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 02:24:03.996710 - step 28 of 96 - 14584 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 02:54:03.996710 - step 29 of 96 - 15104 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 03:24:03.996710 - step 30 of 96 - 15626 active elements (0 deactivated)
12:54:13 INFO    opendrift.models.basemodel:2038: 2024-11-12 03:54:03.996710 - step 31 of 96 - 16146 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 04:24:03.996710 - step 32 of 96 - 16668 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 04:54:03.996710 - step 33 of 96 - 17188 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 05:24:03.996710 - step 34 of 96 - 17708 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 05:54:03.996710 - step 35 of 96 - 18230 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 06:24:03.996710 - step 36 of 96 - 18750 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 06:54:03.996710 - step 37 of 96 - 19272 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 07:24:03.996710 - step 38 of 96 - 19792 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 07:54:03.996710 - step 39 of 96 - 20312 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 08:24:03.996710 - step 40 of 96 - 20834 active elements (0 deactivated)
12:54:14 INFO    opendrift.models.basemodel:2038: 2024-11-12 08:54:03.996710 - step 41 of 96 - 21354 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 09:24:03.996710 - step 42 of 96 - 21876 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 09:54:03.996710 - step 43 of 96 - 22396 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 10:24:03.996710 - step 44 of 96 - 22916 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 10:54:03.996710 - step 45 of 96 - 23438 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 11:24:03.996710 - step 46 of 96 - 23958 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 11:54:03.996710 - step 47 of 96 - 24480 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 12:24:03.996710 - step 48 of 96 - 25000 active elements (0 deactivated)
12:54:15 INFO    opendrift.models.basemodel:2038: 2024-11-12 12:54:03.996710 - step 49 of 96 - 25520 active elements (0 deactivated)
12:54:16 INFO    opendrift.models.basemodel:2038: 2024-11-12 13:24:03.996710 - step 50 of 96 - 26042 active elements (0 deactivated)
12:54:16 INFO    opendrift.models.basemodel:2038: 2024-11-12 13:54:03.996710 - step 51 of 96 - 26562 active elements (0 deactivated)
12:54:16 INFO    opendrift.models.basemodel:2038: 2024-11-12 14:24:03.996710 - step 52 of 96 - 27084 active elements (0 deactivated)
12:54:16 INFO    opendrift.models.basemodel:2038: 2024-11-12 14:54:03.996710 - step 53 of 96 - 27604 active elements (0 deactivated)
12:54:16 INFO    opendrift.models.basemodel:2038: 2024-11-12 15:24:03.996710 - step 54 of 96 - 28124 active elements (0 deactivated)
12:54:16 INFO    opendrift.models.basemodel:2038: 2024-11-12 15:54:03.996710 - step 55 of 96 - 28646 active elements (0 deactivated)
12:54:16 INFO    opendrift.models.basemodel:2038: 2024-11-12 16:24:03.996710 - step 56 of 96 - 29166 active elements (0 deactivated)
12:54:17 INFO    opendrift.models.basemodel:2038: 2024-11-12 16:54:03.996710 - step 57 of 96 - 29688 active elements (0 deactivated)
12:54:17 INFO    opendrift.models.basemodel:2038: 2024-11-12 17:24:03.996710 - step 58 of 96 - 30208 active elements (0 deactivated)
12:54:17 INFO    opendrift.models.basemodel:2038: 2024-11-12 17:54:03.996710 - step 59 of 96 - 30728 active elements (0 deactivated)
12:54:17 INFO    opendrift.models.basemodel:2038: 2024-11-12 18:24:03.996710 - step 60 of 96 - 31250 active elements (0 deactivated)
12:54:17 INFO    opendrift.models.basemodel:2038: 2024-11-12 18:54:03.996710 - step 61 of 96 - 31770 active elements (0 deactivated)
12:54:17 INFO    opendrift.models.basemodel:2038: 2024-11-12 19:24:03.996710 - step 62 of 96 - 32292 active elements (0 deactivated)
12:54:18 INFO    opendrift.models.basemodel:2038: 2024-11-12 19:54:03.996710 - step 63 of 96 - 32812 active elements (0 deactivated)
12:54:18 INFO    opendrift.models.basemodel:2038: 2024-11-12 20:24:03.996710 - step 64 of 96 - 33334 active elements (0 deactivated)
12:54:18 INFO    opendrift.models.basemodel:2038: 2024-11-12 20:54:03.996710 - step 65 of 96 - 33854 active elements (0 deactivated)
12:54:18 INFO    opendrift.models.basemodel:2038: 2024-11-12 21:24:03.996710 - step 66 of 96 - 34374 active elements (0 deactivated)
12:54:18 INFO    opendrift.models.basemodel:2038: 2024-11-12 21:54:03.996710 - step 67 of 96 - 34896 active elements (0 deactivated)
12:54:19 INFO    opendrift.models.basemodel:2038: 2024-11-12 22:24:03.996710 - step 68 of 96 - 35416 active elements (0 deactivated)
12:54:19 INFO    opendrift.models.basemodel:2038: 2024-11-12 22:54:03.996710 - step 69 of 96 - 35938 active elements (0 deactivated)
12:54:19 INFO    opendrift.models.basemodel:2038: 2024-11-12 23:24:03.996710 - step 70 of 96 - 36458 active elements (0 deactivated)
12:54:19 INFO    opendrift.models.basemodel:2038: 2024-11-12 23:54:03.996710 - step 71 of 96 - 36978 active elements (0 deactivated)
12:54:20 INFO    opendrift.models.basemodel:2038: 2024-11-13 00:24:03.996710 - step 72 of 96 - 37500 active elements (0 deactivated)
12:54:20 INFO    opendrift.models.basemodel:2038: 2024-11-13 00:54:03.996710 - step 73 of 96 - 38020 active elements (0 deactivated)
12:54:20 INFO    opendrift.models.basemodel:2038: 2024-11-13 01:24:03.996710 - step 74 of 96 - 38542 active elements (0 deactivated)
12:54:20 INFO    opendrift.models.basemodel:2038: 2024-11-13 01:54:03.996710 - step 75 of 96 - 39062 active elements (0 deactivated)
12:54:21 INFO    opendrift.models.basemodel:2038: 2024-11-13 02:24:03.996710 - step 76 of 96 - 39582 active elements (0 deactivated)
12:54:21 INFO    opendrift.models.basemodel:2038: 2024-11-13 02:54:03.996710 - step 77 of 96 - 40104 active elements (0 deactivated)
12:54:21 INFO    opendrift.models.basemodel:2038: 2024-11-13 03:24:03.996710 - step 78 of 96 - 40624 active elements (0 deactivated)
12:54:21 INFO    opendrift.models.basemodel:2038: 2024-11-13 03:54:03.996710 - step 79 of 96 - 41146 active elements (0 deactivated)
12:54:22 INFO    opendrift.models.basemodel:2038: 2024-11-13 04:24:03.996710 - step 80 of 96 - 41666 active elements (0 deactivated)
12:54:22 INFO    opendrift.models.basemodel:2038: 2024-11-13 04:54:03.996710 - step 81 of 96 - 42186 active elements (0 deactivated)
12:54:23 INFO    opendrift.models.basemodel:2038: 2024-11-13 05:24:03.996710 - step 82 of 96 - 42708 active elements (0 deactivated)
12:54:23 INFO    opendrift.models.basemodel:2038: 2024-11-13 05:54:03.996710 - step 83 of 96 - 43228 active elements (0 deactivated)
12:54:23 INFO    opendrift.models.basemodel:2038: 2024-11-13 06:24:03.996710 - step 84 of 96 - 43750 active elements (0 deactivated)
12:54:23 INFO    opendrift.models.basemodel:2038: 2024-11-13 06:54:03.996710 - step 85 of 96 - 44270 active elements (0 deactivated)
12:54:24 INFO    opendrift.models.basemodel:2038: 2024-11-13 07:24:03.996710 - step 86 of 96 - 44790 active elements (0 deactivated)
12:54:24 INFO    opendrift.models.basemodel:2038: 2024-11-13 07:54:03.996710 - step 87 of 96 - 45312 active elements (0 deactivated)
12:54:25 INFO    opendrift.models.basemodel:2038: 2024-11-13 08:24:03.996710 - step 88 of 96 - 45832 active elements (0 deactivated)
12:54:25 INFO    opendrift.models.basemodel:2038: 2024-11-13 08:54:03.996710 - step 89 of 96 - 46354 active elements (0 deactivated)
12:54:25 INFO    opendrift.models.basemodel:2038: 2024-11-13 09:24:03.996710 - step 90 of 96 - 46874 active elements (0 deactivated)
12:54:26 INFO    opendrift.models.basemodel:2038: 2024-11-13 09:54:03.996710 - step 91 of 96 - 47394 active elements (0 deactivated)
12:54:26 INFO    opendrift.models.basemodel:2038: 2024-11-13 10:24:03.996710 - step 92 of 96 - 47916 active elements (0 deactivated)
12:54:26 INFO    opendrift.models.basemodel:2038: 2024-11-13 10:54:03.996710 - step 93 of 96 - 48436 active elements (0 deactivated)
12:54:27 INFO    opendrift.models.basemodel:2038: 2024-11-13 11:24:03.996710 - step 94 of 96 - 48958 active elements (0 deactivated)
12:54:27 INFO    opendrift.models.basemodel:2038: 2024-11-13 11:54:03.996710 - step 95 of 96 - 49478 active elements (0 deactivated)
12:54:28 INFO    opendrift.models.basemodel:2038: 2024-11-13 12:24:03.996710 - step 96 of 96 - 50000 active elements (0 deactivated)
12:54:30 INFO    opendrift.export.io_netcdf:121: Wrote 49 steps to file runoff.nc
/opt/conda/envs/opendrift/lib/python3.11/site-packages/numpy/ma/core.py:467: RuntimeWarning: invalid value encountered in cast
  fill_value = np.array(fill_value, copy=False, dtype=ndtype)

Opening the output file lazily with Xarray. This will work even if the file is too large to fit in memory, as it will read and process data chuck-by-chunk directly from file using Dask.

o = opendrift.open_xarray(outfile)
12:54:38 DEBUG   opendrift.config:168: Adding 18 config items from __init__
12:54:38 DEBUG   opendrift.config:178:   Overwriting config item readers:max_number_of_fails
12:54:38 DEBUG   opendrift.config:168: Adding 5 config items from __init__
12:54:38 INFO    opendrift.models.basemodel:515: OpenDriftSimulation initialised (version 1.11.13 / v1.11.13-99-gd2132d3)
12:54:38 DEBUG   opendrift.config:168: Adding 15 config items from oceandrift
12:54:38 DEBUG   opendrift.config:178:   Overwriting config item seed:z
12:54:38 DEBUG   opendrift.export.io_netcdf:239: Importing with Xarray from runoff.nc
12:54:38 INFO    opendrift:118: Returning <class 'opendrift.models.oceandrift.OceanDrift'> object

We want to extract timeseries of river water at the coordinates of a hypothetical measuring station as well as the amount of river water passing through two defined areas/regions

station_lon = 9.4
station_lat = 58.1
box1_lon = [8.4, 8.8]
box1_lat = [57.9, 58.1]
box2_lon = [9.5, 9.9]
box2_lat = [58.3, 58.5]

Animation of the spatial density of river runoff water. Although there are the same number of elements from each river, the density plots are weighted with the actual runoff at time of seeding. This weighting can be done/changed afterwards without needing to redo the simulation. The calculated density fields will be stored/cached in the analysis file for later re-use, as their calculation may be time consuming for huge output files. Note that other analysis/plotting methods are not yet adapted to datasets opened lazily with open_xarray

runoff_river1 = np.abs(np.cos(np.arange(number)*2*np.pi/(number)))  # Impose a temporal variation of runoff
runoff_river2 = 10*runoff_river1  # Let river 2 have 10 times as large runoff as river 1
runoff = np.concatenate((runoff_river1, runoff_river2))

Calculate density with given pixel size, weighted by runoff amount per element

river_water = o.get_histogram(pixelsize_m=1500, weights=runoff, density=False)

rw = river_water.sum(dim='origin_marker')  # For both rivers
#rw = river_water.isel(origin_marker=1)    # For one of the rivers
river_water.name = 'River water [m3/cell]'

text = [{'s': o.origin_marker[0], 'x': 8.55, 'y': 58.56, 'fontsize': 20, 'color': 'g',
         'backgroundcolor': 'white', 'bbox': dict(facecolor='white', alpha=0.8), 'zorder': 1000},
        {'s': o.origin_marker[1], 'x': 8.35, 'y': 58.42, 'fontsize': 20, 'color': 'g',
         'backgroundcolor': 'white', 'bbox': dict(facecolor='white', alpha=0.8), 'zorder': 1000},
        {'s': '* Station', 'x': station_lon, 'y': station_lat, 'fontsize': 20, 'color': 'k',
         'backgroundcolor': 'white', 'bbox': dict(facecolor='none', edgecolor='none', alpha=0.4), 'zorder': 1000}]
box = [{'lon': box1_lon, 'lat': box1_lat, 'text': 'Area 1', 'fc': 'none', 'alpha': 0.8, 'lw': 1, 'ec': 'k'},
       {'lon': box2_lon, 'lat': box2_lat, 'text': 'Area 2', 'fc': 'none', 'alpha': 0.8, 'lw': 1, 'ec': 'k'}]

o.animation(background=rw.where(rw>0), bgalpha=1, fast=False,
            show_elements=False, vmin=0, vmax=120, text=text, box=box)
12:54:38 INFO    opendrift.models.basemodel:3892:       calculating for origin_marker 0...
12:54:38 INFO    opendrift.models.basemodel:3892:       calculating for origin_marker 1...
12:54:39 DEBUG   opendrift.models.basemodel:2365: Setting up map: corners=None, fast=False, lscale=None
12:54:39 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
/opt/conda/envs/opendrift/lib/python3.11/site-packages/cartopy/mpl/geoaxes.py:1692: UserWarning: No data for colormapping provided via 'c'. Parameters 'cmap', 'vmin', 'vmax' will be ignored
  result = super().scatter(*args, **kwargs)
12:54:56 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:54:57 DEBUG   opendrift.models.basemodel:3044: Saving animation..
12:54:57 INFO    opendrift.models.basemodel:4613: Saving animation to /root/project/docs/source/gallery/animations/example_river_runoff_0.gif...
12:54:58 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:54:59 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:01 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:02 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:04 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:05 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:06 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:08 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:09 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:10 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:12 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:13 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:15 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:16 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:18 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:19 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:21 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:22 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:24 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:25 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:26 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:28 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:29 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:31 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:32 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:33 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:35 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:36 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:38 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:39 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:41 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:42 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:44 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:45 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:46 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:48 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:49 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:51 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:52 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:53 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:55 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:56 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:58 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:55:59 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:01 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:02 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:04 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:05 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:06 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:08 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:09 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:11 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:12 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:13 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:15 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:16 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:18 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:19 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:21 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:22 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:24 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:25 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:26 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:28 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:29 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:31 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:32 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:33 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:35 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:36 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:38 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:39 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:41 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:42 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:44 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:45 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:46 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:48 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:49 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:51 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:52 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:53 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:55 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:56 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:58 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:56:59 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:01 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:02 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:04 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:05 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:06 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:08 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:09 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:11 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:12 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:13 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:15 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:16 DEBUG   opendrift.readers.reader_global_landmask:78: Adding GSHHG shapes from cartopy, scale: h, extent: (7.309537506103514, 10.789533996582032, 57.41804962158203, 58.819724273681636)..
12:57:19 DEBUG   opendrift.models.basemodel:4651: MPLBACKEND = agg
12:57:19 DEBUG   opendrift.models.basemodel:4652: DISPLAY = None
12:57:19 DEBUG   opendrift.models.basemodel:4653: Time to save animation: 0:02:21.391194
12:57:19 INFO    opendrift.models.basemodel:3037: Time to make animation: 0:02:40.313226
../_images/example_river_runoff_0.gif

Plotting time series of river runoff, and corresponding water passing through the station and the two defined areas/boxes

fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1)
# Runoff
ax1.plot(seed_times, runoff_river1, label=o.origin_marker[0])
ax1.plot(seed_times, runoff_river2, label=o.origin_marker[1])
ax1.set_ylabel('Runoff  [m3/s]')
ax1.set_title('Runoff')
# Area 1
t1 = river_water.sel(lon_bin=slice(box1_lon[0], box1_lon[1]),
                     lat_bin=slice(box1_lat[0], box1_lat[1]))
t1 = t1.sum(('lon_bin', 'lat_bin'))
t1.isel(origin_marker=0).plot(label=o.origin_marker[0], ax=ax2)
t1.isel(origin_marker=1).plot(label=o.origin_marker[1], ax=ax2)
t1.sum(dim='origin_marker').plot(label='Total', linestyle='--', ax=ax2)
ax2.set_title('Amount of water passing through Area 1')
# Area 2
t2 = river_water.sel(lon_bin=slice(box2_lon[0], box2_lon[1]),
                     lat_bin=slice(box2_lat[0], box2_lat[1]))
t2 = t2.sum(('lon_bin', 'lat_bin'))
t2.isel(origin_marker=0).plot(label=o.origin_marker[0], ax=ax3)
t2.isel(origin_marker=1).plot(label=o.origin_marker[1], ax=ax3)
t2.sum(dim='origin_marker').plot(label='Total', linestyle='--', ax=ax3)
ax3.set_title('Amount of water passing through Area 2')
# Extracting time series at the location of the station
t = river_water.sel(lon_bin=station_lon, lat_bin=station_lat, method='nearest')
t.isel(origin_marker=0).plot(label=o.origin_marker[0], ax=ax4)
t.isel(origin_marker=1).plot(label=o.origin_marker[1], ax=ax4)
t.sum(dim='origin_marker').plot(label='Total', linestyle='--', ax=ax4)
ax4.legend()
ax4.margins(x=0)

for ax in [ax1, ax2, ax3]:
    ax.margins(x=0)
    ax.legend()
    #ax.set_xticks([])
    ax.set_xlabel(None)
ax4.set_title('Density of water at Station')
# TODO disabling due to recent problem with dateformatter
#ax4.xaxis.set_major_formatter(DateFormatter("%d %b %H"))
plt.show()
Runoff, Amount of water passing through Area 1, Amount of water passing through Area 2, Density of water at Station

Finally, plot the spatial distribution of mean age of water

num = o.get_histogram(pixelsize_m=1500, weights=None, density=False)
num.name = 'number'
num.to_netcdf(histogram_file)

mas = o.get_histogram(pixelsize_m=1500, weights=o.ds['age_seconds'], density=False)
mas = mas/3600  # in hours
mas = mas/num  # per area
mas.name='mean_age'
mas.to_netcdf(histogram_file, 'a')
mas = mas.mean(dim='time').sum(dim='origin_marker')  # Mean time of both rivers
#mas = mas.mean(dim='time').isel(origin_marker=1)  # Mean age of a single river
mas.name='Mean age of water [hours]'

o.plot(background=mas.where(mas>0), fast=True, show_elements=False)


# Cleaning up
os.remove(outfile)
os.remove(histogram_file)
OpenDrift - OceanDrift 2024-11-11 12:54 to 2024-11-13 12:54 UTC (49 steps)
12:57:20 INFO    opendrift.models.basemodel:3892:       calculating for origin_marker 0...
12:57:20 INFO    opendrift.models.basemodel:3892:       calculating for origin_marker 1...
12:57:20 INFO    opendrift.models.basemodel:3892:       calculating for origin_marker 0...
12:57:20 INFO    opendrift.models.basemodel:3892:       calculating for origin_marker 1...
12:57:20 DEBUG   opendrift.models.basemodel:2365: Setting up map: corners=None, fast=True, lscale=None
12:57:20 WARNING opendrift.models.basemodel:2411: Plotting fast. This will make your plots less accurate.

Total running time of the script: (3 minutes 23.607 seconds)

Gallery generated by Sphinx-Gallery