NCAR / wrf-python

A collection of diagnostic and interpolation routines for use with output from the Weather Research and Forecasting (WRF-ARW) Model.
https://wrf-python.readthedocs.io
Apache License 2.0
392 stars 149 forks source link

wrf.interplevel returns NaN when interpolating at a level where the sample points are #198

Open qiuyang50 opened 1 year ago

qiuyang50 commented 1 year ago

Hi, I recently used wrf.interplevel to interpolate a 3d field onto a single pressure level 50000 Pa. I found a very wired result that every time when the 50000 Pa appears in the sample points, the result is NaN. If I added a little value to 50000Pa, it returns the correct value (approximately). Below is just a simple example to reproduce the issue. Please help!

# construct vert array xx = np.linspace(0,1,11) xg = np.zeros((11,4,3)) for j in np.arange(4): for i in np.arange(3): xg[:,j,i] = xx

# assign field3d array yg = np.random.rand(11,4,3)

# print results for comparison print(' True answer: ', yg[5,:,:]) print(' NaN result: ', wrf.interplevel(yg,xg,0.5).to_numpy()) print('Corrected result: ', wrf.interplevel(yg,xg,0.5+1e-8).to_numpy())

erogluorhan commented 1 year ago

Hi @qiuyang50 thanks very much for sharing this with us! We'll look into it when we have some time.