From c9830d6fc58cf0657f99bb4f4aded06c448c4c88 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01> Date: Fri, 11 Jun 2010 20:24:09 +0000 Subject: [PATCH] added correction to save the path to the doc page so it can be used when generating the variable report; also fixed bug with float values being overridden when data types were changed git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@120 8a9318a1-56ba-4d59-b755-99d26321be01 --- pyglance/glance/compare.py | 1 + pyglance/glance/data.py | 41 +++++++++++++++++++----------- pyglance/glance/stats.py | 17 +++++++++---- pyglance/glance/variablereport.txt | 2 +- 4 files changed, 40 insertions(+), 21 deletions(-) diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py index 04c93cc..2b1e5c8 100644 --- a/pyglance/glance/compare.py +++ b/pyglance/glance/compare.py @@ -1181,6 +1181,7 @@ def reportGen_library_call (a_path, b_path, var_list=[ ], LOG.debug("Variable directory (" + variableDir + ") does not exist.") LOG.debug("Creating variable directory.") os.makedirs(variableDir) + varRunInfo['doc_path'] = quote(os.path.join(pathsTemp['out'], './' + 'doc.html')) # should this be somewhere else? # figure out the masks we want, and then do our statistical analysis mask_a_to_use = None diff --git a/pyglance/glance/data.py b/pyglance/glance/data.py index 5d4c253..0a5d36b 100644 --- a/pyglance/glance/data.py +++ b/pyglance/glance/data.py @@ -181,8 +181,10 @@ class DiffInfoObject (object) : # figure out the shared type type_to_return = data1.dtype + changed_type = False if data1.dtype is not data2.dtype: type_to_return = np.common_type(data1, data2) + changed_type = True # upcast the type if we need to if type_to_return in DiffInfoObject.DATATYPE_UPCASTS : @@ -193,21 +195,30 @@ class DiffInfoObject (object) : # figure out the fill value fill_value_to_return = None - # if we're looking at float or complex data, use a nan - if (np.issubdtype(type_to_return, np.float) or - np.issubdtype(type_to_return, np.complex)) : - fill_value_to_return = np.nan - - # if we're looking at int data, use the minimum value - elif np.issubdtype(type_to_return, np.int) : - fill_value_to_return = np.iinfo(type_to_return).min - - # if we're looking at unsigned data, use the maximum value - elif ((type_to_return is np.uint8) or - (type_to_return is np.uint16) or - (type_to_return is np.uint32) or - (type_to_return is np.uint64)) : - fill_value_to_return = np.iinfo(type_to_return).max + # if both of the old fill values exist and are the same, use them + if (fill1 is not None) and (fill1 == fill2) : + + fill_value_to_return = fill1 + if changed_type : + fill_value_to_return = type_to_return(fill_value_to_return) + + else: + + # if we're looking at float or complex data, use a nan + if (np.issubdtype(type_to_return, np.float) or + np.issubdtype(type_to_return, np.complex)) : + fill_value_to_return = np.nan + + # if we're looking at int data, use the minimum value + elif np.issubdtype(type_to_return, np.int) : + fill_value_to_return = np.iinfo(type_to_return).min + + # if we're looking at unsigned data, use the maximum value + elif ((type_to_return is np.uint8) or + (type_to_return is np.uint16) or + (type_to_return is np.uint32) or + (type_to_return is np.uint64)) : + fill_value_to_return = np.iinfo(type_to_return).max return type_to_return, fill_value_to_return diff --git a/pyglance/glance/stats.py b/pyglance/glance/stats.py index e748740..d75921a 100644 --- a/pyglance/glance/stats.py +++ b/pyglance/glance/stats.py @@ -496,11 +496,18 @@ class NumericalComparisonStatistics (StatisticalData) : if (include_basic_analysis) : basic_dict = NumericalComparisonStatistics.basic_analysis(diffInfoObject.diff_data_object.data, valid_in_both) - self.rms_diff = basic_dict['rms_diff'] - self.std_diff = basic_dict['std_diff'] - self.mean_diff = basic_dict['mean_diff'] - self.median_diff = basic_dict['median_diff'] - self.max_diff = basic_dict['max_diff'] + if len(basic_dict) > 0 : + self.rms_diff = basic_dict['rms_diff'] + self.std_diff = basic_dict['std_diff'] + self.mean_diff = basic_dict['mean_diff'] + self.median_diff = basic_dict['median_diff'] + self.max_diff = basic_dict['max_diff'] + else : + self.rms_diff = np.nan + self.std_diff = np.nan + self.mean_diff = np.nan + self.median_diff = np.nan + self.max_diff = np.nan self.temp_analysis = basic_dict def dictionary_form(self) : diff --git a/pyglance/glance/variablereport.txt b/pyglance/glance/variablereport.txt index f244599..abcdc0d 100644 --- a/pyglance/glance/variablereport.txt +++ b/pyglance/glance/variablereport.txt @@ -190,7 +190,7 @@ Copyright (c) 2009 University of Wisconsin SSEC. All rights reserved. </dt> <dd> % for statName, statValue in sorted(list(dataSet.items())) : - ${statName}<a href="../doc.html">*</a>: ${report.make_formatted_display_string(statValue)} <br> + ${statName}<a href="${runInfo['doc_path']}">*</a>: ${report.make_formatted_display_string(statValue)} <br> % endfor <br> <dd> -- GitLab