Skip to content

Instantly share code, notes, and snippets.

@jurand71
Created December 1, 2022 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurand71/ff00ea928805c61d3df05c50169f96b7 to your computer and use it in GitHub Desktop.
Save jurand71/ff00ea928805c61d3df05c50169f96b7 to your computer and use it in GitHub Desktop.
import numpy as np
import matplotlib.pyplot as plt
import geopandas
import cartopy.crs as ccrs
shpfilename = 'natural-earth-data/ne_10m_admin_0_countries_pol.shp'
# read the shapefile using geopandas
df_shp = geopandas.read_file(shpfilename)
# read Poland's geometry
poly = df_shp.loc[df_shp['ADM0_A3_PL'] == 'POL']['geometry'].values[0]
#create plot and set up basemap
plt.figure(figsize=(15,8))
ax = plt.axes(projection=ccrs.PlateCarree(), frameon=False)
#set coordinate and map extent
ax.set_extent([13.5, 24.5, 48.5, 55.5], crs=ccrs.PlateCarree())
#Poland's boundary
ax.add_geometries([poly], crs=ccrs.PlateCarree(), facecolor='none', edgecolor='0.6')
# data of seasonal annomalies in wind in December
first_period = df.ua10[0]
# przy values moze byc koniecznosc przekszalcenia do tablicy dwuwymiarowej jezeli przy sciaganiu
# danych z Copernicusa byłoby kilka okresów
# coordinates and wind values
values = first_period.values
lon, lat = np.meshgrid(first_period.longitude, first_period.latitude)
# countour from matplotlib
cs = ax.contourf(lon, lat, values, alpha = 0.3, transform=ccrs.PlateCarree(), levels=50, cmap="seismic", vmin=-2, vmax=1)
plt.colorbar(cs, orientation="vertical", ax=ax)
plt.title('Prognoza odstępstw od średniej wieloletniej prędkości wiatru na wysokości 10m w grudniu 2022')
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment