HWRF  trunk@4391
Public Member Functions | Public Attributes | List of all members
hwrf.fcsttask.WRFTaskBase Class Reference

base class of classes that run wrf or real_nmm More...

Detailed Description

base class of classes that run wrf or real_nmm

This is the abstract base class of tasks that run real or WRF. The purpose of this class is simply to reduce code duplication.

Definition at line 488 of file fcsttask.py.

Inheritance diagram for hwrf.fcsttask.WRFTaskBase:
hwrf.fcsttask.FcstTask hwrf.hwrftask.HWRFTask produtil.datastore.Task produtil.datastore.Datum hwrf.fcsttask.RealNMM hwrf.fcsttask.WRFAnl hwrf.fcsttask.WRFAtmos hwrf.multistorm.RealInit hwrf.fcsttask.WRFAnl4Trak hwrf.fcsttask.WRFGhost hwrf.coupling.CoupledWRF hwrf.multistorm.WRFAtmosMultiStorm hwrf.fcsttask.WRFGhostForPost hwrf.fcsttask.AnalysisCycle hwrf.hycom.WRFCoupledHYCOM hwrf.mpipomtc.WRFCoupledPOM hwrf.ww3.WRFCoupledWW3 hwrf.ww3.WRFWW3POM

Public Member Functions

def __init__ (self, dstore, conf, section, wrf, keeprun=True, kwargs)
 constructor More...
 
def make_wrf (self, wrf)
 creates a WRFSimulation object for this class More...
 
def add_geogrid (self, g)
 adds a geogrid input source More...
 
def add_metgrid (self, m)
 adds a metgrid input source More...
 
def add_prep_hybrid (self, p)
 adds a prep_hybrid input source More...
 
def use_prep_hybrid (self)
 returns True if prep_hybrid was requested, and False otherwise. More...
 
def add_wrfinput (self, r)
 adds a wrfinput_d01 input source More...
 
def add_wrfbdy (self, r)
 adds a wrfbdy_d01 input source More...
 
def add_fort65 (self, r)
 adds a coupler fort.65 input source More...
 
def add_real (self, r)
 add a fort.65, wrfinput_d01 and wrfbdy_d01 input source More...
 
def add_wrfanl (self, r, domain)
 add a wrfanl input source for a specific domain More...
 
def make_products (self)
 called from constructor, creates Products More...
 
def link_fix (self)
 links or copies fixed data files More...
 
def check_all_inputs (self)
 Checks to see if all needed input is available. More...
 
def link_all_inputs
 Links all inputs provided by the various add_* member functions. More...
 
def need_all_metgrid (self)
 Returns True if all metgrid files are needed as input to this Task.
 
def run_exe
 runs the executable More...
 
def final_prerun (self)
 last step before running executable More...
 
def initial_prerun (self)
 called immediately after cding to a scrub directory More...
 
def run (self)
 run the wrf or real_nmm More...
 
def postrun (self)
 called just after run_exe() succeeds. More...
 
def deliver_products (self)
 delivers products to their destinations More...
 
def make_namelist
 generates the wrf namelist.input file More...
 
def wrf (self)
 Returns the WRFSimulation object used by this task. More...
 
def sim (self)
 Returns the WRFSimulation object used by this task. More...
 
- Public Member Functions inherited from hwrf.fcsttask.FcstTask
def __init__ (self, dstore, conf, section, outdir=None, taskname=None, kwargs)
 Creates a FcstTask object. More...
 
def has_input (self, typename)
 is there any input data of this type to this task? More...
 
def add_input (self, typename, inobj)
 add input of a specified type More...
 
def check_input (self, typenames, kwargs)
 check if input data is available More...
 
def link_input (self, typenames, just_check=False, kwargs)
 link or check for inputs More...
 
- Public Member Functions inherited from hwrf.hwrftask.HWRFTask
def __init__ (self, dstore, conf, section, taskname=None, workdir=None, outdir=None, storminfo=UNSPECIFIED, taskvars=UNSPECIFIED, kwargs)
 Creates an HWRFTask. More...
 
def isfakestorm (self)
 
def ismultistorm (self)
 
def get_workdir (self)
 Returns the directory the class should work in, as set by the "workdir" metadata value. More...
 
def set_workdir (self, val)
 Sets the directory the class should work in. More...
 
def get_outdir (self)
 Gets the directory that should receive output data. More...
 
