Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

how to use the wrfout file in get_pyngl and glob?

huangsy

New member
dear friends,
I encountered two issues when processing wrf output data.
first one: when I use the get_pyngl, it told me that RuntimeError: 'pyngl' is not installed or is disabled. but I have install the Nio &Ngl in conda, how to call this program?
here is my code.
#6.5PyNGL example using a variable
from wrf import getvar, get_pyngl, geo_bounds, latlon_coords
from __future__ import print_function
from netCDF4 import Dataset

ncfile = Dataset("/mnt/hgfs/H/1-dataprocess/6-wrfoutput/w-test4/wrfout_d01_2020-03-01_00.nc")

#get the sea level pressure
slp = getvar(ncfile, "slp")
print(slp)

#import Nio, Ngl
#get tge pyngl resources from the variable
pyngl_resources = get_pyngl(slp)
print(pyngl_resources)

#get the latitude and longitude coordinate.
lats,lons = latlon_coords(slp)
print(lats, lons)

#get the geobounds from the SLP variable
bounds = geo_bounds(slp)
print(bounds)

#get the geographic boundaries for a subset of the domain
slp_subset = slp[100:150,2:50]
slp_subset_bounds = geo_bounds(slp_subset)
print(slp_subset_bounds)

second one: when I want to add all wrf files to analysis, it showed a AttributeError: NetCDF: Can't open HDF5 attribute. I am sure the file path of wrf outfiles is right and can you tell me how to solve this problem?
here is my code.
#7* geographic boundaries with moving nest example
from wrf import ALL_TIMES, getvar, geo_bounds
from glob import glob
from netCDF4 import Dataset as nc
#get all the domain 01 files
wrf_filenames = glob("/mnt/hgfs/H/dataprocess/6-wrfoutput/wrfout_d01_*")
ncfile = [nc(x) for x in wrf_filenames]
print(ncfile)

#slp is the example variable and includes all times
slp = getvar(ncfile, "slp", timeidx=ALL_TIMES)
print(slp.shape)
#get the geographic boundaries
bounds = geo_bounds(slp)
print(bounds)

here attaches my wrf outfile. can you help me?
 
Top