RHESSysWorkflows  1.33
Variables
PatchToCumulativeMap Namespace Reference

Tool for making cummulative maps of patch-scale RHESSys output variables. More...

Variables

tuple PATCH_DAILY_RE = re.compile('^(.+_patch.daily)$')
 
tuple VARIABLE_EXPR_RE = re.compile(r'\b([a-zA-z][a-zA-Z0-9_\.]+)\b')
 
string RECLASS_MAP_TMP = "patchtomovietmp_%d"
 
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 patchDailyFilepaths = []
 
list outputFilePaths = []
 
tuple outputDir = os.path.abspath(args.outputDir)
 
string outputFile = "%s.png"
 
tuple cdfFilepath = os.path.join(outputDir, args.cdfOutputfile)
 
list variables = ['patchID']
 
tuple m = VARIABLE_EXPR_RE.findall(args.outputVariable)
 
 title = args.mapTitle
 
tuple tmpDir = tempfile.mkdtemp()
 
tuple reclassRule = os.path.join(tmpDir, 'reclass.rule')
 
tuple colorTable = os.path.join(tmpDir, 'color.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 f = open(patchDailyFilepath)
 
tuple data = RHESSysOutput.readColumnsFromPatchDailyFile(f, variables)
 
 patchIDs = None
 
 variable = None
 
list dataForDate = data[key]
 
tuple expr = VARIABLE_EXPR_RE.sub(r'np.array(dataForDate["\1"])', args.outputVariable)
 
int max_val = 0
 
 max_idx = None
 
 max_patchID = None
 
list normalizedVariables = []
 
list outputFilePath = outputFilePaths[i]
 
tuple reclass = open(reclassRule, 'w')
 
tuple fig = plt.figure(figsize=(8, 6), dpi=80, tight_layout=True)
 
tuple ax = fig.add_subplot(111)
 
float min_val = 0.01
 
tuple x = np.linspace(min_val, max_val, num=len(variablesList[0]))
 
list data_plt = []
 
tuple tmp_ecdf = sm.distributions.ECDF(var)
 
string cdfFilepath_png = "%s.png"
 
string cdfFilepath_pdf = "%s.pdf"
 

Detailed Description

Tool for making cummulative maps of patch-scale RHESSys 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

Todo:
Add ability to read in two files, accumulate data, and write normalized map (value / max(value))

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

Todo:
Add ability to read in two files, accumulate data, and write normalized map (value / max(value))

Variable Documentation

tuple PatchToCumulativeMap.args = parser.parse_args()
tuple PatchToCumulativeMap.ax = fig.add_subplot(111)
tuple PatchToCumulativeMap.cdfFilepath = os.path.join(outputDir, args.cdfOutputfile)
string PatchToCumulativeMap.cdfFilepath_pdf = "%s.pdf"
string PatchToCumulativeMap.cdfFilepath_png = "%s.png"
tuple PatchToCumulativeMap.colorTable = os.path.join(tmpDir, 'color.rule')
PatchToCumulativeMap.configFile = None
tuple PatchToCumulativeMap.context = Context(args.projectDir, configFile)
tuple PatchToCumulativeMap.data = RHESSysOutput.readColumnsFromPatchDailyFile(f, variables)
list PatchToCumulativeMap.data_plt = []
list PatchToCumulativeMap.dataForDate = data[key]
tuple PatchToCumulativeMap.expr = VARIABLE_EXPR_RE.sub(r'np.array(dataForDate["\1"])', args.outputVariable)
tuple PatchToCumulativeMap.f = open(patchDailyFilepath)
tuple PatchToCumulativeMap.fig = plt.figure(figsize=(8, 6), dpi=80, tight_layout=True)
tuple PatchToCumulativeMap.grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
tuple PatchToCumulativeMap.grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
tuple PatchToCumulativeMap.grassLib = GRASSLib(grassConfig=grassConfig)
string PatchToCumulativeMap.help = 'The configuration file.'
tuple PatchToCumulativeMap.m = VARIABLE_EXPR_RE.findall(args.outputVariable)
tuple PatchToCumulativeMap.max_idx = None
list PatchToCumulativeMap.max_patchID = None
tuple PatchToCumulativeMap.max_val = 0
tuple PatchToCumulativeMap.metadata = RHESSysMetadata.readRHESSysEntries(context)
float PatchToCumulativeMap.min_val = 0.01
list PatchToCumulativeMap.normalizedVariables = []
tuple PatchToCumulativeMap.outputDir = os.path.abspath(args.outputDir)
string PatchToCumulativeMap.outputFile = "%s.png"
list PatchToCumulativeMap.outputFilePath = outputFilePaths[i]
list PatchToCumulativeMap.outputFilePaths = []
tuple PatchToCumulativeMap.parser = argparse.ArgumentParser(description='Generate cummulative map of patch-scale RHESSys output variables')
tuple PatchToCumulativeMap.PATCH_DAILY_RE = re.compile('^(.+_patch.daily)$')
list PatchToCumulativeMap.patchDailyFilepaths = []
list PatchToCumulativeMap.patchIDs = None
tuple PatchToCumulativeMap.reclass = open(reclassRule, 'w')
string PatchToCumulativeMap.RECLASS_MAP_TMP = "patchtomovietmp_%d"
tuple PatchToCumulativeMap.reclassRule = os.path.join(tmpDir, 'reclass.rule')
tuple PatchToCumulativeMap.result
Initial value:
1 = grassLib.script.run_command('r.mask',
2  input=args.mask,
3  maskcats="1",
4  flags="o")
PatchToCumulativeMap.title = args.mapTitle
tuple PatchToCumulativeMap.tmp_ecdf = sm.distributions.ECDF(var)
tuple PatchToCumulativeMap.tmpDir = tempfile.mkdtemp()
tuple PatchToCumulativeMap.variable = None
tuple PatchToCumulativeMap.VARIABLE_EXPR_RE = re.compile(r'\b([a-zA-z][a-zA-Z0-9_\.]+)\b')
list PatchToCumulativeMap.variables = ['patchID']
list PatchToCumulativeMap.variablesList = []
tuple PatchToCumulativeMap.x = np.linspace(min_val, max_val, num=len(variablesList[0]))