diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py index ae8efbd162820ce861fcbde31a5a44ff4d4ed45c..cb8d240f02153a02ea66b198d919857190e2cb33 100644 --- a/pyglance/glance/compare.py +++ b/pyglance/glance/compare.py @@ -179,7 +179,7 @@ def _resolve_names(fileAObject, fileBObject, defaultValues, if ('alternate_name_in_B' in currNameInfo) : name_b = currNameInfo['alternate_name_in_B'] - if (name in fileCommonNames) | \ + if (name in fileCommonNames) or \ (currNameInfo.has_key('alternate_name_in_B') and (name in nameComparison['uniqueToAVars']) and (name_b in nameComparison['uniqueToBVars'])) : diff --git a/pyglance/glance/io.py b/pyglance/glance/io.py index 9e5309641c17f8f5d1f635b67599f0b1948b386b..b9319ee266b264b2ee19c31421d19b8e96e66502 100644 --- a/pyglance/glance/io.py +++ b/pyglance/glance/io.py @@ -80,9 +80,13 @@ class hdf(SD): LOG.warn ('Scaling method of \"' + str(scaling_method) + '\" will be ignored in favor of hdf standard method. ' + 'This may cause problems with data consistency') + # get information about where the data is the missing value + missing_val = self.missing_value(name) + missing_mask = (raw_data_copy == missing_value) + # create the scaled version of the data scaled_data_copy = np.array(raw_data_copy, dtype=data_type) - scaled_data_copy = (scaled_data_copy - add_offset) * scale_factor #TODO, type truncation issues? + scaled_data_copy[~missing_mask] = (scaled_data_copy[~missing_mask] - add_offset) * scale_factor #TODO, type truncation issues? return scaled_data_copy @@ -140,9 +144,13 @@ class nc(CDF): if (scale_factor == 1.0) and (add_offset == 0.0) : return raw_data_copy + # get information about where the data is the missing value + missing_val = self.missing_value(name) + missing_mask = (raw_data_copy == missing_value) + # create the scaled version of the data scaled_data_copy = np.array(raw_data_copy, dtype=data_type) - scaled_data_copy = (scaled_data_copy - add_offset) * scale_factor #TODO, type truncation issues? + scaled_data_copy[~missing_mask] = (scaled_data_copy[~missing_mask] - add_offset) * scale_factor #TODO, type truncation issues? return scaled_data_copy @@ -212,9 +220,13 @@ class h5(object): if (scale_factor == 1.0) and (add_offset == 0.0) : return raw_data_copy + # get information about where the data is the missing value + missing_val = self.missing_value(name) + missing_mask = (raw_data_copy == missing_value) + # create the scaled version of the data scaled_data_copy = np.array(raw_data_copy, dtype=data_type) - scaled_data_copy = (scaled_data_copy - add_offset) * scale_factor #TODO, type truncation issues? + scaled_data_copy[~missing_mask] = (scaled_data_copy[~missing_mask] - add_offset) * scale_factor #TODO, type truncation issues? return scaled_data_copy diff --git a/pyglance/glance/plot.py b/pyglance/glance/plot.py index ae2ec2b0934baa0a8febe87e0f7b7b07b7fb950e..49f929c9bd67b4312923099ebe1f16544199d51f 100644 --- a/pyglance/glance/plot.py +++ b/pyglance/glance/plot.py @@ -18,6 +18,8 @@ from matplotlib import cm import matplotlib.colors as colors from matplotlib.ticker import FormatStrFormatter +from PIL import Image + import os, sys, logging import numpy as np @@ -439,8 +441,14 @@ def _handle_fig_creation_task(child_figure_function, log_message, LOG.info(log_message) figure.savefig(fullFigOutputNamePath, dpi=fullSizeDPI) if (shouldMakeSmall) : - figure.savefig(smallFigOutputNamePath, dpi=thumbSizeDPI) - + + tempImage = Image.open(fullFigOutputNamePath) + scaleFactor = float(thumbSizeDPI) / float(fullSizeDPI) + originalSize = tempImage.size + newSize = (int(originalSize[0] * scaleFactor), int(originalSize[1] * scaleFactor)) + tempImage = tempImage.resize(newSize, Image.ANTIALIAS) + tempImage.save(smallFigOutputNamePath) + # get rid of the figure plt.close(figure) del(figure)