Hello everyone,
For a while I have been using successfully wrf-python version 1.3.2.6, but recently a colleague of mine tried extractig cape_2d with wrf-python and found strange patterns in the map, the same happened with slp variable:
However terrain variable (also extracted with wrf-python) seems fine:
I have tried using his code to reproduce the results... but I couldn't! I got correct values, for example with CAPE:
Does it make any sense? His version is the latest one, 1.3.4.1. The code to get the results is the following:
For a while I have been using successfully wrf-python version 1.3.2.6, but recently a colleague of mine tried extractig cape_2d with wrf-python and found strange patterns in the map, the same happened with slp variable:
However terrain variable (also extracted with wrf-python) seems fine:
I have tried using his code to reproduce the results... but I couldn't! I got correct values, for example with CAPE:
Does it make any sense? His version is the latest one, 1.3.4.1. The code to get the results is the following:
Code:
import numpy as np
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from netCDF4 import Dataset
from wrf import (getvar, interplevel, smooth2d, to_np, latlon_coords,
get_cartopy, cartopy_xlim, cartopy_ylim)
ncfile = Dataset("wrfout")
slp = getvar(ncfile, "slp")
cape_2d = getvar(ncfile, "cape_2d")
ter = getvar(ncfile, "ter")
mcape = cape_2d.isel(mcape_mcin_lcl_lfc=0)
lats, lons = latlon_coords(cape_2d)
lons_np = to_np(lons)
lats_np = to_np(lats)
var = mcape
var_np = to_np(var)
fig = plt.figure(figsize=(12,8))
ax = plt.axes(projection=ccrs.PlateCarree())
var_min = np.min(var_np)
var_max = np.max(var_np)
var_levels = np.linspace(var_min, var_max, 10)
var_levels = np.linspace(0, 3650, 10)
var_contours = ax.contourf(lons_np, lats_np, var_np,
levels=var_levels,
transform=ccrs.PlateCarree(),
cmap="YlOrRd", extend='both')
plt.colorbar(var_contours, label="")
ax.coastlines(resolution='50m')
ax.add_feature(ccrs.cartopy.feature.BORDERS, linestyle=':')
ax.add_feature(ccrs.cartopy.feature.STATES, linestyle=':')
margin = 0.1
ax.set_extent([np.min(lons_np) - margin, np.max(lons_np) + margin,
np.min(lats_np) - margin, np.max(lats_np) + margin],
crs=ccrs.PlateCarree())
ax.gridlines(draw_labels=True, dms=True, x_inline=False, y_inline=False)
ax.set_title("")
plt.show()