SF.net SVN: matplotlib:[6967] trunk/toolkits/basemap/examples/ plothighsandlows.py
Revision: 6967 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6967&view=rev Author: jswhit Date: 2009-03-08 13:05:11 + (Sun, 08 Mar 2009) Log Message: --- cosmetic changes. Modified Paths: -- trunk/toolkits/basemap/examples/plothighsandlows.py Modified: trunk/toolkits/basemap/examples/plothighsandlows.py === --- trunk/toolkits/basemap/examples/plothighsandlows.py 2009-03-08 06:37:06 UTC (rev 6966) +++ trunk/toolkits/basemap/examples/plothighsandlows.py 2009-03-08 13:05:11 UTC (rev 6967) @@ -43,7 +43,8 @@ # (higher value, fewer highs and lows) local_min, local_max = extrema(prmsl, mode='wrap', window=25) # create Basemap instance. -m = Basemap(llcrnrlon=0,llcrnrlat=-65,urcrnrlon=360,urcrnrlat=65,projection='merc') +m =\ +Basemap(llcrnrlon=0,llcrnrlat=-80,urcrnrlon=360,urcrnrlat=80,projection='mill') # add wrap-around point in longitude. prmsl, lons = addcyclic(prmsl, lons1) # contour levels @@ -56,8 +57,8 @@ cs = m.contour(x,y,prmsl,clevs,colors='k',linewidths=1.) m.drawcoastlines(linewidth=1.25) m.fillcontinents(color='0.8') -m.drawparallels(np.arange(-80,81,20)) -m.drawmeridians(np.arange(0,360,60)) +m.drawparallels(np.arange(-80,81,20),labels=[1,1,0,0]) +m.drawmeridians(np.arange(0,360,60),labels=[0,0,0,1]) xlows = x[local_min]; xhighs = x[local_max] ylows = y[local_min]; yhighs = y[local_max] lowvals = prmsl[local_min]; highvals = prmsl[local_max] @@ -65,6 +66,7 @@ xyplotted = [] # don't plot if there is already a L or H within dmin meters. dmin = 50 +yoffset = 0.022*(m.ymax-m.ymin) 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] @@ -72,7 +74,7 @@ plt.text(x,y,'L',fontsize=14,fontweight='bold', horizontalalignment='center', verticalalignment='center',color='blue') -plt.text(x,y-40,repr(int(p)),fontsize=9, +plt.text(x,y-yoffset,repr(int(p)),fontsize=9, horizontalalignment='center', verticalalignment='top',color='blue') xyplotted.append((x,y)) @@ -85,7 +87,7 @@ plt.text(x,y,'H',fontsize=14,fontweight='bold', horizontalalignment='center', verticalalignment='center',color='red') -plt.text(x,y-40,repr(int(p)),fontsize=9, +plt.text(x,y-yoffset,repr(int(p)),fontsize=9, horizontalalignment='center', verticalalignment='top',color='red') xyplotted.append((x,y)) 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
SF.net SVN: matplotlib:[6968] trunk/toolkits/basemap/examples/ plothighsandlows.py
Revision: 6968 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6968&view=rev Author: jswhit Date: 2009-03-08 13:18:34 + (Sun, 08 Mar 2009) Log Message: --- make central pressures more readable by making text boxes semi-transparent 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:05:11 UTC (rev 6967) +++ trunk/toolkits/basemap/examples/plothighsandlows.py 2009-03-08 13:18:34 UTC (rev 6968) @@ -72,11 +72,10 @@ dist = [np.sqrt((x-x0)**2+(y-y0)**2) for x0,y0 in xyplotted] if not dist or min(dist) > dmin: plt.text(x,y,'L',fontsize=14,fontweight='bold', - horizontalalignment='center', - verticalalignment='center',color='blue') +ha='center',va='center',color='b') plt.text(x,y-yoffset,repr(int(p)),fontsize=9, - horizontalalignment='center', - verticalalignment='top',color='blue') +ha='center',va='top',color='b', +bbox = dict(boxstyle="square",ec='None',fc=(1,1,1,0.5))) xyplotted.append((x,y)) # plot highs as red H's, with max pressure value underneath. xyplotted = [] @@ -85,11 +84,10 @@ dist = [np.sqrt((x-x0)**2+(y-y0)**2) for x0,y0 in xyplotted] if not dist or min(dist) > dmin: plt.text(x,y,'H',fontsize=14,fontweight='bold', - horizontalalignment='center', - verticalalignment='center',color='red') +ha='center',va='center',color='r') plt.text(x,y-yoffset,repr(int(p)),fontsize=9, - horizontalalignment='center', - verticalalignment='top',color='red') +ha='center',va='top',color='r', +bbox = dict(boxstyle="square",ec='None',fc=(1,1,1,0.5))) xyplotted.append((x,y)) plt.title('Mean Sea-Level Pressure (with Highs and Lows) %s' % MMDDHH) plt.show() 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
SF.net SVN: matplotlib:[6969] trunk/toolkits/basemap/examples/ plothighsandlows.py
Revision: 6969 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6969&view=rev Author: jswhit Date: 2009-03-08 13:29:00 + (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 (MMDDHH) 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 = 50 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