def set_outdir (self, val)
 Sets the directory that should receive output data. More...
 
def realtime (self)
 Is this job a real-time forecast job? More...
 
def redirect (self)
 Should subprograms' outputs be redirected to separate files?
 
def scrub (self)
 Should temporary files be deleted as soon as they are not needed?
 
def tvset (self, opt, val)
 Sets a taskvar option's value. More...
 
def tvdel (self, opt)
 Deletes an object-local value set by tvset. More...
 
def tvget (self, opt)
 Gets a taskvar's value. More...
 
def tvhave
 Is a taskvar set? More...
 
def taskvars (self)
 The dict of object-local values used for string substitution. More...
 
def confint
 Alias for self.conf.getint for section self.section. More...
 
def confstr
 Alias for self.conf.getstr for section self.section. More...
 
def conffloat
 Alias for self.conf.getfloat for section self.section. More...
 
def confbool
 Alias for self.conf.getbool for section self.section. More...
 
def confget
 Alias for self.conf.get for section self.section. More...
 
def confitems
 Alias for self.conf.items for section self.section. More...
 
def confstrinterp (self, string, section=None, kwargs)
 Alias for self.icstr for backward compatibility. More...
 
def conftimestrinterp (self, string, ftime, atime=None, section=None, kwargs)
 Alias for self.timestr for backward comaptibility. More...
 
def confraw
 Get a raw configuration value before string expansion. More...
 
def icstr (self, string, section=None, kwargs)
 Expands a string in the given conf section. More...
 
def timestr (self, string, ftime, atime=None, section=None, kwargs)
 Expands a string in the given conf section, including time vars. More...
 
def getdir
 Alias for hwrf.config.HWRFConfig.get() for the "dir" section. More...
 
def getexe
 Alias for hwrf.config.HWRFConfig.get() for the "exe" section. More...
 
def getconf (self)
 Returns this HWRFTask's hwrf.config.HWRFConfig object. More...
 
def getsection (self)
 Returns this HWRFTask's section name in the HWRFConfig. More...
 
def log
 Obtain a logging domain. More...
 
def inputiter (self)
 Iterates over all inputs required by this task. More...
 
- Public Member Functions inherited from produtil.datastore.Task
def __init__ (self, dstore, taskname, logger=None, kwargs)
 Task constructor. More...
 
def jlogfile (self)
 returns the jlogfile logger. More...
 
def postmsg (self, message, args, kwargs)
 same as produtil.log.jlogger.info() More...
 
def setstate (self, val)
 Sets the state of this job. More...
 
def getstate (self)
 Returns the job state. More...
 
def strstate (self)
 A string representation of the job state. More...
 
def gettaskname (self)
 Returns the task name part of the database ID, which is the same as the prodname. More...
 
def products (self, args, kwargs)
 Iterate over the products this task produces. More...
 
def log (self)
 Returns the logger object for this task. More...
 
def clean (self)
 Cleans up any unneeded data used by this task. More...
 
def unrun (self)
 Undoes the effect of run(). More...
 
def run (self)
 Performs the work this Task should do and generates all products. More...
 
def is_completed (self)
 Is this task complete? More...
 
def completed (self)
 Read-only property: is this task completed? Same as is_completed() More...
 
def runpart (self)
 Run some of this task's work, deliver some products. More...
 
- Public Member Functions inherited from produtil.datastore.Datum
def __init__ (self, dstore, prodname, category, meta=None, cache=30, location=None, kwargs)
 Datum constructor. More...
 
def __enter__ (self)
 Acquires this object's thread lock. More...
 
def __exit__ (self, etype, evalue, traceback)
 Releases this object's thread lock. More...
 
def validate (self)
 Validates this object's Datastore, prodname and category. More...
 
def getid (self)
 Returns the database ID of this datum. More...
 
def getdatastore (self)
 Returns the datastore of this datum. More...
 
def transaction (self)
 Creates, but does not lock, a Transaction for this datum's datastore. More...
 
def getprodtype (self)
 Returns the product type of this Datum. More...
 
def getprodname (self)
 Returns the product name part of the database ID. More...
 
def getcategory (self)
 Returns the product category part of the database ID. More...
 
def getlocation (self)
 Returns the "location" field of this Datum's database entry. More...
 
def setlocation (self, v)
 Sets the "location" field of this Datum's database entry. More...
 
