GMTB Workflow Documentation
get_grib_field.py
Go to the documentation of this file.
1 import pygrib
2 
3 ##\ingroup graphics
4 def get_ua_field(fn,level,typeOfLevel,**kwargs):
5  # Get the required grib field given a file name
6  # fn: filename, var: variable to plot, lev: level
7  # to plot in hPa, levtype: type of level in grib file
8  # anlTime: optional analysis time
9  # for a sanity check, fcstHr: option forecast hour
10  # in case a file contains multiples and not in fn.
11 
12  # Set up args
13  print "GET ARGS: ", locals()
14  tmp = locals()
15  alist = {}
16  for i in tmp:
17  if tmp[i] is not None and i != 'fn':
18  print i , tmp[i]
19  if i == 'level':
20  alist[i] = int(tmp[i])
21  elif i == 'kwargs':
22  for j in tmp['kwargs']:
23  if tmp['kwargs'][j] is not None and j != 'fn':
24  alist[j]=tmp['kwargs'][j]
25  else:
26  alist[i] = tmp[i]
27  print "ALIST ", alist
28  grbs=pygrib.open(fn)
29  grb = grbs.select(**alist)[0]
30  print "PRINTING GRB: ", grb
31 
32  return grb
33 
34 
def get_ua_field(fn, level, typeOfLevel, kwargs)