Thank you for the insight, Kevin.
We figured out the issue, and it came down to the projection of the WRF-H data used in conjection with the cartopy projections in python. To resolve this issue, the WRF-H native x,y grid data was projected to lat/lon using the pyproj package:
from pyproj import Proj
X, Y = np.meshgrid(ctrl_wrfh_chrtout_gr.x.values, ctrl_wrfh_chrtout_gr.y.values)
source = pyproj.Proj(ctrl_wrfh_chrtout_gr.proj4)
lon, lat = source(X.flatten(), Y.flatten(), inverse=True)
The lat/lons were then added as coordinates to the gridded streamflow xarray dataset:
mean_stmflow_grd.coords['lat'] = (mean_stmflow_grd.dims, lat_2d)
mean_stmflow_grd.coords['lon'] = (mean_stmflow_grd.dims, lon_2d)
Then the streamflow could be plotted over shapefiles of U.S. states using the transform function in cartopy:
fig = plt.figure(figsize = (8,8))
v = np.linspace(0,1200,11,endpoint = True)
cmap = 'BuPu'
ax = plt.subplot(1, 1, 1, projection=ccrs.LambertConformal(central_longitude=-93))
ax.add_geometries(state, crs=ccrs.PlateCarree(), facecolor='none', edgecolor='0.1', linewidth = 0.6, zorder=6)
c1 = plt.pcolormesh(mean_stmflow_grd.lon.values, mean_stmflow_grd.lat.values, mean_stmflow_grd.values, vmax=100, cmap = cmap, transform=ccrs.PlateCarree(),)
plt.show()
I hope this helps if others have the same issue!
- Erin