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: <md...@us...> - 2008-09-03 19:15:30
|
Revision: 6061
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6061&view=rev
Author: mdboom
Date: 2008-09-03 19:15:22 +0000 (Wed, 03 Sep 2008)
Log Message:
-----------
[ 2091036 ] Using log axes with base 2 fails
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/scale.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-09-01 22:50:47 UTC (rev 6060)
+++ trunk/matplotlib/CHANGELOG 2008-09-03 19:15:22 UTC (rev 6061)
@@ -1,3 +1,5 @@
+2008-09-03 Fix log with base 2 - MGD
+
2008-09-01 Added support for bilinear interpolation in
NonUniformImage; patch by Gregory Lielens. - EF
Modified: trunk/matplotlib/lib/matplotlib/scale.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/scale.py 2008-09-01 22:50:47 UTC (rev 6060)
+++ trunk/matplotlib/lib/matplotlib/scale.py 2008-09-03 19:15:22 UTC (rev 6061)
@@ -91,7 +91,7 @@
def transform(self, a):
a = _mask_non_positives(a * 2.0)
if isinstance(a, MaskedArray):
- return ma.log2(a)
+ return ma.log(a) / np.log(2)
return np.log2(a)
def inverted(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-09-01 22:50:49
|
Revision: 6060
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6060&view=rev
Author: efiring
Date: 2008-09-01 22:50:47 +0000 (Mon, 01 Sep 2008)
Log Message:
-----------
Allocate acols, arows only if needed; change suggested by Mike D.
Other slight cleanups in _image.cpp.
Modified Paths:
--------------
trunk/matplotlib/src/_image.cpp
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp 2008-09-01 22:27:07 UTC (rev 6059)
+++ trunk/matplotlib/src/_image.cpp 2008-09-01 22:50:47 UTC (rev 6060)
@@ -711,7 +711,7 @@
size_t numrows = (size_t)Py::Int(args[0]);
size_t numcols = (size_t)Py::Int(args[1]);
- if (numrows > 1 << 15 || numcols > 1 << 15) {
+ if (numrows >= 32768 || numcols >= 32768) {
throw Py::RuntimeError("numrows and numcols must both be less than 32768");
}
@@ -1088,7 +1088,7 @@
size_t x = Py::Int(args[1]);
size_t y = Py::Int(args[2]);
- if (x > 1 << 15 || y > 1 << 15) {
+ if (x >= 32768 || y >= 32768) {
throw Py::ValueError("x and y must both be less than 32768");
}
@@ -1335,7 +1335,7 @@
PyMem_Free(arows);
return;
}
-
+
Py::Object
_image_module::pcolor(const Py::Tuple& args) {
_VERBOSE("_image_module::pcolor");
@@ -1352,7 +1352,7 @@
Py::Tuple bounds = args[5];
unsigned int interpolation = Py::Int(args[6]);
- if (rows > 1 << 15 || cols > 1 << 15) {
+ if (rows >= 32768 || cols >= 32768) {
throw Py::ValueError("rows and cols must both be less than 32768");
}
@@ -1370,11 +1370,11 @@
// Check we have something to output to
if (rows == 0 || cols ==0)
throw Py::ValueError("Cannot scale to zero size");
-
+
PyArrayObject *x = NULL; PyArrayObject *y = NULL; PyArrayObject *d = NULL;
unsigned int * rowstarts = NULL; unsigned int*colstarts = NULL;
float *acols = NULL; float *arows = NULL;
-
+
// Get numpy arrays
x = (PyArrayObject *) PyArray_ContiguousFromObject(xp.ptr(), PyArray_FLOAT, 1, 1);
if (x == NULL) {
@@ -1406,14 +1406,12 @@
// Allocate memory for pointer arrays
rowstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*rows));
- arows = reinterpret_cast<float *>(PyMem_Malloc(sizeof(float)*rows));
- if (rowstarts == NULL || arows == NULL ) {
+ if (rowstarts == NULL) {
_pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::MemoryError("Cannot allocate memory for lookup table");
}
colstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*cols));
- acols = reinterpret_cast<float*>(PyMem_Malloc(sizeof(float)*cols));
- if (colstarts == NULL || acols == NULL) {
+ if (colstarts == NULL) {
_pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::MemoryError("Cannot allocate memory for lookup table");
}
@@ -1430,8 +1428,8 @@
_pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::MemoryError("Could not allocate memory for image");
}
-
+
// Calculate the pointer arrays to map input x to output x
unsigned int i, j;
unsigned int * colstart = colstarts;
@@ -1451,7 +1449,7 @@
start = reinterpret_cast<unsigned char*>(d->data);
int s0 = d->strides[0];
int s1 = d->strides[1];
-
+
if(interpolation == Image::NEAREST) {
_bin_indices_middle(colstart, cols, xs1, nx,dx,x_min);
_bin_indices_middle(rowstart, rows, ys1, ny, dy,y_min);
@@ -1473,11 +1471,22 @@
}
}
else if(interpolation == Image::BILINEAR) {
+ arows = reinterpret_cast<float *>(PyMem_Malloc(sizeof(float)*rows));
+ if (arows == NULL ) {
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
+ throw Py::MemoryError("Cannot allocate memory for lookup table");
+ }
+ acols = reinterpret_cast<float*>(PyMem_Malloc(sizeof(float)*cols));
+ if (acols == NULL) {
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
+ throw Py::MemoryError("Cannot allocate memory for lookup table");
+ }
+
_bin_indices_middle_linear(acols, colstart, cols, xs1, nx,dx,x_min);
_bin_indices_middle_linear(arows, rowstart, rows, ys1, ny, dy,y_min);
double a00,a01,a10,a11,alpha,beta;
-
-
+
+
agg::int8u * start00;
agg::int8u * start01;
agg::int8u * start10;
@@ -1489,12 +1498,12 @@
{
alpha=arows[i];
beta=acols[j];
-
+
a00=alpha*beta;
a01=alpha*(1.0-beta);
a10=(1.0-alpha)*beta;
a11=1.0-a00-a01-a10;
-
+
start00=(agg::int8u *)(start + s0*rowstart[i] + s1*colstart[j]);
start01=start00+s1;
start10=start00+s0;
@@ -1506,22 +1515,18 @@
position += 4;
}
}
-
+
}
-
- // Attatch output buffer to output buffer
+ // Attach output buffer to output buffer
imo->rbufOut = new agg::rendering_buffer;
imo->bufferOut = buffer;
imo->rbufOut->attach(imo->bufferOut, imo->colsOut, imo->rowsOut, imo->colsOut * imo->BPP);
-
_pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
return Py::asObject(imo);
-
-
}
@@ -1548,7 +1553,7 @@
Py::Tuple bounds = args[5];
Py::Object bgp = args[6];
- if (rows > 1 << 15 || cols > 1 << 15) {
+ if (rows >= 32768 || cols >= 32768) {
throw Py::ValueError("rows and cols must both be less than 32768");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-09-01 22:27:09
|
Revision: 6059
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6059&view=rev
Author: efiring
Date: 2008-09-01 22:27:07 +0000 (Mon, 01 Sep 2008)
Log Message:
-----------
Improve backend_driver error reporting.
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/image_nonuniform.py
trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py
trunk/matplotlib/examples/tests/backend_driver.py
Modified: trunk/matplotlib/examples/pylab_examples/image_nonuniform.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_nonuniform.py 2008-09-01 21:09:09 UTC (rev 6058)
+++ trunk/matplotlib/examples/pylab_examples/image_nonuniform.py 2008-09-01 22:27:07 UTC (rev 6059)
@@ -13,7 +13,7 @@
x = np.linspace(-4, 4, 9)
x2 = x**3
y = np.linspace(-4, 4, 9)
-print 'Size %d points' % (len(x) * len(y))
+#print 'Size %d points' % (len(x) * len(y))
z = np.sqrt(x[np.newaxis,:]**2 + y[:,np.newaxis]**2)
fig = figure()
Modified: trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py 2008-09-01 21:09:09 UTC (rev 6058)
+++ trunk/matplotlib/examples/pylab_examples/stix_fonts_demo.py 2008-09-01 22:27:07 UTC (rev 6059)
@@ -31,7 +31,7 @@
axis([0, 3, -len(tests), 0])
yticks(arange(len(tests)) * -1)
for i, s in enumerate(tests):
- print (i, s.encode("ascii", "backslashreplace"))
+ #print (i, s.encode("ascii", "backslashreplace"))
text(0.1, -i, s, fontsize=32)
savefig('stix_fonts_example')
Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py 2008-09-01 21:09:09 UTC (rev 6058)
+++ trunk/matplotlib/examples/tests/backend_driver.py 2008-09-01 22:27:07 UTC (rev 6059)
@@ -204,7 +204,7 @@
os.unlink(os.path.join(path,fname))
else:
os.mkdir(backend)
-
+ failures = []
for fullpath in files:
print ('\tdriving %-40s' % (fullpath)),
@@ -257,10 +257,14 @@
print (end_time - start_time), ret
#os.system('%s %s %s' % (python, tmpfile_name, switchstring))
os.remove(tmpfile_name)
+ if ret:
+ failures.append(fullpath)
+ return failures
if __name__ == '__main__':
times = {}
+ failures = {}
default_backends = ['agg', 'ps', 'svg', 'pdf', 'template']
if len(sys.argv)==2 and sys.argv[1]=='--clean':
localdirs = [d for d in glob.glob('*') if os.path.isdir(d)]
@@ -299,13 +303,16 @@
switchstring = ' '.join(switches)
print 'testing %s %s' % (backend, switchstring)
t0 = time.time()
- drive(backend, python, switches)
+ failures[backend] = drive(backend, python, switches)
t1 = time.time()
times[backend] = (t1-t0)/60.0
# print times
for backend, elapsed in times.items():
print 'Backend %s took %1.2f minutes to complete' % ( backend, elapsed)
+ failed = failures[backend]
+ if failed:
+ print ' Failures: ', failed
if 'Template' in times:
print '\ttemplate ratio %1.3f, template residual %1.3f' % (
elapsed/times['Template'], elapsed-times['Template'])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-09-01 21:09:11
|
Revision: 6058
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6058&view=rev
Author: efiring
Date: 2008-09-01 21:09:09 +0000 (Mon, 01 Sep 2008)
Log Message:
-----------
Update CHANGELOG for Lielens NonUniformImage patch
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/axes.py
trunk/matplotlib/lib/matplotlib/pyplot.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-09-01 21:06:34 UTC (rev 6057)
+++ trunk/matplotlib/CHANGELOG 2008-09-01 21:09:09 UTC (rev 6058)
@@ -1,3 +1,6 @@
+2008-09-01 Added support for bilinear interpolation in
+ NonUniformImage; patch by Gregory Lielens. - EF
+
2008-08-28 Added support for multiple histograms with data of
different length - MM
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-09-01 21:06:34 UTC (rev 6057)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-09-01 21:09:09 UTC (rev 6058)
@@ -6216,7 +6216,7 @@
elif len(x.shape)==2 and x.shape[1]<x.shape[0]:
warnings.warn('2D hist should be nsamples x nvariables; this looks transposed')
except ValueError:
- # multiple hist with data of different length
+ # multiple hist with data of different length
if iterable(x[0]) and not is_string_like(x[0]):
tx = []
for i in xrange(len(x)):
Modified: trunk/matplotlib/lib/matplotlib/pyplot.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/pyplot.py 2008-09-01 21:06:34 UTC (rev 6057)
+++ trunk/matplotlib/lib/matplotlib/pyplot.py 2008-09-01 21:09:09 UTC (rev 6058)
@@ -2354,7 +2354,7 @@
except:
hold(b)
raise
-
+
hold(b)
return ret
if Axes.barbs.__doc__ is not None:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-09-01 21:06:37
|
Revision: 6057
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6057&view=rev
Author: efiring
Date: 2008-09-01 21:06:34 +0000 (Mon, 01 Sep 2008)
Log Message:
-----------
Bilinear interp in NonUniformImage; slightly modified patch by Gregory Lielens
Includes a bugfix in _image.pcolor2.
Replaced pylab_examples/pcolor_nonuniform.py with the more
aptly-named image_nonuniform.py, modified it to show both
interpolation types, and added it to backend_driver.py.
Modified Paths:
--------------
trunk/matplotlib/examples/tests/backend_driver.py
trunk/matplotlib/lib/matplotlib/image.py
trunk/matplotlib/src/_image.cpp
Added Paths:
-----------
trunk/matplotlib/examples/pylab_examples/image_nonuniform.py
Removed Paths:
-------------
trunk/matplotlib/examples/pylab_examples/pcolor_nonuniform.py
Added: trunk/matplotlib/examples/pylab_examples/image_nonuniform.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/image_nonuniform.py (rev 0)
+++ trunk/matplotlib/examples/pylab_examples/image_nonuniform.py 2008-09-01 21:06:34 UTC (rev 6057)
@@ -0,0 +1,55 @@
+'''
+This illustrates the NonUniformImage class, which still needs
+an axes method interface; either a separate interface, or a
+generalization of imshow.
+'''
+
+from matplotlib.pyplot import figure, show
+import numpy as np
+from matplotlib.image import NonUniformImage
+
+interp='nearest'
+
+x = np.linspace(-4, 4, 9)
+x2 = x**3
+y = np.linspace(-4, 4, 9)
+print 'Size %d points' % (len(x) * len(y))
+z = np.sqrt(x[np.newaxis,:]**2 + y[:,np.newaxis]**2)
+
+fig = figure()
+fig.suptitle('NonUniformImage class')
+ax = fig.add_subplot(221)
+im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4))
+im.set_data(x, y, z)
+ax.images.append(im)
+ax.set_xlim(-4,4)
+ax.set_ylim(-4,4)
+ax.set_title(interp)
+
+ax = fig.add_subplot(222)
+im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4))
+im.set_data(x2, y, z)
+ax.images.append(im)
+ax.set_xlim(-64,64)
+ax.set_ylim(-4,4)
+ax.set_title(interp)
+
+interp = 'bilinear'
+
+ax = fig.add_subplot(223)
+im = NonUniformImage(ax, interpolation=interp, extent=(-4,4,-4,4))
+im.set_data(x, y, z)
+ax.images.append(im)
+ax.set_xlim(-4,4)
+ax.set_ylim(-4,4)
+ax.set_title(interp)
+
+ax = fig.add_subplot(224)
+im = NonUniformImage(ax, interpolation=interp, extent=(-64,64,-4,4))
+im.set_data(x2, y, z)
+ax.images.append(im)
+ax.set_xlim(-64,64)
+ax.set_ylim(-4,4)
+ax.set_title(interp)
+
+show()
Deleted: trunk/matplotlib/examples/pylab_examples/pcolor_nonuniform.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/pcolor_nonuniform.py 2008-08-30 10:11:37 UTC (rev 6056)
+++ trunk/matplotlib/examples/pylab_examples/pcolor_nonuniform.py 2008-09-01 21:06:34 UTC (rev 6057)
@@ -1,26 +0,0 @@
-from matplotlib.pyplot import figure, show
-import numpy as np
-from matplotlib.image import NonUniformImage
-
-x = np.arange(-4, 4, 0.005)
-y = np.arange(-4, 4, 0.005)
-print 'Size %d points' % (len(x) * len(y))
-z = np.sqrt(x[np.newaxis,:]**2 + y[:,np.newaxis]**2)
-
-fig = figure()
-ax = fig.add_subplot(111)
-im = NonUniformImage(ax, extent=(-4,4,-4,4))
-im.set_data(x, y, z)
-ax.images.append(im)
-ax.set_xlim(-4,4)
-ax.set_ylim(-4,4)
-
-fig2 = figure()
-ax = fig2.add_subplot(111)
-x2 = x**3
-im = NonUniformImage(ax, extent=(-64,64,-4,4))
-im.set_data(x2, y, z)
-ax.images.append(im)
-ax.set_xlim(-64,64)
-ax.set_ylim(-4,4)
-show()
Modified: trunk/matplotlib/examples/tests/backend_driver.py
===================================================================
--- trunk/matplotlib/examples/tests/backend_driver.py 2008-08-30 10:11:37 UTC (rev 6056)
+++ trunk/matplotlib/examples/tests/backend_driver.py 2008-09-01 21:06:34 UTC (rev 6057)
@@ -66,6 +66,7 @@
'image_demo2.py',
'image_masked.py',
'image_origin.py',
+ 'image_nonuniform.py',
'invert_axes.py',
'layer_images.py',
'legend_auto.py',
Modified: trunk/matplotlib/lib/matplotlib/image.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/image.py 2008-08-30 10:11:37 UTC (rev 6056)
+++ trunk/matplotlib/lib/matplotlib/image.py 2008-09-01 21:06:34 UTC (rev 6057)
@@ -392,13 +392,14 @@
def __init__(self, ax,
**kwargs
):
+ interp = kwargs.pop('interpolation', 'nearest')
AxesImage.__init__(self, ax,
**kwargs)
+ AxesImage.set_interpolation(self, interp)
def make_image(self, magnification=1.0):
if self._A is None:
raise RuntimeError('You must first set the image array')
-
x0, y0, v_width, v_height = self.axes.viewLim.bounds
l, b, r, t = self.axes.bbox.extents
width = (round(r) + 0.5) - (round(l) - 0.5)
@@ -407,10 +408,13 @@
height *= magnification
im = _image.pcolor(self._Ax, self._Ay, self._A,
height, width,
- (x0, x0+v_width, y0, y0+v_height))
+ (x0, x0+v_width, y0, y0+v_height),
+ self._interpd[self._interpolation])
+
fc = self.axes.patch.get_facecolor()
bg = mcolors.colorConverter.to_rgba(fc, 0)
im.set_bg(*bg)
+ im.is_grayscale = self.is_grayscale
return im
def set_data(self, x, y, A):
@@ -430,9 +434,11 @@
if len(A.shape) == 2:
if A.dtype != np.uint8:
A = (self.cmap(self.norm(A))*255).astype(np.uint8)
+ self.is_grayscale = self.cmap.is_gray()
else:
A = np.repeat(A[:,:,np.newaxis], 4, 2)
A[:,:,3] = 255
+ self.is_grayscale = True
else:
if A.dtype != np.uint8:
A = (255*A).astype(np.uint8)
@@ -441,6 +447,7 @@
B[:,:,0:3] = A
B[:,:,3] = 255
A = B
+ self.is_grayscale = False
self._A = A
self._Ax = x
self._Ay = y
@@ -450,8 +457,8 @@
raise NotImplementedError('Method not supported')
def set_interpolation(self, s):
- if s != None and s != 'nearest':
- raise NotImplementedError('Only nearest neighbor supported')
+ if s != None and not s in ('nearest','bilinear'):
+ raise NotImplementedError('Only nearest neighbor and bilinear interpolations are supported')
AxesImage.set_interpolation(self, s)
def get_extent(self):
Modified: trunk/matplotlib/src/_image.cpp
===================================================================
--- trunk/matplotlib/src/_image.cpp 2008-08-30 10:11:37 UTC (rev 6056)
+++ trunk/matplotlib/src/_image.cpp 2008-09-01 21:06:34 UTC (rev 6057)
@@ -1138,21 +1138,211 @@
return Py::asObject(imo);
}
+// utilities for irregular grids
+void _bin_indices_middle(unsigned int *irows, int nrows, float *ys1, int ny,float dy, float y_min)
+{ int i,j, j_last;
+ unsigned int * rowstart = irows;
+ float *ys2 = ys1+1;
+ float *yl = ys1 + ny ;
+ float yo = y_min + dy/2.0;
+ float ym = 0.5f*(*ys1 + *ys2);
+ // y/rows
+ j = 0;
+ j_last = j;
+ for (i=0;i<nrows;i++,yo+=dy,rowstart++) {
+ while(ys2 != yl && yo > ym) {
+ ys1 = ys2;
+ ys2 = ys1+1;
+ ym = 0.5f*(*ys1 + *ys2);
+ j++;
+ }
+ *rowstart = j - j_last;
+ j_last = j;
+ }
+}
+void _bin_indices_middle_linear(float *arows, unsigned int *irows, int nrows, float *y, int ny,float dy, float y_min)
+{ int i;
+ int ii = 0;
+ int iilast = ny-1;
+ float sc = 1/dy;
+ int iy0 = (int)floor(sc * (y[ii] - y_min) );
+ int iy1 = (int)floor(sc * (y[ii+1] - y_min) );
+ float invgap=1.0f/(iy1-iy0);
+ for (i=0; i<nrows && i<=iy0; i++) {
+ irows[i] = 0;
+ arows[i] = 1.0;
+ //std::cerr<<"i="<<i<<" ii="<<0<<" a="<< arows[i]<< std::endl;
+ }
+ for (; i<nrows; i++) {
+ while (i > iy1 && ii < iilast) {
+ ii++;
+ iy0 = iy1;
+ iy1 = (int)floor(sc * (y[ii+1] - y_min));
+ invgap=1.0f/(iy1-iy0);
+ }
+ if (i >= iy0 && i <= iy1) {
+ irows[i] = ii;
+ arows[i]=(iy1-i)*invgap;
+ //std::cerr<<"i="<<i<<" ii="<<ii<<" a="<< arows[i]<< std::endl;
+ }
+ else break;
+ }
+ for (; i<nrows; i++) {
+ irows[i] =iilast-1;
+ arows[i] = 0.0;
+ //std::cerr<<"i="<<i<<" ii="<<iilast-1<<" a="<< arows[i]<< std::endl;
+ }
+}
+
+void _bin_indices(int *irows, int nrows, double *y, int ny,
+ double sc, double offs)
+{
+ int i;
+ if (sc*(y[ny-1] - y[0]) > 0)
+ {
+ int ii = 0;
+ int iilast = ny-1;
+ int iy0 = (int)floor(sc * (y[ii] - offs));
+ int iy1 = (int)floor(sc * (y[ii+1] - offs));
+ for (i=0; i<nrows && i<iy0; i++) {
+ irows[i] = -1;
+ }
+ for (; i<nrows; i++) {
+ while (i > iy1 && ii < iilast) {
+ ii++;
+ iy0 = iy1;
+ iy1 = (int)floor(sc * (y[ii+1] - offs));
+ }
+ if (i >= iy0 && i <= iy1) irows[i] = ii;
+ else break;
+ }
+ for (; i<nrows; i++) {
+ irows[i] = -1;
+ }
+ }
+ else
+ {
+ int iilast = ny-1;
+ int ii = iilast;
+ int iy0 = (int)floor(sc * (y[ii] - offs));
+ int iy1 = (int)floor(sc * (y[ii-1] - offs));
+ for (i=0; i<nrows && i<iy0; i++) {
+ irows[i] = -1;
+ }
+ for (; i<nrows; i++) {
+ while (i > iy1 && ii > 1) {
+ ii--;
+ iy0 = iy1;
+ iy1 = (int)floor(sc * (y[ii-1] - offs));
+ }
+ if (i >= iy0 && i <= iy1) irows[i] = ii-1;
+ else break;
+ }
+ for (; i<nrows; i++) {
+ irows[i] = -1;
+ }
+ }
+}
+
+void _bin_indices_linear(float *arows, int *irows, int nrows, double *y, int ny,
+ double sc, double offs)
+{
+ int i;
+ if (sc*(y[ny-1] - y[0]) > 0)
+ {
+ int ii = 0;
+ int iilast = ny-1;
+ int iy0 = (int)floor(sc * (y[ii] - offs));
+ int iy1 = (int)floor(sc * (y[ii+1] - offs));
+ float invgap=1.0/(iy1-iy0);
+ for (i=0; i<nrows && i<iy0; i++) {
+ irows[i] = -1;
+ }
+ for (; i<nrows; i++) {
+ while (i > iy1 && ii < iilast) {
+ ii++;
+ iy0 = iy1;
+ iy1 = (int)floor(sc * (y[ii+1] - offs));
+ invgap=1.0/(iy1-iy0);
+ }
+ if (i >= iy0 && i <= iy1) {
+ irows[i] = ii;
+ arows[i]=(iy1-i)*invgap;
+ }
+ else break;
+ }
+ for (; i<nrows; i++) {
+ irows[i] = -1;
+ }
+ }
+ else
+ {
+ int iilast = ny-1;
+ int ii = iilast;
+ int iy0 = (int)floor(sc * (y[ii] - offs));
+ int iy1 = (int)floor(sc * (y[ii-1] - offs));
+ float invgap=1.0/(iy1-iy0);
+ for (i=0; i<nrows && i<iy0; i++) {
+ irows[i] = -1;
+ }
+ for (; i<nrows; i++) {
+ while (i > iy1 && ii > 1) {
+ ii--;
+ iy0 = iy1;
+ iy1 = (int)floor(sc * (y[ii-1] - offs));
+ invgap=1.0/(iy1-iy0);
+ }
+ if (i >= iy0 && i <= iy1) {
+ irows[i] = ii-1;
+ arows[i]=(i-iy0)*invgap;
+ }
+ else break;
+ }
+ for (; i<nrows; i++) {
+ irows[i] = -1;
+ }
+ }
+}
+
+
+
char __image_module_pcolor__doc__[] =
"pcolor(x, y, data, rows, cols, bounds)\n"
"\n"
-"Generate a psudo-color image from data on a non-univorm grid using\n"
-"nearest neighbour interpolation.\n"
+"Generate a pseudo-color image from data on a non-uniform grid using\n"
+"nearest neighbour or linear interpolation.\n"
"bounds = (x_min, x_max, y_min, y_max)\n"
+"interpolation = NEAREST or BILINEAR \n"
;
+
+void _pcolor_cleanup(PyArrayObject* x, PyArrayObject* y, PyArrayObject *d,
+ unsigned int * rowstarts ,unsigned int*colstarts ,
+ float *acols , float *arows) {
+ if (x)
+ Py_XDECREF(x);
+ if (y)
+ Py_XDECREF(y);
+ if(d)
+ Py_XDECREF(d);
+ if(rowstarts)
+ PyMem_Free(rowstarts);
+ if(colstarts)
+ PyMem_Free(colstarts);
+ if(acols)
+ PyMem_Free(acols);
+ if(arows)
+ PyMem_Free(arows);
+ return;
+}
+
Py::Object
_image_module::pcolor(const Py::Tuple& args) {
_VERBOSE("_image_module::pcolor");
- if (args.length() != 6)
- throw Py::TypeError("Incorrect number of arguments (6 expected)");
+ if (args.length() != 7)
+ throw Py::TypeError("Incorrect number of arguments (7 expected)");
Py::Object xp = args[0];
Py::Object yp = args[1];
@@ -1160,6 +1350,7 @@
unsigned int rows = Py::Int(args[3]);
unsigned int cols = Py::Int(args[4]);
Py::Tuple bounds = args[5];
+ unsigned int interpolation = Py::Int(args[6]);
if (rows > 1 << 15 || cols > 1 << 15) {
throw Py::ValueError("rows and cols must both be less than 32768");
@@ -1179,26 +1370,29 @@
// Check we have something to output to
if (rows == 0 || cols ==0)
throw Py::ValueError("Cannot scale to zero size");
-
+
+ PyArrayObject *x = NULL; PyArrayObject *y = NULL; PyArrayObject *d = NULL;
+ unsigned int * rowstarts = NULL; unsigned int*colstarts = NULL;
+ float *acols = NULL; float *arows = NULL;
+
// Get numpy arrays
- PyArrayObject *x = (PyArrayObject *) PyArray_ContiguousFromObject(xp.ptr(), PyArray_FLOAT, 1, 1);
- if (x == NULL)
+ x = (PyArrayObject *) PyArray_ContiguousFromObject(xp.ptr(), PyArray_FLOAT, 1, 1);
+ if (x == NULL) {
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::ValueError("x is of incorrect type (wanted 1D float)");
- PyArrayObject *y = (PyArrayObject *) PyArray_ContiguousFromObject(yp.ptr(), PyArray_FLOAT, 1, 1);
+ }
+ y = (PyArrayObject *) PyArray_ContiguousFromObject(yp.ptr(), PyArray_FLOAT, 1, 1);
if (y == NULL) {
- Py_XDECREF(x);
- throw Py::ValueError("y is of incorrect type (wanted 1D float)");
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
+ throw Py::ValueError("y is of incorrect type (wanted 1D float)");
}
- PyArrayObject *d = (PyArrayObject *) PyArray_ContiguousFromObject(dp.ptr(), PyArray_UBYTE, 3, 3);
+ d = (PyArrayObject *) PyArray_ContiguousFromObject(dp.ptr(), PyArray_UBYTE, 3, 3);
if (d == NULL) {
- Py_XDECREF(x);
- Py_XDECREF(y);
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::ValueError("data is of incorrect type (wanted 3D UInt8)");
}
if (d->dimensions[2] != 4) {
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(d);
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::ValueError("data must be in RGBA format");
}
@@ -1206,26 +1400,21 @@
int nx = x->dimensions[0];
int ny = y->dimensions[0];
if (nx != d->dimensions[1] || ny != d->dimensions[0]) {
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(d);
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::ValueError("data and axis dimensions do not match");
}
// Allocate memory for pointer arrays
- unsigned int * rowstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*rows));
- if (rowstarts == NULL) {
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(d);
+ rowstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*rows));
+ arows = reinterpret_cast<float *>(PyMem_Malloc(sizeof(float)*rows));
+ if (rowstarts == NULL || arows == NULL ) {
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::MemoryError("Cannot allocate memory for lookup table");
}
- unsigned int * colstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int*)*cols));
- if (colstarts == NULL) {
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(d);
- PyMem_Free(rowstarts);
+ colstarts = reinterpret_cast<unsigned int*>(PyMem_Malloc(sizeof(unsigned int)*cols));
+ acols = reinterpret_cast<float*>(PyMem_Malloc(sizeof(float)*cols));
+ if (colstarts == NULL || acols == NULL) {
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::MemoryError("Cannot allocate memory for lookup table");
}
@@ -1238,54 +1427,17 @@
size_t NUMBYTES(rows * cols * 4);
agg::int8u *buffer = new agg::int8u[NUMBYTES];
if (buffer == NULL) {
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(d);
- PyMem_Free(rowstarts);
- PyMem_Free(colstarts);
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
throw Py::MemoryError("Could not allocate memory for image");
}
+
// Calculate the pointer arrays to map input x to output x
- unsigned int i, j, j_last;
+ unsigned int i, j;
unsigned int * colstart = colstarts;
unsigned int * rowstart = rowstarts;
float *xs1 = reinterpret_cast<float*>(x->data);
float *ys1 = reinterpret_cast<float*>(y->data);
- float *xs2 = xs1+1;
- float *ys2 = ys1+1;
- float *xl = xs1 + nx - 1;
- float *yl = ys1 + ny - 1;
- float xo = x_min + dx/2.0;
- float yo = y_min + dy/2.0;
- float xm = 0.5*(*xs1 + *xs2);
- float ym = 0.5*(*ys1 + *ys2);
- // x/cols
- j = 0;
- j_last = j;
- for (i=0;i<cols;i++,xo+=dx,colstart++) {
- while(xs2 != xl && xo > xm) {
- xs1 = xs2;
- xs2 = xs1+1;
- xm = 0.5f*(*xs1 + *xs2);
- j++;
- }
- *colstart = j - j_last;
- j_last = j;
- }
- // y/rows
- j = 0;
- j_last = j;
- for (i=0;i<rows;i++,yo+=dy,rowstart++) {
- while(ys2 != yl && yo > ym) {
- ys1 = ys2;
- ys2 = ys1+1;
- ym = 0.5f*(*ys1 + *ys2);
- j++;
- }
- *rowstart = j - j_last;
- j_last = j;
- }
// Copy data to output buffer
@@ -1297,87 +1449,82 @@
agg::int8u * position = buffer;
agg::int8u * oldposition = NULL;
start = reinterpret_cast<unsigned char*>(d->data);
- for(i=0;i<rows;i++,rowstart++)
- {
- if (i > 0 && *rowstart == 0) {
- memcpy(position, oldposition, rowsize*sizeof(agg::int8u));
- oldposition = position;
- position += rowsize;
- } else {
- oldposition = position;
- start += *rowstart * inrowsize;
- inposition = start;
- for(j=0,colstart=colstarts;j<cols;j++,position+=4,colstart++) {
- inposition += *colstart * 4;
- memcpy(position, inposition, 4*sizeof(agg::int8u));
+ int s0 = d->strides[0];
+ int s1 = d->strides[1];
+
+ if(interpolation == Image::NEAREST) {
+ _bin_indices_middle(colstart, cols, xs1, nx,dx,x_min);
+ _bin_indices_middle(rowstart, rows, ys1, ny, dy,y_min);
+ for(i=0;i<rows;i++,rowstart++)
+ {
+ if (i > 0 && *rowstart == 0) {
+ memcpy(position, oldposition, rowsize*sizeof(agg::int8u));
+ oldposition = position;
+ position += rowsize;
+ } else {
+ oldposition = position;
+ start += *rowstart * inrowsize;
+ inposition = start;
+ for(j=0,colstart=colstarts;j<cols;j++,position+=4,colstart++) {
+ inposition += *colstart * 4;
+ memcpy(position, inposition, 4*sizeof(agg::int8u));
+ }
}
}
}
+ else if(interpolation == Image::BILINEAR) {
+ _bin_indices_middle_linear(acols, colstart, cols, xs1, nx,dx,x_min);
+ _bin_indices_middle_linear(arows, rowstart, rows, ys1, ny, dy,y_min);
+ double a00,a01,a10,a11,alpha,beta;
+
+
+ agg::int8u * start00;
+ agg::int8u * start01;
+ agg::int8u * start10;
+ agg::int8u * start11;
+ // Copy data to output buffer
+ for (i=0; i<rows; i++)
+ {
+ for (j=0; j<cols; j++)
+ {
+ alpha=arows[i];
+ beta=acols[j];
+
+ a00=alpha*beta;
+ a01=alpha*(1.0-beta);
+ a10=(1.0-alpha)*beta;
+ a11=1.0-a00-a01-a10;
+
+ start00=(agg::int8u *)(start + s0*rowstart[i] + s1*colstart[j]);
+ start01=start00+s1;
+ start10=start00+s0;
+ start11=start10+s1;
+ position[0] =(agg::int8u)(start00[0]*a00+start01[0]*a01+start10[0]*a10+start11[0]*a11);
+ position[1] =(agg::int8u)(start00[1]*a00+start01[1]*a01+start10[1]*a10+start11[1]*a11);
+ position[2] =(agg::int8u)(start00[2]*a00+start01[2]*a01+start10[2]*a10+start11[2]*a11);
+ position[3] =(agg::int8u)(start00[3]*a00+start01[3]*a01+start10[3]*a10+start11[3]*a11);
+ position += 4;
+ }
+ }
+
+ }
+
// Attatch output buffer to output buffer
imo->rbufOut = new agg::rendering_buffer;
imo->bufferOut = buffer;
imo->rbufOut->attach(imo->bufferOut, imo->colsOut, imo->rowsOut, imo->colsOut * imo->BPP);
- Py_XDECREF(x);
- Py_XDECREF(y);
- Py_XDECREF(d);
- PyMem_Free(rowstarts);
- PyMem_Free(colstarts);
+
+ _pcolor_cleanup(x,y,d,rowstarts,colstarts,acols,arows);
return Py::asObject(imo);
-}
+
-void _bin_indices(int *irows, int nrows, double *y, int ny,
- double sc, double offs)
-{
- int i;
- if (sc*(y[ny-1] - y[0]) > 0)
- {
- int ii = 0;
- int iilast = ny-1;
- int iy0 = (int)floor(sc * (y[ii] - offs));
- int iy1 = (int)floor(sc * (y[ii+1] - offs));
- for (i=0; i<nrows && i<iy0; i++) {
- irows[i] = -1;
- }
- for (; i<nrows; i++) {
- while (i > iy1 && ii < iilast) {
- ii++;
- iy0 = iy1;
- iy1 = (int)floor(sc * (y[ii+1] - offs));
- }
- if (i >= iy0 && i <= iy1) irows[i] = ii;
- else break;
- }
- for (; i<nrows; i++) {
- irows[i] = -1;
- }
- }
- else
- {
- int iilast = ny-1;
- int ii = iilast;
- int iy0 = (int)floor(sc * (y[ii] - offs));
- int iy1 = (int)floor(sc * (y[ii-1] - offs));
- for (i=0; i<nrows && i<iy0; i++) {
- irows[i] = -1;
- }
- for (; i<nrows; i++) {
- while (i > iy1 && ii > 1) {
- ii--;
- iy0 = iy1;
- iy1 = (int)floor(sc * (y[ii-1] - offs));
- }
- if (i >= iy0 && i <= iy1) irows[i] = ii-1;
- else break;
- }
- for (; i<nrows; i++) {
- irows[i] = -1;
- }
- }
+
}
+
char __image_module_pcolor2__doc__[] =
"pcolor2(x, y, data, rows, cols, bounds, bg)\n"
"\n"
@@ -1477,7 +1624,7 @@
Py_XDECREF(bg);
throw Py::MemoryError("Cannot allocate memory for lookup table");
}
- int * jcols = reinterpret_cast<int*>(PyMem_Malloc(sizeof(int*)*cols));
+ int * jcols = reinterpret_cast<int*>(PyMem_Malloc(sizeof(int)*cols));
if (jcols == NULL) {
Py_XDECREF(x);
Py_XDECREF(y);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-08-30 10:11:40
|
Revision: 6056
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6056&view=rev
Author: mmetz_bn
Date: 2008-08-30 10:11:37 +0000 (Sat, 30 Aug 2008)
Log Message:
-----------
fix problem with hist
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py
Modified: trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2008-08-28 13:50:39 UTC (rev 6055)
+++ trunk/matplotlib/examples/pylab_examples/mri_with_eeg.py 2008-08-30 10:11:37 UTC (rev 6056)
@@ -24,7 +24,7 @@
if 1: # plot the histogram of MRI intensity
subplot(222)
im = ravel(im)
- im = take(im, nonzero(im)) # ignore the background
+ im = ravel(take(im, nonzero(im))) # ignore the background
im = im/(2.0**15) # normalize
hist(im, 100)
xticks([-1, -.5, 0, .5, 1])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-08-28 13:50:42
|
Revision: 6055
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6055&view=rev
Author: mmetz_bn
Date: 2008-08-28 13:50:39 +0000 (Thu, 28 Aug 2008)
Log Message:
-----------
support for multi-hist with different length
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py
trunk/matplotlib/lib/matplotlib/axes.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-08-28 13:12:46 UTC (rev 6054)
+++ trunk/matplotlib/CHANGELOG 2008-08-28 13:50:39 UTC (rev 6055)
@@ -1,3 +1,6 @@
+2008-08-28 Added support for multiple histograms with data of
+ different length - MM
+
2008-08-28 Fix step plots with log scale - MGD
2008-08-28 Fix masked arrays with markers in non-Agg backends - MGD
Modified: trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2008-08-28 13:12:46 UTC (rev 6054)
+++ trunk/matplotlib/examples/pylab_examples/histogram_demo_extended.py 2008-08-28 13:50:39 UTC (rev 6055)
@@ -78,5 +78,16 @@
n, bins, patches = P.hist(x, 10, normed=1, histtype='barstacked')
+#
+# finally: make a multiple-histogram of data-sets with different length
+#
+x0 = mu + sigma*P.randn(10000)
+x1 = mu + sigma*P.randn(7000)
+x2 = mu + sigma*P.randn(3000)
+P.figure()
+
+n, bins, patches = P.hist( [x0,x1,x2], 10, histtype='bar')
+
+
P.show()
\ No newline at end of file
Modified: trunk/matplotlib/lib/matplotlib/axes.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/axes.py 2008-08-28 13:12:46 UTC (rev 6054)
+++ trunk/matplotlib/lib/matplotlib/axes.py 2008-08-28 13:50:39 UTC (rev 6055)
@@ -6157,7 +6157,7 @@
- 'step' generates a lineplot that is by default
unfilled
- - 'stepfilled' generates a lineplot that this by default
+ - 'stepfilled' generates a lineplot that is by default
filled.
*align*: ['left' | 'mid' | 'right' ]
@@ -6209,26 +6209,27 @@
raise DeprecationWarning(
'hist now uses the rwidth to give relative width and not absolute width')
- # todo: make hist() work with list of arrays with different lengths
- x = np.asarray(x).copy()
- if len(x.shape)==2 and min(x.shape)==1:
- x.shape = max(x.shape),
+ try:
+ x = np.transpose(np.asarray(x).copy())
+ if len(x.shape)==1:
+ x.shape = (1,x.shape[0])
+ elif len(x.shape)==2 and x.shape[1]<x.shape[0]:
+ warnings.warn('2D hist should be nsamples x nvariables; this looks transposed')
+ except ValueError:
+ # multiple hist with data of different length
+ if iterable(x[0]) and not is_string_like(x[0]):
+ tx = []
+ for i in xrange(len(x)):
+ tx.append( np.asarray(x[i]).copy() )
+ x = tx
- if len(x.shape)==2 and x.shape[0]<x.shape[1]:
- warnings.warn('2D hist should be nsamples x nvariables; this looks transposed')
-
- if len(x.shape)==2:
- n = []
- for i in xrange(x.shape[1]):
- # this will automatically overwrite bins,
- # so that each histogram uses the same bins
- m, bins = np.histogram(x[:,i], bins, range=range,
- normed=bool(normed), new=True)
- n.append(m)
- else:
- n, bins = np.histogram(x, bins, range=range,
+ n = []
+ for i in xrange(len(x)):
+ # this will automatically overwrite bins,
+ # so that each histogram uses the same bins
+ m, bins = np.histogram(x[i], bins, range=range,
normed=bool(normed), new=True)
- n = [n,]
+ n.append(m)
if cumulative:
slc = slice(None)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-08-28 13:12:50
|
Revision: 6054
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6054&view=rev
Author: mdboom
Date: 2008-08-28 13:12:46 +0000 (Thu, 28 Aug 2008)
Log Message:
-----------
Fix step plots with log scale
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/lines.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-08-28 12:45:37 UTC (rev 6053)
+++ trunk/matplotlib/CHANGELOG 2008-08-28 13:12:46 UTC (rev 6054)
@@ -1,3 +1,5 @@
+2008-08-28 Fix step plots with log scale - MGD
+
2008-08-28 Fix masked arrays with markers in non-Agg backends - MGD
2008-08-28 Fix clip_on kwarg so it actually works correctly - MGD
Modified: trunk/matplotlib/lib/matplotlib/lines.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/lines.py 2008-08-28 12:45:37 UTC (rev 6053)
+++ trunk/matplotlib/lib/matplotlib/lines.py 2008-08-28 13:12:46 UTC (rev 6054)
@@ -14,7 +14,7 @@
from cbook import iterable, is_string_like, is_numlike, ls_mapper, dedent
from colors import colorConverter
from path import Path
-from transforms import Affine2D, Bbox, TransformedPath
+from transforms import Affine2D, Bbox, TransformedPath, IdentityTransform
from matplotlib import rcParams
# special-purpose marker identifiers:
@@ -675,7 +675,8 @@
steps[0::2, 1], steps[1:-1:2, 1] = vertices[:, 1], vertices[1:, 1]
path = Path(steps)
- self._draw_solid(renderer, gc, path, trans)
+ path = path.transformed(self.get_transform())
+ self._draw_solid(renderer, gc, path, IdentityTransform())
def _draw_steps_post(self, renderer, gc, path, trans):
@@ -686,7 +687,8 @@
steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:-1, 1]
path = Path(steps)
- self._draw_solid(renderer, gc, path, trans)
+ path = path.transformed(self.get_transform())
+ self._draw_solid(renderer, gc, path, IdentityTransform())
def _draw_steps_mid(self, renderer, gc, path, trans):
@@ -700,7 +702,8 @@
steps[0::2, 1], steps[1::2, 1] = vertices[:, 1], vertices[:, 1]
path = Path(steps)
- self._draw_solid(renderer, gc, path, trans)
+ path = path.transformed(self.get_transform())
+ self._draw_solid(renderer, gc, path, IdentityTransform())
def _draw_dashed(self, renderer, gc, path, trans):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-08-28 12:45:40
|
Revision: 6053
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6053&view=rev
Author: mdboom
Date: 2008-08-28 12:45:37 +0000 (Thu, 28 Aug 2008)
Log Message:
-----------
Fix clip_on kwarg to work correctly.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backend_bases.py
trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-08-28 12:42:52 UTC (rev 6052)
+++ trunk/matplotlib/CHANGELOG 2008-08-28 12:45:37 UTC (rev 6053)
@@ -1,3 +1,5 @@
+2008-08-28 Fix masked arrays with markers in non-Agg backends - MGD
+
2008-08-28 Fix clip_on kwarg so it actually works correctly - MGD
2008-08-25 Fix locale problems in SVG backend - MGD
Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-08-28 12:42:52 UTC (rev 6052)
+++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2008-08-28 12:45:37 UTC (rev 6053)
@@ -97,10 +97,12 @@
once and reuse it multiple times.
"""
tpath = trans.transform_path(path)
- for x, y in tpath.vertices:
- self.draw_path(gc, marker_path,
- marker_trans + transforms.Affine2D().translate(x, y),
- rgbFace)
+ for vertices, codes in tpath.iter_segments():
+ if len(vertices):
+ x,y = vertices[-2:]
+ self.draw_path(gc, marker_path,
+ marker_trans + transforms.Affine2D().translate(x, y),
+ rgbFace)
def draw_path_collection(self, master_transform, cliprect, clippath,
clippath_trans, paths, all_transforms, offsets,
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-08-28 12:42:52 UTC (rev 6052)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2008-08-28 12:45:37 UTC (rev 6053)
@@ -1247,11 +1247,13 @@
output(Op.gsave)
lastx, lasty = 0, 0
- for x, y in tpath.vertices:
- dx, dy = x - lastx, y - lasty
- output(1, 0, 0, 1, dx, dy, Op.concat_matrix,
- marker, Op.use_xobject)
- lastx, lasty = x, y
+ for vertices, code in tpath.iter_segments():
+ if len(vertices):
+ x, y = vertices[-2:]
+ dx, dy = x - lastx, y - lasty
+ output(1, 0, 0, 1, dx, dy, Op.concat_matrix,
+ marker, Op.use_xobject)
+ lastx, lasty = x, y
output(Op.grestore)
def _setup_textpos(self, x, y, angle, oldx=0, oldy=0, oldangle=0):
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-08-28 12:42:52 UTC (rev 6052)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2008-08-28 12:45:37 UTC (rev 6053)
@@ -510,8 +510,10 @@
ps_cmd.extend(['stroke', 'grestore', '} bind def'])
tpath = trans.transform_path(path)
- for x, y in tpath.vertices:
- ps_cmd.append("%g %g o" % (x, y))
+ for vertices, code in tpath.iter_segments():
+ if len(vertices):
+ x, y = vertices[-2:]
+ ps_cmd.append("%g %g o" % (x, y))
ps = '\n'.join(ps_cmd)
self._draw_ps(ps, gc, rgbFace, fill=False, stroke=False)
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-28 12:42:52 UTC (rev 6052)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-28 12:45:37 UTC (rev 6053)
@@ -209,10 +209,12 @@
write('<g %s>' % clippath)
trans_and_flip = self._make_flip_transform(trans)
tpath = trans_and_flip.transform_path(path)
- for x, y in tpath.vertices:
- details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y)
- style = self._get_style(gc, rgbFace)
- self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details))
+ for vertices, code in tpath.iter_segments():
+ if len(vertices):
+ x, y = vertices[-2:]
+ details = 'xlink:href="#%s" x="%f" y="%f"' % (name, x, y)
+ style = self._get_style(gc, rgbFace)
+ self._svgwriter.write ('<use style="%s" %s/>\n' % (style, details))
write('</g>')
def draw_path_collection(self, master_transform, cliprect, clippath,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-08-28 12:42:55
|
Revision: 6052
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6052&view=rev
Author: mdboom
Date: 2008-08-28 12:42:52 +0000 (Thu, 28 Aug 2008)
Log Message:
-----------
Fix clip_on kwarg to work correctly.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/artist.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-08-26 13:24:00 UTC (rev 6051)
+++ trunk/matplotlib/CHANGELOG 2008-08-28 12:42:52 UTC (rev 6052)
@@ -1,3 +1,5 @@
+2008-08-28 Fix clip_on kwarg so it actually works correctly - MGD
+
2008-08-25 Fix locale problems in SVG backend - MGD
2008-08-22 fix quiver so masked values are not plotted - JSW
Modified: trunk/matplotlib/lib/matplotlib/artist.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/artist.py 2008-08-26 13:24:00 UTC (rev 6051)
+++ trunk/matplotlib/lib/matplotlib/artist.py 2008-08-28 12:42:52 UTC (rev 6052)
@@ -39,7 +39,7 @@
self._alpha = 1.0
self.clipbox = None
self._clippath = None
- self._clipon = False
+ self._clipon = True
self._lod = False
self._label = ''
self._picker = None
@@ -292,7 +292,6 @@
ACCEPTS: a :class:`matplotlib.transform.Bbox` instance
"""
self.clipbox = clipbox
- self._clipon = clipbox is not None or self._clippath is not None
self.pchanged()
def set_clip_path(self, path, transform=None):
@@ -341,7 +340,6 @@
print type(path), type(transform)
raise TypeError("Invalid arguments to set_clip_path")
- self._clipon = self.clipbox is not None or self._clippath is not None
self.pchanged()
def get_alpha(self):
@@ -361,7 +359,7 @@
def get_clip_on(self):
'Return whether artist uses clipping'
- return self._clipon and (self.clipbox is not None or self._clippath is not None)
+ return self._clipon
def get_clip_box(self):
'Return artist clipbox'
@@ -388,16 +386,17 @@
ACCEPTS: [True | False]
"""
self._clipon = b
- if not b:
- self.clipbox = None
- self._clippath = None
self.pchanged()
def _set_gc_clip(self, gc):
'set the clip properly for the gc'
- if self.clipbox is not None:
- gc.set_clip_rectangle(self.clipbox)
- gc.set_clip_path(self._clippath)
+ if self._clipon:
+ if self.clipbox is not None:
+ gc.set_clip_rectangle(self.clipbox)
+ gc.set_clip_path(self._clippath)
+ else:
+ gc.set_clip_rectangle(None)
+ gc.set_clip_path(None)
def draw(self, renderer, *args, **kwargs):
'Derived classes drawing method'
@@ -511,7 +510,7 @@
def findobj(self, match=None):
"""
pyplot signature:
- findobj(o=gcf(), match=None)
+ findobj(o=gcf(), match=None)
recursively find all :class:matplotlib.artist.Artist instances
contained in self
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jd...@us...> - 2008-08-26 13:24:03
|
Revision: 6051
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6051&view=rev
Author: jdh2358
Date: 2008-08-26 13:24:00 +0000 (Tue, 26 Aug 2008)
Log Message:
-----------
some fixes for exceltools
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/mlab.py
trunk/matplotlib/lib/mpl_toolkits/exceltools.py
Modified: trunk/matplotlib/lib/matplotlib/mlab.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/mlab.py 2008-08-25 22:21:49 UTC (rev 6050)
+++ trunk/matplotlib/lib/matplotlib/mlab.py 2008-08-26 13:24:00 UTC (rev 6051)
@@ -1818,16 +1818,23 @@
#helpers for loading, saving, manipulating and viewing numpy record arrays
+
def safe_isnan(x):
'isnan for arbitrary types'
+ if cbook.is_string_like(x):
+ return False
try: b = np.isnan(x)
except NotImplementedError: return False
+ except TypeError: return False
else: return b
def safe_isinf(x):
'isnan for arbitrary types'
+ if cbook.is_string_like(x):
+ return False
try: b = np.isinf(x)
except NotImplementedError: return False
+ except TypeError: return False
else: return b
def rec_append_field(rec, name, arr, dtype=None):
Modified: trunk/matplotlib/lib/mpl_toolkits/exceltools.py
===================================================================
--- trunk/matplotlib/lib/mpl_toolkits/exceltools.py 2008-08-25 22:21:49 UTC (rev 6050)
+++ trunk/matplotlib/lib/mpl_toolkits/exceltools.py 2008-08-26 13:24:00 UTC (rev 6051)
@@ -20,7 +20,7 @@
"""
import copy
-import numpy as npy
+import numpy as np
import pyExcelerator as excel
import matplotlib.cbook as cbook
import matplotlib.mlab as mlab
@@ -97,7 +97,7 @@
rownum+=1
- ind = npy.arange(len(r.dtype.names))
+ ind = np.arange(len(r.dtype.names))
for row in r:
for i in ind:
val = row[i]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-08-25 22:21:56
|
Revision: 6050
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6050&view=rev
Author: mdboom
Date: 2008-08-25 22:21:49 +0000 (Mon, 25 Aug 2008)
Log Message:
-----------
Fix locale problems in SVG backend (thanks, Mathieu Leplatre for reporting)
Modified Paths:
--------------
branches/v0_91_maint/CHANGELOG
branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
Modified: branches/v0_91_maint/CHANGELOG
===================================================================
--- branches/v0_91_maint/CHANGELOG 2008-08-25 22:14:33 UTC (rev 6049)
+++ branches/v0_91_maint/CHANGELOG 2008-08-25 22:21:49 UTC (rev 6050)
@@ -1,3 +1,5 @@
+2008-08-25 Fix locale issues in SVG backend - MGD
+
2008-08-01 Backported memory leak fixes in _ttconv.cpp - MGD
2008-07-24 Deprecated (raise NotImplementedError) all the mlab2
Modified: branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py
===================================================================
--- branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-08-25 22:14:33 UTC (rev 6049)
+++ branches/v0_91_maint/lib/matplotlib/backends/backend_svg.py 2008-08-25 22:21:49 UTC (rev 6050)
@@ -116,13 +116,13 @@
if seq is None:
dashes = ''
else:
- dashes = 'stroke-dasharray: %s; stroke-dashoffset: %s;' % (
- ','.join(['%s'%val for val in seq]), offset)
+ dashes = 'stroke-dasharray: %s; stroke-dashoffset: %f;' % (
+ ','.join(['%f'%val for val in seq]), offset)
linewidth = gc.get_linewidth()
if linewidth:
- return 'fill: %s; stroke: %s; stroke-width: %s; ' \
- 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %s' % (
+ return 'fill: %s; stroke: %s; stroke-width: %f; ' \
+ 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %f' % (
fill,
rgb2hex(gc.get_rgb()),
linewidth,
@@ -132,7 +132,7 @@
gc.get_alpha(),
)
else:
- return 'fill: %s; opacity: %s' % (\
+ return 'fill: %s; opacity: %f' % (\
fill,
gc.get_alpha(),
)
@@ -170,7 +170,7 @@
box = """\
<defs>
<clipPath id="%(key)s">
- <rect x="%(x)s" y="%(y)s" width="%(w)s" height="%(h)s"
+ <rect x="%(x)f" y="%(y)f" width="%(w)f" height="%(h)f"
style="%(style)s"/>
</clipPath>
</defs>
@@ -195,7 +195,7 @@
"""
Ignores angles for now
"""
- details = 'cx="%s" cy="%s" rx="%s" ry="%s" transform="rotate(%1.1f %s %s)"' % \
+ details = 'cx="%f" cy="%f" rx="%f" ry="%f" transform="rotate(%1.1f %f %f)"' % \
(x, self.height-y, width/2.0, height/2.0, -rotation, x, self.height-y)
self._draw_svg_element('ellipse', details, gc, rgbFace)
@@ -214,7 +214,7 @@
trans[4] += trans[0]
trans[5] += trans[3]
trans[5] = -trans[5]
- transstr = 'transform="matrix(%s %s %s %s %s %s)" '%tuple(trans)
+ transstr = 'transform="matrix(%f %f %f %f %f %f)" '%tuple(trans)
assert trans[1] == 0
assert trans[2] == 0
numrows,numcols = im.get_size()
@@ -258,12 +258,12 @@
hrefstr = filename
self._svgwriter.write (
- '<image x="%s" y="%s" width="%s" height="%s" '
+ '<image x="%f" y="%f" width="%f" height="%f" '
'xlink:href="%s" %s/>\n'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, hrefstr, transstr)
)
def draw_line(self, gc, x1, y1, x2, y2):
- details = 'd="M%s,%sL%s,%s"' % (x1, self.height-y1,
+ details = 'd="M%f,%fL%f,%f"' % (x1, self.height-y1,
x2, self.height-y2)
self._draw_svg_element('path', details, gc, None)
@@ -273,9 +273,9 @@
raise ValueError('x and y must be the same length')
y = self.height - y
- details = ['d="M%s,%s' % (x[0], y[0])]
+ details = ['d="M%f,%f' % (x[0], y[0])]
xys = zip(x[1:], y[1:])
- details.extend(['L%s,%s' % tup for tup in xys])
+ details.extend(['L%f,%f' % tup for tup in xys])
details.append('"')
details = ''.join(details)
self._draw_svg_element('path', details, gc, None)
@@ -285,12 +285,12 @@
self.draw_arc(gc, gc.get_rgb(), x, y, 1, 0, 0, 0, 0)
def draw_polygon(self, gc, rgbFace, points):
- details = 'points = "%s"' % ' '.join(['%s,%s'%(x,self.height-y)
+ details = 'points = "%s"' % ' '.join(['%f,%f'%(x,self.height-y)
for x, y in points])
self._draw_svg_element('polygon', details, gc, rgbFace)
def draw_rectangle(self, gc, rgbFace, x, y, width, height):
- details = 'width="%s" height="%s" x="%s" y="%s"' % (width, height, x,
+ details = 'width="%f" height="%f" x="%f" y="%f"' % (width, height, x,
self.height-y-height)
self._draw_svg_element('rect', details, gc, rgbFace)
@@ -319,12 +319,12 @@
write(path)
write('</defs>\n')
- svg = ['<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha())]
+ svg = ['<g style="fill: %s; opacity: %f" transform="' % (color, gc.get_alpha())]
if angle != 0:
- svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle))
+ svg.append('translate(%f,%f)rotate(%1.1f)' % (x,y,-angle))
elif x != 0 or y != 0:
- svg.append('translate(%s,%s)' % (x, y))
- svg.append('scale(%s)">\n' % (fontsize / self.FONT_SCALE))
+ svg.append('translate(%f,%f)' % (x, y))
+ svg.append('scale(%f)">\n' % (fontsize / self.FONT_SCALE))
cmap = font.get_charmap()
lastgind = None
@@ -347,7 +347,7 @@
svg.append('<use xlink:href="#%s"' % charnum)
if currx != 0:
- svg.append(' transform="translate(%s)"' %
+ svg.append(' transform="translate(%f)"' %
(currx * (self.FONT_SCALE / fontsize)))
svg.append('/>\n')
currx += (glyph.linearHoriAdvance / 65536.0) / (self.FONT_SCALE / fontsize)
@@ -358,16 +358,16 @@
fontfamily = font.family_name
fontstyle = prop.get_style()
- style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %s' %
+ style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %f' %
(fontsize, fontfamily,fontstyle, color, gc.get_alpha()))
if angle!=0:
- transform = 'transform="translate(%s,%s) rotate(%1.1f) translate(%s,%s)"' % (x,y,-angle,-x,-y)
+ transform = 'transform="translate(%f,%f) rotate(%1.1f) translate(%f,%f)"' % (x,y,-angle,-x,-y)
# Inkscape doesn't support rotate(angle x y)
else:
transform = ''
svg = """\
-<text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text>
+<text style="%(style)s" x="%(x)f" y="%(y)f" %(transform)s>%(thetext)s</text>
""" % locals()
write(svg)
@@ -389,17 +389,17 @@
currx, curry = 0.0, 0.0
for step in glyph.path:
if step[0] == 0: # MOVE_TO
- path_data.append("M%s %s" %
+ path_data.append("M%f %f" %
(step[1], -step[2]))
elif step[0] == 1: # LINE_TO
- path_data.append("l%s %s" %
+ path_data.append("l%f %f" %
(step[1] - currx, -step[2] - curry))
elif step[0] == 2: # CURVE3
- path_data.append("q%s %s %s %s" %
+ path_data.append("q%f %f %f %f" %
(step[1] - currx, -step[2] - curry,
step[3] - currx, -step[4] - curry))
elif step[0] == 3: # CURVE4
- path_data.append("c%s %s %s %s %s %s" %
+ path_data.append("c%f %f %f %f %f %f" %
(step[1] - currx, -step[2] - curry,
step[3] - currx, -step[4] - curry,
step[5] - currx, -step[6] - curry))
@@ -453,16 +453,16 @@
svg = ['<g style="%s" transform="' % style]
if angle != 0:
- svg.append('translate(%s,%s)rotate(%1.1f)'
+ svg.append('translate(%f,%f)rotate(%1.1f)'
% (x,y,-angle) )
else:
- svg.append('translate(%s,%s)' % (x, y))
+ svg.append('translate(%f,%f)' % (x, y))
svg.append('">\n')
for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:
charid = self._get_char_def_id(font, thetext)
- svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' %
+ svg.append('<use xlink:href="#%s" transform="translate(%f,%f)scale(%f)"/>\n' %
(charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE))
svg.append('</g>\n')
else: # not rcParams['svg.embed_char_paths']
@@ -481,15 +481,15 @@
svg.append('<tspan style="%s"' % style)
xadvance = metrics.advance
- svg.append(' textLength="%s"' % xadvance)
+ svg.append(' textLength="%f"' % xadvance)
dx = new_x - curr_x
if dx != 0.0:
- svg.append(' dx="%s"' % dx)
+ svg.append(' dx="%f"' % dx)
dy = new_y - curr_y
if dy != 0.0:
- svg.append(' dy="%s"' % dy)
+ svg.append(' dy="%f"' % dy)
thetext = escape_xml_text(thetext)
@@ -504,14 +504,14 @@
style = "fill: %s; stroke: none" % color
svg.append('<g style="%s" transform="' % style)
if angle != 0:
- svg.append('translate(%s,%s) rotate(%1.1f)'
+ svg.append('translate(%f,%f) rotate(%1.1f)'
% (x,y,-angle) )
else:
- svg.append('translate(%s,%s)' % (x, y))
+ svg.append('translate(%f,%f)' % (x, y))
svg.append('">\n')
for x, y, width, height in svg_rects:
- svg.append('<rect x="%s" y="%s" width="%s" height="%s" fill="black" stroke="none" />' % (x, -y + height, width, height))
+ svg.append('<rect x="%f" y="%f" width="%f" height="%f" fill="black" stroke="none" />' % (x, -y + height, width, height))
svg.append("</g>")
self.open_group("mathtext")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <md...@us...> - 2008-08-25 22:14:40
|
Revision: 6049
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6049&view=rev
Author: mdboom
Date: 2008-08-25 22:14:33 +0000 (Mon, 25 Aug 2008)
Log Message:
-----------
Fix locale problems in SVG backend (thanks, Mathieu Leplatre for reporting)
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-08-22 19:19:29 UTC (rev 6048)
+++ trunk/matplotlib/CHANGELOG 2008-08-25 22:14:33 UTC (rev 6049)
@@ -1,3 +1,5 @@
+2008-08-25 Fix locale problems in SVG backend - MGD
+
2008-08-22 fix quiver so masked values are not plotted - JSW
2008-08-18 improve interactive pan/zoom in qt4 backend on windows - DSD
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-22 19:19:29 UTC (rev 6048)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2008-08-25 22:14:33 UTC (rev 6049)
@@ -96,13 +96,13 @@
if seq is None:
dashes = ''
else:
- dashes = 'stroke-dasharray: %s; stroke-dashoffset: %s;' % (
- ','.join(['%s'%val for val in seq]), offset)
+ dashes = 'stroke-dasharray: %s; stroke-dashoffset: %f;' % (
+ ','.join(['%f'%val for val in seq]), offset)
linewidth = gc.get_linewidth()
if linewidth:
- return 'fill: %s; stroke: %s; stroke-width: %s; ' \
- 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %s' % (
+ return 'fill: %s; stroke: %s; stroke-width: %f; ' \
+ 'stroke-linejoin: %s; stroke-linecap: %s; %s opacity: %f' % (
fill,
rgb2hex(gc.get_rgb()[:3]),
linewidth,
@@ -112,7 +112,7 @@
gc.get_alpha(),
)
else:
- return 'fill: %s; opacity: %s' % (\
+ return 'fill: %s; opacity: %f' % (\
fill,
gc.get_alpha(),
)
@@ -126,7 +126,7 @@
elif cliprect is not None:
x, y, w, h = cliprect.bounds
y = self.height-(y+h)
- path = '<rect x="%(x)s" y="%(y)s" width="%(w)s" height="%(h)s"/>' % locals()
+ path = '<rect x="%(x)f" y="%(y)f" width="%(w)f" height="%(h)f"/>' % locals()
else:
return None
@@ -153,10 +153,10 @@
return rcParams['svg.image_noscale']
_path_commands = {
- Path.MOVETO: 'M%s %s',
- Path.LINETO: 'L%s %s',
- Path.CURVE3: 'Q%s %s %s %s',
- Path.CURVE4: 'C%s %s %s %s %s %s'
+ Path.MOVETO: 'M%f %f',
+ Path.LINETO: 'L%f %f',
+ Path.CURVE3: 'Q%f %f %f %f',
+ Path.CURVE4: 'C%f %f %f %f %f %f'
}
def _make_flip_transform(self, transform):
@@ -258,7 +258,7 @@
trans[4] += trans[0]
trans[5] += trans[3]
trans[5] = -trans[5]
- transstr = 'transform="matrix(%s %s %s %s %s %s)" '%tuple(trans)
+ transstr = 'transform="matrix(%f %f %f %f %f %f)" '%tuple(trans)
assert trans[1] == 0
assert trans[2] == 0
numrows,numcols = im.get_size()
@@ -269,7 +269,7 @@
h,w = im.get_size_out()
self._svgwriter.write (
- '<image x="%s" y="%s" width="%s" height="%s" '
+ '<image x="%f" y="%f" width="%f" height="%f" '
'%s xlink:href="'%(x/trans[0], (self.height-y)/trans[3]-h, w, h, transstr)
)
@@ -323,12 +323,12 @@
if clipid is not None:
svg.append('<g clip-path="url(#%s)">\n' % clipid)
- svg.append('<g style="fill: %s; opacity: %s" transform="' % (color, gc.get_alpha()))
+ svg.append('<g style="fill: %s; opacity: %f" transform="' % (color, gc.get_alpha()))
if angle != 0:
- svg.append('translate(%s,%s)rotate(%1.1f)' % (x,y,-angle))
+ svg.append('translate(%f,%f)rotate(%1.1f)' % (x,y,-angle))
elif x != 0 or y != 0:
- svg.append('translate(%s,%s)' % (x, y))
- svg.append('scale(%s)">\n' % (fontsize / self.FONT_SCALE))
+ svg.append('translate(%f,%f)' % (x, y))
+ svg.append('scale(%f)">\n' % (fontsize / self.FONT_SCALE))
cmap = font.get_charmap()
lastgind = None
@@ -350,7 +350,7 @@
svg.append('<use xlink:href="#%s"' % charnum)
if currx != 0:
- svg.append(' x="%s"' %
+ svg.append(' x="%f"' %
(currx * (self.FONT_SCALE / fontsize)))
svg.append('/>\n')
@@ -365,16 +365,16 @@
fontfamily = font.family_name
fontstyle = prop.get_style()
- style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %s' %
+ style = ('font-size: %f; font-family: %s; font-style: %s; fill: %s; opacity: %f' %
(fontsize, fontfamily,fontstyle, color, gc.get_alpha()))
if angle!=0:
- transform = 'transform="translate(%s,%s) rotate(%1.1f) translate(%s,%s)"' % (x,y,-angle,-x,-y)
+ transform = 'transform="translate(%f,%f) rotate(%1.1f) translate(%f,%f)"' % (x,y,-angle,-x,-y)
# Inkscape doesn't support rotate(angle x y)
else:
transform = ''
svg = """\
-<text style="%(style)s" x="%(x)s" y="%(y)s" %(transform)s>%(thetext)s</text>
+<text style="%(style)s" x="%(x)f" y="%(y)f" %(transform)s>%(thetext)s</text>
""" % locals()
write(svg)
@@ -396,17 +396,17 @@
currx, curry = 0.0, 0.0
for step in glyph.path:
if step[0] == 0: # MOVE_TO
- path_data.append("M%s %s" %
+ path_data.append("M%f %f" %
(step[1], -step[2]))
elif step[0] == 1: # LINE_TO
- path_data.append("l%s %s" %
+ path_data.append("l%f %f" %
(step[1] - currx, -step[2] - curry))
elif step[0] == 2: # CURVE3
- path_data.append("q%s %s %s %s" %
+ path_data.append("q%f %f %f %f" %
(step[1] - currx, -step[2] - curry,
step[3] - currx, -step[4] - curry))
elif step[0] == 3: # CURVE4
- path_data.append("c%s %s %s %s %s %s" %
+ path_data.append("c%f %f %f %f %f %f" %
(step[1] - currx, -step[2] - curry,
step[3] - currx, -step[4] - curry,
step[5] - currx, -step[6] - curry))
@@ -460,16 +460,16 @@
svg = ['<g style="%s" transform="' % style]
if angle != 0:
- svg.append('translate(%s,%s)rotate(%1.1f)'
+ svg.append('translate(%f,%f)rotate(%1.1f)'
% (x,y,-angle) )
else:
- svg.append('translate(%s,%s)' % (x, y))
+ svg.append('translate(%f,%f)' % (x, y))
svg.append('">\n')
for font, fontsize, thetext, new_x, new_y_mtc, metrics in svg_glyphs:
charid = self._get_char_def_id(font, thetext)
- svg.append('<use xlink:href="#%s" transform="translate(%s,%s)scale(%s)"/>\n' %
+ svg.append('<use xlink:href="#%s" transform="translate(%f,%f)scale(%f)"/>\n' %
(charid, new_x, -new_y_mtc, fontsize / self.FONT_SCALE))
svg.append('</g>\n')
else: # not rcParams['svg.embed_char_paths']
@@ -488,15 +488,15 @@
svg.append('<tspan style="%s"' % style)
xadvance = metrics.advance
- svg.append(' textLength="%s"' % xadvance)
+ svg.append(' textLength="%f"' % xadvance)
dx = new_x - curr_x
if dx != 0.0:
- svg.append(' dx="%s"' % dx)
+ svg.append(' dx="%f"' % dx)
dy = new_y - curr_y
if dy != 0.0:
- svg.append(' dy="%s"' % dy)
+ svg.append(' dy="%f"' % dy)
thetext = escape_xml_text(thetext)
@@ -511,14 +511,14 @@
style = "fill: %s; stroke: none" % color
svg.append('<g style="%s" transform="' % style)
if angle != 0:
- svg.append('translate(%s,%s) rotate(%1.1f)'
+ svg.append('translate(%f,%f) rotate(%1.1f)'
% (x,y,-angle) )
else:
- svg.append('translate(%s,%s)' % (x, y))
+ svg.append('translate(%f,%f)' % (x, y))
svg.append('">\n')
for x, y, width, height in svg_rects:
- svg.append('<rect x="%s" y="%s" width="%s" height="%s" fill="black" stroke="none" />' % (x, -y + height, width, height))
+ svg.append('<rect x="%f" y="%f" width="%f" height="%f" fill="black" stroke="none" />' % (x, -y + height, width, height))
svg.append("</g>")
self.open_group("mathtext")
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-22 19:19:31
|
Revision: 6048
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6048&view=rev
Author: jswhit
Date: 2008-08-22 19:19:29 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
fix quiver so masked values not plotted.
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-08-22 19:19:07 UTC (rev 6047)
+++ trunk/matplotlib/CHANGELOG 2008-08-22 19:19:29 UTC (rev 6048)
@@ -1,3 +1,5 @@
+2008-08-22 fix quiver so masked values are not plotted - JSW
+
2008-08-18 improve interactive pan/zoom in qt4 backend on windows - DSD
2008-08-11 Fix more bugs in NaN/inf handling. In particular, path simplification
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-22 19:19:09
|
Revision: 6047
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6047&view=rev
Author: jswhit
Date: 2008-08-22 19:19:07 +0000 (Fri, 22 Aug 2008)
Log Message:
-----------
fix quiver so masked values are not plotted.
Modified Paths:
--------------
trunk/matplotlib/examples/pylab_examples/quiver_demo.py
trunk/matplotlib/lib/matplotlib/quiver.py
Modified: trunk/matplotlib/examples/pylab_examples/quiver_demo.py
===================================================================
--- trunk/matplotlib/examples/pylab_examples/quiver_demo.py 2008-08-21 15:29:12 UTC (rev 6046)
+++ trunk/matplotlib/examples/pylab_examples/quiver_demo.py 2008-08-22 19:19:07 UTC (rev 6047)
@@ -9,6 +9,7 @@
'''
from pylab import *
+from numpy import ma
X,Y = meshgrid( arange(0,2*pi,.2),arange(0,2*pi,.2) )
U = cos(X)
@@ -64,6 +65,20 @@
axis([-1, 7, -1, 7])
title("triangular head; scale with x view; black edges")
+#6
+figure()
+M = zeros(U.shape, dtype='bool')
+M[U.shape[0]/3:2*U.shape[0]/3,U.shape[1]/3:2*U.shape[1]/3] = True
+U = ma.masked_array(U, mask=M)
+V = ma.masked_array(V, mask=M)
+Q = quiver( U, V)
+qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W',
+ fontproperties={'weight': 'bold'})
+l,r,b,t = axis()
+dx, dy = r-l, t-b
+axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy])
+title('Minimal arguments, no kwargs - masked values')
+
show()
Modified: trunk/matplotlib/lib/matplotlib/quiver.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-21 15:29:12 UTC (rev 6046)
+++ trunk/matplotlib/lib/matplotlib/quiver.py 2008-08-22 19:19:07 UTC (rev 6047)
@@ -334,6 +334,12 @@
def __init__(self, ax, *args, **kw):
self.ax = ax
X, Y, U, V, C = self._parse_args(*args)
+ if C is not None:
+ X, Y, U, V, C = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(),
+ V.ravel(),C.ravel())
+ else:
+ X, Y, U, V = delete_masked_points(X.ravel(),Y.ravel(),U.ravel(),
+ V.ravel())
self.X = X
self.Y = Y
self.XY = np.hstack((X[:,np.newaxis], Y[:,np.newaxis]))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mme...@us...> - 2008-08-21 15:29:16
|
Revision: 6046
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6046&view=rev
Author: mmetz_bn
Date: 2008-08-21 15:29:12 +0000 (Thu, 21 Aug 2008)
Log Message:
-----------
import warnings; close bug # 2053683
Modified Paths:
--------------
trunk/matplotlib/lib/matplotlib/cbook.py
Modified: trunk/matplotlib/lib/matplotlib/cbook.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/cbook.py 2008-08-19 11:58:23 UTC (rev 6045)
+++ trunk/matplotlib/lib/matplotlib/cbook.py 2008-08-21 15:29:12 UTC (rev 6046)
@@ -5,6 +5,7 @@
from __future__ import generators
import re, os, errno, sys, StringIO, traceback, locale, threading, types
import time, datetime
+import warnings
import numpy as np
import numpy.ma as ma
from weakref import ref
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-19 11:58:26
|
Revision: 6045
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6045&view=rev
Author: jswhit
Date: 2008-08-19 11:58:23 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
update
Modified Paths:
--------------
trunk/toolkits/basemap/doc/users/graticule.rst
Modified: trunk/toolkits/basemap/doc/users/graticule.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/graticule.rst 2008-08-19 09:35:03 UTC (rev 6044)
+++ trunk/toolkits/basemap/doc/users/graticule.rst 2008-08-19 11:58:23 UTC (rev 6045)
@@ -8,6 +8,13 @@
:func:`~mpl_toolkits.basemap.Basemap.drawparallels` and
:func:`~mpl_toolkits.basemap.Basemap.drawmeridians` instance methods.
The longitude and latitude lines can be labelled where they
-the map projection boundary.
+the map projection boundary. There are four exceptions: meridians
+and parallels cannot be labelled on maps with
+``proj`` set to ``ortho`` (orthographic projection),
+and meridians cannot be labelled on maps with
+``proj`` set to ``robin`` (robinson), ``moll`` (mollweide) or ``sinu``
+(sinusoidal). This is because the lines can be very close
+together where they intersect the boundary on these maps, so that
+they really need to be labelled on the interior of the plot.
.. toctree::
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fer...@us...> - 2008-08-19 09:35:08
|
Revision: 6044
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6044&view=rev
Author: fer_perez
Date: 2008-08-19 09:35:03 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
Update examples and skeletons in py4science.
- Fixes after previous feedback so they are all syntactically correct.
- Switch to using nose instead of unittest for an eaiser workflow.
Modified Paths:
--------------
trunk/py4science/examples/fft_imdenoise.py
trunk/py4science/examples/qsort.py
trunk/py4science/examples/skel/fft_imdenoise_skel.py
trunk/py4science/examples/skel/qsort_skel.py
trunk/py4science/examples/skel/trapezoid_skel.py
trunk/py4science/examples/skel/wallis_pi_skel.py
trunk/py4science/examples/skel/wordfreqs_skel.py
trunk/py4science/examples/trapezoid.py
Modified: trunk/py4science/examples/fft_imdenoise.py
===================================================================
--- trunk/py4science/examples/fft_imdenoise.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/fft_imdenoise.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -20,58 +20,64 @@
print M.shape, M.dtype
plt.imshow(M, plt.cm.Blues)
-try:
- # Read in original image, convert to floating point for further
- # manipulation; imread returns a MxNx4 RGBA image. Since the
- # image is grayscale, just extrac the 1st channel
- im = plt.imread('data/moonlanding.png').astype(float)[:,:,0]
-except:
- print "Could not open image."
- sys.exit(-1)
-# Compute the 2d FFT of the input image
-F = np.fft.fft2(im)
+if __name__ == '__main__':
-# Now, make a copy of the original spectrum and truncate coefficients.
-keep_fraction = 0.1
+ try:
+ # Read in original image, convert to floating point for further
+ # manipulation; imread returns a MxNx4 RGBA image. Since the image is
+ # grayscale, just extrac the 1st channel
+ im = plt.imread('data/moonlanding.png').astype(float)[:,:,0]
+ except:
+ print "Could not open image."
+ sys.exit(-1)
-# Call ff a copy of the original transform. Numpy arrays have a copy method
-# for this purpose.
-ff = F.copy()
+ # Compute the 2d FFT of the input image
+ F = np.fft.fft2(im)
-# Set r and c to be the number of rows and columns of the array.
-r,c = ff.shape
+ # Now, make a copy of the original spectrum and truncate coefficients.
+ keep_fraction = 0.1
-# Set to zero all rows with indices between r*keep_fraction and
-# r*(1-keep_fraction):
-ff[r*keep_fraction:r*(1-keep_fraction)] = 0
+ # Call ff a copy of the original transform. Numpy arrays have a copy
+ # method for this purpose.
+ ff = F.copy()
-# Similarly with the columns:
-ff[:, c*keep_fraction:c*(1-keep_fraction)] = 0
+ # Set r and c to be the number of rows and columns of the array.
+ r,c = ff.shape
-# Reconstruct the denoised image from the filtered spectrum, keep only the real
-# part for display
-im_new = np.fft.ifft2(ff).real
+ # Set to zero all rows with indices between r*keep_fraction and
+ # r*(1-keep_fraction):
+ ff[r*keep_fraction:r*(1-keep_fraction)] = 0
-# Show the results
-plt.figure()
+ # Similarly with the columns:
+ ff[:, c*keep_fraction:c*(1-keep_fraction)] = 0
-plt.subplot(221)
-plt.title('Original image')
-plt.imshow(im, plt.cm.gray)
+ # Reconstruct the denoised image from the filtered spectrum, keep only the
+ # real part for display
+ im_new = np.fft.ifft2(ff).real
-plt.subplot(222)
-plt.title('Fourier transform')
-plot_spectrum(F)
+ # Show the results
+ plt.figure()
-plt.subplot(224)
-plt.title('Filtered Spectrum')
-plot_spectrum(ff)
+ plt.subplot(221)
+ plt.title('Original image')
+ plt.imshow(im, plt.cm.gray)
-plt.subplot(223)
-plt.title('Reconstructed Image')
-plt.imshow(im_new, plt.cm.gray)
+ plt.subplot(222)
+ plt.title('Fourier transform')
+ plot_spectrum(F)
-plt.savefig('fft_imdenoise.png', dpi=150)
-plt.savefig('fft_imdenoise.eps')
-plt.show()
+ plt.subplot(224)
+ plt.title('Filtered Spectrum')
+ plot_spectrum(ff)
+
+ plt.subplot(223)
+ plt.title('Reconstructed Image')
+ plt.imshow(im_new, plt.cm.gray)
+
+ plt.savefig('fft_imdenoise.png', dpi=150)
+ plt.savefig('fft_imdenoise.eps')
+
+ # Adjust the spacing between subplots for readability
+ plt.subplots_adjust(hspace=0.32)
+ plt.show()
Modified: trunk/py4science/examples/qsort.py
===================================================================
--- trunk/py4science/examples/qsort.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/qsort.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -18,22 +18,28 @@
return qsort(less_than) + [pivot] + qsort(greater_equal)
-if __name__ == '__main__':
- from unittest import main, TestCase
- import random
- class qsortTestCase(TestCase):
- def test_sorted(self):
- seq = range(10)
- sseq = qsort(seq)
- self.assertEqual(seq,sseq)
+#-----------------------------------------------------------------------------
+# Tests
+#-----------------------------------------------------------------------------
+import random
- def test_random(self):
- tseq = range(10)
- rseq = range(10)
- random.shuffle(rseq)
- sseq = qsort(rseq)
- print tseq
- print sseq
- self.assertEqual(tseq,sseq)
- main()
+import nose, nose.tools as nt
+
+def test_sorted():
+ seq = range(10)
+ sseq = qsort(seq)
+ nt.assert_equal(seq,sseq)
+
+def test_random():
+ tseq = range(10)
+ rseq = range(10)
+ random.shuffle(rseq)
+ sseq = qsort(rseq)
+ nt.assert_equal(tseq,sseq)
+
+# If called from the command line, run all the tests
+if __name__ == '__main__':
+ # This call form is ipython-friendly
+ nose.runmodule(argv=['-s','--with-doctest'],
+ exit=False)
Modified: trunk/py4science/examples/skel/fft_imdenoise_skel.py
===================================================================
--- trunk/py4science/examples/skel/fft_imdenoise_skel.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/skel/fft_imdenoise_skel.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -1,10 +1,11 @@
#!/usr/bin/env python
"""Image denoising example using 2-dimensional FFT."""
-import numpy as N
-import pylab as P
-import scipy as S
+XXX = None # a sentinel for missing pieces
+import numpy as np
+from matplotlib import pyplot as plt
+
def mag_phase(F):
"""Return magnitude and phase components of spectrum F."""
@@ -13,7 +14,7 @@
def plot_spectrum(F, amplify=1000):
"""Normalise, amplify and plot an amplitude spectrum."""
- M = # XXX use mag_phase to get the magnitude...
+ M = XXX # use mag_phase to get the magnitude...
# XXX Now, rescale M by amplify/maximum_of_M. Numpy arrays can be scaled
# in-place with ARR *= number. For the max of an array, look for its max
@@ -25,56 +26,58 @@
# Display: this one already works, if you did everything right with M
- P.imshow(M, P.cm.Blues)
+ plt.imshow(M, plt.cm.Blues)
-# 'main' script
+if __name__ == '__main__':
+ im = XXX # make an image array from the file 'moonlanding.png', using the
+ # pylab imread() function. You will need to just extract the red
+ # channel from the MxNx4 RGBA matrix to represent the grayscale
+ # intensities
-im = # XXX make an image array from the file 'moonlanding.png', using the
- # pylab imread() function. You will need to just extract the red
- # channel from the MxNx4 RGBA matrix to represent the grayscale
- # intensities
+ F = XXX # Compute the 2d FFT of the input image. Look for a 2-d FFT in
+ # np.fft.
-F = # Compute the 2d FFT of the input image. Look for a 2-d FFT in N.fft.
+ # Define the fraction of coefficients (in each direction) we keep
+ keep_fraction = 0.1
-# Define the fraction of coefficients (in each direction) we keep
-keep_fraction = 0.1
+ # XXX Call ff a copy of the original transform. Numpy arrays have a copy
+ # method for this purpose.
-# XXX Call ff a copy of the original transform. Numpy arrays have a copy method
-# for this purpose.
+ # XXX Set r and c to be the number of rows and columns of the array. Look
+ # for the shape attribute...
-# XXX Set r and c to be the number of rows and columns of the array. Look for
-# the shape attribute...
+ # Set to zero all rows with indices between r*keep_fraction and
+ # r*(1-keep_fraction):
-# Set to zero all rows with indices between r*keep_fraction and
-# r*(1-keep_fraction):
+ # Similarly with the columns:
-# Similarly with the columns:
+ # Reconstruct the denoised image from the filtered spectrum. There's an
+ # inverse 2d fft in the dft module as well. Call the result im_new
-# Reconstruct the denoised image from the filtered spectrum. There's an
-# inverse 2d fft in the dft module as well. Call the result im_new
+ # Show the results.
-# Show the results.
+ # The code below already works, if you did everything above right.
+ plt.figure()
-# The code below already works, if you did everything above right.
-P.figure()
+ plt.subplot(221)
+ plt.title('Original image')
+ plt.imshow(im, plt.cm.gray)
-P.subplot(221)
-P.title('Original image')
-P.imshow(im, P.cm.gray)
+ plt.subplot(222)
+ plt.title('Fourier transform')
+ plot_spectrum(F)
-P.subplot(222)
-P.title('Fourier transform')
-plot_spectrum(F)
+ plt.subplot(224)
+ plt.title('Filtered Spectrum')
+ plot_spectrum(ff)
-P.subplot(224)
-P.title('Filtered Spectrum')
-plot_spectrum(ff)
+ plt.subplot(223)
+ plt.title('Reconstructed Image')
+ plt.imshow(im_new, plt.cm.gray)
-P.subplot(223)
-P.title('Reconstructed Image')
-P.imshow(im_new, P.cm.gray)
-
-P.show()
+ # Adjust the spacing between subplots for readability
+ plt.subplots_adjust(hspace=0.32)
+ plt.show()
Modified: trunk/py4science/examples/skel/qsort_skel.py
===================================================================
--- trunk/py4science/examples/skel/qsort_skel.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/skel/qsort_skel.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -1,24 +1,45 @@
-"""Simple quicksort implementation."""
+"""Simple quicksort implementation.
+From http://en.wikipedia.org/wiki/Quicksort:
+
+function quicksort(array)
+ var list less, greater
+ if length(array) ≤ 1
+ return array
+ select and remove a pivot value pivot from array
+ for each x in array
+ if x ≤ pivot then append x to less
+ else append x to greater
+ return concatenate(quicksort(less), pivot, quicksort(greater))
+"""
+
def qsort(lst):
"""Return a sorted copy of the input list."""
raise NotImplementedError
-if __name__ == '__main__':
- from unittest import main, TestCase
- import random
+#-----------------------------------------------------------------------------
+# Tests
+#-----------------------------------------------------------------------------
+import random
- class qsortTestCase(TestCase):
- def test_sorted(self):
- seq = range(10)
- sseq = qsort(seq)
- self.assertEqual(seq,sseq)
+import nose.tools as nt
- def test_random(self):
- tseq = range(10)
- rseq = range(10)
- random.shuffle(rseq)
- sseq = qsort(rseq)
- self.assertEqual(tseq,sseq)
- main()
+def test_sorted():
+ seq = range(10)
+ sseq = qsort(seq)
+ nt.assert_equal(seq,sseq)
+
+def test_random():
+ tseq = range(10)
+ rseq = range(10)
+ random.shuffle(rseq)
+ sseq = qsort(rseq)
+ nt.assert_equal(tseq,sseq)
+
+if __name__ == '__main__':
+ # From the command line, run the test suite
+ import nose
+ # This call form is ipython-friendly
+ nose.runmodule(argv=['-s','--with-doctest'],
+ exit=False)
Modified: trunk/py4science/examples/skel/trapezoid_skel.py
===================================================================
--- trunk/py4science/examples/skel/trapezoid_skel.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/skel/trapezoid_skel.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -39,29 +39,32 @@
# x?
raise NotImplementedError
-if __name__ == '__main__':
- # Simple tests for trapezoid integrator, when this module is called as a
- # script from the command line.
- import unittest
- import numpy.testing as ntest
+#-----------------------------------------------------------------------------
+# Tests
+#-----------------------------------------------------------------------------
+import nose, nose.tools as nt
+import numpy.testing as nptest
- def square(x): return x**2
+def square(x): return x**2
- class trapzTestCase(unittest.TestCase):
- def test_err(self):
- self.assertRaises(ValueError,trapz,range(2),range(3))
+def test_err():
+ nt.assert_raises(ValueError,trapz,range(2),range(3))
- def test_call(self):
- x = N.linspace(0,1,100)
- y = N.array(map(square,x))
- ntest.assert_almost_equal(trapz(x,y),1./3,4)
+def test_call():
+ x = np.linspace(0,1,100)
+ y = np.array(map(square,x))
+ nptest.assert_almost_equal(trapz(x,y),1./3,4)
- class trapzfTestCase(unittest.TestCase):
- def test_square(self):
- ntest.assert_almost_equal(trapzf(square,0,1),1./3,4)
+def test_square():
+ nptest.assert_almost_equal(trapzf(square,0,1),1./3,4)
- def test_square2(self):
- ntest.assert_almost_equal(trapzf(square,0,3,350),9.0,4)
+def test_square2():
+ nptest.assert_almost_equal(trapzf(square,0,3,350),9.0,4)
- unittest.main()
+
+# If called from the command line, run all the tests
+if __name__ == '__main__':
+ # This call form is ipython-friendly
+ nose.runmodule(argv=['-s','--with-doctest'],
+ exit=False)
Modified: trunk/py4science/examples/skel/wallis_pi_skel.py
===================================================================
--- trunk/py4science/examples/skel/wallis_pi_skel.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/skel/wallis_pi_skel.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -8,6 +8,8 @@
from decimal import Decimal
+XXX = None # a sentinel for missing pieces
+
def pi(n):
"""Compute pi using n terms of Wallis' product.
@@ -15,7 +17,7 @@
pi(n) = 2 \prod_{i=1}^{n}\frac{4i^2}{4i^2-1}."""
- XXX
+ raise NotImplementedError
# This part only executes when the code is run as a script, not when it is
# imported as a library
Modified: trunk/py4science/examples/skel/wordfreqs_skel.py
===================================================================
--- trunk/py4science/examples/skel/wordfreqs_skel.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/skel/wordfreqs_skel.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -1,10 +1,14 @@
#!/usr/bin/env python
"""Word frequencies - count word frequencies in a string."""
+XXX = None # a sentinel for missing pieces
+
def word_freq(text):
"""Return a dictionary of word frequencies for the given text."""
- # XXX you need to write this
+ # you need to write this
+ return XXX
+
def print_vk(lst):
"""Print a list of value/key pairs nicely formatted in key/value order."""
@@ -17,6 +21,7 @@
for v,k in lst:
print fmt % (k,v)
+
def freq_summ(freqs,n=10):
"""Print a simple summary of a word frequencies dictionary.
@@ -26,10 +31,10 @@
Optional inputs:
- n: the number of items to print"""
- words,counts = # XXX look at the keys and values methods of dicts
+ words,counts = XXX # look at the keys and values methods of dicts
# Sort by count
- items = # XXX think of a list, look at zip() and think of sort()
+ items = XXX # think of a list, look at zip() and think of sort()
print 'Number of words:',len(freqs)
print
@@ -39,10 +44,12 @@
print '%d most frequent words:' % n
print_vk(items[-n:])
+
if __name__ == '__main__':
- text = # XXX
- # You need to read the contents of the file HISTORY.gz. Do NOT unzip it
- # manually, look at the gzip module from the standard library and the
- # read() method of file objects.
+ # You need to read the contents of the file HISTORY.gz and store it in the
+ # variable named 'text'. Do NOT unzip it manually, look at the gzip module
+ # from the standard library and the read() method of file objects.
+ text = XXX
+
freqs = word_freq(text)
freq_summ(freqs,20)
Modified: trunk/py4science/examples/trapezoid.py
===================================================================
--- trunk/py4science/examples/trapezoid.py 2008-08-18 21:06:56 UTC (rev 6043)
+++ trunk/py4science/examples/trapezoid.py 2008-08-19 09:35:03 UTC (rev 6044)
@@ -1,7 +1,7 @@
#!/usr/bin/env python
"""Simple trapezoid-rule integrator."""
-import numpy as N
+import numpy as np
def trapz(x, y):
"""Simple trapezoid integrator for sequence-based innput.
@@ -40,43 +40,41 @@
- The value of the trapezoid-rule approximation to the integral."""
# Generate an equally spaced grid to sample the function at
- x = N.linspace(a,b,npts)
+ x = np.linspace(a,b,npts)
# For an equispaced grid, the x spacing can just be read off from the first
# two points and factored out of the summation.
dx = x[1]-x[0]
# Sample the input function at all values of x
- y = N.array(map(f,x))
+ y = np.array(map(f,x))
# Compute the trapezoid rule sum for the final result
return 0.5*dx*(y[1:]+y[:-1]).sum()
-if __name__ == '__main__':
- # Simple tests for trapezoid integrator, when this module is called as a
- # script from the command line. From ipython, run it via:
- #
- # run -e trapezoid
- #
- # so that ipython ignores the SystemExit exception automatically raised by
- # the unittest module at the end.
- import unittest
- import numpy.testing as ntest
+#-----------------------------------------------------------------------------
+# Tests
+#-----------------------------------------------------------------------------
+import nose, nose.tools as nt
+import numpy.testing as nptest
- def square(x): return x**2
+def square(x): return x**2
- class trapzTestCase(unittest.TestCase):
- def test_err(self):
- self.assertRaises(ValueError,trapz,range(2),range(3))
+def test_err():
+ nt.assert_raises(ValueError,trapz,range(2),range(3))
- def test_call(self):
- x = N.linspace(0,1,100)
- y = N.array(map(square,x))
- ntest.assert_almost_equal(trapz(x,y),1./3,4)
+def test_call():
+ x = np.linspace(0,1,100)
+ y = np.array(map(square,x))
+ nptest.assert_almost_equal(trapz(x,y),1./3,4)
- class trapzfTestCase(unittest.TestCase):
- def test_square(self):
- ntest.assert_almost_equal(trapzf(square,0,1),1./3,4)
+def test_square():
+ nptest.assert_almost_equal(trapzf(square,0,1),1./3,4)
- def test_square2(self):
- ntest.assert_almost_equal(trapzf(square,0,3,350),9.0,4)
+def test_square2():
+ nptest.assert_almost_equal(trapzf(square,0,3,350),9.0,4)
- unittest.main()
+
+# If called from the command line, run all the tests
+if __name__ == '__main__':
+ # This call form is ipython-friendly
+ nose.runmodule(argv=['-s','--with-doctest'],
+ exit=False)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ds...@us...> - 2008-08-18 21:07:04
|
Revision: 6043
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6043&view=rev
Author: dsdale
Date: 2008-08-18 21:06:56 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
improved interactive pan/zoom in qt4agg backend on windows
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-08-18 20:18:56 UTC (rev 6042)
+++ trunk/matplotlib/CHANGELOG 2008-08-18 21:06:56 UTC (rev 6043)
@@ -1,3 +1,5 @@
+2008-08-18 improve interactive pan/zoom in qt4 backend on windows - DSD
+
2008-08-11 Fix more bugs in NaN/inf handling. In particular, path simplification
(which does not handle NaNs or infs) will be turned off automatically
when infs or NaNs are present. Also masked arrays are now converted
Modified: trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-08-18 20:18:56 UTC (rev 6042)
+++ trunk/matplotlib/lib/matplotlib/backends/backend_qt4agg.py 2008-08-18 21:06:56 UTC (rev 6043)
@@ -132,6 +132,8 @@
self.replot = True
FigureCanvasAgg.draw(self)
self.update()
+ # Added following line to improve realtime pan/zoom on windows:
+ QtGui.qApp.processEvents()
def blit(self, bbox=None):
"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ef...@us...> - 2008-08-18 20:19:03
|
Revision: 6042
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6042&view=rev
Author: efiring
Date: 2008-08-18 20:18:56 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
Fix bug introduced in 6033, reported by Jae-Joon Lee
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 2008-08-18 14:43:13 UTC (rev 6041)
+++ trunk/matplotlib/src/agg_py_path_iterator.h 2008-08-18 20:18:56 UTC (rev 6042)
@@ -39,7 +39,7 @@
(codes_obj.ptr(), PyArray_UINT8, 1, 1);
if (!m_codes)
throw Py::ValueError("Invalid codes array.");
- if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 1))
+ if (PyArray_DIM(m_codes, 0) != PyArray_DIM(m_vertices, 0))
throw Py::ValueError("Codes array is wrong length");
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-18 14:43:16
|
Revision: 6041
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6041&view=rev
Author: jswhit
Date: 2008-08-18 14:43:13 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
another minor tweak
Modified Paths:
--------------
trunk/toolkits/basemap/examples/cubed_sphere.py
Modified: trunk/toolkits/basemap/examples/cubed_sphere.py
===================================================================
--- trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-18 11:44:30 UTC (rev 6040)
+++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-18 14:43:13 UTC (rev 6041)
@@ -23,10 +23,10 @@
rsphere=rsphere)
m.bluemarble()
m.drawparallels(np.arange(-90,91,10),color='0.5')
- m.drawmeridians(np.arange(0,360,10),color='0.5')
+ m.drawmeridians(np.arange(5,365,10),color='0.5')
#m.drawlsmask(ocean_color='aqua',land_color='coral')
#m.drawparallels(np.arange(-90,91,10))
- #m.drawmeridians(np.arange(0,360,10))
+ #m.drawmeridians(np.arange(5,365,10))
fig.text (0.625,0.75,\
'World Map on a Cube\n Gnomonic Projection',\
fontsize=14)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-18 11:44:34
|
Revision: 6040
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6040&view=rev
Author: jswhit
Date: 2008-08-18 11:44:30 +0000 (Mon, 18 Aug 2008)
Log Message:
-----------
minor tweaks
Modified Paths:
--------------
trunk/toolkits/basemap/examples/cubed_sphere.py
Modified: trunk/toolkits/basemap/examples/cubed_sphere.py
===================================================================
--- trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:56:20 UTC (rev 6039)
+++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-18 11:44:30 UTC (rev 6040)
@@ -6,7 +6,7 @@
# face with gnomonic projection.
# http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html
# suitable for cutting and folding.
-fig = plt.figure(figsize=(8,6))
+fig = plt.figure(figsize=(10,7.5))
fig.subplots_adjust(bottom=0, left=0, right=1, top=1, wspace=0, hspace=0)
rsphere = 6370997.
width = 2.*rsphere; height=width
@@ -14,20 +14,20 @@
for lat_0 in [90,0,-90]:
for ncol in range(0,4):
npanel = npanel + 1
- if lat_0 != 0 and ncol != 1: continue
- ax=fig.add_subplot(3,4,npanel)
- ax.set_frame_on(False)
- lon_0=225 + 90*(ncol+1) - 45
- m = Basemap(width=width,height=height,resolution=None,\
- projection='gnom',lon_0=lon_0,lat_0=lat_0,\
- rsphere=rsphere)
- m.bluemarble()
- m.drawparallels(np.arange(-90,91,10),color='0.5')
- m.drawmeridians(np.arange(0,360,10),color='0.5')
- #m.drawlsmask(ocean_color='aqua',land_color='coral')
- #m.drawparallels(np.arange(-90,91,10))
- #m.drawmeridians(np.arange(0,360,10))
-fig.text(0.625,0.75,\
- 'World Map on a Cube\n Gnomonic Projection',\
- fontsize=14)
+ if lat_0 == 0 or ncol == 1:
+ ax=fig.add_subplot(3,4,npanel)
+ ax.set_frame_on(False)
+ lon_0=225 + 90*(ncol+1) - 45
+ m = Basemap(width=width,height=height,resolution=None,\
+ projection='gnom',lon_0=lon_0,lat_0=lat_0,\
+ rsphere=rsphere)
+ m.bluemarble()
+ m.drawparallels(np.arange(-90,91,10),color='0.5')
+ m.drawmeridians(np.arange(0,360,10),color='0.5')
+ #m.drawlsmask(ocean_color='aqua',land_color='coral')
+ #m.drawparallels(np.arange(-90,91,10))
+ #m.drawmeridians(np.arange(0,360,10))
+fig.text (0.625,0.75,\
+ 'World Map on a Cube\n Gnomonic Projection',\
+ fontsize=14)
plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-17 22:56:23
|
Revision: 6039
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6039&view=rev
Author: jswhit
Date: 2008-08-17 22:56:20 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
update
Modified Paths:
--------------
trunk/toolkits/basemap/examples/cubed_sphere.py
Modified: trunk/toolkits/basemap/examples/cubed_sphere.py
===================================================================
--- trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:17:56 UTC (rev 6038)
+++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:56:20 UTC (rev 6039)
@@ -24,6 +24,9 @@
m.bluemarble()
m.drawparallels(np.arange(-90,91,10),color='0.5')
m.drawmeridians(np.arange(0,360,10),color='0.5')
+ #m.drawlsmask(ocean_color='aqua',land_color='coral')
+ #m.drawparallels(np.arange(-90,91,10))
+ #m.drawmeridians(np.arange(0,360,10))
fig.text(0.625,0.75,\
'World Map on a Cube\n Gnomonic Projection',\
fontsize=14)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-17 22:18:00
|
Revision: 6038
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6038&view=rev
Author: jswhit
Date: 2008-08-17 22:17:56 +0000 (Sun, 17 Aug 2008)
Log Message:
-----------
added cubed_sphere.py example
Modified Paths:
--------------
trunk/toolkits/basemap/Changelog
trunk/toolkits/basemap/MANIFEST.in
trunk/toolkits/basemap/examples/README
Added Paths:
-----------
trunk/toolkits/basemap/examples/cubed_sphere.py
Modified: trunk/toolkits/basemap/Changelog
===================================================================
--- trunk/toolkits/basemap/Changelog 2008-08-16 22:48:18 UTC (rev 6037)
+++ trunk/toolkits/basemap/Changelog 2008-08-17 22:17:56 UTC (rev 6038)
@@ -1,4 +1,5 @@
version 0.99.2 (not yet released)
+ * added cubed_sphere example.
* updated NetCDFFile to use pupynere 1.0.2 (now can write as well
as read!).
* now works with geos version 3.
Modified: trunk/toolkits/basemap/MANIFEST.in
===================================================================
--- trunk/toolkits/basemap/MANIFEST.in 2008-08-16 22:48:18 UTC (rev 6037)
+++ trunk/toolkits/basemap/MANIFEST.in 2008-08-17 22:17:56 UTC (rev 6038)
@@ -11,6 +11,7 @@
include setup.cfg
include setupegg.py
include src/*
+include examples/cubed_sphere.py
include examples/simpletest.py
include examples/hires.py
include examples/simpletest_oo.py
Modified: trunk/toolkits/basemap/examples/README
===================================================================
--- trunk/toolkits/basemap/examples/README 2008-08-16 22:48:18 UTC (rev 6037)
+++ trunk/toolkits/basemap/examples/README 2008-08-17 22:17:56 UTC (rev 6038)
@@ -111,6 +111,9 @@
plotprecip.py use nonlinear precip colormap included with basemap
to make a rainfall plot.
+cubed_sphere.py - plot a "cubed globe" suitable for cutting and folding,
+a la http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html.
+
run_all.py is a driver script that runs all the examples except fcstmaps.py,
testgdal.py, geos_demo_2.py, warpimage.py, and pnganim.py (which
rely on external dependencies and/or an internet connection).
Added: trunk/toolkits/basemap/examples/cubed_sphere.py
===================================================================
--- trunk/toolkits/basemap/examples/cubed_sphere.py (rev 0)
+++ trunk/toolkits/basemap/examples/cubed_sphere.py 2008-08-17 22:17:56 UTC (rev 6038)
@@ -0,0 +1,30 @@
+from mpl_toolkits.basemap import Basemap
+import matplotlib.pyplot as plt
+import numpy as np
+# 'cubed sphere'
+# inscribe the sphere in a cube, then separately project each cube
+# face with gnomonic projection.
+# http://www.progonos.com/furuti/MapProj/Normal/ProjPoly/Foldout/Cube/cube.html
+# suitable for cutting and folding.
+fig = plt.figure(figsize=(8,6))
+fig.subplots_adjust(bottom=0, left=0, right=1, top=1, wspace=0, hspace=0)
+rsphere = 6370997.
+width = 2.*rsphere; height=width
+npanel=0
+for lat_0 in [90,0,-90]:
+ for ncol in range(0,4):
+ npanel = npanel + 1
+ if lat_0 != 0 and ncol != 1: continue
+ ax=fig.add_subplot(3,4,npanel)
+ ax.set_frame_on(False)
+ lon_0=225 + 90*(ncol+1) - 45
+ m = Basemap(width=width,height=height,resolution=None,\
+ projection='gnom',lon_0=lon_0,lat_0=lat_0,\
+ rsphere=rsphere)
+ m.bluemarble()
+ m.drawparallels(np.arange(-90,91,10),color='0.5')
+ m.drawmeridians(np.arange(0,360,10),color='0.5')
+fig.text(0.625,0.75,\
+ 'World Map on a Cube\n Gnomonic Projection',\
+ fontsize=14)
+plt.show()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <js...@us...> - 2008-08-16 22:48:21
|
Revision: 6037
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6037&view=rev
Author: jswhit
Date: 2008-08-16 22:48:18 +0000 (Sat, 16 Aug 2008)
Log Message:
-----------
added install instructions to new docs
Modified Paths:
--------------
trunk/toolkits/basemap/README
trunk/toolkits/basemap/doc/users/index.rst
Added Paths:
-----------
trunk/toolkits/basemap/doc/users/installing.rst
Modified: trunk/toolkits/basemap/README
===================================================================
--- trunk/toolkits/basemap/README 2008-08-14 13:38:01 UTC (rev 6036)
+++ trunk/toolkits/basemap/README 2008-08-16 22:48:18 UTC (rev 6037)
@@ -14,8 +14,6 @@
The GEOS (Geometry Engine - Open Source) library (version 2.2.3 or higher).
Source code is included in the geos-2.2.3 directory.
-setuptools (only if your are using python 2.3)
-
PIL (http://pythonware.com/products/pil) is optional (only
needed for Basemap warpimage and bluemarble methods).
@@ -71,11 +69,8 @@
0) Install pre-requisite python modules numpy and matplotlib.
-1) Then download basemap-X.Y.Z.tar.gz (approx 32 mb) from
+1) Then download basemap-X.Y.Z.tar.gz (approx 100 mb) from
the sourceforge download site, unpack and cd to basemap-X.Y.Z.
-If you want the full-resolution coastline dataset (useful if you
-will be making maps of very small regions), get
-basemap-fullresdata-X.Y.Z.tar.gz (approx. 100 mb).
2) Install the GEOS library. If you already have it on your
system, just set the environment variable GEOS_DIR to point to the location
Modified: trunk/toolkits/basemap/doc/users/index.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/index.rst 2008-08-14 13:38:01 UTC (rev 6036)
+++ trunk/toolkits/basemap/doc/users/index.rst 2008-08-16 22:48:18 UTC (rev 6037)
@@ -10,6 +10,7 @@
.. toctree::
intro.rst
+ installing.rst
mapsetup.rst
geography.rst
graticule.rst
Added: trunk/toolkits/basemap/doc/users/installing.rst
===================================================================
--- trunk/toolkits/basemap/doc/users/installing.rst (rev 0)
+++ trunk/toolkits/basemap/doc/users/installing.rst 2008-08-16 22:48:18 UTC (rev 6037)
@@ -0,0 +1,99 @@
+.. _installing:
+
+**********
+Installing
+**********
+
+Dependencies
+============
+
+**Requirements**
+
+These are external packages which you will need to install before
+installing basemap.
+
+
+matplotlib 0.98 (or later, `download <http://sf.net/projects/matplotlib/>`__)
+
+python 2.4 (or later but not python3)
+ matplotlib requires python 2.4 or later (`download <http://www.python.org/download/>`__)
+
+numpy 1.1 (or later)
+ array support for python (`download <http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=175103>`__)
+
+**Required libraries that ship with basemap**
+
+`GEOS <http://trac.osgeo.org/geos/>`__ (Geometry Engine - Open Source) library 2.2.3 or later (2.2.3 recommended).
+ Source code is included in the geos-2.2.3 directory.
+ When building from source, must be built and installed separately
+ from basemap (see build instructions below).
+ Included in Windows binary installers.
+
+`PROJ4 <http://trac.osgeo.org/proj/>`__ Cartographic Projections Library.
+ Patched version automatically built into basemap.
+
+`pyshapelib <http://intevation.de/pipermail/thuban-devel/2004-May/000184.html>`__
+ C library with python interface for reading ESRI shapefiles (automatically
+ built and installed with basemap).
+
+`pupnyere <http://pypi.python.org/pypi/pupynere/>`__
+ Pure python `netCDF <http://www.unidata.ucar.edu/software/netcdf/>`__
+ interface automatically installed with basemap.
+
+`pydap <http://code.google.com/p/pydap>`__
+ Pure python `OPeNDAP <http://opendap.org>`__ implementation.
+ If not present, client (not server) will be installed with basemap.
+
+`httplib2 <http://code.google.com/p/httplib2>`__ (needed for pydap client).
+ If not present, will be installed with basemap.
+
+
+**Optional libraries**
+
+PIL
+ Python Imaging Library (`download <http://www.pythonware.com/products/pil/>`__),
+ only needed for :func:`~mpl_toolkits.basemap.Basemap.bluemarble` and :func:`~mpl_toolkits.basemap.Basemap.warpimage` instance methods.
+
+Installation
+============
+
+Windows binary installers are available for
+`download <http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792/&abmode=1>`__.
+
+For other platforms, download the source release and follow these steps:
+
+
+* Install pre-requisite requirements.
+
+* Untar the basemap version X.Y.Z source tar.gz file, and
+ and cd to the basemap-X.Y.Z directory.
+
+* Install the GEOS library. If you already have it on your
+ system, just set the environment variable GEOS_DIR to point to the location
+ of libgeos_c and geos_c.h (if libgeos_c is in /usr/local/lib and
+ geos_c.h is in /usr/local/include, set GEOS_DIR to /usr/local).
+ Then go to next step. If you don't have it, you can build it from
+ the source code included with basemap by following these steps::
+
+ cd geos-2.2.3
+ export GEOS_DIR=<where you want the libs and headers to go>
+ # A reasonable choice on a Unix-like system is /usr/local, or
+ # if you don't have permission to write there, your home directory.
+ ./configure --prefix=$GEOS_DIR
+ make; make install
+
+* cd back to the top level basemap directory (basemap-X.Y.Z) and
+ run the usual ``python setup.py install``. Check your installation
+ by running ``from mpl_toolkits.basemap import Basemap`` at the python
+ prompt.
+
+ Basemap includes two auxilliary packages, pydap and httplib2.
+ By default, setup.py checks to
+ see if these are already installed, and if so does not try to overwrite
+ them. If you get import errors related to either of these two packages,
+ edit setup.cfg and set pydap and/or httplib2 to True to force
+ installation of the included versions.
+
+* To test, cd to the examples directory and run ``python simpletest.py``.
+ To run all the examples (except those that have extra dependencies
+ or require an internet connection), execute ``python run_all.py``.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|