def __hash__ (self)
 Integer hash function. More...
 
def __str__ (self)
 Human-readable description of this Datum. More...
 
def __repr__ (self)
 Python code-like description of this Datum. More...
 
def __cmp__ (self, other)
 Compares two Datums' prodnames and categories. More...
 
def set_loc_avail (self, loc, avail)
 Sets the location and availability of this Datum in a single transaction. More...
 
def update (self)
 Discards all cached metadata and refreshes it from the Datastore. More...
 
def __getitem__ (self, k)
 Returns the value of the specified metadata key or raises KeyError. More...
 
def meta
 Return the value of a metadata key. More...
 
def get
 Alias for self.meta() Returns the value of the specified metadata key or returns default if it is unset. More...
 
def __setitem__ (self, k, v)
 Sets the value of the specified metadata key. More...
 
def __delitem__ (self, k)
 Deletes the specified metadata key, which must not be "available" or "location". More...
 
def __contains__ (self, k)
 Determines if a metadata key is set. More...
 
def iteritems (self)
 Iterates over all metadata (key,value) pairs for this Datum, including "available" and "location". More...
 

Public Attributes

 dt_epsilon
 epsilon value for time equality comparisons
 
 keeprun
 if False, temporary files are deleted, otherwise they're kept
 
 location
 
- Public Attributes inherited from hwrf.fcsttask.FcstTask
 inputs
 a mapping of typename to a list of input objects
 
- Public Attributes inherited from hwrf.hwrftask.HWRFTask
 storminfo
 The hwrf.storminfo.StormInfo describing the vitals information for the storm processed by this HWRFTask. More...
 

Additional Inherited Members

- Properties inherited from hwrf.hwrftask.HWRFTask
 workdir
 The directory in which this task should be run. More...
 
 outdir
 The directory in which this task should deliver its final output. More...
 
 conf
 This HWRFTask's hwrf.config.HWRFConfig object. More...
 
 section
 The confsection in self.section for this HWRFTask (read-only) More...
 
- Properties inherited from produtil.datastore.Task
 state
 Read-write property: the job state. More...
 
 taskname
 Read-only property: the name of this task. More...
 
- Properties inherited from produtil.datastore.Datum
 prodname = property(getprodname,None,None,)
 Read-only property, an alias for getprodname(): the product name part of the database ID. More...
 
 category = property(getcategory,None,None,)
 Read-only property, an alias for getcategory(), the category name part of the database ID. More...
 
 prodtype
 Read-only property, an alias for getprodtype(), the product type. More...
 
 did
 Read-only property, an alias for getid(). More...
 
 dstore
 Read-only property, an alias for getdatastore(), the Datastore in which this Datum resides. More...
 
 location
 Read-write property, an alias for getlocation() and setlocation(). More...
 

Constructor & Destructor Documentation

def hwrf.fcsttask.WRFTaskBase.__init__ (   self,
  dstore,
  conf,
  section,
  wrf,
  keeprun = True,
  kwargs 
)

constructor

Creates a WRFTaskBase for the specified datastore, conf and section. The wrf argument is a WRFSimulation. It will not be used directly: instead the wrf is copied, and the copy is used. If keeprun=True, then the output of the simulation, after running it, will not be scrubbed. Other keyword arguments are passed to the superclass FcstTask.

Parameters
dstorethe produtil.datastore.Datastore to use
confthe hwrf.config.HWRFConfig that provides configuration ifnormation
sectionthe config section in conf
wrfthe hwrf.wrf.WRFSimulation object that is being run
keeprunif True, the simulation temporary files are not deleted
kwargspassed unmodified to FcstTask.__init__()

Definition at line 493 of file fcsttask.py.

Member Function Documentation

def hwrf.fcsttask.WRFTaskBase.add_fort65 (   self,
  r 
)

adds a coupler fort.65 input source

Adds an input source (via self.add_input) that will provide the fort.65 output from real_nmm. given object must have a fort65_at_time(atime,domain) function that returns a Product to link for a specified analysis time and WRFDomain object. Returns self.

Parameters
rthe src argument to Fort652WRF.__init__

Definition at line 743 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.add_real().

def hwrf.fcsttask.WRFTaskBase.add_geogrid (   self,
  g 
)

adds a geogrid input source

