From: <js...@us...> - 2009-08-24 20:31:24
|
Revision: 7556 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7556&view=rev Author: jswhit Date: 2009-08-24 20:31:17 +0000 (Mon, 24 Aug 2009) Log Message: ----------- add new daynight.py example. Modified Paths: -------------- trunk/toolkits/basemap/MANIFEST.in trunk/toolkits/basemap/examples/README trunk/toolkits/basemap/examples/daynight.py Modified: trunk/toolkits/basemap/MANIFEST.in =================================================================== --- trunk/toolkits/basemap/MANIFEST.in 2009-08-24 19:03:32 UTC (rev 7555) +++ trunk/toolkits/basemap/MANIFEST.in 2009-08-24 20:31:17 UTC (rev 7556) @@ -19,6 +19,7 @@ include examples/hires.py include examples/simpletest_oo.py include examples/randompoints.py +include examples/daynight.py include examples/test.py include examples/us_25m.dem include examples/testgdal.py Modified: trunk/toolkits/basemap/examples/README =================================================================== --- trunk/toolkits/basemap/examples/README 2009-08-24 19:03:32 UTC (rev 7555) +++ trunk/toolkits/basemap/examples/README 2009-08-24 20:31:17 UTC (rev 7556) @@ -131,3 +131,5 @@ plothighsandlows.py shows to plot H's and L's at the local extrema of a pressure map (requires scipy). + +daynight.py shows how to shade the regions of a map where the sun has set. Modified: trunk/toolkits/basemap/examples/daynight.py =================================================================== --- trunk/toolkits/basemap/examples/daynight.py 2009-08-24 19:03:32 UTC (rev 7555) +++ trunk/toolkits/basemap/examples/daynight.py 2009-08-24 20:31:17 UTC (rev 7556) @@ -3,6 +3,9 @@ import matplotlib.pyplot as plt from datetime import datetime +# example showing how to compute the day/night terminator and shade nightime +# areas on a map. + def epem(date): """ input: date - datetime object (assumed UTC) @@ -56,7 +59,7 @@ daynight[:,nlon] = np.where(lats2[:,nlon]>lats[nlon],0,daynight[:,nlon]) return lons2,lats2,daynight -# now, in UTC time. +# current time in UTC. d = datetime.utcnow() # miller projection @@ -66,6 +69,7 @@ map.drawparallels(np.arange(-90,90,30),labels=[1,0,0,0]) map.drawmeridians(np.arange(-180,180,60),labels=[0,0,0,1]) # create grid of day=0, night=1 +# 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. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |