TransWikia.com

Wind speed data plot contains blank gaps

Earth Science Asked by mpletch1 on September 5, 2021

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 fornwrfout_d04_2017-05-27_20:00:00')
  i+=1
  plt.show()
  plt.savefig('wrf_windspeed.png')

enter image description here

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.

One 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.

Correct answer by BarocliniCplusplus on September 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP