Skip to content

Commit 5dfe9ee

Browse files
authored
Merge pull request #1650 from knutfrode/dev
[run-ex] Adding example illustrating custom shape landmask reader for…
2 parents 6dea224 + 1143db4 commit 5dfe9ee

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

examples/example_lake.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
"""
3+
Caspian / lake
4+
===============
5+
"""
6+
7+
from datetime import datetime, timedelta
8+
from opendrift.models.oceandrift import OceanDrift
9+
from opendrift.readers import reader_shape
10+
import cartopy
11+
12+
#%%
13+
# The default GSHHG landmask reader classifies lakes
14+
# (e.g. Caspian Sea) as land and not water.
15+
# For simulations in lakes, we can use a custom reader for lakes only.
16+
level = 'h' # using high resolution coastline
17+
reader_lakes = reader_shape.Reader.from_shpfiles(
18+
f'{cartopy.config['data_dir']}/shapefiles/gshhs/{level}/GSHHS_{level}_L2.shp',
19+
invert=True) # Inverting since inside of polygons is water (lake) and not land.
20+
21+
#%%
22+
# Disabling the default landmask reader, and using the above reader instead
23+
o = OceanDrift(loglevel=20)
24+
o.add_reader(reader_lakes)
25+
o.set_config('general:use_auto_landmask', False) # To use custom landmask instead
26+
o.set_config('environment:constant:x_sea_water_velocity', 1)
27+
o.set_config('drift:horizontal_diffusivity', 100)
28+
o.seed_elements(lon=48.819, lat=44.959, radius=5000, number=100, time=datetime.now())
29+
30+
o.run(steps=10)
31+
o.plot(fast=False, buffer=2)

0 commit comments

Comments
 (0)