From 01a255039068830c2598a2435e0ad6e9ba9bb981 Mon Sep 17 00:00:00 2001 From: marpyr <51707055+marpyr@users.noreply.github.com> Date: Fri, 11 Dec 2020 10:44:51 +0100 Subject: [PATCH] Create viz.py --- predictability_utils/utils/viz.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/predictability_utils/utils/viz.py b/predictability_utils/utils/viz.py index abd6857..40e8b44 100644 --- a/predictability_utils/utils/viz.py +++ b/predictability_utils/utils/viz.py @@ -19,3 +19,23 @@ def visualize_example_preds(out_true, out_pred, map_shape, y_train, years): plt.ylabel(str(1900 + y_train + y)) plt.suptitle('example predictions (left: predicted, right: true)') plt.show() + + +def visualize_ACC(anomaly_corrs, lat, lon, map_shape, title): + + anomaly_corrs_map = anomaly_corrs.reshape(*map_shape) + m = Basemap(projection='cyl', llcrnrlon=min(lon), llcrnrlat=min(lat), + urcrnrlon=max(lon), urcrnrlat=max(lat)) + clevs = np.linspace(-1, 1, 21) + lons, lats = m(*np.meshgrid(lon, lat)) + h = m.contourf(lons, lats, anomaly_corrs_map, clevs, cmap=plt.cm.RdBu_r) + m.contour(lons, lats, anomaly_corrs_map, levels=[0.5], colors=['k']) + m.drawcoastlines() + m.drawparallels(np.arange(35.,70.,10.), labels=[1,0,0,1], fontsize=12) + m.drawmeridians(np.arange(0.,25.,10.), labels=[1,0,0,1], fontsize=12) + m.drawmapboundary(fill_color='white') + col = m.colorbar(h, location='bottom', size='15%', pad="12%") + col.ax.tick_params(labelsize=13, labelrotation=45) + plt.title(title, fontsize=12) + plt.subplots_adjust(hspace=0.35, wspace=0.3) +