GMTB Workflow Documentation
regrib.py
Go to the documentation of this file.
1 ##\file regrib.py
2 import os,sys,subprocess
3 ncep_grids = {
4  'G104': 'nps:255:60 220.525:147:90755 -0.268:110:90755' ,
5  'G218': 'lambert:265.000:25 226.514:614:12190.58 12.190:428:12190.58' ,
6  'G3': 'ncep grid 3'
7  }
8 # MET Definitions:
9 #{ "G104", 'N', 60.0, -0.268, 139.475, 0.0, 0.0, 105.0, 90.755, ncep_earth_radius_km, 147, 110 },
10 #{ "G218", 25.0, 25.0, 12.19, 133.459, 0.0, 0.0, 95.0, 12.191, ncep_earth_radius_km, 614, 428 },
11 
12 
13 #NCEP Descriptions:
14 #G218: LC CONUS nx=614,ny=428,La1=12.19,Lo1=226.514E=133.459W,Lov=265E=95W
15 # dx=dy=12.19058,pole @(347.668, 1190.097)
16 
17 ## \defgroup new_grid new_grid
18 #\ingroup graphics
20 
21 ##\ingroup new_grid
22  def __init__(self,outgrid,infile,outfile,wind_rot=None):
23  self.outgrid = outgrid
24  self.infile = infile
25  self.outfile = outfile
26  self.wind_rot = wind_rot
27 
28 ##\ingroup new_grid
29  def regrid(self):
30  options = ' '.join(['-set_grib_type same -new_grid_winds ',self.wind_rot, ' -new_grid', ncep_grids.get(self.outgrid)])
31  print "running: %s" % (' '.join(['wgrib2 ', self.infile, options, self.outfile]))
32  os.system(' '.join(['wgrib2', self.infile, options, self.outfile]))
33 # subprocess.call(['wgrib2', self.infile, options, self.outfile])
34  return
def __init__
Definition: regrib.py:22
def regrid(self)
Definition: regrib.py:29