-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathmaps-with-bathymetry.py
More file actions
55 lines (49 loc) · 1.22 KB
/
maps-with-bathymetry.py
File metadata and controls
55 lines (49 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import xarray as xr, numpy as np
from matplotlib import pyplot as plt
from cartopy import crs as ccrs, feature as cfeature
import cmocean
gebco = xr.open_dataset("data/gebco_2020_noordzee.nc")
#%% Visualise the dataset
fig = plt.figure(dpi=300)
ax = fig.add_subplot(projection=ccrs.Robinson())
vmin = -300
vmax = 0
cmap = cmocean.cm.topo
cmap = cmocean.tools.crop(cmap, vmin, vmax, 0)
# Draw bathymetry data
bathymetry = (
gebco.elevation
# .coarsen(lat=10, lon=10, boundary="trim").mean()
.plot(
add_colorbar=False,
ax=ax,
# cmap="Blues_r",
cmap=cmap,
transform=ccrs.PlateCarree(),
vmin=vmin,
vmax=vmax,
)
)
cbar = plt.colorbar(bathymetry)
cbar.set_label("Depth / m")
ticks = np.array(list(range(vmin, vmax + 1, 50)))
cbar.set_ticks(ticks)
cbar.set_ticklabels(-ticks)
# Add land areas
ax.add_feature(
cfeature.NaturalEarthFeature(
"physical", "land", "10m"
),
facecolor="xkcd:dark grey",
edgecolor="none",
)
ax.add_feature(
cfeature.NaturalEarthFeature(
"physical", "lakes", "10m"
),
facecolor=cmap(1.0),
edgecolor="none",
)
# Axis settings
ax.set_extent([0, 8, 50, 60])
plt.savefig("figures/maps-with-bathymetry.png")