From 136d4b0c307e7d7a5bb44293622651e481273e5a Mon Sep 17 00:00:00 2001
From: "(no author)" <(no author)@8a9318a1-56ba-4d59-b755-99d26321be01>
Date: Fri, 9 Jul 2010 19:22:01 +0000
Subject: [PATCH] added ability to test total error (sum of error for epsilon
 and finiteness mismatch) and corrected imshow method to keep original images
 in the same range when directed)

git-svn-id: https://svn.ssec.wisc.edu/repos/glance/trunk@124 8a9318a1-56ba-4d59-b755-99d26321be01
---
 pyglance/glance/compare.py       | 24 ------------------------
 pyglance/glance/figures.py       |  6 +++++-
 pyglance/glance/plotcreatefns.py | 12 ++++++++----
 3 files changed, 13 insertions(+), 29 deletions(-)

diff --git a/pyglance/glance/compare.py b/pyglance/glance/compare.py
index 7263c7d..8b92fbe 100644
--- a/pyglance/glance/compare.py
+++ b/pyglance/glance/compare.py
@@ -1517,30 +1517,6 @@ python -m glance
             except KeyError :
                 LOG.warn('Unable to open / process file selection: ' + fn)
     
-    # TODO, remove this method?
-    def sdr_cris(*args):
-        """compare sdr_cris output
-        parameters are variable name followed by detector number
-        sdr_cris desired.h5 actual.h5 ESRealLW 0
-        """ # TODO ******* standardize with method?
-        afn,bfn = args[:2]
-        LOG.info("opening %s" % afn)
-        a = io.open(afn)
-        LOG.info("opening %s" % bfn)
-        b = io.open(bfn)
-        
-        # shape is [scanline, field, detector, wnum]
-        vname = '/All_Data/CrIS-SDR_All/' + args[2]
-        det_idx = int(args[3])
-        def get(f):
-            spc = f[vname][:,:,det_idx,:]
-            nsl,nfor,nwn = spc.shape
-            return spc.reshape( (nsl*nfor,nwn) )
-        aspc = get(a)
-        bspc = get(b)
-        plot.compare_spectra(bspc,aspc)
-        plot.show()
-    
     def stats(*args):
         """create statistics summary of variables
         Summarize difference statistics between listed variables.
diff --git a/pyglance/glance/figures.py b/pyglance/glance/figures.py
index 537d9f2..ef5035d 100644
--- a/pyglance/glance/figures.py
+++ b/pyglance/glance/figures.py
@@ -407,7 +407,7 @@ def create_quiver_mapped_figure(data, latitude, longitude, baseMapInstance, boun
     
     return figure
 
-def create_simple_figure(data, figureTitle, invalidMask=None, tagData=None, colorMap=None) :
+def create_simple_figure(data, figureTitle, invalidMask=None, tagData=None, colorMap=None, colorbarLimits=None) :
     """
     create a simple figure showing the data given masked by the invalid mask
     any tagData passed in will be interpreted as trouble points on the image and plotted as a
@@ -432,6 +432,10 @@ def create_simple_figure(data, figureTitle, invalidMask=None, tagData=None, colo
     if (data is not None) and (sum(invalidMask) < invalidMask.size) :
         # draw our data
         im = imshow(cleanData, **kwargs)
+        
+        # if our colorbar has limits set those
+        if colorbarLimits is not None :
+            clim(vmin=colorbarLimits[0], vmax=colorbarLimits[-1])
         # make a color bar
         cbar = colorbar(format='%.3g')
     
diff --git a/pyglance/glance/plotcreatefns.py b/pyglance/glance/plotcreatefns.py
index bc8b238..b5505ff 100644
--- a/pyglance/glance/plotcreatefns.py
+++ b/pyglance/glance/plotcreatefns.py
@@ -109,8 +109,8 @@ def _make_shared_range(aData, goodInAMask, bData, goodInBMask, shouldUseSharedRa
     # figure out the shared range for A and B's data, by default don't share a range
     sharedRange = None
     if (shouldUseSharedRangeForOriginal) :
-        sharedRange = figures._make_range(aData, ~goodInAMask, 50, offset_to_range=figures.offsetToRange,
-                                   data_b=bData, invalid_b_mask=~goodInBMask)
+        sharedRange = figures._make_range(aData, goodInAMask, 50, offset_to_range=figures.offsetToRange,
+                                   data_b=bData, valid_b_mask=goodInBMask)
     
     return sharedRange
 
@@ -942,6 +942,10 @@ class IMShowPlotFunctionFactory (PlottingFunctionFactory) :
         
         functionsToReturn = { }
         
+        sharedRange = _make_shared_range(aData, goodInAMask,
+                                         bData, goodInBMask,
+                                         shouldUseSharedRangeForOriginal)
+        
         # make the original data plots
         if ('do_plot_originals' not in doPlotSettingsDict) or (doPlotSettingsDict['do_plot_originals']) :
             
@@ -949,7 +953,7 @@ class IMShowPlotFunctionFactory (PlottingFunctionFactory) :
             assert(aData.shape == goodInAMask.shape)
             
             functionsToReturn['originalA'] = ((lambda: figures.create_simple_figure(aData, variableDisplayName + "\nin File A",
-                                                                            invalidMask=~goodInAMask)),
+                                                                            invalidMask=~goodInAMask, colorbarLimits=sharedRange)),
                                               variableDisplayName + " in file a",
                                               "A.png",  original_fig_list)
             
@@ -957,7 +961,7 @@ class IMShowPlotFunctionFactory (PlottingFunctionFactory) :
             assert(bData.shape == goodInBMask.shape)
             
             functionsToReturn['originalB'] = ((lambda: figures.create_simple_figure(bData, variableDisplayName + "\nin File B",
-                                                                            invalidMask=~goodInBMask)),
+                                                                            invalidMask=~goodInBMask, colorbarLimits=sharedRange)),
                                               variableDisplayName + " in file b",
                                               "B.png",  original_fig_list)
         
-- 
GitLab