I am learning on how to plot various variables from WRF output netcdf file. My requirement is to extract variables for a certain lat/lon (8.4875° N, 76.9525° E) in order to plot SkewT profiles using the matplotlib package.
I found a similar question on this SO page netcdf4 extract for subset of lat lon . However, its location is a set of boundaries.
Check out xray . You'll have to do some work to make the SkewT chart but accessing and summarizing the netCDF Dataset and variables will be pretty easy. Just a few examples below.
import xray
ds = xray.open_dataset('your_wrf_file.nc')
ds_point = ds.sel(lon=76.9525, lat=8.4875)
ds_point['Temperature'].plot() # plot profile at point assuming Temperature had dimensions of (level, lat, lon)
df = ds_point.to_dataframe() # export dataset to Pandas.DataFrame
temp_array = ds_point['Temperature'].values # access the underlying numpy array of the "Temperature" variable
我通常要做的是在使用ncl,python,R等进行绘图之前,使用CDO从命令行中提取最接近网格点的列:
cdo remapnn,lon=76.9525/lat=8.4875 wrf_file.nc pnt_file.nc
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.