RHESSysWorkflows  1.33
Variables
PatchToMap Namespace Reference

Tool for mapping patch-scale RHESSys yearly output variables. More...

Variables

int INT_RESCALE = 100
 
tuple VARIABLE_EXPR_RE = re.compile(r'\b([a-zA-z][a-zA-Z0-9_\.]+)\b')
 
tuple RANDOM = random.randint(100000, 999999)
 
string RECLASS_MAP_TMP = "patchzonalstats_cover_{0}"
 
string STATS_MAP_TMP = "patchzonalstats_output_{0}"
 
list methods
 
tuple parser = argparse.ArgumentParser(description='Generate cummulative map of patch-scale RHESSys output variables')
 
string help = 'The configuration file.'
 
tuple args = parser.parse_args()
 
 configFile = None
 
tuple context = Context(args.projectDir, configFile)
 
tuple metadata = RHESSysMetadata.readRHESSysEntries(context)
 
list patchFilepaths = []
 
list variables = ['patchID']
 
tuple m = VARIABLE_EXPR_RE.findall(args.outputVariable)
 
tuple tmpDir = tempfile.mkdtemp()
 
tuple reclassRule = os.path.join(tmpDir, 'reclass.rule')
 
tuple grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
 
tuple grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
 
tuple grassLib = GRASSLib(grassConfig=grassConfig)
 
tuple result
 
list variablesList = []
 
tuple data = np.genfromtxt(patchFilepath, names=True)
 
list patchIDs = [ int(p) for p in data['patchID'] ]
 
tuple expr = VARIABLE_EXPR_RE.sub(r'data["\1"]', args.outputVariable)
 
list reclass_map = args.mapNames[i]
 
tuple reclass = open(reclassRule, 'w')
 

Detailed Description

Tool for mapping patch-scale RHESSys yearly output variables.

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

Copyright (c) 2014, 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. Configuration file must define the following sections and values: 'GRASS', 'GISBASE'
  2. The following metadata entry(ies) must be present in the RHESSys section of the metadata associated with the project directory: grass_dbase grass_location grass_mapset

Post conditions

None

Variable Documentation

tuple PatchToMap.args = parser.parse_args()
PatchToMap.configFile = None
tuple PatchToMap.context = Context(args.projectDir, configFile)
list PatchToMap.data = np.genfromtxt(patchFilepath, names=True)
tuple PatchToMap.expr = VARIABLE_EXPR_RE.sub(r'data["\1"]', args.outputVariable)
tuple PatchToMap.grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
tuple PatchToMap.grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
tuple PatchToMap.grassLib = GRASSLib(grassConfig=grassConfig)
string PatchToMap.help = 'The configuration file.'
int PatchToMap.INT_RESCALE = 100
tuple PatchToMap.m = VARIABLE_EXPR_RE.findall(args.outputVariable)
tuple PatchToMap.metadata = RHESSysMetadata.readRHESSysEntries(context)
list PatchToMap.methods
Initial value:
1 = ['average', 'mode', 'median', 'avedev', 'stddev', 'variance',
2  'skewness', 'kurtosis', 'min', 'max', 'sum']
tuple PatchToMap.parser = argparse.ArgumentParser(description='Generate cummulative map of patch-scale RHESSys output variables')
list PatchToMap.patchFilepaths = []
list PatchToMap.patchIDs = [ int(p) for p in data['patchID'] ]
tuple PatchToMap.RANDOM = random.randint(100000, 999999)
tuple PatchToMap.reclass = open(reclassRule, 'w')
list PatchToMap.reclass_map = args.mapNames[i]
string PatchToMap.RECLASS_MAP_TMP = "patchzonalstats_cover_{0}"
tuple PatchToMap.reclassRule = os.path.join(tmpDir, 'reclass.rule')
tuple PatchToMap.result
Initial value:
1 = grassLib.script.run_command('r.mask',
2  input=args.mask,
3  maskcats="1",
4  flags="o")
string PatchToMap.STATS_MAP_TMP = "patchzonalstats_output_{0}"
tuple PatchToMap.tmpDir = tempfile.mkdtemp()
tuple PatchToMap.VARIABLE_EXPR_RE = re.compile(r'\b([a-zA-z][a-zA-Z0-9_\.]+)\b')
list PatchToMap.variables = ['patchID']
list PatchToMap.variablesList = []