RHESSysWorkflows  1.33
Variables
RunModel Namespace Reference

Run RHESSys. More...

Variables

tuple parser = argparse.ArgumentParser(description='Run RHESSys, recording information about the run in metadata')
 
string help = 'The configuration file'
 
tuple outputType = parser.add_mutually_exclusive_group(required=True)
 
tuple args = parser.parse_args()
 
tuple cmdline = RHESSysMetadata.getCommandLine()
 
 configFile = None
 
tuple context = Context(args.projectDir, configFile)
 
tuple metadata = RHESSysMetadata.readRHESSysEntries(context)
 
list rhessysDir = metadata['rhessys_dir']
 
tuple paths = RHESSysPaths(args.projectDir, rhessysDir)
 
list rhessysBinPathRel = metadata['rhessys_bin']
 
tuple rhessysBinPath = os.path.join(context.projectDir, rhessysBinPathRel)
 
tuple outputDir = os.path.join(paths.RHESSYS_OUT, args.outputPrefix)
 
tuple outputPrefix = os.path.join(outputDir, RHESSysMetadata.MODEL_NAME)
 
tuple outputPrefixRel = paths.relpath(outputPrefix)
 
tuple outputDirRel = paths.relpath(outputDir)
 
tuple worldfile = os.path.join(paths.RHESSYS_WORLD, args.worldfile)
 
tuple worldfileRel = paths.relpath(worldfile)
 
tuple tecfile = os.path.join(paths.RHESSYS_TEC, args.tecfile)
 
tuple tecfileRel = paths.relpath(tecfile)
 
string cmd_proto = "{bin} -st {startDate} -ed {endDate} {outputType} -pre {outputPrefix} -t {tecfile} -w {worldfile} -r {flowtables} {remainders}"
 
 surfaceFlow = None
 
list subsurfaceFlow = args.flowtables[0]
 
tuple subsurfaceFlowRel = paths.relpath(subsurfaceFlow)
 
 flowtables = subsurfaceFlow
 
 flowtablesRel = subsurfaceFlowRel
 
tuple surfaceFlowRel = paths.relpath(surfaceFlow)
 
string remainders = ' '
 
string startDate = ' '
 
string endDate = ' '
 
tuple cmd
 
tuple cmdRel
 
tuple cmdArgs = cmd.split()
 
tuple process = subprocess.Popen(cmdArgs, cwd=paths.RHESSYS_DIR, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
 
tuple rhessysOutPath = os.path.join(outputDir, 'rhessys.out')
 
tuple rhessysOut = open(rhessysOutPath, 'w')
 
tuple line = process.stdout.readline()
 
tuple run = ModelRun()
 

Detailed Description

Run RHESSys.

This software is provided free of charge under the New BSD License. Please see the following license information:

Copyright (c) 2013, University of North Carolina at Chapel Hill All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OF NORTH CAROLINA AT CHAPEL HILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Author
Brian Miles brian.nosp@m._mil.nosp@m.es@un.nosp@m.c.ed.nosp@m.u

Pre conditions

  1. The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: rhessys_dir rhessys_bin

Post conditions

  1. Will write an entry to the model run section of the project metadata
  2. Will write an entry to the history section of the project metadata when the model run sucessfully completes

Usage:

1 RunModel.py -p /path/to/project_dir -d "Scenario 1" (--basin | --hillslope | --zone | --patch | --canopy) -pre OUTPUT_PREFIX -st YYYY M D H -ed YYYY M D H -w WORLDFILE -t TECFILE -r FLOWTABLE [SURFACE_FLOWTABLE] [-- RHESSYS_ARG_1 ... RHESSYS_ARG_N]

Variable Documentation

tuple RunModel.args = parser.parse_args()
tuple RunModel.cmd
Initial value:
1 = cmd_proto.format(bin=rhessysBinPath, startDate=startDate, endDate=endDate,
2  outputType=args.outputType, outputPrefix=outputPrefix,
3  tecfile=tecfile, worldfile=worldfile, flowtables=flowtables, remainders=remainders)
string RunModel.cmd_proto = "{bin} -st {startDate} -ed {endDate} {outputType} -pre {outputPrefix} -t {tecfile} -w {worldfile} -r {flowtables} {remainders}"
tuple RunModel.cmdArgs = cmd.split()
tuple RunModel.cmdline = RHESSysMetadata.getCommandLine()
tuple RunModel.cmdRel
Initial value:
1 = cmd_proto.format(bin=rhessysBinPathRel, startDate=startDate, endDate=endDate,
2  outputType=args.outputType, outputPrefix=outputPrefixRel,
3  tecfile=tecfileRel, worldfile=worldfileRel, flowtables=flowtablesRel, remainders=remainders)
RunModel.configFile = None
tuple RunModel.context = Context(args.projectDir, configFile)
string RunModel.endDate = ' '
RunModel.flowtables = subsurfaceFlow
RunModel.flowtablesRel = subsurfaceFlowRel
string RunModel.help = 'The configuration file'
tuple RunModel.line = process.stdout.readline()
tuple RunModel.metadata = RHESSysMetadata.readRHESSysEntries(context)
tuple RunModel.outputDir = os.path.join(paths.RHESSYS_OUT, args.outputPrefix)
tuple RunModel.outputDirRel = paths.relpath(outputDir)
tuple RunModel.outputPrefix = os.path.join(outputDir, RHESSysMetadata.MODEL_NAME)
tuple RunModel.outputPrefixRel = paths.relpath(outputPrefix)
tuple RunModel.outputType = parser.add_mutually_exclusive_group(required=True)
tuple RunModel.parser = argparse.ArgumentParser(description='Run RHESSys, recording information about the run in metadata')
tuple RunModel.paths = RHESSysPaths(args.projectDir, rhessysDir)
tuple RunModel.process = subprocess.Popen(cmdArgs, cwd=paths.RHESSYS_DIR, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
string RunModel.remainders = ' '
tuple RunModel.rhessysBinPath = os.path.join(context.projectDir, rhessysBinPathRel)
list RunModel.rhessysBinPathRel = metadata['rhessys_bin']
list RunModel.rhessysDir = metadata['rhessys_dir']
tuple RunModel.rhessysOut = open(rhessysOutPath, 'w')
tuple RunModel.rhessysOutPath = os.path.join(outputDir, 'rhessys.out')
tuple RunModel.run = ModelRun()
string RunModel.startDate = ' '
tuple RunModel.subsurfaceFlow = args.flowtables[0]
tuple RunModel.subsurfaceFlowRel = paths.relpath(subsurfaceFlow)
tuple RunModel.surfaceFlow = None
tuple RunModel.surfaceFlowRel = paths.relpath(surfaceFlow)
tuple RunModel.tecfile = os.path.join(paths.RHESSYS_TEC, args.tecfile)
tuple RunModel.tecfileRel = paths.relpath(tecfile)
tuple RunModel.worldfile = os.path.join(paths.RHESSYS_WORLD, args.worldfile)
tuple RunModel.worldfileRel = paths.relpath(worldfile)