Skip to content
Snippets Groups Projects
Commit 0d64fe34 authored by Alan De Smet's avatar Alan De Smet
Browse files

Group pairs of statistics on one file (A vs B)

parent 88fbe338
No related branches found
No related tags found
1 merge request!9Improved report formatting#18
......@@ -16,6 +16,7 @@ Copyright (c) 2011 University of Wisconsin SSEC. All rights reserved.
<head>
<title>${self.title()}</title>
<style>
th.l { text-align: left; }
td.n,th.n { text-align: right; }
body { font-family: sans-serif; }
h4 { margin-bottom: 0; }
......
......@@ -228,6 +228,7 @@ OPTIONS_LONLAT_EPSILON_KEY = 'lonlatepsilon'
RUN_INFO_DICT_KEY = 'runInfo'
FILES_INFO_DICT_KEY = 'files'
STATS_INFO_DICT_KEY = 'statGroups'
GROUPED_STATS_INFO_DICT_KEY = 'groupedStats'
SPATIAL_INFO_DICT_KEY = 'spatial'
IMAGE_NAME_INFO_DICT_KEY = 'imageNames'
VARIABLE_NAMES_DICT_KEY = 'varNames'
......
......@@ -207,6 +207,51 @@ def generate_and_save_doc_page(definitions, outputPath) :
return
def group_stats_by_file(statGroups):
""" Group statistics by file
Where there are pairs of statistics in the form *_[ab] or [ab]_*, group
them together. So given
{ 'General Statistics': {
'min_a': -1,
'min_b': -10
'epsilon': 3
}
}
returns
{ 'General Statistics': {
'min': { 'a': -1. b: -10 },
'epsilon': { 'both':3 }
}
}
"""
def id_file(varname):
if varname[1] == "_":
return (varname[2:], varname[0])
if varname[-2] == "_":
return (varname[:-2], varname[-1])
return (varname, "both")
ret = {}
for groupname, group in statGroups.items():
ret[groupname] = {}
for var, val in group.items():
justvar, file = id_file(var)
#sys.stderr.write("{0} -> {1} {2}\n".format(var, justvar, file))
if justvar not in ret[groupname]:
ret[groupname][justvar] = { 'a':'', 'b':'', 'both':''}
ret[groupname][justvar][file] = val
return ret
def generate_and_save_variable_report(files,
variableRunInfo, # contains variable specific run information
generalRunInfo, # contains run information not related to the variable
......@@ -313,12 +358,15 @@ def generate_and_save_variable_report(files,
# information about the run in general
runInfo = generalRunInfo.copy()
runInfo.update(variableRunInfo)
groupedStats = group_stats_by_file(statGroups)
# put all the info together in the kwargs
kwargs = {
RUN_INFO_DICT_KEY: runInfo,
FILES_INFO_DICT_KEY : files,
STATS_INFO_DICT_KEY: statGroups,
GROUPED_STATS_INFO_DICT_KEY: groupedStats,
SPATIAL_INFO_DICT_KEY: spatial,
IMAGE_NAME_INFO_DICT_KEY: imageNames,
ATTRS_INFO_DICT_KEY: variableAttrs,
......
......@@ -117,13 +117,15 @@ Copyright (c) 2011 University of Wisconsin SSEC. All rights reserved.
## list out all of the statistics groups we have
<table>
% for setName in sorted(list(statGroups)) :
<% dataSet = statGroups[setName] %>
<tr><td><h4 colspan="2">${setName}</h4></td></tr>
% for setName in sorted(list(groupedStats)) :
<% dataSet = groupedStats[setName] %>
<tr><th class="l">${setName}</th><th>Both</th><th>File A</th><th>File B</th></tr>
% for statName, statValue in sorted(list(dataSet.items())) :
<tr>
<td class="n">${statName}<%block name="statDocLink"><a href="${runInfo[constants.DOCUMENTATION_PATH_KEY]}">*</a>:</%block></td>
<td class="n">${report.make_formatted_display_string(statValue)}</td>
<td class="n">${report.make_formatted_display_string(statValue['both'])}</td>
<td class="n">${report.make_formatted_display_string(statValue['a'])}</td>
<td class="n">${report.make_formatted_display_string(statValue['b'])}</td>
</tr>
% endfor
% endfor
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment