:param lon_plot: :param lat_plot: :param errors: Note that if plot_type is 2D, i.e is in ['heatmap', 'contour'], it has to have shape lat x lon :param var_name: :param plot_type: :param dpi: :return:
(lon_plot, lat_plot, errors, var_name=None, plot_type='scatter', dpi=70, title="")
| 260 | |
| 261 | |
| 262 | def profile_plot(lon_plot, lat_plot, errors, var_name=None, plot_type='scatter', dpi=70, title=""): |
| 263 | """ |
| 264 | |
| 265 | :param lon_plot: |
| 266 | :param lat_plot: |
| 267 | :param errors: Note that if plot_type is 2D, i.e is in ['heatmap', 'contour'], it has to have shape lat x lon |
| 268 | :param var_name: |
| 269 | :param plot_type: |
| 270 | :param dpi: |
| 271 | :return: |
| 272 | """ |
| 273 | import cartopy.crs as ccrs |
| 274 | import cartopy.feature as cfeature |
| 275 | fig = plt.figure(figsize=(12, 8)) |
| 276 | plt.rcParams['figure.dpi'] = dpi |
| 277 | plot_type = plot_type.lower() |
| 278 | |
| 279 | ax = fig.add_subplot(1, 1, 1, projection=ccrs.Robinson()) |
| 280 | ax.add_feature(cfeature.COASTLINE) |
| 281 | ax.gridlines() |
| 282 | # ax.stock_img() |
| 283 | ax.set_global() |
| 284 | |
| 285 | # jet = plt.cm.get_cmap('RdBu_r') |
| 286 | jet = plt.cm.get_cmap('plasma') |
| 287 | |
| 288 | # nightshade |
| 289 | # current_time = datetime.now() Can work well if we can get the UTC time for the data |
| 290 | # ax.add_feature(Nightshade(current_time, alpha=0.3)) |
| 291 | |
| 292 | # Circle params |
| 293 | fs_text = 10 |
| 294 | padd = -0.18 |
| 295 | stroffset = -0.2 |
| 296 | circlesize = 100 |
| 297 | lw = 2.2 |
| 298 | |
| 299 | if plot_type == 'contour': |
| 300 | sc = ax.contourf(lon_plot, lat_plot, errors, transform=ccrs.PlateCarree(), alpha=0.85, cmap="Reds", |
| 301 | levels=100) |
| 302 | elif plot_type == 'heatmap': |
| 303 | sc = ax.pcolormesh(lon_plot, lat_plot, errors, cmap="Reds", transform=ccrs.PlateCarree()) |
| 304 | else: |
| 305 | sc = ax.scatter(x=lon_plot, y=lat_plot, s=circlesize, |
| 306 | c=errors, norm=TwoSlopeNorm(5, vmin=0, vmax=10), |
| 307 | alpha=0.8, cmap=jet, linewidths=lw, |
| 308 | transform=ccrs.PlateCarree()) |
| 309 | |
| 310 | ax.set_title(f'{title}{plot_type.upper()}-{var_name.upper()} error', fontsize=fs_text) |
| 311 | # Colour Bar |
| 312 | cbar = plt.colorbar(sc, ax=ax, aspect=30, pad=0.01, shrink=0.4, orientation='vertical') |
| 313 | cbar.ax.set_ylabel('W m$^{-2}$', rotation=270, labelpad=10) |
| 314 | return fig |
| 315 | |
| 316 | |
| 317 | def prediction_hist(preds: dict, TOA=False, surface=False, |