pygrib
pygrib copied to clipboard
Unable to read NCEP FNL multilayer data
I'm trying to read the NCEP FNL grib files https://rda.ucar.edu/datasets/ds083.3/index.html
`file = 'gdas1.fnl0p25.2015081106.f00.grib2' #example filename
gr = pygrib.open(file)
msg = gr[285] #get record number 285
print(msg)
temp_vals = msg.values
print(temp_vals)
print(temp_vals.shape)
print(np.amax(temp_vals),np.amin(temp_vals))
lats,lons = msg.latlons()
print(lats) `
285:Temperature:K (instant):regular_ll:pressureFromGroundLayer:levels 3000-0 Pa:fcst time 0 hrs:from 201508110600 [[275. 275. 275. ... 275. 275. 275.] [275. 275. 275. ... 275. 275. 275.] [275. 275. 275. ... 275. 275. 275.] ... [226. 226. 226. ... 226. 226. 226.] [226. 226. 226. ... 226. 226. 226.] [225. 225. 225. ... 225. 225. 225.]] (721, 1440) 316.0 215.0 [[ 90. 90. 90. ... 90. 90. 90. ] [ 89.75 89.75 89.75 ... 89.75 89.75 89.75] [ 89.5 89.5 89.5 ... 89.5 89.5 89.5 ] ... [-89.5 -89.5 -89.5 ... -89.5 -89.5 -89.5 ] [-89.75 -89.75 -89.75 ... -89.75 -89.75 -89.75] [-90. -90. -90. ... -90. -90. -90. ]]
levels is 3000-0 Pa ;temp_vals.shape is (721, 1440) , not included the vertical levels!
There's a separate message for each vertical level
There's a separate message for each vertical level
why ? 285:Temperature:K (instant):regular_ll:pressureFromGroundLayer:levels 3000-0 Pa:fcst time 0 hrs:from 201508110600 , levels is 3000-0Pa ,this is not a single level I think
It is a single level - that's how grib messages work. Each one is a 2D field. The 'level' key is the vertical level. '3000-0 Pa' probably indicates a vertical mean.