From 9579c4fd2ff149e0e747a99dbff64861bf2d44ab Mon Sep 17 00:00:00 2001 From: Eva Schiffer <evas@ssec.wisc.edu> Date: Tue, 7 Jul 2015 14:12:35 -0500 Subject: [PATCH] fixing an bug with how errors propagate from problems in image creation --- pyglance/glance/figures.py | 4 ++-- pyglance/glance/io.py | 9 +++++---- pyglance/glance/plot.py | 12 ++++++++---- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/pyglance/glance/figures.py b/pyglance/glance/figures.py index 835fc63..865738c 100644 --- a/pyglance/glance/figures.py +++ b/pyglance/glance/figures.py @@ -78,8 +78,8 @@ def _make_range(data_a, valid_a_mask, num_intervals, offset_to_range=0.0, data_b minVal = min(delta.min_with_mask(data_b, valid_b_mask), minVal) maxVal = max(delta.max_with_mask(data_b, valid_b_mask), maxVal) - minVal = minVal - offset_to_range - maxVal = maxVal + offset_to_range + minVal -= offset_to_range + maxVal += offset_to_range return np.linspace(minVal, maxVal, num_intervals) diff --git a/pyglance/glance/io.py b/pyglance/glance/io.py index 0d580f1..0652a86 100644 --- a/pyglance/glance/io.py +++ b/pyglance/glance/io.py @@ -420,11 +420,9 @@ class nc (object): # get our raw data and scaling info variable_object = self.get_variable_object(name) - #print ("*** opened variable: " + name) - + """ # This scaling code is no longer required because the library automatically handles scaling raw_data_copy = variable_object[:] # load the scale factor and add offset - temp = self.attributeCache.get_variable_attributes(name) if SCALE_FACTOR_STR in temp.keys() : scale_factor = temp[SCALE_FACTOR_STR] @@ -443,8 +441,11 @@ class nc (object): # create the scaled version of the data scaled_data_copy = np.array(raw_data_copy, dtype=data_type) scaled_data_copy[~missing_mask] = (scaled_data_copy[~missing_mask] * scale_factor) + add_offset #TODO, type truncation issues? + """ - return scaled_data_copy + scaled_data_copy = np.array(variable_object[:], dtype=data_type) + + return scaled_data_copy # TODO, this hasn't been supported in other file types def close (self) : diff --git a/pyglance/glance/plot.py b/pyglance/glance/plot.py index d65f9de..71d7fb5 100644 --- a/pyglance/glance/plot.py +++ b/pyglance/glance/plot.py @@ -329,10 +329,14 @@ def plot_and_save_comparison_figures (aData, bData, # only plot the compared images if we aren't short circuiting them if (outputInfoList is not compared_images) or (not shortCircuitComparisons) : - _log_spawn_and_wait_if_needed(figLongDesc, childPids, figFunction, outputPath, figFileName, - makeSmall, doFork, shouldClearMemoryWithThreads, fullDPI=fullDPI, thumbDPI=thumbDPI) - # if we made an attempt to make the file, hang onto the name - outputInfoList.append(figFileName) + try : + _log_spawn_and_wait_if_needed(figLongDesc, childPids, figFunction, outputPath, figFileName, + makeSmall, doFork, shouldClearMemoryWithThreads, fullDPI=fullDPI, thumbDPI=thumbDPI) + # if we made an attempt to make the file, hang onto the name + outputInfoList.append(figFileName) + except ValueError, ve : + LOG.warn("Unable to create " + figDesc + " figure for " + variableDisplayName + ": " + str(ve)) + # now we need to wait for all of our child processes to terminate before returning if (isParent) : # just in case -- GitLab