Adds an input source (via self.add_input) that will provide the output of WPS geogrid.exe. The given object must have a geodat member function which takes a WRFDomain as its argument and returns a Product to link. Returns self.

Parameters
gthe src argument to Geog2WRF.__init__()
Returns
self

Definition at line 680 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.add_metgrid (   self,
  m 
)

adds a metgrid input source

Adds an input source (via self.add_input) that will provide the output of WPS metgrid.exe. The given object must have a met_at_time function that returns a Product to link for a specified forecast time. Returns self.

Parameters
mthe src argument to Met2WRF.__init__()
Returns
self

Definition at line 691 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.add_prep_hybrid (   self,
  p 
)

adds a prep_hybrid input source

Adds an input source (via self.add_input) that will provide the output of the prep_hybrid program. The given object must have a products function that iterates over products for a given name='bdy' or name='init' and a time=F for a given forecast time F. Returns self.

Parameters
pthe src argument to Prep2WRF.__init__()
Returns
self

Definition at line 702 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.add_real (   self,
  r 
)

add a fort.65, wrfinput_d01 and wrfbdy_d01 input source

This is a convenience function that simply passes its argument to self.add_fort65, add_wrfinput and add_wrfbdy in that order. Returns self.

Parameters
rthe src argument to Fort652WRF.__init__(), WRFBdy2WRF.__init__() and WRFInput2WRF.__init__()
Returns
self

Definition at line 754 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.add_wrfanl (   self,
  r,
  domain 
)

add a wrfanl input source for a specific domain

Adds an input source (via self.add_input) that will provide the wrfanl output file from a prior run of wrf.exe. The given object must have a wrfanl_at_time function that returns a Product to link for a specified analysis time and domain. Returns self.

Parameters
rthe src argument to WRFAnl2WRF.__init__()
domainthe domain for whom this is the wrfanl product
Returns
self

Definition at line 767 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.add_wrfbdy (   self,
  r 
)

adds a wrfbdy_d01 input source

Adds an input source (via self.add_input) that will provide the wrfbdy output of a real_nmm run. The given object must have a wrfbdy_at_time(atime,domain) function that returns a Product to link for a specified analysis time and WRFDomain object. Returns self.

Parameters
rthe src argument to WRFBdy2WRF.__init__()
Returns
self

Definition at line 731 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.add_real().

def hwrf.fcsttask.WRFTaskBase.add_wrfinput (   self,
  r 
)

adds a wrfinput_d01 input source

Adds an input source (via self.add_input) that will provide the wrfinput output file from real_nmm. The given object must have a wrfinput_at_time(atime,domain) function that returns a Product for a given analysis time and WRFDomain object. Returns self.

Parameters
rthe src argument to WRFInput2WRF.__init__()
Returns
self

Definition at line 719 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.add_real().

def hwrf.fcsttask.WRFTaskBase.check_all_inputs (   self)

Checks to see if all needed input is available.

Definition at line 813 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.deliver_products (   self)

delivers products to their destinations

Called by self.run() after postrun(), just before CDing out of the work directory. This should deliver products to their destinations. The default implementation raises NotImplementedError. This MUST be overridden in subclasses.

Definition at line 959 of file fcsttask.py.

Referenced by hwrf.mpipomtc.POMInit.run(), hwrf.ww3.WW3Init.run(), hwrf.finalmergetask.FinalMergeTask.run(), hwrf.wps.Geogrid.run(), hwrf.gsi.GSIBase.run(), hwrf.wps.Ungrib.run(), hwrf.wps.Metgrid.run(), and hwrf.relocate.Merge.run().

def hwrf.fcsttask.WRFTaskBase.final_prerun (   self)

last step before running executable

Called by self.run() just before calling run_exe. The default implementation does nothing. This is intended to be overridden by subclasses.

Definition at line 908 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.initial_prerun (   self)

called immediately after cding to a scrub directory

Called by self.run() after CDing to the new directory, but before doing anything else. The default implementation does nothing. This is intended to be overridden by subclasses.

Definition at line 914 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.link_all_inputs (   self,
  just_check = False 
)

Links all inputs provided by the various add_* member functions.

Parameters
just_checkif True, just check to see if data is available. If False, actually copy.

Definition at line 816 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.check_all_inputs().

def hwrf.fcsttask.WRFTaskBase.link_fix (   self)

links or copies fixed data files

Links or copies fix files needed by WRF. Will copy if the link_wrf_fix=no in this task's config section. Otherwise, the files are linked.

