<p>The simplest way I've found in Python is to use the <a href="https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.getvar.html#wrf.getvar" rel="nofollow noreferrer">getvar</a> function with the 'ua,' 'va,' or 'wa' variables from the <a href="https://wrf-python.readthedocs.io/en/latest/index.html" rel="nofollow noreferrer">WRF-Python module</a>. Alternatively, you can take the midpoint between the staggers.</p>
<p>Edit: For example, using the WRF-Python module, you can get the destaggered wind variables with the following code</p>
<blockquote>
<p><code>import netcdf4 as nc</code></p>
<p><code>import wrf</code></p>
<p><code>f=nc.Dataset('example.nc')</code></p>
<p><code>u=wrf.getvar(f,'ua')</code></p>
<p><code>v=wrf.getvar(f,'va')</code></p>
<p><code>w=wrf.getvar(f,'wa')</code></p>
</blockquote>

CC BY-SA 4.0
2019-12-17T17:47:07.900Z
Willing to share a sample script?
thiagoveloso
CC BY-SA 4.0
2019-12-17T18:09:00.023Z
`import wrf`,
`import netCDF4 as nc`,
`f=nc.Dataset(fName)`,
`u=wrf.getvar(f,'ua')`
BarocliniCplusplus
CC BY-SA 4.0
2019-12-17T18:16:23.837Z
Thanks for sharing! I think I can do the same in R. But what about the de-staggering itself?
thiagoveloso
CC BY-SA 4.0
2019-12-17T18:19:19.320Z
There is a function for that too! https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.destagger.html
BarocliniCplusplus
CC BY-SA 4.0
2019-12-17T18:20:57.347Z
But a rough destaggering could be something like `(var[:,:,1:,:]+var[:,:,:-1,:])/2.`
BarocliniCplusplus
CC BY-SA 4.0
2019-12-18T11:43:36.570Z
Cool, thanks for the insight? Can you include these code lines in your answer? I will then accept it.
thiagoveloso
CC BY-SA 4.0
2019-12-18T15:41:44.290Z
Included the example code in the answer
BarocliniCplusplus
CC BY-SA 4.0
2019-12-17T17:24:23.980Z
2019-12-18T15:41:11.323Z
2020-06-18T08:25:19.090Z
BarocliniCplusplus
<p>I am trying to calculate wind speed from the U and V wind components of a <code>Weather Research and Forecasting</code> (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 .</p>

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

CC BY-SA 4.0
2019-12-17T17:49:26.007Z
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.
thiagoveloso
<meteorology><models><numerical-modelling><wrf>
How to de-stagger (or unstagger) WRF wind fields?
thiagoveloso
# How to de-stagger (or unstagger) WRF wind fields?

(Asked by: username_0 on 2019-12-17)

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?

**Tags:** meteorology, models, numerical-modelling, wrf

> **Comments:**
> **username_0**: 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.  

---

## 1 answers

### Answer by username_1 on 2019-12-17. Score: 1

The simplest way I've found in Python is to use the [getvar](https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.getvar.html#wrf.getvar) function with the 'ua,' 'va,' or 'wa' variables from the [WRF-Python module](https://wrf-python.readthedocs.io/en/latest/index.html). 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')`

> **Comments:**
> **username_0**: Willing to share a sample script?  
> **username_1**: `import wrf`, `import netCDF4 as nc`, `f=nc.Dataset(fName)`, `u=wrf.getvar(f,'ua')`  
> **username_0**: Thanks for sharing! I think I can do the same in R. But what about the de-staggering itself?  
> **username_1**: There is a function for that too! https://wrf-python.readthedocs.io/en/latest/user_api/generated/wrf.destagger.html  
> **username_1**: But a rough destaggering could be something like `(var[:,:,1:,:]+var[:,:,:-1,:])/2.`  
> **username_0**: Cool, thanks for the insight? Can you include these code lines in your answer? I will then accept it.  
> **username_1**: Included the example code in the answer  

---

