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

vinterp fails to do extrapolation #79

Closed erictklai closed 5 years ago

erictklai commented 5 years ago

I was trying to vertically interpolate my WRF output to pressure levels. My WRF simulation includes some islands, such that the largest height at the lowest model level is 2625 m.

As the 1st step, I tested vinterp, by interpolating the height field to some selected pressure levels: ht=getvar(dataset,"height",units="m") levels=[1000,850,500,200] ht_int=vinterp(dataset,ht,'p',levels,extrapolate=True)

So, ht_int[0, : , : ] is the interpolated height value at the 1000 hPa level. And, I expected that the values range from -50 to 50 m. However, it turns out that, the maximum value of ht_int[0, : , :] is still 2625 m, the same as the largest value at the lowest model level. The minimum value is about 30 m.

I repeated the vinterp with the extrapolate=False, I got the same results. It seems that the code does not do extrapolation to give levels below ground even with extrapolate=True.

For ht_int[2, : , : ] (the interpolated value at the 500 hPa level), I got the expected result.

erictklai commented 5 years ago

I think I have figured out the reason. The parameter _fieldtype is optional, and by default it is 'None'. This yields icase=0. However, as per the wrf_vintrp.f90, extrapolation is only arranged for icase>0. That's why the field is not extrapolated even with extrapolate=True. I tried that with extrapolate=True and _fieldtype='ght' (icase=2), I got reasonable extrapolated results.

Hence, I suggest to add more description in the handbook to remind users that _fieldtype should be specified if they want to extrapolate the pressure, height, temperature, potential temperature or equivalent potential temperature field.

bladwig1 commented 5 years ago

That's correct. Extrapolation is only performed when the vertical coordinate type is pressure or height, and the field type has to be specified as pressure (with height vertical coordinate), height (with pressure as vertical coordinate), or temperature (with height or pressure). It uses standard atmosphere to do the extrapolation. The documentation had already been updated a bit when #74 was fixed (currently in develop branch), but it still needs some work, so I'll keep this issue open until I check in the doc improvements. Thanks!