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
410 stars 155 forks source link

NaN when desiredlev equal to vert in wrf.interplevel #190

Closed s-redfern closed 2 years ago

s-redfern commented 2 years ago

I'm not sure if this is expected behavior, but it seems that when the the vertical coordinate array and the desired interpolation levels input to wrf.interplevel are the same, the function will return NaNs at those points.

I can get around it by slightly adjusting my inputs for the desired output levels at places where it's a problem, but wanted to post about this if it actually is an unexpected issue with the wrf-python package.

Opio-Cornelius commented 2 years ago

I also found NaN values being returned when I use wrf.interplevel. This only affected model layers from the surface, ~ 1013 hPa upto 850 hPa. The problem does not affect the entire domain though, just a few patches, but they are noteworthy. The file attached herein is an early trial example (the data is not as correct), but it shows the problem well.

NO2_wrf_chem.

michaelavs commented 2 years ago

Hi @s-redfern and @Opio-Cornelius, As a preface, I am under the impression that these layers are from the surface to the top level of you dataset (i.e. your dataset pressure range is from 1013 to 850 hpa, and NaN values are at or around those areas). If that is the case, then the reason you will have values returned as NaN is due to the way an interpolation works mathematically. Interpolations can work up to, but not inclusively of the range of the values, so you could have an interpolation from 1000 to 900 hpa but if a region inside of the domain is at, above, or below the pressure range, they will be returned as NaN (above and below values could be captured through an extrapolation routine, but the exact values would still be NaN in this case too).

Now, if you are doing the interpolation and seeing that every value at every level is being returned as a NaN between the top and bottom levels (i.e. valid range is 1013 to 850, interpolating between 950 and 900, and only NaN values are returned), then that would not be an expected output from wrf-python and I would definitely like to take a further look there.