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

Custom vertical dimension in vinterp #54

Closed honnorat closed 6 years ago

honnorat commented 6 years ago

Hello,

It would be nice to allow wrf.vinterp() use a custom name for the vertical dimension it creates. Currently, it is called interp_level and cannot be changed.

This would allow the interpolation along an existing coordinate variable, or along different vertical axes.

Example:

from netCDF4 import Dataset
import wrf
nc = Dataset("test/ci_tests/ci_test_file.nc")
tk = wrf.getvar(ncfile, "tk")
levels = [925, 850, 750, 500]

tkp_def = wrf.vinterp(nc, field=tk, vert_coord="pressure", interp_levels=levels)
tkp_new = wrf.vinterp(nc, field=tk, vert_coord="pressure", interp_levels=levels, vdim_name="p_levels")
print("default:", tkp_def.dims)
print("named dim:", tkp_new.dims)

result:

default: ('interp_level', 'south_north', 'west_east')
named dim: ('p_levels', 'south_north', 'west_east')
bladwig1 commented 6 years ago

You can change coordinate names using xarray's DataArray.rename() function.