Revision: 6969
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6969&view=rev
Author:   jswhit
Date:     2009-03-08 13:29:00 +0000 (Sun, 08 Mar 2009)

Log Message:
-----------
streamline extrema function

Modified Paths:
--------------
    trunk/toolkits/basemap/examples/plothighsandlows.py

Modified: trunk/toolkits/basemap/examples/plothighsandlows.py
===================================================================
--- trunk/toolkits/basemap/examples/plothighsandlows.py 2009-03-08 13:18:34 UTC 
(rev 6968)
+++ trunk/toolkits/basemap/examples/plothighsandlows.py 2009-03-08 13:29:00 UTC 
(rev 6969)
@@ -9,15 +9,14 @@
 from scipy.ndimage.filters import minimum_filter, maximum_filter
 
 def extrema(mat,mode='wrap',window=10):
+    """find the indices of local extrema (min and max)
+    in the input array."""
     mn = minimum_filter(mat, size=window, mode=mode)
     mx = maximum_filter(mat, size=window, mode=mode)
     # (mat == mx) true if pixel is equal to the local max
-    # The next computation suppresses responses where
-    # the function is flat.
-    local_maxima = ((mat == mx) & (mat != mn)) 
-    local_minima = ((mat == mn) & (mat != mx)) 
-    # Get the indices of the maxima, minima
-    return np.nonzero(local_minima), np.nonzero(local_maxima)
+    # (mat == mn) true if pixel is equal to the local in
+    # Return the indices of the maxima, minima
+    return np.nonzero(mat == mn), np.nonzero(mat == mx)
 
 if len(sys.argv) < 2:
     print 'enter date to plot (YYYYMMDDHH) on command line'
@@ -65,8 +64,8 @@
 # plot lows as blue L's, with min pressure value underneath.
 xyplotted = []
 # don't plot if there is already a L or H within dmin meters.
-dmin = 500000
 yoffset = 0.022*(m.ymax-m.ymin)
+dmin = yoffset
 for x,y,p in zip(xlows, ylows, lowvals):
     if x < m.xmax and x > m.xmin and y < m.ymax and y > m.ymin:
         dist = [np.sqrt((x-x0)**2+(y-y0)**2) for x0,y0 in xyplotted]


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Matplotlib-checkins mailing list
Matplotlib-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to