import numpy as np
with np.load("weather_data.npz") as weather:
wind_u = weather["wind_u"]
wind_v = weather["wind_v"]
temperature = weather["temperature"]
rain = weather["rain"]
uk_mask = weather["uk"]
irl_mask = weather["ireland"]
spain_mask = weather["spain"]
import matplotlib.pyplot as plt
fig, ax = plt.subplots(
ncols=2, # two subplot, side by side
figsize=(10,5), # make the figure a little bigger
constrained_layout=True, # make the best use of the space
)
# The two subplots are ax[0] and ax[1]
# coolwarm is a diverging colour map
# Pass the vmin and vmax to set them to the same scale
im_u = ax[0].imshow(wind_u, cmap="coolwarm", vmin=-20, vmax=20)
im_v = ax[1].imshow(wind_v, cmap="coolwarm", vmin=-20, vmax=20)
fig.colorbar(im_v, ax=ax[1])
ax[0].title.set_text("Wind velocity U ($ms^{-1}$) (red: East, blue: West)")
ax[1].title.set_text("Wind velocity V ($ms^{-1}$) (red: North, blue: South)")
wind_speed = np.sqrt(wind_u ** 2 + wind_v ** 2)
wind_dir = np.degrees(np.arctan2(wind_u, wind_v)) # clockwise from North
import matplotlib.pyplot as plt
fig, ax = plt.subplots(ncols=2, figsize=(10,5), constrained_layout=True)
im_s = ax[0].imshow(wind_speed, vmin=0)
im_d = ax[1].imshow(wind_dir, cmap="twilight") # twilight is a cyclic colour map
ax[0].title.set_text("Wind speed ($ms^{-1}$)")
ax[1].title.set_text("Wind direction (red: East, blue: West)")
fig.colorbar(im_s, ax=ax[0])