Many NaN values with wrf.vinterp - user or function error?

187 views
Skip to first unread message

Lucy Recchia

unread,
Oct 10, 2019, 5:38:03 AM10/10/19
to wrfpython-talk
Hi,

I'm getting NaNs for almost every other interpolated level for my variable. I had no problems in NCL with the equivalent function wrf_user_vert_interp. Could you please advise if I'm doing the calculation correctly, and/or how to deal with all the NaNs. I've attached a minimal working example of my python code below.

from netCDF4 import Dataset
from wrf import *

a = Dataset("wrfout_d01_2016-06-06_00_00_00","r")

# Get the v-component of winds on mass points (m/s)
v    = getvar(a, "va", timeidx=ALL_TIMES)    
# Get the water vapour mixing ratio (kg/kg)
Q    = getvar(a, "QVAPOR", timeidx=ALL_TIMES)   

angle = 42.75883
# across transect winds (m/s)
v_t = u*np.sin(np.radians(angle)) + v*np.cos(np.radians(angle))  
# across transect moisture flux (g m kg-1 s-1)
q_vt = Q*1000*v_t 

# Set details of the new levels to interpolate to
lev_sur = 1000                           # surface level    (hPa)
lev_top = 50                               # pressure top    (hPa)
lev_int = 25                                # level interval    (hPa)
levels  = np.flip(np.arange(lev_top,lev_sur+lev_int,lev_int)) # pressure levels (hPa)

qvt_intrp      = vinterp(a, field=q_vt, vert_coord="pressure", interp_levels=levels, timeidx=ALL_TIMES) 


Example output (truncated):
qvt_intrp =  [[[[ 8.52649078e+01  8.77275620e+01  8.76647949e+01 ...  3.94561729e+01
     3.69428711e+01  3.76337051e+01]
   [ 9.01927719e+01  9.14745407e+01  9.06746750e+01 ...  3.76780930e+01
     3.61646194e+01  3.71705208e+01]
   [ 9.41303329e+01  9.45869446e+01  9.34471741e+01 ...  3.71717300e+01
     3.60162582e+01  3.64224472e+01]
   ...
   [            nan             nan             nan ...             nan
                nan             nan]
   [            nan             nan             nan ...             nan
                nan             nan]
   [            nan             nan             nan ...             nan
                nan             nan]]

  [[ 8.03185196e+01  8.28470459e+01  8.35841370e+01 ...  3.73917313e+01
     3.56839447e+01  3.58619843e+01]
   [ 8.49450684e+01  8.65458450e+01  8.64417038e+01 ...  3.60826569e+01
     3.50137711e+01  3.52602615e+01]
   [ 8.91770325e+01  9.02119217e+01  8.92981415e+01 ...  3.57003365e+01
     3.46946602e+01  3.43340225e+01]
   ...
   [            nan             nan             nan ...             nan
                nan             nan]
   [            nan             nan             nan ...             nan
                nan             nan]
   [            nan             nan             nan ...             nan
                nan             nan]]


Thanks in advance.



Reply all
Reply to author
Forward
0 new messages