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')
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.