# Create the figure and plot background on different axes for i in range(1,49): timestep=timeinit+timedelta(hours=i) crs = ccrs.Mercator() fig, axarr = plt.subplots(nrows=3, ncols=7, figsize=(25, 10), constrained_layout=False, subplot_kw={'projection': crs}) axlist = axarr.flatten() for ax in axlist: plot_background(ax) time2 = data_det_vmax['gust'].metpy.time #clevs_dbz = np.arange(-2.5,72.5,2.5) #clevs_uh = np.arange(0,650,50) clevs_gust = np.arange(10,150,10) # cmap = plt.get_cmap('gist_ncar') # newcmap = ListedColormap(cmap(np.linspace(0.15, 0.9, 30))) cf1 = axlist[20].contourf(data_det_vmax.longitude, data_det_vmax.latitude, det_gust.metpy.loc[{'time': time2[i-1]}]*3.6, clevs_gust, cmap='CMRmap_r', extend='max',transform=ccrs.PlateCarree()) ccf1= axlist[20].contour(data_det_vmax.longitude, data_det_vmax.latitude, det_gust.metpy.loc[{'time': time2[i-1]}]*3.6, [50,70,90,110], colors='black', linestyles='dotted', linewidths=1, transform=ccrs.PlateCarree()) try: axlist[20].clabel(ccf1,fontsize=8, inline=1, inline_spacing=3, fmt='%i', rightside_up=True) except: print('error') axlist[20].set_title('Deterministic', fontsize=16) for j in range(0,20): # Upper left plot cf1 = axlist[j].contourf(data_gust.longitude, data_gust.latitude, vmax.metpy.loc[{'step': time[i], 'number': member[j]}]*3.6, clevs_gust, cmap='CMRmap_r', extend='max', transform=ccrs.PlateCarree()) ccf1= axlist[j].contour(data_gust.longitude, data_gust.latitude, vmax.metpy.loc[{'step': time[i], 'number': member[j]}]*3.6, [50,70,90,110], colors='black', linestyles='dotted', linewidths=1, transform=ccrs.PlateCarree()) try: axlist[j].clabel(ccf1,fontsize=8, inline=1, inline_spacing=3, fmt='%i', rightside_up=True) except: print('error') axlist[j].set_title('Member '+str(j+1), fontsize=16) #cb1= fig.colorbar(cf1, ax=axlist[j], orientation='vertical', #shrink=1, fraction=0.03, pad=0) #cb1.set_label('dBZ', size='x-large') # Set height padding for plots fig.set_constrained_layout_pads(w_pad=0., h_pad=10, hspace=0., wspace=0.) cb = fig.colorbar(cf1, ax=axarr.ravel().tolist(), orientation='vertical', ticks=(10,20,30,40,50,60,70,80,90,100,110,120,130), fraction=0.03, aspect=30, pad=0.02) cb.set_label('km/h', size='x-large') # Set figure title plt.gcf().text(0.135, 0.98, 'Model: ICON-D2-EPS 0.02° | ' + timeinit.strftime('Init: %d.%m.%Y %H:%M UTC | ')+timestep.strftime('Valid: %d.%m.%Y %H:%M UTC'), fontsize=20) plt.gcf().text(0.135, 0.94, 'Parameter: 1-hourly Maximum Wind Gust', fontsize=20) #plt.gcf().text(0.6, 0.94, timeinit.strftime('Init: %d.%m.%Y %H:%M UTC / ')+timestep.strftime('Valid: %d.%m.%Y %H:%M UTC'), fontsize=20) #plt.gcf().text(0.55, 0.09, 'Note: Updraft helicity is vertically averaged between 500 and 6000 m AGL.', fontsize=10) # Display the plot time2 = str(i*1) base_filename='icond2eps_vmax_' suffix='.jpeg' latest='latest' my_file = base_filename+time2+suffix print(my_file) plt.savefig(my_file, format="jpeg", bbox_inches='tight', dpi=100) plt.close(fig)