<p>The answer is actually pretty easy. The WRF model lies on a grid. The vertical component of the grid is unevenly spaced, though you can manually space it. The vertical coordinate of WRF uses a sigma vertical coordinate (even though the namelist calls them eta): <span class="math-container">$$\sigma=\frac{P-P_{surface}}{P_{top}-P_{surface}}$$</span>. So the values of sigma are specified (or just resorted to the default values). So when you get altitude levels for WRF, there is a space between the levels. You would probably find something similar if you change the y-axis to west-east or south-north.</p>
<p>The default vertical spacing for WRF has higher resolution near the surface, which is useful for convection and PBL modeling.</p>

CC BY-SA 4.0
2020-07-08T20:30:06.130Z
This observation answered my question. Thank you so much!
mpletch1
CC BY-SA 4.0
2020-07-08T22:31:16.023Z
You're welcome!
BarocliniCplusplus
CC BY-SA 4.0
2020-07-08T02:52:47.583Z
2020-07-08T02:52:47.583Z
BarocliniCplusplus
<p>I am relatively new to Python, and I am having trouble plotting some data. Specifically, I am plotting wind speed data on a 2-D plot that I grabbed from the Weather Research &amp; Forecasting (WRF) weather model. Though I'm able to generate a plot, there are noticeable gaps in plot, particularly as the model height increases. The purpose of generating these plots is to compare WRF model data to observations collected from dropsondes during a field campaign. Below is the code that I've been working with as well as the plot that was generated.</p>
<pre><code>import numpy as np
from netCDF4 import Dataset
import wrf
from wrf import getvar
import glob
import pandas as pd
import matplotlib.pyplot as plt

dir = glob.glob('~/wrfout_d04_2017-05-27_20:00:00')
dir.sort()
nf = range(0,len(dir),6)

for n in nf:
  data = Dataset(dir[n], 'r')
  windspeed = wrf.getvar(data, 'uvmet_wspd_wdir', meta = False)[0,:]
  winddir = wrf.getvar(data, 'wdir', meta = False)
  altitude = wrf.getvar(data, 'z', meta = False)
  lat = wrf.getvar(data, 'lat', meta = False)
  lon = wrf.getvar(data, 'lon', meta = False)

  for i in range(len(windspeed)):
    fig = plt.figure
    plt.plot(windspeed[i], altitude[i], color = 'blue')
    plt.axis('tight')
    plt.xlabel('Wind speed (m/s)')
    plt.ylabel('Height (m)')
    plt.title('Wind speed and model height for\nwrfout_d04_2017-05-27_20:00:00')
  i+=1
  plt.show()
  plt.savefig('wrf_windspeed.png')
</code></pre>
<p><a href="https://i.sstatic.net/y9cQa.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/y9cQa.png" alt="enter image description here" /></a></p>
<p>I've tried checking to see if the WRF output file 'wrfout_d04_2017-05-27_20:00:00' contains masked data using ncdump -h wrfout_d04_2017-05-27_20:00:00, but I'm not seeing anything there. I really appreciate anyone taking the time to read this post and any recommendations would be greatly appreciated.</p>

CC BY-SA 4.0
2020-07-07T07:25:16.770Z
The output looks reasonable: the data are written out on discrete vertical layers as @a_donda wrote. Probably the height of each layer varies spatially (the horizontal lines are slightly blurred). This might be due to pressure coordinates or terrain following coordinates.
daniel.heydebreck
<meteorology><wrf><python>
Wind speed data plot contains blank gaps
mpletch1
# Wind speed data plot contains blank gaps

(Asked by: username_0 on 2020-07-06)

I am relatively new to Python, and I am having trouble plotting some data. Specifically, I am plotting wind speed data on a 2-D plot that I grabbed from the Weather Research & Forecasting (WRF) weather model. Though I'm able to generate a plot, there are noticeable gaps in plot, particularly as the model height increases. The purpose of generating these plots is to compare WRF model data to observations collected from dropsondes during a field campaign. Below is the code that I've been working with as well as the plot that was generated.

```
import numpy as np
from netCDF4 import Dataset
import wrf
from wrf import getvar
import glob
import pandas as pd
import matplotlib.pyplot as plt

dir = glob.glob('~/wrfout_d04_2017-05-27_20:00:00')
dir.sort()
nf = range(0,len(dir),6)

for n in nf:
  data = Dataset(dir[n], 'r')
  windspeed = wrf.getvar(data, 'uvmet_wspd_wdir', meta = False)[0,:]
  winddir = wrf.getvar(data, 'wdir', meta = False)
  altitude = wrf.getvar(data, 'z', meta = False)
  lat = wrf.getvar(data, 'lat', meta = False)
  lon = wrf.getvar(data, 'lon', meta = False)

  for i in range(len(windspeed)):
    fig = plt.figure
    plt.plot(windspeed[i], altitude[i], color = 'blue')
    plt.axis('tight')
    plt.xlabel('Wind speed (m/s)')
    plt.ylabel('Height (m)')
    plt.title('Wind speed and model height for\nwrfout_d04_2017-05-27_20:00:00')
  i+=1
  plt.show()
  plt.savefig('wrf_windspeed.png')

```

[![enter image description here](https://i.sstatic.net/y9cQa.png)](https://i.sstatic.net/y9cQa.png)

I've tried checking to see if the WRF output file 'wrfout\_d04\_2017-05-27\_20:00:00' contains masked data using ncdump -h wrfout\_d04\_2017-05-27\_20:00:00, but I'm not seeing anything there. I really appreciate anyone taking the time to read this post and any recommendations would be greatly appreciated.

**Tags:** meteorology, wrf, python

> **Comments:**
> **username_1**: The output looks reasonable: the data are written out on discrete vertical layers as @a_donda wrote. Probably the height of each layer varies spatially (the horizontal lines are slightly blurred). This might be due to pressure coordinates or terrain following coordinates.  

---

## 1 answers

### Answer by username_2 on 2020-07-08. Score: 2 | Accepted answer

The answer is actually pretty easy. The WRF model lies on a grid. The vertical component of the grid is unevenly spaced, though you can manually space it. The vertical coordinate of WRF uses a sigma vertical coordinate (even though the namelist calls them eta): $$\sigma=\frac{P-P\_{surface}}{P\_{top}-P\_{surface}}$$. So the values of sigma are specified (or just resorted to the default values). So when you get altitude levels for WRF, there is a space between the levels. You would probably find something similar if you change the y-axis to west-east or south-north.

The default vertical spacing for WRF has higher resolution near the surface, which is useful for convection and PBL modeling.

> **Comments:**
> **username_0**: This observation answered my question. Thank you so much!  
> **username_2**: You're welcome!  

---

