1
$\begingroup$

I am trying to calculate wind speed from the U and V wind components of a Weather Research and Forecasting (WRF) simulation. However, I came to realize that some variables of the model (including wind components) are staggered. This makes it really difficult to analyze the model output as is, since the dimensions of staggered variables differ from those of non-staggered variables .

Does anybody have any hints on how to de-stagger these fields in a netcdf file produced by the WRF model?

$\endgroup$
  • $\begingroup$ Is this what you want - ncl.ucar.edu/Document/Functions/WRF_arw/… ? $\endgroup$ – gansub Dec 17 '19 at 15:05
  • $\begingroup$ python does it too - buildmedia.readthedocs.org/media/pdf/wrf-python/1.0b1/… $\endgroup$ – gansub Dec 17 '19 at 15:24
  • $\begingroup$ Thanks for the links. The problem with those solutions is that your have to manually extract the data, de-stagger it and then reconstruct the netcdf file with the updated data. This is pretty advanced, and I have little experience with Python and NCL. I'm looking for some more generic tool that does all the work automatically - if such a tool exists. $\endgroup$ – thiagoveloso Dec 17 '19 at 17:49
1
$\begingroup$

The simplest way I've found in Python is to use the getvar function with the 'ua,' 'va,' or 'wa' variables from the WRF-Python module. Alternatively, you can take the midpoint between the staggers.

Edit: For example, using the WRF-Python module, you can get the destaggered wind variables with the following code

import netcdf4 as nc

import wrf

f=nc.Dataset('example.nc')

u=wrf.getvar(f,'ua')

v=wrf.getvar(f,'va')

w=wrf.getvar(f,'wa')

| improve this answer | |
$\endgroup$
  • $\begingroup$ Willing to share a sample script? $\endgroup$ – thiagoveloso Dec 17 '19 at 17:47
  • $\begingroup$ import wrf, import netCDF4 as nc, f=nc.Dataset(fName), u=wrf.getvar(f,'ua') $\endgroup$ – BarocliniCplusplus Dec 17 '19 at 18:09
  • $\begingroup$ Thanks for sharing! I think I can do the same in R. But what about the de-staggering itself? $\endgroup$ – thiagoveloso Dec 17 '19 at 18:16
  • $\begingroup$ There is a function for that too! wrf-python.readthedocs.io/en/latest/user_api/generated/… $\endgroup$ – BarocliniCplusplus Dec 17 '19 at 18:19
  • $\begingroup$ But a rough destaggering could be something like (var[:,:,1:,:]+var[:,:,:-1,:])/2. $\endgroup$ – BarocliniCplusplus Dec 17 '19 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.