Revision: 6843
          http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6843&view=rev
Author:   jswhit
Date:     2009-01-27 17:41:33 +0000 (Tue, 27 Jan 2009)

Log Message:
-----------
don't use fancy indexing in date2index (won't work for opendap datasets)

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

Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py       
2009-01-27 12:34:49 UTC (rev 6842)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py       
2009-01-27 17:41:33 UTC (rev 6843)
@@ -937,7 +937,9 @@
 
 def _check_index(indices, dates, nctime, calendar):
     """Assert that the time indices given correspond to the given dates."""
-    t = nctime[indices]
+    t = numpy.empty(len(indices), nctime.dtype)
+    for n,i in enumerate(indices):
+        t[n] = nctime[i]
     assert numpy.all( num2date(t, nctime.units, calendar) == dates)
 
 
@@ -974,25 +976,20 @@
         dt = t1 - t0
         index[:] = (num-t0)/dt
 
-        # convert numpy scalars or single element arrays to python ints.
-        index = _toscalar(index)
-
         # Checking that the index really corresponds to the given date.
         _check_index(index, dates, nctime, calendar)
 
     except AssertionError:
 
-        index = numpy.empty(numpy.alen(dates), int)
-
         # If check fails, use brute force method.
         index[:] = numpy.digitize(num, nctime[:]) - 1
 
-        # convert numpy scalars or single element arrays to python ints.
-        index = _toscalar(index)
-
         # Perform check again.
         _check_index(index, dates, nctime, calendar)
 
+    # convert numpy scalars or single element arrays to python ints.
+    index = _toscalar(index)
+
     return index
 
 


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

------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins

Reply via email to