wrf-python icon indicating copy to clipboard operation
wrf-python copied to clipboard

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

Open qiuyang50 opened this issue 3 years ago • 1 comments

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())

qiuyang50 avatar Dec 02 '22 21:12 qiuyang50

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

erogluorhan avatar Feb 14 '23 15:02 erogluorhan