Visualize WRF output with NCL

2 minute read

Published:

This post is mainly introducing how to read wrf out data and calculate other variables via NCL.

u,v at mass grid :

In wrf out, dimension of u and v are different with mass.

Ref : WRF_Readme_Chapter3

To solve this, one can use wrf_user_getvar to get values of u and v on mass grid point. In fact, NCL just calculate the average of two adjacent points.

u=wrf_user_getvar(a,"ua",0)
v=wrf_user_getvar(a,"va",0)

sea level pressure

slp=wrf_user_getvar(a,”slp”,0)

relative humidity ( unit: % )

rh=wrf_user_getvar(a,"rh",0)

Omega ( unit : Pa/s )

omg=wrf_user_getvar(a,"omg",0)

temperature ( unit : C )

tc=wrf_user_getvar(a,"tc",0)

dew point depression ( unit : C)

dewDep=wrf_user_getvar(a,"tc",0)-wrf_user_getvar(a,"td",0)

divergence (unit : /s)

\[\displaystyle div= \frac{du}{dx}+\frac{dv}{dy}\]

if one uses lat and lon to calculate divergence, please see uv2dv_cfd

div = uv2dv_cfd(u,v,lat2d(:,49),lon2d(49,:),0)

remark: uv2dv_cfd only applies one-dimensional lat lon array

mixing water ratio (unit: kg/kg)

mix_ratio=a->QVAPOR(0,:,:,:)

specific humidity ( unit : kg/kg)

\[\displaystyle sh= \frac{q}{1+q}\]
sh=mix_ratio/(1+mix_ratio)

moisture flux convergence ( unit : kg/kg/s)

the formula for moisture flux is (ref: website)

\[\displaystyle mf= V \cdot q = (q u,q v )\] \[\displaystyle mconv=-\nabla (V \cdot q) =- \left( \frac{d (q\cdot u)}{dx}+\frac{d(q\cdot v)}{dy} \right)\]

Similar to divergence, one uses uv2dv_cfd to get convergence with known 1-dimensional lat lon.

mfc= -uv2dv_cfd(u*mix_ratio,v*mix_ratio,lat2d(:,49),lon2d(49,:),0)

(Recommend) However, one also uses center_finite_diff_n with known $ \displaystyle dx$ and $ \displaystyle dy$.

dmconvdy = -center_finite_diff_n (mix_ratio*v, dy, False, 0, 1)
dmconvdx = -center_finite_diff_n (mix_ratio*u, dx, False, 0, 2)
mfa=(dmconvdx+dmconvdy)

moisture flux advection (unit : kg/kg/s)

\[\displaystyle madv=V \cdot \nabla q=u \frac{dq}{dx} +v \frac{dq}{dy}\]

Using function center_finite_diff_n, one can calculate $ \displaystyle \frac{dq}{dx}$ and $ \displaystyle \frac{dq}{dy}$ with fixed $ \displaystyle dx$ and $ \displaystyle dy$.

dqdy = center_finite_diff_n (mix_ratio, dy, False, 0, 1)
dqdx = center_finite_diff_n (mix_ratio, dx, False, 0, 2)
mfa=(dqdx*u+dqdy*v)

Another method is using grad_latlon_cfd. However, its input variables lat lon are one-dimensional, it is not accurate if lat lon are 2-dimensional.

Also, NCL has many functions to calculate advection , such as advect_variable. However ,it requires globe grids which is, in other word, not suitable with local grids.

vorticity (unit: $10^{-5}/s$ ) from wrf_user_getvar

vor=wrf_user_getvar(a,"avo",0)