RHESSysWorkflows  1.33
Namespaces | Functions | Variables
PatchZonalStats.py File Reference

Namespaces

 PatchZonalStats
 Tool for calculating zonal statistics for patch-scale RHESSys output variables.
 

Functions

def PatchZonalStats.line_legend
 Use proxy objects to force lines in legend display. More...
 
def PatchZonalStats.simple_axis
 
def PatchZonalStats.plot_cdf
 

Variables

list PatchZonalStats.LINE_TYPES = ['solid', 'dashed', 'dashdot', 'dotted']
 
tuple PatchZonalStats.NUM_LINE_TYPES = len(LINE_TYPES)
 
int PatchZonalStats.INT_RESCALE = 100
 
tuple PatchZonalStats.VARIABLE_EXPR_RE = re.compile(r'\b([a-zA-z][a-zA-Z0-9_\.]+)\b')
 
tuple PatchZonalStats.RANDOM = random.randint(100000, 999999)
 
string PatchZonalStats.RECLASS_MAP_TMP = "patchzonalstats_cover_{0}"
 
string PatchZonalStats.STATS_MAP_TMP = "patchzonalstats_output_{0}"
 
list PatchZonalStats.methods
 
tuple PatchZonalStats.parser = argparse.ArgumentParser(description='Generate cummulative map of patch-scale RHESSys output variables')
 
string PatchZonalStats.help = 'The configuration file.'
 
list PatchZonalStats.choices = ['ultralight','light','normal','regular','book','medium','roman','semibold','demibold','demi','bold','heavy','extra bold','black']
 
string PatchZonalStats.default = 'regular'
 
tuple PatchZonalStats.args = parser.parse_args()
 
 PatchZonalStats.configFile = None
 
tuple PatchZonalStats.context = Context(args.projectDir, configFile)
 
 PatchZonalStats.linestyles = None
 
 PatchZonalStats.outputFileNames = args.legend
 
tuple PatchZonalStats.metadata = RHESSysMetadata.readRHESSysEntries(context)
 
list PatchZonalStats.patchFilepaths = []
 
tuple PatchZonalStats.outputDir = os.path.abspath(args.outputDir)
 
string PatchZonalStats.outputFile = "{0}.pdf"
 
tuple PatchZonalStats.outputFilePath = os.path.join(outputDir, outputFile)
 
 PatchZonalStats.variableLabels = args.variableName
 
list PatchZonalStats.variables = ['patchID']
 
tuple PatchZonalStats.m = VARIABLE_EXPR_RE.findall(args.outputVariable)
 
tuple PatchZonalStats.tmpDir = tempfile.mkdtemp()
 
tuple PatchZonalStats.reclassRule = os.path.join(tmpDir, 'reclass.rule')
 
tuple PatchZonalStats.grassDbase = os.path.join(context.projectDir, metadata['grass_dbase'])
 
tuple PatchZonalStats.grassConfig = GRASSConfig(context, grassDbase, metadata['grass_location'], metadata['grass_mapset'])
 
tuple PatchZonalStats.grassLib = GRASSLib(grassConfig=grassConfig)
 
tuple PatchZonalStats.result
 
list PatchZonalStats.variablesList = []
 
tuple PatchZonalStats.data = np.genfromtxt(patchFilepath, names=True)
 
list PatchZonalStats.patchIDs = [ int(p) for p in data['patchID'] ]
 
tuple PatchZonalStats.expr = VARIABLE_EXPR_RE.sub(r'data["\1"]', args.outputVariable)
 
tuple PatchZonalStats.var = eval(expr)
 
 PatchZonalStats.zones = args.zones
 
tuple PatchZonalStats.maps_to_delete = set()
 
string PatchZonalStats.reclass_map = "{0}_{1}"
 
 PatchZonalStats.variable_scaled = variable*INT_RESCALE
 
tuple PatchZonalStats.variable_int = variable_scaled.astype(int)
 
tuple PatchZonalStats.reclass = open(reclassRule, 'w')
 
string PatchZonalStats.permrast = "{0}_{1}_{2}"
 
string PatchZonalStats.rMapcalcExpr = '$permrast=@$tmprast/float($scale)'
 
 PatchZonalStats.scale = True)
 
tuple PatchZonalStats.pipe = grassLib.script.pipe_command('r.stats', flags='ln', input=STATS_MAP_TMP)
 
list PatchZonalStats.stats_scaled = []
 
tuple PatchZonalStats.stats = np.array(stats_scaled)
 
list PatchZonalStats.tmp_data = data[zone]
 
int PatchZonalStats.min_x = 0
 
tuple PatchZonalStats.max_x = max(np.max(datum), max_x)
 
int PatchZonalStats.fig_width = 4
 
tuple PatchZonalStats.fig = plt.figure(figsize=(fig_width, 3), dpi=80, tight_layout=True)
 
tuple PatchZonalStats.num_zones = len(zones)
 
list PatchZonalStats.var_label = variableLabels[i]
 
int PatchZonalStats.fig_num = i+1
 
tuple PatchZonalStats.ax = fig.add_subplot(1, num_zones, fig_num)
 
 PatchZonalStats.linetype = linestyles,
 
 PatchZonalStats.linewidth = args.linewidth,
 
 PatchZonalStats.legend_fontsize = args.legendfontsize,
 
 PatchZonalStats.fontweight = args.fontweight,
 
 PatchZonalStats.axes_fontsize = args.axesfontsize,
 
 PatchZonalStats.ticklabel_fontsize = args.ticklabelfontsize,
 
tuple PatchZonalStats.range = (min_x, max_x)