Reputation: 3910
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.
Upvotes: 0
Views: 1953
Reputation: 8087
What I usually do is extract the nearest gridpoint to the column using CDO from the command line before using ncl,python,R etc for plotting:
cdo remapnn,lon=76.9525/lat=8.4875 wrf_file.nc pnt_file.nc
Upvotes: 0
Reputation: 6444
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
Upvotes: 1