Revision: 7559
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7559&view=rev
Author:   jswhit
Date:     2009-08-24 22:18:05 +0000 (Mon, 24 Aug 2009)

Log Message:
-----------
use masked array for daynight grid

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

Modified: trunk/toolkits/basemap/examples/daynight.py
===================================================================
--- trunk/toolkits/basemap/examples/daynight.py 2009-08-24 21:28:00 UTC (rev 
7558)
+++ trunk/toolkits/basemap/examples/daynight.py 2009-08-24 22:18:05 UTC (rev 
7559)
@@ -1,7 +1,8 @@
 import numpy as np
-from mpl_toolkits.basemap import Basemap, netcdftime
+from mpl_toolkits.basemap import Basemap, netcdftime, shiftgrid
 import matplotlib.pyplot as plt
 from datetime import datetime
+from numpy import ma
 
 # example showing how to compute the day/night terminator and shade nightime
 # areas on a map.
@@ -59,6 +60,7 @@
     lats = lats[np.newaxis,:]*np.ones((nlats,nlons),dtype=np.float32)
     daynight = np.ones(lons2.shape, np.int8)
     daynight = np.where(lats2>lats,0,daynight)
+    daynight = ma.array(daynight,mask=1-daynight) # mask day areas.
     return lons2,lats2,daynight
 
 # current time in UTC.
@@ -77,9 +79,8 @@
 # 1441 means use a 0.25 degree grid.
 lons,lats,daynight = daynightgrid(d,1441)
 x,y = map(lons, lats)
-# contour this grid with 1 contour level, specifying colors.
-# (gray for night, white for day). Use alpha transparency so
-# map shows through.
-CS=map.contourf(x,y,daynight,1,colors=['white','0.7'],alpha=0.5)
+# contour this grid with 1 contour level, specifying color for night areas.
+# Use alpha transparency so map shows through.
+CS=map.contourf(x,y,daynight,1,colors=['0.7'],alpha=0.5)
 plt.title('Day/Night Map for %s (UTC)' %d )
 plt.show()


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

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to