HWRF  trunk@4391
Classes | Functions | Variables
hwrf.config Namespace Reference

parses UNIX conf files and makes the result readily available More...

Detailed Description

parses UNIX conf files and makes the result readily available

The hwrf.config module reads configuration information for the HWRF system from one or more *.conf files, via the Python ConfigParser module. This module also automatically fills in certain information, such as fields calculated from the tcvitals or date. The result is accessible via the HWRFConfig class, which provides many ways of automatically accessing configuration options.

Classes

class  ConfFormatter
 Internal class that implements HWRFConfig.strinterp() More...
 
class  ConfTimeFormatter
 internal function that implements time formatting More...
 
class  Environment
 returns environment variables, allowing substitutions More...
 
class  HWRFConfig
 a class that contains configuration information More...
 

Functions

def confwalker (conf, start, selector, acceptor, recursevar)
 walks through a ConfigParser-like object performing some action More...
 
def from_file (filename)
 Reads the specified conf file into an HWRFConfig object. More...
 
def from_string (confstr)
 Reads the given string as if it was a conf file into an HWRFConfig object. More...
 

Variables

list __all__ = ['from_file','from-string','confwalker','HWRFConfig','fordriver','ENVIRONMENT']
 decides what symbols are imported by "from hwrf.config import *"
 
tuple ENVIRONMENT = Environment()
 an Environment object. More...
 
dictionary FCST_KEYS
 the list of forecast time keys recognized by ConfTimeFormatter More...
 
dictionary ANL_KEYS
 the list of analysis time keys recognized by ConfTimeFormatter More...
 
dictionary ANL_M6_KEYS
 
dictionary ANL_P6_KEYS
 
tuple TIME_DIFF_KEYS = set(['fahr','famin','fahrmin'])
 the list of "forecast time minus analysis time" keys recognized by ConfTimeFormatter
 
tuple NOTFOUND = object()
 a special constant that represents a key not being found
 

Function Documentation

def hwrf.config.confwalker (   conf,
  start,
  selector,
  acceptor,
  recursevar 
)

walks through a ConfigParser-like object performing some action

Recurses through a ConfigParser-like object "conf" starting at section "start", performing a specified action. The special variable whose name is in recursevar specifies a list of additional sections to recurse into. No section will be processed more than once, and sections are processed in breadth-first order. For each variable seen in each section (including recursevar), this will call selector(sectionname, varname) to see if the variable should be processed. If selector returns True, then acceptor(section, varname, value) will be called.

Parameters
confthe ConfigParser-like object
startthe starting section
selectora function selector(section,option) that decides if an option needs processing (True) or not (False)
acceptora function acceptor(section,option,value) run on all options for which the selector returns True
recursevaran option in each section that lists more sections the confwalker should touch. If the selector returns True for the recursevar, then the recursevar will be sent to the acceptor. However, it will be scanned for sections to recurse into even if the selector rejects it.

Definition at line 329 of file config.py.

def hwrf.config.from_file (   filename)

Reads the specified conf file into an HWRFConfig object.

Creates a new HWRFConfig object and instructs it to read the specified file.

Parameters
filenamethe path to the file that is to be read
Returns
a new HWRFConfig object

Definition at line 371 of file config.py.

def hwrf.config.from_string (   confstr)

Reads the given string as if it was a conf file into an HWRFConfig object.

Creates a new HWRFConfig object and reads the string data into it as if it was a config file

Parameters
confstrthe config data
Returns
a new HWRFConfig object

Definition at line 383 of file config.py.

Variable Documentation

hwrf.config.ANL_KEYS
Initial value:
1 = { 'aYMDHM':'%Y%m%d%H%M', 'aYMDH':'%Y%m%d%H', 'aYMD':'%Y%m%d',
2  'ayear':'%Y', 'aYYYY':'%Y', 'aYY':'%y', 'aCC':'%C', 'acen':'%C',
3  'amonth':'%m', 'aMM':'%m', 'aday':'%d', 'aDD':'%d', 'ahour':'%H',
4  'acyc':'%H', 'aHH':'%H', 'aminute':'%M', 'amin':'%M' }

the list of analysis time keys recognized by ConfTimeFormatter

Definition at line 153 of file config.py.

dictionary hwrf.config.ANL_M6_KEYS
Initial value:
1 = { 'am6YMDHM':'%Y%m%d%H%M', 'am6YMDH':'%Y%m%d%H', 'am6YMD':'%Y%m%d',
2  'am6year':'%Y', 'am6YYYY':'%Y', 'am6YY':'%y', 'am6CC':'%C', 'am6cen':'%C',
3  'am6month':'%m', 'am6MM':'%m', 'am6day':'%d', 'am6DD':'%d', 'am6hour':'%H',
4  'am6cyc':'%H', 'am6HH':'%H', 'am6minute':'%M', 'am6min':'%M' }

Definition at line 165 of file config.py.

dictionary hwrf.config.ANL_P6_KEYS
Initial value:
1 = { 'ap6YMDHM':'%Y%m%d%H%M', 'ap6YMDH':'%Y%m%d%H', 'ap6YMD':'%Y%m%d',
2  'ap6year':'%Y', 'ap6YYYY':'%Y', 'ap6YY':'%y', 'ap6CC':'%C', 'ap6cen':'%C',
3  'ap6month':'%m', 'ap6MM':'%m', 'ap6day':'%d', 'ap6DD':'%d', 'ap6hour':'%H',
4  'ap6cyc':'%H', 'ap6HH':'%H', 'ap6minute':'%M', 'ap6min':'%M' }

Definition at line 177 of file config.py.

hwrf.config.ENVIRONMENT = Environment()

an Environment object.

You should never need to instantiate another one.

Definition at line 64 of file config.py.

hwrf.config.FCST_KEYS
Initial value:
1 = { 'fYMDHM':'%Y%m%d%H%M', 'fYMDH':'%Y%m%d%H', 'fYMD':'%Y%m%d',
2  'fyear':'%Y', 'fYYYY':'%Y', 'fYY':'%y', 'fCC':'%C', 'fcen':'%C',
3  'fmonth':'%m', 'fMM':'%m', 'fday':'%d', 'fDD':'%d', 'fhour':'%H',
4  'fcyc':'%H', 'fHH':'%H', 'fminute':'%M', 'fmin':'%M' }

the list of forecast time keys recognized by ConfTimeFormatter

Definition at line 141 of file config.py.