HWRF  trunk@4391
Public Member Functions | Properties | List of all members
hwrf.regrib.Regrib Class Reference

This is a helper class intended to be used internally by RegribMany. More...

Detailed Description

This is a helper class intended to be used internally by RegribMany.

It performs a small number of GRIB manipulations intended to produce the result of a single GRIB expression.

Definition at line 186 of file regrib.py.

Inheritance diagram for hwrf.regrib.Regrib:
hwrf.regrib.RegribBase

Public Member Functions

def __init__ (self, result, op, workprefix=None, kwargs)
 Creates a Regrib object whose result has the given name (in "result") and produces the output of the specified operation "op", prepending the given prefix "workprefix" to temporary and output filenames. More...
 
def set_workprefix
 Sets the work directory and filename prefix to the given value, or sets it to a reasonable default if workprefix is None or missing. More...
 
def reset
 Discards all temporary data, and re-initializes this object for the specified result name, operator and workprefix. More...
 
def getop (self)
 Returns the GRIBBase object that performs this Regrib's work. More...
 
def is_ready (self, kwargs)
 Returns True if this Regrib object's operator is "ready" (according to is_ready) and False otherwise. More...
 
def input_valid (self, kwargs)
 Returns True if the specified kwargs are valid for this Regrib object's operator and False otherwise. More...
 
def make (self, kwargs)
 Runs this Regrib object's operator's make function with the given keyword arguments, returning the results. More...
 
def indextemp (self, grib)
 Generates a temporary filename to use for the specified GRIB1/2 file's index file. More...
 
def gribtemp
 Returns a tuple (grib,index) containing a suggested GRIB1/2 filename and index filename. More...
 
def tempfile
 Creates a name of a temporary file. More...
 
- Public Member Functions inherited from hwrf.regrib.RegribBase
def __init__
 Creates a RegribBase. More...
 
def getcopygb (self)
 Returns the copygb ImmutableRunner.
 
def getcnvgrib_g12 (self)
 Returns the cnvgrib -p32 -g12 command, which should be an ImmutableRunner.
 
def getcnvgrib_g21 (self)
 Returns the cnvgrib -g21 command, which should be an ImmutableRunner. More...
 
def getwgrib (self)
 Returns the wgrib command, which should be an ImmutableRunner. More...
 
def getlog (self)
 Returns the logger.Logging object to use for logging messages, or None if no logger was provided to the constructor. More...
 
def setlog (self, val)
 Sets the logger.Logging object to use for logging messages. More...
 
def getprodargs (self)
 Returns the array of arguments to send to the products iterators. More...
 
def getprodkwargs (self)
 Returns a dict of keyword arguments to send to the products iterators. More...
 
def setsync_frequently (self, flag)
 Sets the sync_frequently flag. More...
 
def getsync_frequently (self)
 Returns the value of the sync_frequently flag. More...
 

Properties

 op
 The GRIBBase object that performs this Regrib's work. More...
 
- Properties inherited from hwrf.regrib.RegribBase
 sync_frequently
 Boolean flag: should we call sync frequently? More...
 
 logger
 A logging.Logger for log messages. More...
 
 prodargs
 A list of additional positional arguments to send to Task.products. More...
 
 prodkwargs
 A dict of additional keyword arguments to send to Task.products. More...
 
 wgrib
 A produtil.prog.ImmutableRunner for running wgrib, or None if unavailable. More...
 
 copygb
 A produtil.prog.ImmutableRunner for running copygb, or None if unavailable. More...
 
 cnvgrib_g21
 A produtil.prog.ImmutableRunner for running cnvgrib to convert from GRIB2 to GRIB1, or None if unavailable. More...
 
 cnvgrib_g12
 A produtil.prog.ImmutableRunner for running cnvgrib to convert from GRIB1 to GRIB2, or None if unavailable. More...
 

Constructor & Destructor Documentation

def hwrf.regrib.Regrib.__init__ (   self,
  result,
  op,
  workprefix = None,
  kwargs 
)

