You can subscribe to this list here.
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
| 2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
| 2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
| 2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
| 2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <js...@us...> - 2009-01-26 22:54:43
|
Revision: 6837
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6837&view=rev
Author: jswhit
Date: 2009-01-26 22:54:38 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
update date2index docstring.
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 22:49:01 UTC (rev 6836)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 22:54:38 UTC (rev 6837)
@@ -3973,6 +3973,9 @@
``proleptic_gregorian``, ``noleap``, ``365_day``,
``julian``, ``all_leap``, ``366_day``.
Default is ``proleptic_gregorian``.
+ If ``calendar=None``, will use ``calendar`` attribute
+ of ``nctime`` object, and if that attribute does
+ not exist calendar is set to ``standard``.
============== ====================================================
Returns an index or a sequence of indices.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-26 22:49:05
|
Revision: 6836
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6836&view=rev
Author: jswhit
Date: 2009-01-26 22:49:01 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
bugfixes for date2index
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-26 20:27:50 UTC (rev 6835)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py 2009-01-26 22:49:01 UTC (rev 6836)
@@ -7,7 +7,7 @@
_units = ['days','hours','minutes','seconds','day','hour','minute','second']
_calendars = ['standard','gregorian','proleptic_gregorian','noleap','julian','all_leap','365_day','366_day','360_day']
-__version__ = '0.7'
+__version__ = '0.7.1'
class datetime:
"""
@@ -975,22 +975,29 @@
index[:] = (num-t0)/dt
# convert numpy scalars or single element arrays to python ints.
- if not len(index.shape) or index.shape == (1,):
- index = index.item()
+ 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.
- if not len(index.shape) or index.shape == (1,):
- index = index.item()
+ index = _toscalar(index)
# Perform check again.
_check_index(index, dates, nctime, calendar)
return index
+
+def _toscalar(a):
+ if a.shape in [(),(1,)]:
+ return a.item()
+ else:
+ return a
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-26 20:27:54
|
Revision: 6835
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6835&view=rev
Author: jswhit
Date: 2009-01-26 20:27:50 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
make default calendar proleptic_gregorian for date2index
(to be consistent with num2date and date2num)
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 20:27:17 UTC (rev 6834)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 20:27:50 UTC (rev 6835)
@@ -3943,7 +3943,7 @@
cdftime = netcdftime.utime(units,calendar=calendar)
return cdftime.date2num(dates)
-def date2index(dates, nctime, calendar=None):
+def date2index(dates, nctime, calendar='proleptic_gregorian'):
"""
Return indices of a netCDF time variable corresponding to the given dates.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-26 20:27:22
|
Revision: 6834
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6834&view=rev
Author: jswhit
Date: 2009-01-26 20:27:17 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
specify calendar
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plotsst.py
trunk/toolkits/basemap/examples/pnganim.py
Modified: trunk/toolkits/basemap/examples/plotsst.py
===================================================================
--- trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 20:01:58 UTC (rev 6833)
+++ trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 20:27:17 UTC (rev 6834)
@@ -15,8 +15,8 @@
dataset = NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/totalAagg')
# find index of desired time.
time = dataset.variables['time']
-nt = date2index(date, time)
-print num2date(time[nt],time.units)
+nt = date2index(date, time, calendar='standard')
+print num2date(time[nt],time.units, calendar='standard')
# read sst. Will automatically create a masked array using
# missing_value variable attribute.
sst = dataset.variables['sst'][nt]
Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 20:01:58 UTC (rev 6833)
+++ trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 20:27:17 UTC (rev 6834)
@@ -9,15 +9,13 @@
import matplotlib.mlab as mlab
import numpy.ma as ma
import datetime, sys, time, subprocess
-from mpl_toolkits.basemap import Basemap, shiftgrid, NetCDFFile, num2date
+from mpl_toolkits.basemap import Basemap, shiftgrid, NetCDFFile, date2index, num2date
# times for March 1993 'storm of the century'
-YYYYMMDDHH1 = '1993031000'
-YYYYMMDDHH2 = '1993031700'
+date1 = datetime.datetime(1993,3,10,0)
+date2 = datetime.datetime(1993,3,17,0)
+print date1, date2
-YYYY = YYYYMMDDHH1[0:4]
-if YYYY != YYYYMMDDHH2[0:4]:
- raise ValueError,'dates must be in same year'
# set OpenDAP server URL.
URL="http://nomad1.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/pgb"
@@ -32,18 +30,10 @@
latitudes = data.variables['lat'][:]
longitudes = data.variables['lon'][:].tolist()
times = data.variables['time']
-# convert numeric time values to datetime objects.
-fdates = num2date(times[:],units=times.units,calendar='standard')
-# put times in YYYYMMDDHH format.
-dates = [fdate.strftime('%Y%m%d%H') for fdate in fdates]
-if YYYYMMDDHH1 not in dates or YYYYMMDDHH2 not in dates:
- raise ValueError, 'date1 or date2 not a valid date (must be in form YYYYMMDDHH, where HH is 00,06,12 or 18)'
-# find indices bounding desired times.
-ntime1 = dates.index(YYYYMMDDHH1)
-ntime2 = dates.index(YYYYMMDDHH2)
+ntime1 = date2index(date1,times,calendar='standard')
+ntime2 = date2index(date2,times,calendar='standard')
print 'ntime1,ntime2:',ntime1,ntime2
-if ntime1 >= ntime2:
- raise ValueError,'date2 must be greater than date1'
+print num2date(times[ntime1],times.units,calendar='standard'), num2date(times[ntime2],times.units,calendar='standard')
# get sea level pressure and 10-m wind data.
slpdata = data.variables['presmsl']
udata = data.variables['ugrdprs']
@@ -52,7 +42,7 @@
slpin = 0.01*slpdata[ntime1:ntime2+1,:,:]
uin = udata[ntime1:ntime2+1,0,:,:]
vin = vdata[ntime1:ntime2+1,0,:,:]
-datelabels = dates[ntime1:ntime2+1]
+dates = num2date(times[ntime1:ntime2+1], times.units, calendar='standard')
# add cyclic points
slp = np.zeros((slpin.shape[0],slpin.shape[1],slpin.shape[2]+1),np.float64)
slp[:,:,0:-1] = slpin; slp[:,:,-1] = slpin[:,:,0]
@@ -68,13 +58,12 @@
print uin.min(), uin.max()
print vin.min(), vin.max()
print 'dates'
-print datelabels
+print dates
# make orthographic basemaplt.
m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
plt.ion() # interactive mode on.
uin = udata[ntime1:ntime2+1,0,:,:]
vin = vdata[ntime1:ntime2+1,0,:,:]
-datelabels = dates[ntime1:ntime2+1]
# make orthographic basemaplt.
m = Basemap(resolution='c',projection='ortho',lat_0=60.,lon_0=-60.)
plt.ion() # interactive mode on.
@@ -94,7 +83,7 @@
l, b, w, h = pos.bounds
# loop over times, make contour plots, draw coastlines,
# parallels, meridians and title.
-for nt,date in enumerate(datelabels[1:]):
+for nt,date in enumerate(dates):
CS = m.contour(x,y,slp[nt,:,:],clevs,linewidths=0.5,colors='k',animated=True)
CS = m.contourf(x,y,slp[nt,:,:],clevs,cmap=plt.cm.RdBu_r,animated=True)
# plot wind vectors on lat/lon grid.
@@ -117,7 +106,7 @@
m.drawcoastlines(linewidth=1.5)
m.drawparallels(parallels)
m.drawmeridians(meridians)
- plt.title('SLP and Wind Vectors '+date)
+ plt.title('SLP and Wind Vectors '+str(date))
if nt == 0: # plot colorbar on a separate axes (only for first frame)
cax = plt.axes([l+w-0.05, b, 0.03, h]) # setup colorbar axes
fig.colorbar(CS,drawedges=True, cax=cax) # draw colorbar
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-26 20:02:03
|
Revision: 6833
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6833&view=rev
Author: jswhit
Date: 2009-01-26 20:01:58 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
fix URL in fcstmaps.py example, update Changelog.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/examples/pnganim.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2009-01-26 19:51:34 UTC (rev 6832)
+++ trunk/toolkits/basemap/Changelog 2009-01-26 20:01:58 UTC (rev 6833)
@@ -1,4 +1,5 @@
version 0.99.4 (not yet released)
+ * added date2index function.
* added 'maskoceans' function.
* update pupynere to version 1.0.8 (supports writing large files).
* added more informative error message in readshapefile when
Modified: trunk/toolkits/basemap/examples/pnganim.py
===================================================================
--- trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 19:51:34 UTC (rev 6832)
+++ trunk/toolkits/basemap/examples/pnganim.py 2009-01-26 20:01:58 UTC (rev 6833)
@@ -20,24 +20,15 @@
raise ValueError,'dates must be in same year'
# set OpenDAP server URL.
-URLbase="http://nomad3.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/"
-URL=URLbase+'pres'
-URLu=URLbase+'wind'
-URLv=URLbase+'wind'
+URL="http://nomad1.ncep.noaa.gov:9090/dods/reanalyses/reanalysis-2/6hr/pgb/pgb"
print URL
-print URLu
-print URLv
try:
data = NetCDFFile(URL)
- datau = NetCDFFile(URLu)
- datav = NetCDFFile(URLv)
except:
raise IOError, 'opendap server not providing the requested data'
# read lats,lons,times.
print data.variables.keys()
-print datau.variables.keys()
-print datav.variables.keys()
latitudes = data.variables['lat'][:]
longitudes = data.variables['lon'][:].tolist()
times = data.variables['time']
@@ -55,8 +46,8 @@
raise ValueError,'date2 must be greater than date1'
# get sea level pressure and 10-m wind data.
slpdata = data.variables['presmsl']
-udata = datau.variables['ugrdprs']
-vdata = datau.variables['vgrdprs']
+udata = data.variables['ugrdprs']
+vdata = data.variables['vgrdprs']
# mult slp by 0.01 to put in units of millibars.
slpin = 0.01*slpdata[ntime1:ntime2+1,:,:]
uin = udata[ntime1:ntime2+1,0,:,:]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-26 19:51:36
|
Revision: 6832
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6832&view=rev
Author: jswhit
Date: 2009-01-26 19:51:34 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
update URL
Modified Paths:
--------------
trunk/toolkits/basemap/examples/fcstmaps.py
Modified: trunk/toolkits/basemap/examples/fcstmaps.py
===================================================================
--- trunk/toolkits/basemap/examples/fcstmaps.py 2009-01-26 19:48:47 UTC (rev 6831)
+++ trunk/toolkits/basemap/examples/fcstmaps.py 2009-01-26 19:51:34 UTC (rev 6832)
@@ -15,7 +15,7 @@
YYYYMMDD = datetime.datetime.today().strftime('%Y%m%d')
# set OpenDAP server URL.
-URLbase="http://nomad3.ncep.noaa.gov:9090/dods/mrf/mrf"
+URLbase="http://nomad1.ncep.noaa.gov:9090/dods/mrf/mrf"
URL=URLbase+YYYYMMDD+'/mrf'+YYYYMMDD
print URL+'\n'
try:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-26 19:48:53
|
Revision: 6831
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6831&view=rev
Author: jswhit
Date: 2009-01-26 19:48:47 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
update URL, use new date2index function.
Modified Paths:
--------------
trunk/toolkits/basemap/examples/plotsst.py
Modified: trunk/toolkits/basemap/examples/plotsst.py
===================================================================
--- trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 19:48:04 UTC (rev 6830)
+++ trunk/toolkits/basemap/examples/plotsst.py 2009-01-26 19:48:47 UTC (rev 6831)
@@ -1,26 +1,30 @@
-from mpl_toolkits.basemap import Basemap, NetCDFFile
+from mpl_toolkits.basemap import Basemap, NetCDFFile, date2index, num2date
import numpy as np
import matplotlib.pyplot as plt
-import sys
+import sys, datetime
# read in sea-surface temperature and ice data
# can be a local file, a URL for a remote opendap dataset,
-# or (if PyNIO is installed) a GRIB or HDF file.
if len(sys.argv) == 1:
date = '20071215'
else:
date = sys.argv[1]
-if date[0:4] > '2005':
- ncfile = NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/'+date[0:4]+'/AVHRR/sst4-navy-eot.'+date+'.nc')
-else:
- ncfile = NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/'+date[0:4]+'/AVHRR/sst4-path-eot.'+date+'.nc')
+# convert datestring to datetime object.
+date = datetime.datetime(int(date[0:4]),int(date[4:6]),int(date[6:8]))
+print date
+# open dataset.
+dataset = NetCDFFile('http://nomads.ncdc.noaa.gov/thredds/dodsC/oisst/totalAagg')
+# find index of desired time.
+time = dataset.variables['time']
+nt = date2index(date, time)
+print num2date(time[nt],time.units)
# read sst. Will automatically create a masked array using
# missing_value variable attribute.
-sst = ncfile.variables['sst'][:]
+sst = dataset.variables['sst'][nt]
# read ice.
-ice = ncfile.variables['ice'][:]
+ice = dataset.variables['ice'][nt]
# read lats and lons (representing centers of grid boxes).
-lats = ncfile.variables['lat'][:]
-lons = ncfile.variables['lon'][:]
+lats = dataset.variables['lat'][:]
+lons = dataset.variables['lon'][:]
# shift lats, lons so values represent edges of grid boxes
# (as pcolor expects).
delon = lons[1]-lons[0]
@@ -34,7 +38,6 @@
# create Basemap instance for mollweide projection.
# coastlines not used, so resolution set to None to skip
# continent processing (this speeds things up a bit)
-#m = Basemap(projection='ortho',lon_0=-110,lat_0=20,resolution=None)
m = Basemap(projection='moll',lon_0=lons.mean(),lat_0=0,resolution=None)
# compute map projection coordinates of grid.
x, y = m(*np.meshgrid(lons, lats))
@@ -42,7 +45,7 @@
# color background of map projection region.
# missing values over land will show up this color.
m.drawmapboundary(fill_color='0.3')
-# plot ice, then with pcolor
+# plot sst, then ice with pcolor
im1 = m.pcolor(x,y,sst,shading='flat',cmap=plt.cm.jet)
im2 = m.pcolor(x,y,ice,shading='flat',cmap=plt.cm.gist_gray)
# draw parallels and meridians, but don't bother labelling them.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-26 19:48:09
|
Revision: 6830
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6830&view=rev
Author: jswhit
Date: 2009-01-26 19:48:04 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
update netcdftime to version 0.7, add date2index function.
Modified Paths:
--------------
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 16:39:14 UTC (rev 6829)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-26 19:48:04 UTC (rev 6830)
@@ -17,6 +17,8 @@
:func:`num2date`: convert from a numeric time value to a datetime object.
:func:`date2num`: convert from a datetime object to a numeric time value.
+
+:func:`date2index`: compute a time variable index corresponding to a date.
"""
from matplotlib import __version__ as _matplotlib_version
from matplotlib.cbook import is_scalar, dedent
@@ -3941,6 +3943,42 @@
cdftime = netcdftime.utime(units,calendar=calendar)
return cdftime.date2num(dates)
+def date2index(dates, nctime, calendar=None):
+ """
+ Return indices of a netCDF time variable corresponding to the given dates.
+
+ .. tabularcolumns:: |l|L|
+
+ ============== ====================================================
+ Arguments Description
+ ============== ====================================================
+ dates A datetime object or a sequence of datetime objects.
+ The datetime objects should not include a
+ time-zone offset.
+ nctime A netCDF time variable object. The nctime object
+ must have a ``units`` attribute.
+ ============== ====================================================
+
+ .. tabularcolumns:: |l|L|
+
+ ============== ====================================================
+ Keywords Description
+ ============== ====================================================
+ calendar describes the calendar used in the time
+ calculations. All the values currently defined in
+ the CF metadata convention
+ (http://cf-pcmdi.llnl.gov/documents/cf-conventions/)
+ are supported.
+ Valid calendars ``standard``, ``gregorian``,
+ ``proleptic_gregorian``, ``noleap``, ``365_day``,
+ ``julian``, ``all_leap``, ``366_day``.
+ Default is ``proleptic_gregorian``.
+ ============== ====================================================
+
+ Returns an index or a sequence of indices.
+ """
+ return netcdftime.date2index(dates, nctime, calendar=None)
+
def maskoceans(lonsin,latsin,datain,inlands=False):
"""
mask data (``datain``), defined on a grid with latitudes ``latsin``
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py 2009-01-26 16:39:14 UTC (rev 6829)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/netcdftime.py 2009-01-26 19:48:04 UTC (rev 6830)
@@ -1,14 +1,13 @@
"""
Performs conversions of netCDF time coordinate data to/from datetime objects.
"""
-import math, re, time
-import numpy as np
+import math, numpy, re, time
from datetime import datetime as real_datetime
_units = ['days','hours','minutes','seconds','day','hour','minute','second']
_calendars = ['standard','gregorian','proleptic_gregorian','noleap','julian','all_leap','365_day','366_day','360_day']
-__version__ = '0.6'
+__version__ = '0.7'
class datetime:
"""
@@ -467,8 +466,8 @@
The B{C{calendar}} keyword describes the calendar used in the time calculations.
All the values currently defined in the U{CF metadata convention
-<http://www.cgd.ucar.edu/cms/eaton/cf-metadata/CF-1.0.html#time>} are
-accepted. The default is C{'standard'}, which corresponds to the mixed
+<http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.1/cf-conventions.html#time-coordinate>}
+are accepted. The default is C{'standard'}, which corresponds to the mixed
Gregorian/Julian calendar used by the C{udunits library}. Valid calendars
are:
@@ -534,8 +533,7 @@
C{'standard'} or C{'gregorian'} calendars. An exception will be raised if you pass
a 'datetime-like' object in that range to the C{L{date2num}} class method.
-Words of Wisdom from the British MetOffice concerning reference dates
-U{http://www.metoffice.com/research/hadleycentre/models/GDT/ch26.html}:
+Words of Wisdom from the British MetOffice concerning reference dates:
"udunits implements the mixed Gregorian/Julian calendar system, as
followed in England, in which dates prior to 1582-10-15 are assumed to use
@@ -560,8 +558,8 @@
@keyword calendar: describes the calendar used in the time calculations.
All the values currently defined in the U{CF metadata convention
-<http://www.cgd.ucar.edu/cms/eaton/cf-metadata/CF-1.0.html#time>} are
-accepted. The default is C{'standard'}, which corresponds to the mixed
+<http://cf-pcmdi.llnl.gov/documents/cf-conventions/1.1/cf-conventions.html#time-coordinate>}
+are accepted. The default is C{'standard'}, which corresponds to the mixed
Gregorian/Julian calendar used by the C{udunits library}. Valid calendars
are:
- C{'gregorian'} or C{'standard'} (default):
@@ -630,7 +628,7 @@
except:
isscalar = True
if not isscalar:
- date = np.array(date)
+ date = numpy.array(date)
shape = date.shape
if self.calendar in ['julian','standard','gregorian','proleptic_gregorian']:
if isscalar:
@@ -657,7 +655,7 @@
else:
jdelta = [_360DayFromDate(d)-self._jd0 for d in date.flat]
if not isscalar:
- jdelta = np.array(jdelta)
+ jdelta = numpy.array(jdelta)
# convert to desired units, add time zone offset.
if self.units in ['second','seconds']:
jdelta = jdelta*86400. + self.tzoffset*60.
@@ -670,7 +668,7 @@
if isscalar:
return jdelta
else:
- return np.reshape(jdelta,shape)
+ return numpy.reshape(jdelta,shape)
def num2date(self,time_value):
"""
@@ -682,8 +680,8 @@
Resolution is 1 second.
-Works for scalars, sequences and np arrays.
-Returns a scalar if input is a scalar, else returns a np array.
+Works for scalars, sequences and numpy arrays.
+Returns a scalar if input is a scalar, else returns a numpy array.
The datetime instances returned by C{num2date} are 'real' python datetime
objects if the date falls in the Gregorian calendar (i.e.
@@ -700,7 +698,7 @@
except:
isscalar = True
if not isscalar:
- time_value = np.array(time_value)
+ time_value = numpy.array(time_value, dtype='d')
shape = time_value.shape
# convert to desired units, remove time zone offset.
if self.units in ['second','seconds']:
@@ -735,7 +733,7 @@
if isscalar:
return date
else:
- return np.reshape(np.array(date),shape)
+ return numpy.reshape(numpy.array(date),shape)
def _parse_date(origin):
"""Parses a date string and returns a tuple
@@ -852,3 +850,147 @@
for site in sites:
s = s[:site] + syear + s[site+4:]
return s
+
+def date2num(dates,units,calendar='standard'):
+ """
+date2num(dates,units,calendar='standard')
+
+Return numeric time values given datetime objects. The units
+of the numeric time values are described by the L{units} argument
+and the L{calendar} keyword. The datetime objects must
+be in UTC with no time-zone offset. If there is a
+time-zone offset in C{units}, it will be applied to the
+returned numeric values.
+
+Like the matplotlib C{date2num} function, except that it allows
+for different units and calendars. Behaves the same if
+C{units = 'days since 0001-01-01 00:00:00'} and
+C{calendar = 'proleptic_gregorian'}.
+
+@param dates: A datetime object or a sequence of datetime objects.
+ The datetime objects should not include a time-zone offset.
+
+@param units: a string of the form C{'B{time units} since B{reference time}}'
+ describing the time units. B{C{time units}} can be days, hours, minutes
+ or seconds. B{C{reference time}} is the time origin. A valid choice
+ would be units=C{'hours since 1800-01-01 00:00:00 -6:00'}.
+
+@param calendar: describes the calendar used in the time calculations.
+ All the values currently defined in the U{CF metadata convention
+ <http://cf-pcmdi.llnl.gov/documents/cf-conventions/>} are supported.
+ Valid calendars C{'standard', 'gregorian', 'proleptic_gregorian'
+ 'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'}.
+ Default is C{'standard'}, which is a mixed Julian/Gregorian calendar.
+
+@return: a numeric time value, or an array of numeric time values.
+
+The maximum resolution of the numeric time values is 1 second.
+ """
+ cdftime = utime(units,calendar=calendar)
+ return cdftime.date2num(dates)
+
+def num2date(times,units,calendar='standard'):
+ """
+num2date(times,units,calendar='standard')
+
+Return datetime objects given numeric time values. The units
+of the numeric time values are described by the C{units} argument
+and the C{calendar} keyword. The returned datetime objects represent
+UTC with no time-zone offset, even if the specified
+C{units} contain a time-zone offset.
+
+Like the matplotlib C{num2date} function, except that it allows
+for different units and calendars. Behaves the same if
+C{units = 'days since 001-01-01 00:00:00'} and
+C{calendar = 'proleptic_gregorian'}.
+
+@param times: numeric time values. Maximum resolution is 1 second.
+
+@param units: a string of the form C{'B{time units} since B{reference time}}'
+describing the time units. B{C{time units}} can be days, hours, minutes
+or seconds. B{C{reference time}} is the time origin. A valid choice
+would be units=C{'hours since 1800-01-01 00:00:00 -6:00'}.
+
+@param calendar: describes the calendar used in the time calculations.
+All the values currently defined in the U{CF metadata convention
+<http://cf-pcmdi.llnl.gov/documents/cf-conventions/>} are supported.
+Valid calendars C{'standard', 'gregorian', 'proleptic_gregorian'
+'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'}.
+Default is C{'standard'}, which is a mixed Julian/Gregorian calendar.
+
+@return: a datetime instance, or an array of datetime instances.
+
+The datetime instances returned are 'real' python datetime
+objects if the date falls in the Gregorian calendar (i.e.
+C{calendar='proleptic_gregorian'}, or C{calendar = 'standard'} or C{'gregorian'}
+and the date is after 1582-10-15). Otherwise, they are 'phony' datetime
+objects which support some but not all the methods of 'real' python
+datetime objects. This is because the python datetime module cannot
+the uses the C{'proleptic_gregorian'} calendar, even before the switch
+occured from the Julian calendar in 1582. The datetime instances
+do not contain a time-zone offset, even if the specified C{units}
+contains one.
+ """
+ cdftime = utime(units,calendar=calendar)
+ return cdftime.num2date(times)
+
+
+def _check_index(indices, dates, nctime, calendar):
+ """Assert that the time indices given correspond to the given dates."""
+ t = nctime[indices]
+ assert numpy.all( num2date(t, nctime.units, calendar) == dates)
+
+
+def date2index(dates, nctime, calendar=None):
+ """
+ date2index(dates, nctime, calendar=None)
+
+ Return indices of a netCDF time variable corresponding to the given dates.
+
+ @param dates: A datetime object or a sequence of datetime objects.
+ The datetime objects should not include a time-zone offset.
+
+ @param nctime: A netCDF time variable object. The nctime object must have a
+ C{units} attribute.
+
+ @param calendar: Describes the calendar used in the time calculation.
+ Valid calendars C{'standard', 'gregorian', 'proleptic_gregorian'
+ 'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'}.
+ Default is C{'standard'}, which is a mixed Julian/Gregorian calendar
+ If C{calendar} is None, its value is given by C{nctime.calendar} or
+ C{standard} if no such attribute exists.
+ """
+ # Setting the calendar.
+ if calendar is None:
+ calendar = getattr(nctime, 'calendar', 'standard')
+
+ num = numpy.atleast_1d(date2num(dates, nctime.units, calendar))
+
+ index = numpy.empty(numpy.alen(dates), int)
+
+ # Trying to infer the correct index from the starting time and the stride.
+ try:
+ t0, t1 = nctime[:2]
+ dt = t1 - t0
+ index[:] = (num-t0)/dt
+
+ # convert numpy scalars or single element arrays to python ints.
+ if not len(index.shape) or index.shape == (1,):
+ index = index.item()
+
+ # Checking that the index really corresponds to the given date.
+ _check_index(index, dates, nctime, calendar)
+
+ except AssertionError:
+ # If check fails, use brute force method.
+ index[:] = numpy.digitize(num, nctime[:]) - 1
+
+ # convert numpy scalars or single element arrays to python ints.
+ if not len(index.shape) or index.shape == (1,):
+ index = index.item()
+
+ # Perform check again.
+ _check_index(index, dates, nctime, calendar)
+
+ return index
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <lee...@us...> - 2009-01-26 16:39:20
|
Revision: 6829
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6829&view=rev
Author: leejjoon
Date: 2009-01-26 16:39:14 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Improved tight bbox option of the savefig
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/figure.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-01-26 14:40:09 UTC (rev 6828)
+++ trunk/matplotlib/CHANGELOG 2009-01-26 16:39:14 UTC (rev 6829)
@@ -1,3 +1,5 @@
+2009-01-26 Improved tight bbox option of the savefig. - JJL
+
2009-01-26 Make curves and NaNs play nice together - MGD
2009-01-21 Changed the defaults of acorr and xcorr to use
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-26 14:40:09 UTC (rev 6828)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-26 16:39:14 UTC (rev 6829)
@@ -7377,6 +7377,40 @@
integer=True))
return im
+
+ def get_tightbbox(self, renderer):
+ """
+ return the tight bounding box of the axes.
+ The dimension of the Bbox in canvas coordinate.
+ """
+
+ artists = []
+ bb = []
+
+ artists.append(self)
+
+ if self.title.get_visible():
+ artists.append(self.title)
+
+ if self.xaxis.get_visible():
+ artists.append(self.xaxis.label)
+ bbx1, bbx2 = self.xaxis.get_ticklabel_extents(renderer)
+ bb.extend([bbx1, bbx2])
+ if self.yaxis.get_visible():
+ artists.append(self.yaxis.label)
+ bby1, bby2 = self.yaxis.get_ticklabel_extents(renderer)
+ bb.extend([bby1, bby2])
+
+
+ bb.extend([c.get_window_extent(renderer) for c in artists])
+
+ _bbox = mtransforms.Bbox.union([b for b in bb if b.width!=0 or b.height!=0])
+
+ return _bbox
+
+
+
+
class SubplotBase:
"""
Base class for subplots, which are :class:`Axes` instances with
@@ -7514,6 +7548,8 @@
for label in self.get_yticklabels():
label.set_visible(firstcol)
+
+
_subplot_classes = {}
def subplot_class_factory(axes_class=None):
# This makes a new class that inherits from SubclassBase and the
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-26 14:40:09 UTC (rev 6828)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2009-01-26 16:39:14 UTC (rev 6829)
@@ -1479,7 +1479,25 @@
origBboxInches = fig.bbox_inches
_boxout = fig.transFigure._boxout
+ asp_list = []
+ locator_list = []
+ for ax in fig.axes:
+ pos = ax.get_position(original=False).frozen()
+ locator_list.append(ax.get_axes_locator())
+ asp_list.append(ax.get_aspect())
+
+ def _l(a, r, pos=pos): return pos
+ ax.set_axes_locator(_l)
+ ax.set_aspect("auto")
+
+
+
def restore_bbox():
+
+ for ax, asp, loc in zip(fig.axes, asp_list, locator_list):
+ ax.set_aspect(asp)
+ ax.set_axes_locator(loc)
+
fig.bbox = origBbox
fig.bbox_inches = origBboxInches
fig.transFigure._boxout = _boxout
Modified: trunk/matplotlib/lib/matplotlib/figure.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/figure.py 2009-01-26 14:40:09 UTC (rev 6828)
+++ trunk/matplotlib/lib/matplotlib/figure.py 2009-01-26 16:39:14 UTC (rev 6829)
@@ -1111,23 +1111,11 @@
ticklabels. Needs improvement.
"""
- artists = []
bb = []
for ax in self.axes:
+ if ax.get_visible():
+ bb.append(ax.get_tightbbox(renderer))
- artists.append(ax.xaxis.label)
- artists.append(ax.yaxis.label)
- artists.append(ax.title)
- artists.append(ax)
-
- bbx1, bbx2 = ax.xaxis.get_ticklabel_extents(renderer)
- bby1, bby2 = ax.yaxis.get_ticklabel_extents(renderer)
- bb.extend([bbx1, bbx2, bby1, bby2])
-
-
- bb.extend([c.get_window_extent(renderer) for c in artists \
- if c.get_visible()])
-
_bbox = Bbox.union([b for b in bb if b.width!=0 or b.height!=0])
bbox_inches = TransformedBbox(_bbox,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-01-26 14:40:19
|
Revision: 6828
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6828&view=rev
Author: mdboom
Date: 2009-01-26 14:40:09 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Merged revisions 6827 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_98_5_maint
........
r6827 | mdboom | 2009-01-26 09:32:42 -0500 (Mon, 26 Jan 2009) | 2 lines
Make curves and NaNs play nice together
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/patches.py
trunk/matplotlib/lib/matplotlib/path.py
trunk/matplotlib/src/agg_py_path_iterator.h
Property Changed:
----------------
trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6822
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6827
Modified: svn:mergeinfo
- /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822
+ /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822,6827
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-01-26 14:32:42 UTC (rev 6827)
+++ trunk/matplotlib/CHANGELOG 2009-01-26 14:40:09 UTC (rev 6828)
@@ -1,3 +1,5 @@
+2009-01-26 Make curves and NaNs play nice together - MGD
+
2009-01-21 Changed the defaults of acorr and xcorr to use
usevlines=True, maxlags=10 and normed=True since these are
the best defaults
Property changes on: trunk/matplotlib/doc/pyplots/README
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
+ /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827
Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
+ /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827
Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
+ /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822,6827
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-01-26 14:32:42 UTC (rev 6827)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-01-26 14:40:09 UTC (rev 6828)
@@ -299,8 +299,7 @@
tpath = transform.transform_path_non_affine(path)
affine = transform.get_affine()
- if not np.isnan(tpath.vertices).any():
- renderer.draw_path(gc, tpath, affine, rgbFace)
+ renderer.draw_path(gc, tpath, affine, rgbFace)
renderer.close_group('patch')
Modified: trunk/matplotlib/lib/matplotlib/path.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/path.py 2009-01-26 14:32:42 UTC (rev 6827)
+++ trunk/matplotlib/lib/matplotlib/path.py 2009-01-26 14:40:09 UTC (rev 6828)
@@ -213,7 +213,8 @@
if not isfinite(curr_vertices).all():
was_nan = True
elif was_nan:
- yield curr_vertices[-2:], MOVETO
+ yield curr_vertices[:2], MOVETO
+ yield curr_vertices, code
was_nan = False
else:
yield curr_vertices, code
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-26 14:32:42 UTC (rev 6827)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-26 14:40:09 UTC (rev 6828)
@@ -15,7 +15,10 @@
PyArrayObject* m_codes;
size_t m_iterator;
size_t m_total_vertices;
+ size_t m_ok;
bool m_should_simplify;
+ static const unsigned char num_extra_points_map[16];
+ static const unsigned code_map[];
public:
PathIterator(const Py::Object& path_obj) :
@@ -41,6 +44,7 @@
throw Py::ValueError("Invalid codes array.");
if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 0))
throw Py::ValueError("Codes array is wrong length");
+ m_ok = 0;
}
m_should_simplify = should_simplify_obj.isTrue();
@@ -53,8 +57,6 @@
Py_XDECREF(m_codes);
}
- static const unsigned code_map[];
-
private:
inline void vertex(const unsigned idx, double* x, double* y)
{
@@ -82,20 +84,86 @@
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
unsigned code = vertex_with_code(m_iterator++, x, y);
- if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y))
- {
- do
+ if (!m_codes) {
+ // This is the fast path for when we know we have no curves
+ if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y))
{
- if (m_iterator < m_total_vertices)
+ do
{
- vertex(m_iterator++, x, y);
+ if (m_iterator < m_total_vertices)
+ {
+ vertex(m_iterator++, x, y);
+ }
+ else
+ {
+ return agg::path_cmd_stop;
+ }
+ } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
+ return agg::path_cmd_move_to;
+ }
+ }
+ else
+ {
+ // This is the slow method for when there might be curves.
+
+ /* If m_ok is 0, we look ahead to see if the next curve
+ segment has any NaNs. If it does, we skip the whole
+ thing and return a move_to to the first point of the
+ next curve segment. This move_to may include NaNs,
+ which is ok, since in that case, it will always be
+ followed by another non-NaN move_to before any other
+ curves are actually drawn. If the current curve
+ segment doesn't have NaNs, we set the m_ok counter to
+ the number of points in the curve segment, which will
+ skip this check for the next N points.
+ */
+ if (m_ok == 0) {
+ if (code == agg::path_cmd_stop ||
+ code == (agg::path_cmd_end_poly | agg::path_flags_close))
+ {
+ return code;
}
- else
+
+ size_t num_extra_points = num_extra_points_map[code & 0xF];
+ bool has_nan = (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
+ for (size_t i = 0; !has_nan && i < num_extra_points; ++i)
{
- return agg::path_cmd_stop;
+ double x0, y0;
+ vertex(m_iterator + i, &x0, &y0);
+ has_nan = (MPL_notisfinite64(x0) || MPL_notisfinite64(y0));
}
- } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
- return agg::path_cmd_move_to;
+
+ if (has_nan)
+ {
+ m_iterator += num_extra_points;
+ if (m_iterator < m_total_vertices)
+ {
+ code = vertex_with_code(m_iterator, x, y);
+ if (code == agg::path_cmd_stop ||
+ code == (agg::path_cmd_end_poly | agg::path_flags_close))
+ {
+ return code;
+ }
+ else
+ {
+ return agg::path_cmd_move_to;
+ }
+ }
+ else
+ {
+ return agg::path_cmd_stop;
+ }
+ }
+ else /* !has_nan */
+ {
+ m_ok = num_extra_points;
+ return code;
+ }
+ }
+ else /* m_ok != 0 */
+ {
+ m_ok--;
+ }
}
return code;
@@ -127,6 +195,12 @@
agg::path_cmd_end_poly | agg::path_flags_close
};
+const unsigned char PathIterator::num_extra_points_map[] =
+ {0, 0, 0, 1,
+ 2, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0};
+
#define DEBUG_SIMPLIFY 0
template<class VertexSource>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-01-26 14:32:47
|
Revision: 6827
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6827&view=rev
Author: mdboom
Date: 2009-01-26 14:32:42 +0000 (Mon, 26 Jan 2009)
Log Message:
-----------
Make curves and NaNs play nice together
Modified Paths:
--------------
branches/v0_98_5_maint/CHANGELOG
branches/v0_98_5_maint/lib/matplotlib/patches.py
branches/v0_98_5_maint/lib/matplotlib/path.py
branches/v0_98_5_maint/src/agg_py_path_iterator.h
Modified: branches/v0_98_5_maint/CHANGELOG
===================================================================
--- branches/v0_98_5_maint/CHANGELOG 2009-01-25 14:38:48 UTC (rev 6826)
+++ branches/v0_98_5_maint/CHANGELOG 2009-01-26 14:32:42 UTC (rev 6827)
@@ -1,3 +1,5 @@
+2009-01-26 Make curves and NaNs play nice together - MGD
+
2009-01-19 Fix bug in quiver argument handling. - EF
2009-01-19 Fix bug in backend_gtk: don't delete nonexistent toolbar. - EF
Modified: branches/v0_98_5_maint/lib/matplotlib/patches.py
===================================================================
--- branches/v0_98_5_maint/lib/matplotlib/patches.py 2009-01-25 14:38:48 UTC (rev 6826)
+++ branches/v0_98_5_maint/lib/matplotlib/patches.py 2009-01-26 14:32:42 UTC (rev 6827)
@@ -298,8 +298,7 @@
tpath = transform.transform_path_non_affine(path)
affine = transform.get_affine()
- if not np.isnan(tpath.vertices).any():
- renderer.draw_path(gc, tpath, affine, rgbFace)
+ renderer.draw_path(gc, tpath, affine, rgbFace)
#renderer.close_group('patch')
Modified: branches/v0_98_5_maint/lib/matplotlib/path.py
===================================================================
--- branches/v0_98_5_maint/lib/matplotlib/path.py 2009-01-25 14:38:48 UTC (rev 6826)
+++ branches/v0_98_5_maint/lib/matplotlib/path.py 2009-01-26 14:32:42 UTC (rev 6827)
@@ -214,7 +214,8 @@
if not isfinite(curr_vertices).all():
was_nan = True
elif was_nan:
- yield curr_vertices[-2:], MOVETO
+ yield curr_vertices[:2], MOVETO
+ yield curr_vertices, code
was_nan = False
else:
yield curr_vertices, code
Modified: branches/v0_98_5_maint/src/agg_py_path_iterator.h
===================================================================
--- branches/v0_98_5_maint/src/agg_py_path_iterator.h 2009-01-25 14:38:48 UTC (rev 6826)
+++ branches/v0_98_5_maint/src/agg_py_path_iterator.h 2009-01-26 14:32:42 UTC (rev 6827)
@@ -15,7 +15,10 @@
PyArrayObject* m_codes;
size_t m_iterator;
size_t m_total_vertices;
+ size_t m_ok;
bool m_should_simplify;
+ static const unsigned char num_extra_points_map[16];
+ static const unsigned code_map[];
public:
PathIterator(const Py::Object& path_obj) :
@@ -41,6 +44,7 @@
throw Py::ValueError("Invalid codes array.");
if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 0))
throw Py::ValueError("Codes array is wrong length");
+ m_ok = 0;
}
m_should_simplify = should_simplify_obj.isTrue();
@@ -53,8 +57,6 @@
Py_XDECREF(m_codes);
}
- static const unsigned code_map[];
-
private:
inline void vertex(const unsigned idx, double* x, double* y)
{
@@ -82,20 +84,86 @@
if (m_iterator >= m_total_vertices) return agg::path_cmd_stop;
unsigned code = vertex_with_code(m_iterator++, x, y);
- if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y))
- {
- do
+ if (!m_codes) {
+ // This is the fast path for when we know we have no curves
+ if (MPL_notisfinite64(*x) || MPL_notisfinite64(*y))
{
- if (m_iterator < m_total_vertices)
+ do
{
- vertex(m_iterator++, x, y);
+ if (m_iterator < m_total_vertices)
+ {
+ vertex(m_iterator++, x, y);
+ }
+ else
+ {
+ return agg::path_cmd_stop;
+ }
+ } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
+ return agg::path_cmd_move_to;
+ }
+ }
+ else
+ {
+ // This is the slow method for when there might be curves.
+
+ /* If m_ok is 0, we look ahead to see if the next curve
+ segment has any NaNs. If it does, we skip the whole
+ thing and return a move_to to the first point of the
+ next curve segment. This move_to may include NaNs,
+ which is ok, since in that case, it will always be
+ followed by another non-NaN move_to before any other
+ curves are actually drawn. If the current curve
+ segment doesn't have NaNs, we set the m_ok counter to
+ the number of points in the curve segment, which will
+ skip this check for the next N points.
+ */
+ if (m_ok == 0) {
+ if (code == agg::path_cmd_stop ||
+ code == (agg::path_cmd_end_poly | agg::path_flags_close))
+ {
+ return code;
}
- else
+
+ size_t num_extra_points = num_extra_points_map[code & 0xF];
+ bool has_nan = (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
+ for (size_t i = 0; !has_nan && i < num_extra_points; ++i)
{
- return agg::path_cmd_stop;
+ double x0, y0;
+ vertex(m_iterator + i, &x0, &y0);
+ has_nan = (MPL_notisfinite64(x0) || MPL_notisfinite64(y0));
}
- } while (MPL_notisfinite64(*x) || MPL_notisfinite64(*y));
- return agg::path_cmd_move_to;
+
+ if (has_nan)
+ {
+ m_iterator += num_extra_points;
+ if (m_iterator < m_total_vertices)
+ {
+ code = vertex_with_code(m_iterator, x, y);
+ if (code == agg::path_cmd_stop ||
+ code == (agg::path_cmd_end_poly | agg::path_flags_close))
+ {
+ return code;
+ }
+ else
+ {
+ return agg::path_cmd_move_to;
+ }
+ }
+ else
+ {
+ return agg::path_cmd_stop;
+ }
+ }
+ else /* !has_nan */
+ {
+ m_ok = num_extra_points;
+ return code;
+ }
+ }
+ else /* m_ok != 0 */
+ {
+ m_ok--;
+ }
}
return code;
@@ -127,6 +195,12 @@
agg::path_cmd_end_poly | agg::path_flags_close
};
+const unsigned char PathIterator::num_extra_points_map[] =
+ {0, 0, 0, 1,
+ 2, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0};
+
#define DEBUG_SIMPLIFY 0
template<class VertexSource>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-25 14:38:55
|
Revision: 6826
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6826&view=rev
Author: jswhit
Date: 2009-01-25 14:38:48 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
add comments.
Modified Paths:
--------------
trunk/toolkits/basemap/examples/maskoceans.py
Modified: trunk/toolkits/basemap/examples/maskoceans.py
===================================================================
--- trunk/toolkits/basemap/examples/maskoceans.py 2009-01-25 14:29:31 UTC (rev 6825)
+++ trunk/toolkits/basemap/examples/maskoceans.py 2009-01-25 14:38:48 UTC (rev 6826)
@@ -3,6 +3,8 @@
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
+# example showing how to mask out 'wet' areas on a contour or pcolor plot.
+
topodatin = mlab.load('etopo20data.gz')
lonsin = mlab.load('etopo20lons.gz')
latsin = mlab.load('etopo20lats.gz')
@@ -17,29 +19,31 @@
lons, lats = np.meshgrid(lons1,lats1)
x, y = m(lons, lats)
# interpolate land/sea mask to topo grid, mask ocean values.
+# output may look 'blocky' near coastlines, since data is at much
+# lower resolution than land/sea mask.
topo = maskoceans(lons, lats, topoin, inlands=False)
# make contour plot (ocean values will be masked)
-#CS=m.contourf(x,y,topo,np.arange(-300,3001,50),cmap=plt.cm.jet,extend='both')
-im=m.pcolormesh(x,y,topo,cmap=plt.cm.jet,vmin=-300,vmax=3000)
+CS=m.contourf(x,y,topo,np.arange(-300,3001,50),cmap=plt.cm.jet,extend='both')
+#im=m.pcolormesh(x,y,topo,cmap=plt.cm.jet,vmin=-300,vmax=3000)
# draw coastlines.
m.drawcoastlines()
plt.title('ETOPO data with marine areas masked (original grid)')
fig=plt.figure()
# interpolate topo data to higher resolution grid (to better match
-# the land/sea mask).
+# the land/sea mask). Output looks less 'blocky' near coastlines.
nlats = 3*topoin.shape[0]
nlons = 3*topoin.shape[1]
lons = np.linspace(-180,180,nlons)
lats = np.linspace(-90,90,nlats)
lons, lats = np.meshgrid(lons, lats)
+x, y = m(lons, lats)
topo = interp(topoin,lons1,lats1,lons,lats,order=1)
-x, y = m(lons, lats)
# interpolate land/sea mask to topo grid, mask ocean values.
topo = maskoceans(lons, lats, topo, inlands=False)
# make contour plot (ocean values will be masked)
-#CS=m.contourf(x,y,topo,np.arange(-300,3001,50),cmap=plt.cm.jet,extend='both')
-im=m.pcolormesh(x,y,topo,cmap=plt.cm.jet,vmin=-300,vmax=3000)
+CS=m.contourf(x,y,topo,np.arange(-300,3001,50),cmap=plt.cm.jet,extend='both')
+#im=m.pcolormesh(x,y,topo,cmap=plt.cm.jet,vmin=-300,vmax=3000)
# draw coastlines.
m.drawcoastlines()
plt.title('ETOPO data with marine areas masked (data on finer grid)')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-25 14:29:37
|
Revision: 6825
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6825&view=rev
Author: jswhit
Date: 2009-01-25 14:29:31 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
added maskoceans function and example.
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/MANIFEST.in
trunk/toolkits/basemap/examples/README
trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
Added Paths:
-----------
trunk/toolkits/basemap/examples/maskoceans.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2009-01-25 12:56:39 UTC (rev 6824)
+++ trunk/toolkits/basemap/Changelog 2009-01-25 14:29:31 UTC (rev 6825)
@@ -1,4 +1,5 @@
version 0.99.4 (not yet released)
+ * added 'maskoceans' function.
* update pupynere to version 1.0.8 (supports writing large files).
* added more informative error message in readshapefile when
one of the shapefile components can't be found.
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in 2009-01-25 12:56:39 UTC (rev 6824)
+++ trunk/toolkits/basemap/MANIFEST.in 2009-01-25 14:29:31 UTC (rev 6825)
@@ -70,6 +70,7 @@
include examples/plotprecip.py
include examples/nws_precip_conus_20061222.nc
include examples/NetCDFFile_tst.py
+include examples/maskoceans.py
include examples/README
include lib/mpl_toolkits/__init__.py
include lib/mpl_toolkits/basemap/__init__.py
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README 2009-01-25 12:56:39 UTC (rev 6824)
+++ trunk/toolkits/basemap/examples/README 2009-01-25 14:29:31 UTC (rev 6825)
@@ -123,3 +123,5 @@
save_background.py shows how to save a map background and reuse it in another
figure (without having to redraw coastlines).
+
+maskoceans.py shows how to mask 'wet' areas on a plot.
Added: trunk/toolkits/basemap/examples/maskoceans.py
===================================================================
--- trunk/toolkits/basemap/examples/maskoceans.py (rev 0)
+++ trunk/toolkits/basemap/examples/maskoceans.py 2009-01-25 14:29:31 UTC (rev 6825)
@@ -0,0 +1,46 @@
+from mpl_toolkits.basemap import Basemap, shiftgrid, maskoceans, interp
+import numpy as np
+import matplotlib.pyplot as plt
+import matplotlib.mlab as mlab
+
+topodatin = mlab.load('etopo20data.gz')
+lonsin = mlab.load('etopo20lons.gz')
+latsin = mlab.load('etopo20lats.gz')
+
+# shift data so lons go from -180 to 180 instead of 20 to 380.
+topoin,lons1 = shiftgrid(180.,topodatin,lonsin,start=False)
+lats1 = latsin
+
+fig=plt.figure()
+# setup basemap
+m=Basemap(resolution='l',projection='lcc',lon_0=-100,lat_0=40,width=8.e6,height=6.e6)
+lons, lats = np.meshgrid(lons1,lats1)
+x, y = m(lons, lats)
+# interpolate land/sea mask to topo grid, mask ocean values.
+topo = maskoceans(lons, lats, topoin, inlands=False)
+# make contour plot (ocean values will be masked)
+#CS=m.contourf(x,y,topo,np.arange(-300,3001,50),cmap=plt.cm.jet,extend='both')
+im=m.pcolormesh(x,y,topo,cmap=plt.cm.jet,vmin=-300,vmax=3000)
+# draw coastlines.
+m.drawcoastlines()
+plt.title('ETOPO data with marine areas masked (original grid)')
+
+fig=plt.figure()
+# interpolate topo data to higher resolution grid (to better match
+# the land/sea mask).
+nlats = 3*topoin.shape[0]
+nlons = 3*topoin.shape[1]
+lons = np.linspace(-180,180,nlons)
+lats = np.linspace(-90,90,nlats)
+lons, lats = np.meshgrid(lons, lats)
+topo = interp(topoin,lons1,lats1,lons,lats,order=1)
+x, y = m(lons, lats)
+# interpolate land/sea mask to topo grid, mask ocean values.
+topo = maskoceans(lons, lats, topo, inlands=False)
+# make contour plot (ocean values will be masked)
+#CS=m.contourf(x,y,topo,np.arange(-300,3001,50),cmap=plt.cm.jet,extend='both')
+im=m.pcolormesh(x,y,topo,cmap=plt.cm.jet,vmin=-300,vmax=3000)
+# draw coastlines.
+m.drawcoastlines()
+plt.title('ETOPO data with marine areas masked (data on finer grid)')
+plt.show()
Modified: trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py
===================================================================
--- trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-25 12:56:39 UTC (rev 6824)
+++ trunk/toolkits/basemap/lib/mpl_toolkits/basemap/__init__.py 2009-01-25 14:29:31 UTC (rev 6825)
@@ -8,6 +8,8 @@
:func:`interp`: bilinear interpolation between rectilinear grids.
+:func:`maskoceans`: mask 'wet' points of an input array.
+
:func:`shiftgrid`: shifts global lat/lon grids east or west.
:func:`addcyclic`: Add cyclic (wraparound) point in longitude.
@@ -3113,20 +3115,8 @@
# read in.
if self.lsmask is None:
# read in land/sea mask.
- lsmaskf = open(os.path.join(basemap_datadir,'5minmask.bin'),'rb')
- nlons = 4320; nlats = nlons/2
- delta = 360./float(nlons)
- lsmask = np.reshape(np.fromstring(lsmaskf.read(),np.uint8),(nlats,nlons))
- lsmask_lons = np.arange(-180,180.,delta)
- lsmask_lats = np.arange(-90.,90+0.5*delta,delta)
- # add cyclic point in longitude
- lsmask, lsmask_lons = addcyclic(lsmask, lsmask_lons)
- nlons = nlons + 1; nlats = nlats + 1
- # add North Pole point (assumed water)
- tmparr = np.zeros((nlats,nlons),lsmask.dtype)
- tmparr[0:nlats-1,0:nlons] = lsmask
- lsmask = tmparr
- lsmaskf.close()
+ lsmask_lons, lsmask_lats, lsmask = _readlsmask()
+
# instance variable lsmask is set on first invocation,
# it contains the land-sea mask interpolated to the native
# projection grid. Further calls to drawlsmask will not
@@ -3950,3 +3940,53 @@
"""
cdftime = netcdftime.utime(units,calendar=calendar)
return cdftime.date2num(dates)
+
+def maskoceans(lonsin,latsin,datain,inlands=False):
+ """
+ mask data (``datain``), defined on a grid with latitudes ``latsin``
+ longitudes ``lonsin`` so that points over water will not be plotted.
+
+ .. tabularcolumns:: |l|L|
+
+ ============== ====================================================
+ Arguments Description
+ ============== ====================================================
+ lonsin, latsin rank-2 arrays containing longitudes and latitudes of
+ grid.
+ datain rank-2 input array on grid defined by ``lonsin`` and
+ ``latsin``.
+ inlands if False, mask only ocean points. If True, mask
+ ocean points and points over inland water bodies.
+ Default False.
+ ============== ====================================================
+
+ returns a masked array the same shape as datain with "wet" points masked.
+ """
+ # read in land/sea mask.
+ lsmask_lons, lsmask_lats, lsmask = _readlsmask()
+ # nearest-neighbor interpolation to output grid.
+ lsmasko = interp(lsmask,lsmask_lons,lsmask_lats,lonsin,latsin,masked=True,order=0)
+ # mask input data.
+ if inlands: # mask inland water bodies.
+ mask = np.logical_or(lsmasko==0,lsmasko==2)
+ else: # mask just marine areas.
+ mask = lsmasko == 0
+ return ma.masked_array(datain,mask=mask)
+
+def _readlsmask():
+ # read in land/sea mask.
+ lsmaskf = open(os.path.join(basemap_datadir,'5minmask.bin'),'rb')
+ nlons = 4320; nlats = nlons/2
+ delta = 360./float(nlons)
+ lsmask = np.reshape(np.fromstring(lsmaskf.read(),np.uint8),(nlats,nlons))
+ lsmask_lons = np.arange(-180,180.,delta)
+ lsmask_lats = np.arange(-90.,90+0.5*delta,delta)
+ # add cyclic point in longitude
+ lsmask, lsmask_lons = addcyclic(lsmask, lsmask_lons)
+ nlons = nlons + 1; nlats = nlats + 1
+ # add North Pole point (assumed water)
+ tmparr = np.zeros((nlats,nlons),lsmask.dtype)
+ tmparr[0:nlats-1,0:nlons] = lsmask
+ lsmask = tmparr
+ lsmaskf.close()
+ return lsmask_lons, lsmask_lats, lsmask
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2009-01-25 12:56:43
|
Revision: 6824
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6824&view=rev
Author: jswhit
Date: 2009-01-25 12:56:39 +0000 (Sun, 25 Jan 2009)
Log Message:
-----------
fix typo
Modified Paths:
--------------
trunk/toolkits/basemap/setup.cfg
Modified: trunk/toolkits/basemap/setup.cfg
===================================================================
--- trunk/toolkits/basemap/setup.cfg 2009-01-24 18:07:31 UTC (rev 6823)
+++ trunk/toolkits/basemap/setup.cfg 2009-01-25 12:56:39 UTC (rev 6824)
@@ -2,7 +2,7 @@
# By default, basemap checks for a few dependencies and
# installs them if missing. This feature can be turned off
# by uncommenting the following lines. Acceptible values are:
-# auto: install, overwrite an existing installation
+# True: install, overwrite an existing installation
# False: do not install
# auto: install only if the package is unavailable. This
# is the default behavior
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-01-24 18:07:38
|
Revision: 6823
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6823&view=rev
Author: jdh2358
Date: 2009-01-24 18:07:31 +0000 (Sat, 24 Jan 2009)
Log Message:
-----------
Merged revisions 6822 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint
........
r6822 | jdh2358 | 2009-01-24 10:06:02 -0800 (Sat, 24 Jan 2009) | 1 line
drop patches containing nan verts
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/patches.py
Property Changed:
----------------
trunk/matplotlib/
trunk/matplotlib/doc/pyplots/README
trunk/matplotlib/doc/sphinxext/gen_gallery.py
trunk/matplotlib/doc/sphinxext/gen_rst.py
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6818
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6822
Modified: svn:mergeinfo
- /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811
+ /branches/v0_91_maint:5753-5771
/branches/v0_98_5_maint:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6809,6811,6822
Property changes on: trunk/matplotlib/doc/pyplots/README
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805
+ /branches/v0_98_5_maint/doc/pyplots/README:6581,6585,6587,6589-6609,6614,6616,6625,6652,6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
Property changes on: trunk/matplotlib/doc/sphinxext/gen_gallery.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805
+ /branches/v0_91_maint/doc/_templates/gen_gallery.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_gallery.py:6660-6662,6672-6673,6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
Property changes on: trunk/matplotlib/doc/sphinxext/gen_rst.py
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805
+ /branches/v0_91_maint/doc/examples/gen_rst.py:5753-5771
/branches/v0_98_5_maint/doc/sphinxext/gen_rst.py:6714-6715,6717-6732,6752-6754,6761-6773,6781,6792,6800,6802,6805,6822
Modified: trunk/matplotlib/lib/matplotlib/patches.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/patches.py 2009-01-24 18:06:02 UTC (rev 6822)
+++ trunk/matplotlib/lib/matplotlib/patches.py 2009-01-24 18:07:31 UTC (rev 6823)
@@ -299,7 +299,8 @@
tpath = transform.transform_path_non_affine(path)
affine = transform.get_affine()
- renderer.draw_path(gc, tpath, affine, rgbFace)
+ if not np.isnan(tpath.vertices).any():
+ renderer.draw_path(gc, tpath, affine, rgbFace)
renderer.close_group('patch')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-01-24 18:06:04
|
Revision: 6822
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6822&view=rev
Author: jdh2358
Date: 2009-01-24 18:06:02 +0000 (Sat, 24 Jan 2009)
Log Message:
-----------
drop patches containing nan verts
Modified Paths:
--------------
branches/v0_98_5_maint/lib/matplotlib/patches.py
Modified: branches/v0_98_5_maint/lib/matplotlib/patches.py
===================================================================
--- branches/v0_98_5_maint/lib/matplotlib/patches.py 2009-01-23 16:26:48 UTC (rev 6821)
+++ branches/v0_98_5_maint/lib/matplotlib/patches.py 2009-01-24 18:06:02 UTC (rev 6822)
@@ -298,7 +298,8 @@
tpath = transform.transform_path_non_affine(path)
affine = transform.get_affine()
- renderer.draw_path(gc, tpath, affine, rgbFace)
+ if not np.isnan(tpath.vertices).any():
+ renderer.draw_path(gc, tpath, affine, rgbFace)
#renderer.close_group('patch')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ry...@us...> - 2009-01-23 16:26:58
|
Revision: 6821
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6821&view=rev
Author: ryanmay
Date: 2009-01-23 16:26:48 +0000 (Fri, 23 Jan 2009)
Log Message:
-----------
Fix missing backticks on :file: markup
Modified Paths:
--------------
trunk/matplotlib/doc/users/shell.rst
Modified: trunk/matplotlib/doc/users/shell.rst
===================================================================
--- trunk/matplotlib/doc/users/shell.rst 2009-01-23 16:24:35 UTC (rev 6820)
+++ trunk/matplotlib/doc/users/shell.rst 2009-01-23 16:26:48 UTC (rev 6821)
@@ -76,7 +76,7 @@
With the TkAgg backend, that uses the Tkinter user interface toolkit,
you can use matplotlib from an arbitrary python shell. Just set your
``backend : TkAgg`` and ``interactive : True`` in your
-:file:matplotlibrc file (see :ref:`customizing-matplotlib`) and fire
+:file:`matplotlibrc` file (see :ref:`customizing-matplotlib`) and fire
up python. Then::
>>> from pylab import *
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ry...@us...> - 2009-01-23 16:24:38
|
Revision: 6820
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6820&view=rev
Author: ryanmay
Date: 2009-01-23 16:24:35 +0000 (Fri, 23 Jan 2009)
Log Message:
-----------
Fix a couple typos.
Modified Paths:
--------------
trunk/matplotlib/doc/users/shell.rst
Modified: trunk/matplotlib/doc/users/shell.rst
===================================================================
--- trunk/matplotlib/doc/users/shell.rst 2009-01-22 03:12:53 UTC (rev 6819)
+++ trunk/matplotlib/doc/users/shell.rst 2009-01-23 16:24:35 UTC (rev 6820)
@@ -5,7 +5,7 @@
**********************************
By default, matplotlib defers drawing until the end of the script
-because drawing can be an expensive opertation, and you may not want
+because drawing can be an expensive operation, and you may not want
to update the plot every time a single property is changed, only once
after all the properties have changed.
@@ -103,7 +103,7 @@
The *interactive* property of the pyplot interface controls whether a
figure canvas is drawn on every pyplot command. If *interactive* is
-*False*, then the figure state is updated on every plot commands, but
+*False*, then the figure state is updated on every plot command, but
will only be drawn on explicit calls to
:func:`~matplotlib.pyplot.draw`. When *interactive* is
*True*, then every pyplot command triggers a draw.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-01-22 03:12:57
|
Revision: 6819
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6819&view=rev
Author: jdh2358
Date: 2009-01-22 03:12:53 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
Merged revisions 6818 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint
........
r6818 | jdh2358 | 2009-01-21 21:06:44 -0600 (Wed, 21 Jan 2009) | 1 line
fixed line collections legmarker sf bug 2511280
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/legend.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6816
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6818
Modified: trunk/matplotlib/lib/matplotlib/legend.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/legend.py 2009-01-22 03:06:44 UTC (rev 6818)
+++ trunk/matplotlib/lib/matplotlib/legend.py 2009-01-22 03:12:53 UTC (rev 6819)
@@ -272,7 +272,7 @@
self._set_artist_props(self.legendPatch)
self._drawFrame = True
-
+
# init with null renderer
self._init_legend_box(handles, labels)
@@ -327,9 +327,9 @@
def findoffset(width, height, xdescent, ydescent):
return _findoffset(width, height, xdescent, ydescent, renderer)
-
+
self._legend_box.set_offset(findoffset)
-
+
fontsize = renderer.points_to_pixels(self.fontsize)
# if mode == fill, set the width of the legend_box to the
@@ -623,8 +623,11 @@
ydata = ((height-descent)/2.)*np.ones(xdata.shape, float)
legline.set_data(xdata, ydata)
- legline_marker = legline._legmarker
- legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)])
+ # if a line collection is added, the legmarker attr is
+ # not set so we don't need to handle it
+ if hasattr(handle, "_legmarker"):
+ legline_marker = legline._legmarker
+ legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)])
elif isinstance(handle, Patch):
p = handle
@@ -765,7 +768,7 @@
C:"C"}
c = anchor_coefs[loc]
-
+
fontsize = renderer.points_to_pixels(self.fontsize)
container = parentbbox.padded(-(self.borderaxespad) * fontsize)
anchored_box = bbox.anchored(c, container=container)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-01-22 03:06:46
|
Revision: 6818
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6818&view=rev
Author: jdh2358
Date: 2009-01-22 03:06:44 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
fixed line collections legmarker sf bug 2511280
Modified Paths:
--------------
branches/v0_98_5_maint/lib/matplotlib/legend.py
Modified: branches/v0_98_5_maint/lib/matplotlib/legend.py
===================================================================
--- branches/v0_98_5_maint/lib/matplotlib/legend.py 2009-01-22 02:54:23 UTC (rev 6817)
+++ branches/v0_98_5_maint/lib/matplotlib/legend.py 2009-01-22 03:06:44 UTC (rev 6818)
@@ -272,7 +272,7 @@
self._set_artist_props(self.legendPatch)
self._drawFrame = True
-
+
# init with null renderer
self._init_legend_box(handles, labels)
@@ -327,9 +327,9 @@
def findoffset(width, height, xdescent, ydescent):
return _findoffset(width, height, xdescent, ydescent, renderer)
-
+
self._legend_box.set_offset(findoffset)
-
+
fontsize = renderer.points_to_pixels(self.fontsize)
# if mode == fill, set the width of the legend_box to the
@@ -623,8 +623,11 @@
ydata = ((height-descent)/2.)*np.ones(xdata.shape, float)
legline.set_data(xdata, ydata)
- legline_marker = legline._legmarker
- legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)])
+ # if a line collection is added, the legmarker attr is
+ # not set so we don't need to handle it
+ if hasattr(handle, "_legmarker"):
+ legline_marker = legline._legmarker
+ legline_marker.set_data(xdata_marker, ydata[:len(xdata_marker)])
elif isinstance(handle, Patch):
p = handle
@@ -765,7 +768,7 @@
C:"C"}
c = anchor_coefs[loc]
-
+
fontsize = renderer.points_to_pixels(self.fontsize)
container = parentbbox.padded(-(self.borderaxespad) * fontsize)
anchored_box = bbox.anchored(c, container=container)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-01-22 02:54:29
|
Revision: 6817
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6817&view=rev
Author: jdh2358
Date: 2009-01-22 02:54:23 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
Merged revisions 6816 via svnmerge from
https://matplotlib.svn.sourceforge.net/svnroot/matplotlib/branches/v0_98_5_maint
........
r6816 | jdh2358 | 2009-01-21 20:48:32 -0600 (Wed, 21 Jan 2009) | 1 line
fixed a cocoaagg import bug
........
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Modified: svnmerge-integrated
- /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6811
+ /branches/v0_91_maint:1-6428 /branches/v0_98_5_maint:1-6816
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py 2009-01-22 02:48:32 UTC (rev 6816)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_cocoaagg.py 2009-01-22 02:54:23 UTC (rev 6817)
@@ -29,7 +29,7 @@
import matplotlib
from matplotlib.figure import Figure
-from matplotlib.backend_bases import FigureManagerBase
+from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase
from backend_agg import FigureCanvasAgg
from matplotlib._pylab_helpers import Gcf
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-01-22 02:48:38
|
Revision: 6816
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6816&view=rev
Author: jdh2358
Date: 2009-01-22 02:48:32 +0000 (Thu, 22 Jan 2009)
Log Message:
-----------
fixed a cocoaagg import bug
Modified Paths:
--------------
branches/v0_98_5_maint/lib/matplotlib/backends/backend_cocoaagg.py
Modified: branches/v0_98_5_maint/lib/matplotlib/backends/backend_cocoaagg.py
===================================================================
--- branches/v0_98_5_maint/lib/matplotlib/backends/backend_cocoaagg.py 2009-01-21 19:09:15 UTC (rev 6815)
+++ branches/v0_98_5_maint/lib/matplotlib/backends/backend_cocoaagg.py 2009-01-22 02:48:32 UTC (rev 6816)
@@ -29,7 +29,7 @@
import matplotlib
from matplotlib.figure import Figure
-from matplotlib.backend_bases import FigureManagerBase
+from matplotlib.backend_bases import FigureManagerBase, FigureCanvasBase
from backend_agg import FigureCanvasAgg
from matplotlib._pylab_helpers import Gcf
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2009-01-21 19:09:24
|
Revision: 6815
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6815&view=rev
Author: jdh2358
Date: 2009-01-21 19:09:15 +0000 (Wed, 21 Jan 2009)
Log Message:
-----------
changed defaults on acorr and xcorr to norm, usevlines and maxlags=10
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/doc/api/api_changes.rst
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2009-01-21 14:52:26 UTC (rev 6814)
+++ trunk/matplotlib/CHANGELOG 2009-01-21 19:09:15 UTC (rev 6815)
@@ -1,3 +1,7 @@
+2009-01-21 Changed the defaults of acorr and xcorr to use
+ usevlines=True, maxlags=10 and normed=True since these are
+ the best defaults
+
2009-01-19 Fix bug in quiver argument handling. - EF
2009-01-19 Fix bug in backend_gtk: don't delete nonexistent toolbar. - EF
Modified: trunk/matplotlib/doc/api/api_changes.rst
===================================================================
--- trunk/matplotlib/doc/api/api_changes.rst 2009-01-21 14:52:26 UTC (rev 6814)
+++ trunk/matplotlib/doc/api/api_changes.rst 2009-01-21 19:09:15 UTC (rev 6815)
@@ -19,20 +19,24 @@
Changes for 0.98.x
==================
+
+* Changed the defaults of acorr and xcorr to use usevlines=True,
+ maxlags=10 and normed=True since these are the best defaults
+
* Following keyword parameters for :class:`matplotlib.label.Label` are now
- deprecated and new set of parameters are introduced. The new parameters
- are given as a fraction of the font-size. Also, *scatteryoffsets*,
+ deprecated and new set of parameters are introduced. The new parameters
+ are given as a fraction of the font-size. Also, *scatteryoffsets*,
*fancybox* and *columnspacing* are added as keyword parameters.
================ ================
Deprecated New
================ ================
- pad borderpad
- labelsep labelspacing
- handlelen handlelength
- handlestextsep handletextpad
- axespad borderaxespad
- ================ ================
+ pad borderpad
+ labelsep labelspacing
+ handlelen handlelength
+ handlestextsep handletextpad
+ axespad borderaxespad
+ ================ ================
* Removed the configobj and experiemtnal traits rc support
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2009-01-21 14:52:26 UTC (rev 6814)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2009-01-21 19:09:15 UTC (rev 6815)
@@ -3543,8 +3543,8 @@
"""
call signature::
- acorr(x, normed=False, detrend=mlab.detrend_none, usevlines=False,
- maxlags=None, **kwargs)
+ acorr(x, normed=True, detrend=mlab.detrend_none, usevlines=True,
+ maxlags=10, **kwargs)
Plot the autocorrelation of *x*. If *normed* = *True*,
normalize the data by the autocorrelation at 0-th lag. *x* is
@@ -3602,13 +3602,13 @@
return self.xcorr(x, x, **kwargs)
acorr.__doc__ = cbook.dedent(acorr.__doc__) % martist.kwdocd
- def xcorr(self, x, y, normed=False, detrend=mlab.detrend_none,
- usevlines=False, maxlags=None, **kwargs):
+ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
+ usevlines=True, maxlags=10, **kwargs):
"""
call signature::
- xcorr(x, y, normed=False, detrend=mlab.detrend_none,
- usevlines=False, **kwargs):
+ def xcorr(self, x, y, normed=True, detrend=mlab.detrend_none,
+ usevlines=True, maxlags=10, **kwargs):
Plot the cross correlation between *x* and *y*. If *normed* =
*True*, normalize the data by the cross correlation at 0-th
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-01-21 14:52:31
|
Revision: 6814
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6814&view=rev
Author: mdboom
Date: 2009-01-21 14:52:26 +0000 (Wed, 21 Jan 2009)
Log Message:
-----------
Change simplification algorithm so it always returns points from the original data, rather than extrapolated ones. This is somewhat experimental.
Modified Paths:
--------------
trunk/matplotlib/src/agg_py_path_iterator.h
Modified: trunk/matplotlib/src/agg_py_path_iterator.h
===================================================================
--- trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-21 14:25:11 UTC (rev 6813)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2009-01-21 14:52:26 UTC (rev 6814)
@@ -142,8 +142,8 @@
m_do_clipping(width > 0.0 && height > 0.0),
m_origdx(0.0), m_origdy(0.0),
m_origdNorm2(0.0), m_dnorm2Max(0.0), m_dnorm2Min(0.0),
- m_haveMin(false), m_lastMax(false), m_maxX(0.0), m_maxY(0.0),
- m_minX(0.0), m_minY(0.0), m_lastWrittenX(0.0), m_lastWrittenY(0.0)
+ m_lastMax(false), m_nextX(0.0), m_nextY(0.0),
+ m_lastWrittenX(0.0), m_lastWrittenY(0.0)
#if DEBUG_SIMPLIFY
, m_pushed(0), m_skipped(0)
#endif
@@ -302,13 +302,12 @@
//set all the variables to reflect this new orig vector
m_dnorm2Max = m_origdNorm2;
m_dnorm2Min = 0.0;
- m_haveMin = false;
m_lastMax = true;
- m_lastx = m_maxX = *x;
- m_lasty = m_maxY = *y;
- m_lastWrittenX = m_minX = m_lastx;
- m_lastWrittenY = m_minY = m_lasty;
+ m_nextX = m_lastWrittenX = m_lastx;
+ m_nextY = m_lastWrittenY = m_lasty;
+ m_lastx = *x;
+ m_lasty = *y;
#if DEBUG_SIMPLIFY
m_skipped++;
#endif
@@ -358,18 +357,17 @@
{
m_lastMax = true;
m_dnorm2Max = paradNorm2;
- m_maxX = m_lastWrittenX + paradx;
- m_maxY = m_lastWrittenY + parady;
+ m_nextX = *x;
+ m_nextY = *y;
}
}
else
{
- m_haveMin = true;
if (paradNorm2 > m_dnorm2Min)
{
m_dnorm2Min = paradNorm2;
- m_minX = m_lastWrittenX + paradx;
- m_minY = m_lastWrittenY + parady;
+ m_nextX = *x;
+ m_nextY = *y;
}
}
@@ -394,17 +392,12 @@
}
// Fill the queue with the remaining vertices if we've finished the
- // path in the above loop. Mark the path as done, so we don't call
- // m_source->vertex again and segfault.
+ // path in the above loop.
if (cmd == agg::path_cmd_stop)
{
if (m_origdNorm2 != 0.0)
{
- if (m_haveMin)
- {
- queue_push(agg::path_cmd_line_to, m_minX, m_minY);
- }
- queue_push(agg::path_cmd_line_to, m_maxX, m_maxY);
+ queue_push(agg::path_cmd_line_to, m_nextX, m_nextY);
}
queue_push(agg::path_cmd_stop, 0.0, 0.0);
}
@@ -459,12 +452,9 @@
double m_origdNorm2;
double m_dnorm2Max;
double m_dnorm2Min;
- bool m_haveMin;
bool m_lastMax;
- double m_maxX;
- double m_maxY;
- double m_minX;
- double m_minY;
+ double m_nextX;
+ double m_nextY;
double m_lastWrittenX;
double m_lastWrittenY;
@@ -517,11 +507,7 @@
inline void _push(double* x, double* y)
{
- if (m_haveMin)
- {
- queue_push(agg::path_cmd_line_to, m_minX, m_minY);
- }
- queue_push(agg::path_cmd_line_to, m_maxX, m_maxY);
+ queue_push(agg::path_cmd_line_to, m_nextX, m_nextY);
//if we clipped some segments between this line and the next line
//we are starting, we also need to move to the last point.
@@ -546,12 +532,11 @@
m_dnorm2Max = m_origdNorm2;
m_dnorm2Min = 0.0;
- m_haveMin = false;
m_lastMax = true;
- m_lastx = m_maxX = *x;
- m_lasty = m_maxY = *y;
- m_lastWrittenX = m_minX = m_lastx;
- m_lastWrittenY = m_minY = m_lasty;
+ m_lastWrittenX = m_queue[m_queue_write-1].x;
+ m_lastWrittenY = m_queue[m_queue_write-1].y;
+ m_lastx = m_nextX = *x;
+ m_lasty = m_nextY = *y;
m_clipped = false;
#if DEBUG_SIMPLIFY
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2009-01-21 14:25:14
|
Revision: 6813
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6813&view=rev
Author: mdboom
Date: 2009-01-21 14:25:11 +0000 (Wed, 21 Jan 2009)
Log Message:
-----------
Remove %%EOF comment from embedded fonts, in an attempt to resolve Paul Novak's strange Postscript error.
Modified Paths:
--------------
trunk/matplotlib/ttconv/pprdrv_tt.cpp
Modified: trunk/matplotlib/ttconv/pprdrv_tt.cpp
===================================================================
--- trunk/matplotlib/ttconv/pprdrv_tt.cpp 2009-01-20 02:08:37 UTC (rev 6812)
+++ trunk/matplotlib/ttconv/pprdrv_tt.cpp 2009-01-21 14:25:11 UTC (rev 6813)
@@ -1070,7 +1070,7 @@
} /* end of if Type 42 not understood. */
stream.putline("FontName currentdict end definefont pop");
- stream.putline("%%EOF");
+ /* stream.putline("%%EOF"); */
} /* end of ttfont_trailer() */
/*------------------------------------------------------------------
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|