diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py index 590a84b648d707ce1e634fd35ebbf192d68c07f5..e3654a853c4341c4f13994a8ba53e77a626df0f1 100644 --- a/pyglance/glance/compare.py +++ b/pyglance/glance/compare.py @@ -138,7 +138,7 @@ def _resolve_names(fileAObject, fileBObject, defaultValues, if (usingConfigFileFormat) : # if the user didn't ask for any, try everything - if (requestedNames == {}) : + if (len(requestedNames) is 0) : finalFromCommandLine = _parse_varnames(fileCommonNames, ['.*'], defaultValues['epsilon'], defaultValues['missing_value']) for name, epsilon, missing in finalFromCommandLine : @@ -163,20 +163,26 @@ def _resolve_names(fileAObject, fileBObject, defaultValues, # check each of the names the user asked for to see if it is either in the list of common names # or, if the user asked for an alternate name mapping in file B, if the two mapped names are in # files A and B respectively - for name in requestedNames : + for name in requestedNames : # TODO rekey on display name? + + name_b = name + if ('alternate_name_in_B' in requestedNames[name]) : + name_b = requestedNames[name_b]['alternate_name_in_B'] + if (name in fileCommonNames) | \ (requestedNames[name].has_key('alternate_name_in_B') and - (name in nameComparison['uniqueToAVars']) and - (requestedNames[name]['alternate_name_in_B'] in nameComparison['uniqueToBVars'])) : + (name in nameComparison['uniqueToAVars']) and + (name_b in nameComparison['uniqueToBVars'])) : finalNames[name] = defaultValues.copy() finalNames[name]['variable_name'] = name finalNames[name].update(requestedNames[name]) # load the missing value if it was not provided if finalNames[name]['missing_value'] is None : - finalNames[name]['missing_value'] = fileAObject.missing_value(name) - if not('missing_value_alt_in_b' in finalNames[name]) or (finalNames[name]['missing_value_alt_in_b'] is None) : - finalNames[name]['missing_value_alt_in_b'] = fileBObject.missing_value(name) + finalNames[name]['missing_value'] = fileAObject.missing_value(name) + if not('missing_value_alt_in_b' in finalNames[name]) or \ + (finalNames[name]['missing_value_alt_in_b'] is None) : + finalNames[name]['missing_value_alt_in_b'] = fileBObject.missing_value(name_b) else: # format command line input similarly to the stuff from the config file print (requestedNames) @@ -795,7 +801,7 @@ python -m glance # if we wouldn't generate anything, just stop now if (not runInfo['shouldIncludeImages']) and (not runInfo['shouldIncludeReport']) : LOG.warn("User selection of no image generation and no report generation will result in no " + - "content being generated. Aborting report generation function.") + "content being generated. Aborting generation function.") return # get info on who's doing the run and where diff --git a/pyglance/glance/io.py b/pyglance/glance/io.py index 9fd2efc49aa19e9ddfb5dfa1034164d90756272a..9e5309641c17f8f5d1f635b67599f0b1948b386b 100644 --- a/pyglance/glance/io.py +++ b/pyglance/glance/io.py @@ -90,7 +90,15 @@ class hdf(SD): return self.select(name) def missing_value(self, name): - return getattr(self.select(name),'_FillValue',None) + missing_value_attr_name = '_FillValue' + variable_object = self.select(name) + + to_return = None + if hasattr(variable_object, missing_value_attr_name) : + to_return = getattr(variable_object, missing_value_attr_name, None) + SDS.endaccess(variable_object) + + return to_return class nc(CDF): @@ -142,7 +150,20 @@ class nc(CDF): return self.var(name) def missing_value(self, name): - return getattr(self.var(name),'_FillValue',getattr(self.var(name),'missing_value',None)) + + missing_value_attr_name_1 = '_FillValue' + missing_value_attr_name_2 = 'missing_value' + variable_object = self.var(name) + + to_return = None + if hasattr(variable_object, missing_value_attr_name_1) \ + or \ + hasattr(variable_object, missing_value_attr_name_2) : + to_return = getattr(variable_object, missing_value_attr_name_1, + getattr(variable_object, missing_value_attr_name_2, None)) + + return to_return + nc4 = nc cdf = nc diff --git a/pyglance/glance/plot.py b/pyglance/glance/plot.py index 14576fa0928c06504333df1cd85532ced4d6499c..74f4f444a0d281439a9d9d45acf9d1324a1e1d22 100644 --- a/pyglance/glance/plot.py +++ b/pyglance/glance/plot.py @@ -33,7 +33,7 @@ LOG = logging.getLogger(__name__) offsetToRange = 0.0000000000000000001 # the value that will denote "bad" longitudes and latitudes -badLonLat = 1.0E30 +badLonLat = maps.badLonLat # a constant for the larger size dpi fullSizeDPI = 150 # 200 @@ -401,6 +401,9 @@ def plot_and_save_spacial_trouble(longitude, latitude, spatialTroubleFig.savefig(outputPath + "/" + fileBaseName + "." + fileNameDiscriminator + ".small.png", dpi=thumbSizeDPI) + # clear the figure + spatialTroubleFig.clf() + return def _handle_fig_creation_task(child_figure_function, log_message, @@ -427,6 +430,7 @@ def _handle_fig_creation_task(child_figure_function, log_message, figure.savefig(fullFigOutputNamePath, dpi=fullSizeDPI) if (shouldMakeSmall) : figure.savefig(smallFigOutputNamePath, dpi=thumbSizeDPI) + figure.clf() # clear the figure # if we've reached this point and we did fork, # then we're the child process and we should stop now