def testing(data, lat1, lat2, lon1, lon2, t, k): latname = get_coord(data, 'lat', 'name') lonname = get_coord(data, 'lon', 'name') data_sub = dat.subset(data, latname, lat1, lat2, lonname, lon1, lon2) plt.figure() ap.pcolor_latlon(data_sub[t, k], axlims=(lat1, lat2, lon1, lon2), cmap='jet') avg0 = data_sub.mean(axis=-1).mean(axis=-1) avg1 = mean_over_geobox(data, lat1, lat2, lon1, lon2, area_wtd=False) avg2 = mean_over_geobox(data, lat1, lat2, lon1, lon2, area_wtd=True) avg3 = mean_over_geobox(data, lat1, lat2, lon1, lon2, area_wtd=True, land_only=True) print(avg0[t, k].values) print(avg1[t, k].values) print(avg2[t, k].values) print(avg3[t, k].values)
def testing(data, lat1, lat2, lon1, lon2, t, k): latname = get_coord(data, 'lat', 'name') lonname = get_coord(data, 'lon', 'name') data_sub = dat.subset(data, latname, lat1, lat2, lonname, lon1, lon2) plt.figure() ap.pcolor_latlon(data_sub[t,k], axlims=(lat1,lat2,lon1,lon2), cmap='jet') avg0 = data_sub.mean(axis=-1).mean(axis=-1) avg1 = mean_over_geobox(data, lat1, lat2, lon1, lon2, area_wtd=False) avg2 = mean_over_geobox(data, lat1, lat2, lon1, lon2, area_wtd=True) avg3 = mean_over_geobox(data, lat1, lat2, lon1, lon2, area_wtd=True, land_only=True) print(avg0[t, k].values) print(avg1[t, k].values) print(avg2[t, k].values) print(avg3[t, k].values)
# Correct for topography u_orig = u u = correct_for_topography(u_orig, topo) m, k = 3, 1 plt.figure(figsize=(7, 8)) plt.subplot(211) ap.pcolor_latlon(u_orig[m, k], cmap='jet') plt.subplot(212) ap.pcolor_latlon(u[m, k], cmap='jet') # ---------------------------------------------------------------------- # Zonal mean zonal wind season = 'jjas' lon1, lon2 = 60, 100 cint = 5 months = utils.season_months(season) uplot = dat.subset(u, 'lon', lon1, lon2, 'mon', months) uplot = uplot.mean(['lon', 'mon']) ps_plot = dat.subset(topo, 'lon', lon1, lon2) ps_plot = ps_plot.mean('lon') plt.figure() ap.contour_latpres(uplot, clev=cint, topo=ps_plot) plt.figure() ap.contourf_latpres(uplot, clev=cint, topo=ps_plot)
u_orig = u u = correct_for_topography(u_orig, topo) m, k = 3, 1 plt.figure(figsize=(7,8)) plt.subplot(211) ap.pcolor_latlon(u_orig[m,k], cmap='jet') plt.subplot(212) ap.pcolor_latlon(u[m,k], cmap='jet') # ---------------------------------------------------------------------- # Zonal mean zonal wind season='jjas' lon1, lon2 = 60, 100 cint = 5 months = utils.season_months(season) uplot = dat.subset(u, 'lon', lon1, lon2, 'mon', months) uplot = uplot.mean(['lon', 'mon']) ps_plot = dat.subset(topo, 'lon', lon1, lon2) ps_plot = ps_plot.mean('lon') plt.figure() ap.contour_latpres(uplot, clev=cint, topo=ps_plot) plt.figure() ap.contourf_latpres(uplot,clev=cint, topo=ps_plot)