Definition at line 789 of file fcsttask.py.

Referenced by hwrf.post.PostOneWRF.run(), hwrf.wps.Geogrid.run(), hwrf.wps.Ungrib.run(), and hwrf.wps.Metgrid.run().

def hwrf.fcsttask.WRFTaskBase.make_namelist (   self,
  filename = 'namelist.input',
  logger = None 
)

generates the wrf namelist.input file

Runs set_ij_start (swcorner_dynamic) to generate the i & j start locations for domain 2, then generates the namelist.

Parameters
filenamethe namelist.input filename
loggerthe logging.Logger to log messages (optional)

Definition at line 968 of file fcsttask.py.

Referenced by hwrf.namelist.Conf2Namelist.__str__(), hwrf.wps.Geogrid.run(), hwrf.wps.Ungrib.run(), hwrf.wps.Metgrid.run(), and hwrf.tracker.TrackerTask.run().

def hwrf.fcsttask.WRFTaskBase.make_products (   self)

called from constructor, creates Products

This is called from the WRFTaskBase constructor. Subclasses should re-implement this method to generate internal information about what products this class can provide, so that self.products() and self.deliver_products() will function properly. The default implementation does nothing.

Definition at line 781 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.__init__().

def hwrf.fcsttask.WRFTaskBase.make_wrf (   self,
  wrf 
)

creates a WRFSimulation object for this class

Given the wrf object passed to the constructor, creates a new WRFSimulation that is modified for this object. For example, this class may need to add output of a restart and wrfinput file at the end of the simulation, or enable hourly output of history files.

Parameters
wrfthe wrf argument to init

Definition at line 670 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.__init__().

def hwrf.fcsttask.WRFTaskBase.postrun (   self)

called just after run_exe() succeeds.

Called by self.run() just after run_exe returns successfully. The default implementation does nothing; this is intended to be overridden in subclasses.

Definition at line 953 of file fcsttask.py.

def hwrf.fcsttask.WRFTaskBase.run (   self)

run the wrf or real_nmm

Performs all work needed to run the program. Creates the work directory, CD's to it, runs the initial_prerun(), link_fix(), link_all_inputs(), make_namelist(), final_prerun(), run_exe(), postrun() and deliver_products().

Definition at line 920 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.run_exe(), and produtil.datastore.Task.runpart().

def hwrf.fcsttask.WRFTaskBase.run_exe (   self,
  exename = 'wrf',
  not_allranks = False,
  runner = None,
  sleeptime = None 
)

runs the executable

Runs the executable this task is responsible for running. Determines if the program ran correctly. The exename is the name of the argument in the [exe] section of the HWRFConfig. Options:

Parameters
not_allranksBy default (False) all ranks are used to run the executable. Pass not_allranks=True to run on only one rank.
runnerpass a produtil.prog.Runner object if desired. This overrides any decision of what to run: the exename and not_allranks will be ignored, and whatever is supplied in runner is simply passed to produtil.run.run.
sleeptimepassed to produtil.run.run to determine how often to check the child process. By default, the sleeptime option in this task's config section is used, or if that is absent, 30 seconds.
exenameif no runner is specified, self.getexe(exename) is called to get the executable path, and it is run as an MPI program.

Definition at line 861 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFTaskBase.need_all_metgrid().

def hwrf.fcsttask.WRFTaskBase.sim (   self)

Returns the WRFSimulation object used by this task.

This property has the same effect as self.wrf(), but this is a property instead. Hence, you can type self.sim instead of self.wrf()

Definition at line 986 of file fcsttask.py.

Referenced by hwrf.fcsttask.WRFGhost.get_ghost(), hwrf.fcsttask.WRFGhostForPost.get_ghost(), hwrf.fcsttask.WRFAnl.get_wrfanl(), hwrf.fcsttask.WRFAnl4Trak.make_products(), hwrf.fcsttask.WRFAnl4Trak.products(), and hwrf.fcsttask.WRFAnl4Trak.track_domains().

def hwrf.fcsttask.WRFTaskBase.use_prep_hybrid (   self)

returns True if prep_hybrid was requested, and False otherwise.

Definition at line 715 of file fcsttask.py.

Referenced by hwrf.fcsttask.RealNMM.make_wrf().

def hwrf.fcsttask.WRFTaskBase.wrf (   self)

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