Revision: 7577
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=7577&view=rev
Author:   jswhit
Date:     2009-08-26 17:01:34 +0000 (Wed, 26 Aug 2009)

Log Message:
-----------
nightime regions were calculated incorrectly when solar declination < 0
(NH winter).

Modified Paths:
--------------
    trunk/toolkits/basemap/lib/mpl_toolkits/basemap/solar.py

Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/solar.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/solar.py    2009-08-26 
15:32:59 UTC (rev 7576)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/solar.py    2009-08-26 
17:01:34 UTC (rev 7577)
@@ -48,19 +48,22 @@
     # compute day/night terminator from hour angle, declination.
     longitude = lons + tau
     lats = np.arctan(-np.cos(longitude*dg2rad)/np.tan(dec*dg2rad))/dg2rad
-    return lons, lats
+    return lons, lats, tau, dec
 
 def daynight_grid(date, delta, lonmin, lonmax):
     """
     date is datetime object (assumed UTC).
     delta is the grid interval (in degrees) used to compute terminator."""
-    lons, lats = daynight_terminator(date, delta, lonmin, lonmax)
+    lons, lats, tau, dec = daynight_terminator(date, delta, lonmin, lonmax)
     # create day/night grid (1 for night, 0 for day)
     lats2 = np.arange(-90,90+0.5*delta,delta,dtype=np.float32)
     nlons = len(lons); nlats = len(lats2)
     lons2, lats2 = np.meshgrid(lons,lats2)
     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)
+    if dec > 0: # NH summer
+        daynight = np.where(lats2>lats,0,daynight)
+    else: # NH winter
+        daynight = np.where(lats2<lats,0,daynight)
     daynight = ma.array(daynight,mask=1-daynight) # mask day areas.
     return lons2,lats2,daynight


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