HWRF  trunk@4391
Classes | Functions | Variables
pom.util Namespace Reference

Utility scripts for the pom package. More...

Detailed Description

Utility scripts for the pom package.

Many of the functions here are for just testing the python based MPIPOM scripts during its development, can be replaced with much sophisticated functions in the produtil modules.

Note
Please report bugs/questions/comments to bijuthomas(at)mail(dot)uri(dot)edu.
Author
Biju Thomas, GSO, University of Rhode Island.
Date
June 8, 2014

Classes

class  counter
 A simple integer counter class. More...
 

Functions

def ysplitter (ymdh)
 Splits a string with a ten digit YYYYMMDDHH into components. More...
 
def trailzero (astr, n)
 Returns a string of length n or greater, that consists of n-len(astr) zeros followed by astr. More...
 
def inpfile
 Creates an input file from a list of strings. More...
 
def remove (file)
 Deletes the specified file. More...
 
def rmall (args)
 Deletes a list of files. More...
 
def copy
 Copies the source to the destination without retaining permissions our group IDs. More...
 
def move
 Renames the source file to the destination. More...
 
def link (src, dest)
 Links the source file to the destination. More...
 
def runexe (nproc, rundir, exefile, stdin, stdout)
 Runs an executable. More...
 
def read_input (filename)
 Reads the contents of the file for name,value pairs and returns a dict with the contents. More...
 
def makenwrap (f)
 Wrapper for making the POM namelist. More...
 
def dateplushours (ymdh, hours)
 Adds a given number of hours to the date. More...
 
def logi2int (l)
 Turns a bool to an int, returning 1 for True or 0 for False. More...
 
def veto ()
 Prints a message about not exiting, and returns False. More...
 

Variables

string __all__ = 'ysplitter'
 List of symbols to provide by "from pom.util import *".
 
 jn2r = os.path.join
 A synonym for os.path.join.
 

Function Documentation

def pom.util.copy (   src,
  dest,
  force = True 
)

Copies the source to the destination without retaining permissions our group IDs.

Errors are ignored.

Parameters
src,destSource and destination filenames.
forceIf True, the destination file is replaced if it already exists.

Definition at line 77 of file util.py.

def pom.util.dateplushours (   ymdh,
  hours 
)

Adds a given number of hours to the date.

Parameters
ymdhA string "YYYYMMDDHH"
hoursnumber of hours to add

Definition at line 219 of file util.py.

def pom.util.inpfile (   filename,
  lst,
  logger = None 
)

Creates an input file from a list of strings.

Parameters
filenamethe input file to create
lstthe list of strings
loggera logging.Logger for log messages

Definition at line 51 of file util.py.

def pom.util.link (   src,
  dest 
)

Links the source file to the destination.

Parameters
src,destThe source and destination filenames.

Definition at line 128 of file util.py.

def pom.util.logi2int (   l)

Turns a bool to an int, returning 1 for True or 0 for False.

Parameters
lthe bool value.

Definition at line 250 of file util.py.

def pom.util.makenwrap (   f)

Wrapper for making the POM namelist.

Parameters
fthe return value from pom.nml.make()

Definition at line 204 of file util.py.

def pom.util.move (   src,
  dest,
  force = True 
)

Renames the source file to the destination.

Parameters
src,destThe source and destination filenames.
forceif True, the destination is replaced if it already exists.

Definition at line 104 of file util.py.

def pom.util.read_input (   filename)

Reads the contents of the file for name,value pairs and returns a dict with the contents.

Reads the file line-by-line. Searches for pairs of strings "string1,string2" separated by spaces, colons, semicolons or commas. Creates a dict mapping from the first string to the second. Any strings past the second are ignored.

Parameters
filenamethe file to read.

Definition at line 185 of file util.py.

def pom.util.remove (   file)

Deletes the specified file.

Ignores errors.

Parameters
fileThe file to remove.

Definition at line 62 of file util.py.

Referenced by pom.util.rmall().

def pom.util.rmall (   args)

Deletes a list of files.

Parameters
argsAll positional arguments contain names of files to remove.

Definition at line 72 of file util.py.

def pom.util.runexe (   nproc,
  rundir,
  exefile,
  stdin,
  stdout 
)

Runs an executable.

Will only run on the NOAA Jet cluster.

Warning
Do not use this function. It only runs on NOAA Jet. It lacks error checking other than returning the exit code and there is no logging. Use the produtil.run module instead.
Parameters
nprocNumber of processors to use
rundirDirectory in which to run.
exefileExecutable to run.
stdin,stdoutInput and output files.

Definition at line 144 of file util.py.

def pom.util.trailzero (   astr,
  n 
)

Returns a string of length n or greater, that consists of n-len(astr) zeros followed by astr.

Parameters
n,astrthe strings to consider

Definition at line 46 of file util.py.

def pom.util.veto ( )

Prints a message about not exiting, and returns False.

Definition at line 263 of file util.py.

def pom.util.ysplitter (   ymdh)

Splits a string with a ten digit YYYYMMDDHH into components.

Parameters
ymdhA string "YYYYMMDDHH" containing a date and hour.
Returns
a tuple (y4,mm,mm1str,dd,hh) where y4 is the year, mm is the month, dd is the day of the month and hh is the hour. The mmn1 is the nearest month start/end boundary considering the day of month

Definition at line 26 of file util.py.