Cmip6 data visualization

Hi guys I’m working on CMIP6 data and trying to visualize the data using basemap, but the data for some of the ensemble models does not look right

Here is the screenshot:

This is the data i used to plot the image above
def plot_field(m, X, lats, lons, step=0.5, cmap=plt.get_cmap(‘jet’),
ax=False, grid=False, title=None):

lons, lats = np.meshgrid(lons, lats)

if not ax: 
    f, ax = plt.subplots(figsize=(8, (X.shape[0] / float(X.shape[1])) * 8))
m.ax = ax
Xmin = np.nanmin(X)
Xmax = np.nanmax(X)
im = m.contourf(lons, lats, X, np.arange(Xmin, Xmax+step, step), \
                latlon=True, cmap=cmap, extend='both', ax=ax)

im = m.imshow(X, ax=ax)

m.drawcoastlines()
if grid: 
    m.drawmeridians(np.arange(0, 360, 30), labels=[0,0,0,1])
    m.drawparallels(np.arange(-80, 80, 20), labels=[1,0,0,0])
m.colorbar(im)
if title: 
    ax.set_title(title)

Do you have to use basemap?

Try cartopy. Plotting — xarray 0.16.3.dev0+gcc53a77f.d20201130 documentation

https://xarray-contrib.github.io/xarray-tutorial/scipy-tutorial/04_plotting_and_visualization.html#Geography:-Matplotlib-and-Cartopy

just pass “lat” as string instead of lat from numpy. “Lon” likewise