Creates a Regrib object whose result has the given name (in "result") and produces the output of the specified operation "op", prepending the given prefix "workprefix" to temporary and output filenames.

Parameters
resultthe name of this operation result, for referencing it again in a RegribMany object after the operation is complete.
opthe operation to perform
workprefix
kwargsAdditional keyword arguments are sent to RegribBase.__init__()

Definition at line 190 of file regrib.py.

Member Function Documentation

def hwrf.regrib.Regrib.getop (   self)

Returns the GRIBBase object that performs this Regrib's work.

Definition at line 232 of file regrib.py.

def hwrf.regrib.Regrib.gribtemp (   self,
  what = None 
)

Returns a tuple (grib,index) containing a suggested GRIB1/2 filename and index filename.

Parameters
whatThe optional argument "what" must contain no shell metacharacters and is incorporated into the file name.

Definition at line 285 of file regrib.py.

def hwrf.regrib.Regrib.indextemp (   self,
  grib 
)

Generates a temporary filename to use for the specified GRIB1/2 file's index file.

Parameters
gribthe grib filename
Returns
the suggested filename for the wgrib -s output

Definition at line 269 of file regrib.py.

def hwrf.regrib.Regrib.input_valid (   self,
  kwargs 
)

Returns True if the specified kwargs are valid for this Regrib object's operator and False otherwise.

Parameters
kwargsAdditional keyword arguments passed to GRIBBase.input_valid() called on self.op
Returns
the result of GRIBBase.is_ready(), called on self.op

Definition at line 247 of file regrib.py.

def hwrf.regrib.Regrib.is_ready (   self,
  kwargs 
)

Returns True if this Regrib object's operator is "ready" (according to is_ready) and False otherwise.

Parameters
kwargsAdditional keyword arguments passed to GRIBBase.is_ready(), called on self.op.
Returns
The result of GRIBBase.is_ready(), called on self.op

Definition at line 240 of file regrib.py.

Referenced by hwrf.regrib.RegribMany.has_data().

def hwrf.regrib.Regrib.make (   self,
  kwargs 
)

Runs this Regrib object's operator's make function with the given keyword arguments, returning the results.

Parameters
kwargsAdditional keyword arguments passed to GRIBBase.make() called on self.op
Returns
the result of GRIBBase.is_ready(), called on self.op

Definition at line 254 of file regrib.py.

def hwrf.regrib.Regrib.reset (   self,
  result,
  op,
  workprefix = None 
)

Discards all temporary data, and re-initializes this object for the specified result name, operator and workprefix.

This is used by RegribMany to re-use a single Regrib object over and over.

Parameters
resultthe new result object to return, if queried
opthe new operation to return if queried
workprefixthe new work directory and filename prefix

Definition at line 219 of file regrib.py.

def hwrf.regrib.Regrib.set_workprefix (   self,
  workprefix = None 
)

Sets the work directory and filename prefix to the given value, or sets it to a reasonable default if workprefix is None or missing.

The work prefix is not necessarily a directory: it can include additional text to prepend to the filename.

Parameters
workprefixThe new work directory and filename prefix.

Definition at line 206 of file regrib.py.

Referenced by hwrf.regrib.Regrib.__init__(), and hwrf.regrib.Regrib.reset().

def hwrf.regrib.Regrib.tempfile (   self,
  what = None 
)

Creates a name of a temporary file.

Parameters
whatThe "what" argument is a terse explanation of the purpose of the file (such as "merge" or "to-grib2") to include in the filename.
Returns
The suggested filename.

Definition at line 296 of file regrib.py.

Property Documentation

hwrf.regrib.Regrib.op
static
Initial value:
1 = property(getop,None,None,
2  )

The GRIBBase object that performs this Regrib's work.

Definition at line 238 of file regrib.py.

Referenced by hwrf.regrib.Regrib.make().


The documentation for this class was generated from the following file: