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
|
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
|
|
|
|
|
|
1
(4) |
2
(9) |
3
(23) |
4
(34) |
5
(31) |
6
(25) |
7
(10) |
8
(7) |
9
(1) |
10
(18) |
11
(3) |
12
(18) |
13
(13) |
14
(6) |
15
(9) |
16
(6) |
17
(10) |
18
(12) |
19
(1) |
20
(8) |
21
(5) |
22
|
23
|
24
|
25
|
26
(4) |
27
(2) |
28
(4) |
29
|
30
|
31
|
|
|
|
|
|
From: <pki...@us...> - 2007-12-11 17:14:47
|
Revision: 4697 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4697&view=rev Author: pkienzle Date: 2007-12-11 09:14:44 -0800 (Tue, 11 Dec 2007) Log Message: ----------- remove wx specific gui_repaint comment Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backend_bases.py Modified: trunk/matplotlib/lib/matplotlib/backend_bases.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-12-10 21:06:59 UTC (rev 4696) +++ trunk/matplotlib/lib/matplotlib/backend_bases.py 2007-12-11 17:14:44 UTC (rev 4697) @@ -953,7 +953,6 @@ a.set_facecolor('lightblue') else: self._active[a] = None self.draw_idle() - #self.gui_repaint() def pick(self, mouseevent): if not self.widgetlock.locked(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-10 21:07:01
|
Revision: 4696 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4696&view=rev Author: jswhit Date: 2007-12-10 13:06:59 -0800 (Mon, 10 Dec 2007) Log Message: ----------- fix bug in geometry intersection error handling Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-10 20:32:26 UTC (rev 4695) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-10 21:06:59 UTC (rev 4696) @@ -826,7 +826,7 @@ try: geoms = poly.intersection(boundarypolyll) except: - pass + continue # iterate over geometries in intersection. for psub in geoms: # only coastlines are polygons, @@ -880,7 +880,7 @@ try: geoms = poly.intersection(boundarypolyxy) except: - pass + continue # iterate over geometries in intersection. for psub in geoms: b = psub.boundary This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-10 20:32:30
|
Revision: 4695 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4695&view=rev Author: jswhit Date: 2007-12-10 12:32:26 -0800 (Mon, 10 Dec 2007) Log Message: ----------- updated from pydap svn Modified Paths: -------------- trunk/toolkits/basemap/lib/dap/lib.py trunk/toolkits/basemap/lib/dap/parsers/das.py Modified: trunk/toolkits/basemap/lib/dap/lib.py =================================================================== --- trunk/toolkits/basemap/lib/dap/lib.py 2007-12-10 19:53:12 UTC (rev 4694) +++ trunk/toolkits/basemap/lib/dap/lib.py 2007-12-10 20:32:26 UTC (rev 4695) @@ -8,7 +8,7 @@ from urllib import quote as _quote __author__ = 'Roberto De Almeida <ro...@py...>' -__version__ = (2,2,6,1) # module version +__version__ = (2,2,6,2) # module version __dap__ = (2,0) # protocol version # Constants that used to live in __init__.py but had to be moved Modified: trunk/toolkits/basemap/lib/dap/parsers/das.py =================================================================== --- trunk/toolkits/basemap/lib/dap/parsers/das.py 2007-12-10 19:53:12 UTC (rev 4694) +++ trunk/toolkits/basemap/lib/dap/parsers/das.py 2007-12-10 20:32:26 UTC (rev 4695) @@ -222,7 +222,7 @@ if type_.lower() in ['string', 'url']: value = expr_eval(repr(value)) - value = value[1:-1] # strip "" + value = value.strip('"') elif type_.lower() == 'alias': # Support for Alias is not documented in the DAP spec. I based # this on the Java documentation from the OPeNDAP website at: @@ -241,24 +241,15 @@ break else: value = value.attributes - else: - dtype = {'float64': 'd', - 'float32': 'f', - 'int32' : 'l', - 'int16' : 'h', - 'uint32' : 'L', - 'uint16' : 'H', - 'byte' : 'B', - }[type_.lower()] + elif type_.lower() == 'float32': # Convert to right precision; otherwise floats # are converted to Float64 automatically by # Python. - # B. Granger 5/17/07 - This line is giving a DeprecationWarning - # when dtype = 'l'. It looks like it doesn't like getting a float - # when a long int is expected. Because this is in a critical - # code path that I don't know well, and it seems to work OK for now - # I didn't change anything. Should be looked into though. - value = array.array(dtype, [float(value)])[0] + value = array.array('f', [float(value)])[0] + elif type_.lower() == 'float64': + value = array.array('d', [float(value)])[0] + else: + value = int(value) values.append(value) if self._check(','): self._consume(',') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 19:53:14
|
Revision: 4694 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4694&view=rev Author: mdboom Date: 2007-12-10 11:53:12 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Simplify even more Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-12-10 19:46:00 UTC (rev 4693) +++ branches/transforms/lib/matplotlib/path.py 2007-12-10 19:53:12 UTC (rev 4694) @@ -440,20 +440,28 @@ n = int(2 ** math.ceil((eta2 - eta1) / halfpi)) deta = (eta2 - eta1) / n - etaB = eta1 + t = math.tan(0.5 * deta) + alpha = math.sin(deta) * (math.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0 - cos_etaB = math.cos(etaB) - sin_etaB = math.sin(etaB) - xB = cos_etaB - yB = sin_etaB - xB_dot = -sin_etaB - yB_dot = cos_etaB + steps = npy.linspace(eta1, eta2, n + 1, True) + cos_eta = npy.cos(steps) + sin_eta = npy.sin(steps) + xA = cos_eta[:-1] + yA = sin_eta[:-1] + xA_dot = -yA + yA_dot = xA + + xB = cos_eta[1:] + yB = sin_eta[1:] + xB_dot = -yB + yB_dot = xB + if is_wedge: length = n * 3 + 4 vertices = npy.zeros((length, 2), npy.float_) codes = Path.CURVE4 * npy.ones((length, ), Path.code_type) - vertices[1] = [xB, yB] + vertices[1] = [xA[0], yA[0]] codes[0:2] = [Path.MOVETO, Path.LINETO] codes[-2:] = [Path.LINETO, Path.CLOSEPOLY] vertex_offset = 2 @@ -462,28 +470,11 @@ length = n * 3 + 1 vertices = npy.zeros((length, 2), npy.float_) codes = Path.CURVE4 * npy.ones((length, ), Path.code_type) - vertices[0] = [xB, yB] + vertices[0] = [xA[0], yA[0]] codes[0] = Path.MOVETO vertex_offset = 1 end = length - t = math.tan(0.5 * deta) - alpha = math.sin(deta) * (math.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0 - - steps = npy.linspace(eta1, eta2, n + 1, True) - cos_eta = npy.cos(steps) - sin_eta = npy.sin(steps) - - xA = cos_eta[:-1] - yA = sin_eta[:-1] - xA_dot = -yA - yA_dot = xA - - xB = cos_eta[1:] - yB = sin_eta[1:] - xB_dot = -yB - yB_dot = xB - vertices[vertex_offset :end:3, 0] = xA + alpha * xA_dot vertices[vertex_offset :end:3, 1] = yA + alpha * yA_dot vertices[vertex_offset+1:end:3, 0] = xB - alpha * xB_dot This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 19:46:04
|
Revision: 4693 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4693&view=rev Author: mdboom Date: 2007-12-10 11:46:00 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Numpify arc/wedge approximation. Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-12-10 16:27:25 UTC (rev 4692) +++ branches/transforms/lib/matplotlib/path.py 2007-12-10 19:46:00 UTC (rev 4693) @@ -408,10 +408,14 @@ unit_circle = classmethod(unit_circle) #@classmethod - def arc(cls, theta1, theta2, is_wedge=False): + def arc(cls, theta1, theta2, is_wedge=False, n=None): """ Returns an arc on the unit circle from angle theta1 to angle theta2 (in degrees). + + If n is provided, it is the number of spline segments to make. + If n is not provided, the number of spline segments is determined + based on the delta between theta1 and theta2. """ # From Masionobe, L. 2003. "Drawing an elliptical arc using # polylines, quadratic or cubic Bezier curves". @@ -422,7 +426,7 @@ theta1 *= math.pi / 180.0 theta2 *= math.pi / 180.0 - twopi = math.pi * 2.0 + twopi = math.pi * 2.0 halfpi = math.pi * 0.5 eta1 = math.atan2(math.sin(theta1), math.cos(theta1)) @@ -432,7 +436,8 @@ eta2 += twopi # number of curve segments to make - n = int(2 ** math.ceil((eta2 - eta1) / halfpi)) + if n is None: + n = int(2 ** math.ceil((eta2 - eta1) / halfpi)) deta = (eta2 - eta1) / n etaB = eta1 @@ -450,7 +455,9 @@ codes = Path.CURVE4 * npy.ones((length, ), Path.code_type) vertices[1] = [xB, yB] codes[0:2] = [Path.MOVETO, Path.LINETO] + codes[-2:] = [Path.LINETO, Path.CLOSEPOLY] vertex_offset = 2 + end = length - 2 else: length = n * 3 + 1 vertices = npy.zeros((length, 2), npy.float_) @@ -458,32 +465,31 @@ vertices[0] = [xB, yB] codes[0] = Path.MOVETO vertex_offset = 1 + end = length t = math.tan(0.5 * deta) alpha = math.sin(deta) * (math.sqrt(4.0 + 3.0 * t * t) - 1) / 3.0 - for i in xrange(n): - xA = xB - yA = yB - xA_dot = xB_dot - yA_dot = yB_dot + steps = npy.linspace(eta1, eta2, n + 1, True) + cos_eta = npy.cos(steps) + sin_eta = npy.sin(steps) - etaB += deta - cos_etaB = math.cos(etaB) - sin_etaB = math.sin(etaB) - xB = cos_etaB - yB = sin_etaB - xB_dot = -sin_etaB - yB_dot = cos_etaB + xA = cos_eta[:-1] + yA = sin_eta[:-1] + xA_dot = -yA + yA_dot = xA - offset = i*3 + vertex_offset - vertices[offset:offset+3] = [ - [xA + alpha * xA_dot, yA + alpha * yA_dot], - [xB - alpha * xB_dot, yB - alpha * yB_dot], - [xB, yB]] + xB = cos_eta[1:] + yB = sin_eta[1:] + xB_dot = -yB + yB_dot = xB - if is_wedge: - codes[-2:] = [Path.LINETO, Path.CLOSEPOLY] + vertices[vertex_offset :end:3, 0] = xA + alpha * xA_dot + vertices[vertex_offset :end:3, 1] = yA + alpha * yA_dot + vertices[vertex_offset+1:end:3, 0] = xB - alpha * xB_dot + vertices[vertex_offset+1:end:3, 1] = yB - alpha * yB_dot + vertices[vertex_offset+2:end:3, 0] = xB + vertices[vertex_offset+2:end:3, 1] = yB return Path(vertices, codes) arc = classmethod(arc) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-10 16:27:28
|
Revision: 4692 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4692&view=rev Author: jswhit Date: 2007-12-10 08:27:25 -0800 (Mon, 10 Dec 2007) Log Message: ----------- include plotcities.py example Modified Paths: -------------- trunk/toolkits/basemap/MANIFEST.in Modified: trunk/toolkits/basemap/MANIFEST.in =================================================================== --- trunk/toolkits/basemap/MANIFEST.in 2007-12-10 16:26:00 UTC (rev 4691) +++ trunk/toolkits/basemap/MANIFEST.in 2007-12-10 16:27:25 UTC (rev 4692) @@ -30,6 +30,7 @@ include examples/huralll020.shx include examples/hurrtracks.py include examples/fcover.dat +include examples/plotcities.py include examples/plotmap.py include examples/plotmap_oo.py include examples/plotmap_masked.py @@ -54,6 +55,9 @@ include examples/ccsm_popgrid.py include examples/ccsm_popgrid.nc include examples/plot_tissot.py +include examples/cities.dbf +include examples/cities.shp +include examples/cities.shx include examples/tissot.dbf include examples/tissot.shp include examples/tissot.shx This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 16:26:05
|
Revision: 4691 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4691&view=rev Author: mdboom Date: 2007-12-10 08:26:00 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Somehow the merge went awry last time. Fixing. Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_cairo.py branches/transforms/lib/matplotlib/backends/backend_pdf.py branches/transforms/lib/matplotlib/backends/backend_ps.py branches/transforms/lib/matplotlib/backends/backend_svg.py Modified: branches/transforms/lib/matplotlib/backends/backend_cairo.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -118,7 +118,6 @@ ctx.stroke() -<<<<<<< .working #@staticmethod def convert_path(ctx, tpath): for points, code in tpath.iter_segments(): @@ -135,48 +134,12 @@ elif code == Path.CLOSEPOLY: ctx.close_path() convert_path = staticmethod(convert_path) -======= - def draw_path(self, gc, rgbFace, path): - ctx = gc.ctx - ctx.new_path() ->>>>>>> .merge-right.r4686 -<<<<<<< .working def draw_path(self, gc, path, transform, rgbFace=None): if len(path.vertices) > 18980: raise ValueError("The Cairo backend can not draw paths longer than 18980 points.") -======= - while 1: - code, xp, yp = path.vertex() - yp = self.height - yp - - if code == agg.path_cmd_stop: - ctx.close_path() - break - elif code == agg.path_cmd_move_to: - ctx.move_to(xp, yp) - elif code == agg.path_cmd_line_to: - ctx.line_to(xp, yp) - elif code == agg.path_cmd_curve3: - _, xp1, yp1 = path.vertex() - yp1 = self.height - yp1 - ctx.curve_to(xp, yp, xp, yp, xp1, yp1) - elif code == agg.path_cmd_curve4: - _, xp1, yp1 = path.vertex() - yp1 = self.height - yp1 - _, xp2, yp2 = path.vertex() - yp2 = self.height - yp2 - ctx.curve_to(xp, yp, xp1, yp1, xp2, yp2) - elif code == agg.path_cmd_end_poly: - ctx.close_path() - self._fill_and_stroke(ctx, rgbFace) - - def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, - rotation): - if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) ->>>>>>> .merge-right.r4686 ctx = gc.ctx transform = transform + \ Affine2D().scale(1.0, -1.0).translate(0, self.height) Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -1211,97 +1211,7 @@ stat_key, (realpath, Set())) used_characters[1].update(set) -<<<<<<< .working def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): -======= - def draw_arc(self, gcEdge, rgbFace, x, y, width, height, - angle1, angle2, rotation): - """ - Draw an arc using GraphicsContext instance gcEdge, centered at x,y, - with width and height and angles from 0.0 to 360.0 - 0 degrees is at 3-o'clock, rotated by `rotation` degrees - positive angles are anti-clockwise - - If the color rgbFace is not None, fill the arc with it. - """ - # source: agg_bezier_arc.cpp in agg23 - - def arc_to_bezier(cx, cy, rx, ry, angle1, sweep, rotation): - halfsweep = sweep / 2.0 - x0, y0 = cos(halfsweep), sin(halfsweep) - tx = (1.0 - x0) * 4.0/3.0; - ty = y0 - tx * x0 / y0; - px = x0, x0+tx, x0+tx, x0 - py = -y0, -ty, ty, y0 - sn, cs = sin(angle1 + halfsweep), cos(angle1 + halfsweep) - result = [ (rx * (pxi * cs - pyi * sn), - ry * (pxi * sn + pyi * cs)) - for pxi, pyi in zip(px, py) ] - result = [ (cx + cos(rotation)*x - sin(rotation)*y, - cy + sin(rotation)*x + cos(rotation)*y) - for x, y in result ] - return reduce(lambda x, y: x + y, result) - - epsilon = 0.01 - angle1 *= pi/180.0 - angle2 *= pi/180.0 - rotation *= pi/180.0 - sweep = angle2 - angle1 - angle1 = angle1 % (2*pi) - sweep = min(max(-2*pi, sweep), 2*pi) - - if sweep < 0.0: - sweep, angle1, angle2 = -sweep, angle2, angle1 - bp = [ pi/2.0 * i - for i in range(4) - if pi/2.0 * i < sweep-epsilon ] - bp.append(sweep) - subarcs = [ arc_to_bezier(x, y, width/2.0, height/2.0, - bp[i], bp[i+1]-bp[i], rotation) - for i in range(len(bp)-1) ] - - self.check_gc(gcEdge, rgbFace) - self.file.output(subarcs[0][0], subarcs[0][1], Op.moveto) - for arc in subarcs: - self.file.output(*(arc[2:] + (Op.curveto,))) - - self.file.output(self.gc.close_and_paint()) - - def draw_path(self, gc, rgbFace, path): - self.check_gc(gc, rgbFace) - - cmds = [] - - while 1: - code, xp, yp = path.vertex() - - if code == agg.path_cmd_stop: - cmds.append(Op.closepath) - break - elif code == agg.path_cmd_move_to: - cmds.extend([xp, yp, Op.moveto]) - elif code == agg.path_cmd_line_to: - cmds.extend([xp, yp, Op.lineto]) - elif code == agg.path_cmd_curve3: - cmds.extend([xp, yp]) - cmds.extend([xp, yp]) - cmds.extend(path.vertex()[1:]) - cmds.append(Op.curveto) - elif code == agg.path_cmd_curve4: - cmds.extend([xp, yp]) - cmds.extend(path.vertex()[1:]) - cmds.extend(path.vertex()[1:]) - cmds.append(Op.curveto) - elif code == agg.path_cmd_end_poly: - cmds.append(Op.closepath) - self.file.output(*cmds) - self.file.output(self.gc.paint()) - - def get_image_magnification(self): - return self.image_magnification - - def draw_image(self, x, y, im, bbox): ->>>>>>> .merge-right.r4686 #print >>sys.stderr, "draw_image called" # MGDTODO: Support clippath here Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -1430,31 +1430,4 @@ clip newpath } bind def""", -<<<<<<< .working -======= - # angle1 angle2 rx ry x y *ellipse* - - """/ellipse { - newpath - matrix currentmatrix 7 1 roll - translate - scale - 0 0 1 5 3 roll arc - setmatrix - closepath - } bind def""", - """/unitcircle { - newpath -0. -1. moveto -0.2652031 -1.0 0.519579870785 -0.894633691588 0.707106781187 -0.707106781187 curveto -0.894633691588 -0.519579870785 1.0 -0.2652031 1.0 0.0 curveto -1.0 0.2652031 0.894633691588 0.519579870785 0.707106781187 0.707106781187 curveto -0.519579870785 0.894633691588 0.2652031 1.0 0.0 1.0 curveto --0.2652031 1.0 -0.519579870785 0.894633691588 -0.707106781187 0.707106781187 curveto --0.894633691588 0.519579870785 -1.0 0.2652031 -1.0 0.0 curveto --1.0 -0.2652031 -0.894633691588 -0.519579870785 -0.707106781187 -0.707106781187 curveto --0.519579870785 -0.894633691588 -0.2652031 -1.0 0.0 -1.0 curveto -closepath - } bind def""", - ->>>>>>> .merge-right.r4679 ] Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:23:52 UTC (rev 4690) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:26:00 UTC (rev 4691) @@ -140,49 +140,6 @@ def close_group(self, s): self._svgwriter.write('</g>\n') -<<<<<<< .working -======= - def draw_path(self, gc, rgbFace, path): - cmd = [] - - while 1: - code, xp, yp = path.vertex() - yp = self.height - yp - - if code == agg.path_cmd_stop: - cmd.append('z') # Hack, path_cmd_end_poly not found - break - elif code == agg.path_cmd_move_to: - cmd.append('M%g %g' % (xp, yp)) - elif code == agg.path_cmd_line_to: - cmd.append('L%g %g' % (xp, yp)) - elif code == agg.path_cmd_curve3: - verts = [xp, yp] - verts.extent(path.vertex()[1:]) - verts[-1] = self.height - verts[-1] - cmd.append('Q%g %g %g %g' % tuple(verts)) - elif code == agg.path_cmd_curve4: - verts = [xp, yp] - verts.extend(path.vertex()[1:]) - verts[-1] = self.height - verts[-1] - verts.extend(path.vertex()[1:]) - verts[-1] = self.height - verts[-1] - cmd.append('C%g %g %g %g %g %g'%tuple(verts)) - elif code == agg.path_cmd_end_poly: - cmd.append('z') - - path_data = "".join(cmd) - self._draw_svg_element("path", 'd="%s"' % path_data, gc, rgbFace) - - def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation): - """ - Ignores angles for now - """ - details = 'cx="%s" cy="%s" rx="%s" ry="%s" transform="rotate(%1.1f %s %s)"' % \ - (x, self.height-y, width/2.0, height/2.0, -rotation, x, self.height-y) - self._draw_svg_element('ellipse', details, gc, rgbFace) - ->>>>>>> .merge-right.r4686 def option_image_nocomposite(self): """ if svg.image_noscale is True, compositing multiple images into one is prohibited This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-10 16:23:57
|
Revision: 4690 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4690&view=rev Author: jswhit Date: 2007-12-10 08:23:52 -0800 (Mon, 10 Dec 2007) Log Message: ----------- cleanup docstring Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-10 16:21:36 UTC (rev 4689) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-12-10 16:23:52 UTC (rev 4690) @@ -2912,9 +2912,9 @@ times - numeric time values. Maximum resolution is 1 second. - units - a string of the form '<time-units> since <reference time>' - describing the time units. <time-units> can be days, hours, minutes - or seconds. <reference-time> is the time origin. A valid choice + units - a string of the form '<time units> since <reference time>' + describing the time units. <time units> can be days, hours, minutes + or seconds. <reference time> is the time origin. A valid choice would be units='hours since 1800-01-01 00:00:00 -6:00'. calendar - describes the calendar used in the time calculations. @@ -2922,7 +2922,8 @@ (http://cf-pcmdi.llnl.gov/documents/cf-conventions/) are supported. Valid calendars 'standard', 'gregorian', 'proleptic_gregorian' 'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'. - Default is 'standard', which is a mixed Julian/Gregorian calendar. + Default is 'standard'/'gregorian', which is a mixed + Julian/Gregorian calendar. Returns a datetime instance, or an array of datetime instances. @@ -2931,11 +2932,8 @@ calendar='proleptic_gregorian', or calendar = 'standard' or 'gregorian' and the date is after 1582-10-15). Otherwise, they are 'phony' datetime objects which support some but not all the methods of 'real' python - datetime objects. This is because the python datetime module cannot - the weird dates in some calendars (such as '360_day' and 'all_leap' - which don't exist in any real world calendar. The datetime instances - do not contain a time-zone offset, even if the specified units - contains one. + datetime objects. The datetime instances do not contain + a time-zone offset, even if the specified units contains one. """ cdftime = netcdftime.utime(units,calendar=calendar) return cdftime.num2date(times) @@ -2959,9 +2957,9 @@ dates - A datetime object or a sequence of datetime objects. The datetime objects should not include a time-zone offset. - units - a string of the form '<time-units> since <reference time>' - describing the time units. <time-units> can be days, hours, minutes - or seconds. <reference-time> is the time origin. A valid choice + units - a string of the form '<time units> since <reference time>' + describing the time units. <time units> can be days, hours, minutes + or seconds. <reference time> is the time origin. A valid choice would be units='hours since 1800-01-01 00:00:00 -6:00'. calendar - describes the calendar used in the time calculations. @@ -2969,7 +2967,8 @@ (http://cf-pcmdi.llnl.gov/documents/cf-conventions/) are supported. Valid calendars 'standard', 'gregorian', 'proleptic_gregorian' 'noleap', '365_day', '360_day', 'julian', 'all_leap', '366_day'. - Default is 'standard', which is a mixed Julian/Gregorian calendar. + Default is 'standard'/'gregorian', which is a mixed + Julian/Gregorian calendar. Returns a numeric time value, or an array of numeric time values. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 16:21:40
|
Revision: 4689 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4689&view=rev Author: mdboom Date: 2007-12-10 08:21:36 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Merged revisions 4683-4688 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4684 | mdboom | 2007-12-10 10:23:08 -0500 (Mon, 10 Dec 2007) | 2 lines Fix variable name. ........ r4685 | mdboom | 2007-12-10 10:34:29 -0500 (Mon, 10 Dec 2007) | 2 lines Fix syntax for pre-Python 2.5 ........ r4686 | mdboom | 2007-12-10 11:15:30 -0500 (Mon, 10 Dec 2007) | 4 lines Support draw_path (importantly for ellipses) in Pdf, Svg and Cairo backends. Fix SVG text rendering bug. ........ Modified Paths: -------------- branches/transforms/CHANGELOG branches/transforms/lib/matplotlib/backends/backend_cairo.py branches/transforms/lib/matplotlib/backends/backend_pdf.py branches/transforms/lib/matplotlib/backends/backend_svg.py branches/transforms/lib/matplotlib/font_manager.py branches/transforms/lib/matplotlib/patches.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4682 + /trunk/matplotlib:1-4688 Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-12-10 16:17:42 UTC (rev 4688) +++ branches/transforms/CHANGELOG 2007-12-10 16:21:36 UTC (rev 4689) @@ -1,3 +1,9 @@ +2007-12-10 Fix SVG text rendering bug. + +2007-12-10 Increase accuracy of circle and ellipse drawing by using an 8-piece + bezier approximation, rather than a 4-piece one. Fix PDF, SVG and + Cairo backends so they can draw paths (meaning ellipses as well). + 2007-12-07 Issue a warning when drawing an image on a non-linear axis. - MGD 2007-12-06 let widgets.Cursor initialize to the lower x and y bounds Modified: branches/transforms/lib/matplotlib/backends/backend_cairo.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:17:42 UTC (rev 4688) +++ branches/transforms/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:21:36 UTC (rev 4689) @@ -34,6 +34,7 @@ backend_version = cairo.version del _version_required +from matplotlib import agg from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import enumerate, izip, is_string_like @@ -117,6 +118,7 @@ ctx.stroke() +<<<<<<< .working #@staticmethod def convert_path(ctx, tpath): for points, code in tpath.iter_segments(): @@ -133,12 +135,48 @@ elif code == Path.CLOSEPOLY: ctx.close_path() convert_path = staticmethod(convert_path) +======= + def draw_path(self, gc, rgbFace, path): + ctx = gc.ctx + ctx.new_path() +>>>>>>> .merge-right.r4686 +<<<<<<< .working def draw_path(self, gc, path, transform, rgbFace=None): if len(path.vertices) > 18980: raise ValueError("The Cairo backend can not draw paths longer than 18980 points.") +======= + while 1: + code, xp, yp = path.vertex() + yp = self.height - yp + + if code == agg.path_cmd_stop: + ctx.close_path() + break + elif code == agg.path_cmd_move_to: + ctx.move_to(xp, yp) + elif code == agg.path_cmd_line_to: + ctx.line_to(xp, yp) + elif code == agg.path_cmd_curve3: + _, xp1, yp1 = path.vertex() + yp1 = self.height - yp1 + ctx.curve_to(xp, yp, xp, yp, xp1, yp1) + elif code == agg.path_cmd_curve4: + _, xp1, yp1 = path.vertex() + yp1 = self.height - yp1 + _, xp2, yp2 = path.vertex() + yp2 = self.height - yp2 + ctx.curve_to(xp, yp, xp1, yp1, xp2, yp2) + elif code == agg.path_cmd_end_poly: + ctx.close_path() + self._fill_and_stroke(ctx, rgbFace) + + def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, + rotation): + if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) +>>>>>>> .merge-right.r4686 ctx = gc.ctx transform = transform + \ Affine2D().scale(1.0, -1.0).translate(0, self.height) Modified: branches/transforms/lib/matplotlib/backends/backend_pdf.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:17:42 UTC (rev 4688) +++ branches/transforms/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:21:36 UTC (rev 4689) @@ -1211,7 +1211,97 @@ stat_key, (realpath, Set())) used_characters[1].update(set) +<<<<<<< .working def draw_image(self, x, y, im, bbox, clippath=None, clippath_trans=None): +======= + def draw_arc(self, gcEdge, rgbFace, x, y, width, height, + angle1, angle2, rotation): + """ + Draw an arc using GraphicsContext instance gcEdge, centered at x,y, + with width and height and angles from 0.0 to 360.0 + 0 degrees is at 3-o'clock, rotated by `rotation` degrees + positive angles are anti-clockwise + + If the color rgbFace is not None, fill the arc with it. + """ + # source: agg_bezier_arc.cpp in agg23 + + def arc_to_bezier(cx, cy, rx, ry, angle1, sweep, rotation): + halfsweep = sweep / 2.0 + x0, y0 = cos(halfsweep), sin(halfsweep) + tx = (1.0 - x0) * 4.0/3.0; + ty = y0 - tx * x0 / y0; + px = x0, x0+tx, x0+tx, x0 + py = -y0, -ty, ty, y0 + sn, cs = sin(angle1 + halfsweep), cos(angle1 + halfsweep) + result = [ (rx * (pxi * cs - pyi * sn), + ry * (pxi * sn + pyi * cs)) + for pxi, pyi in zip(px, py) ] + result = [ (cx + cos(rotation)*x - sin(rotation)*y, + cy + sin(rotation)*x + cos(rotation)*y) + for x, y in result ] + return reduce(lambda x, y: x + y, result) + + epsilon = 0.01 + angle1 *= pi/180.0 + angle2 *= pi/180.0 + rotation *= pi/180.0 + sweep = angle2 - angle1 + angle1 = angle1 % (2*pi) + sweep = min(max(-2*pi, sweep), 2*pi) + + if sweep < 0.0: + sweep, angle1, angle2 = -sweep, angle2, angle1 + bp = [ pi/2.0 * i + for i in range(4) + if pi/2.0 * i < sweep-epsilon ] + bp.append(sweep) + subarcs = [ arc_to_bezier(x, y, width/2.0, height/2.0, + bp[i], bp[i+1]-bp[i], rotation) + for i in range(len(bp)-1) ] + + self.check_gc(gcEdge, rgbFace) + self.file.output(subarcs[0][0], subarcs[0][1], Op.moveto) + for arc in subarcs: + self.file.output(*(arc[2:] + (Op.curveto,))) + + self.file.output(self.gc.close_and_paint()) + + def draw_path(self, gc, rgbFace, path): + self.check_gc(gc, rgbFace) + + cmds = [] + + while 1: + code, xp, yp = path.vertex() + + if code == agg.path_cmd_stop: + cmds.append(Op.closepath) + break + elif code == agg.path_cmd_move_to: + cmds.extend([xp, yp, Op.moveto]) + elif code == agg.path_cmd_line_to: + cmds.extend([xp, yp, Op.lineto]) + elif code == agg.path_cmd_curve3: + cmds.extend([xp, yp]) + cmds.extend([xp, yp]) + cmds.extend(path.vertex()[1:]) + cmds.append(Op.curveto) + elif code == agg.path_cmd_curve4: + cmds.extend([xp, yp]) + cmds.extend(path.vertex()[1:]) + cmds.extend(path.vertex()[1:]) + cmds.append(Op.curveto) + elif code == agg.path_cmd_end_poly: + cmds.append(Op.closepath) + self.file.output(*cmds) + self.file.output(self.gc.paint()) + + def get_image_magnification(self): + return self.image_magnification + + def draw_image(self, x, y, im, bbox): +>>>>>>> .merge-right.r4686 #print >>sys.stderr, "draw_image called" # MGDTODO: Support clippath here Modified: branches/transforms/lib/matplotlib/backends/backend_svg.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:17:42 UTC (rev 4688) +++ branches/transforms/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:21:36 UTC (rev 4689) @@ -2,6 +2,7 @@ import os, codecs, base64, tempfile, urllib, gzip +from matplotlib import agg from matplotlib import verbose, __version__, rcParams from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase @@ -139,6 +140,49 @@ def close_group(self, s): self._svgwriter.write('</g>\n') +<<<<<<< .working +======= + def draw_path(self, gc, rgbFace, path): + cmd = [] + + while 1: + code, xp, yp = path.vertex() + yp = self.height - yp + + if code == agg.path_cmd_stop: + cmd.append('z') # Hack, path_cmd_end_poly not found + break + elif code == agg.path_cmd_move_to: + cmd.append('M%g %g' % (xp, yp)) + elif code == agg.path_cmd_line_to: + cmd.append('L%g %g' % (xp, yp)) + elif code == agg.path_cmd_curve3: + verts = [xp, yp] + verts.extent(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + cmd.append('Q%g %g %g %g' % tuple(verts)) + elif code == agg.path_cmd_curve4: + verts = [xp, yp] + verts.extend(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + verts.extend(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + cmd.append('C%g %g %g %g %g %g'%tuple(verts)) + elif code == agg.path_cmd_end_poly: + cmd.append('z') + + path_data = "".join(cmd) + self._draw_svg_element("path", 'd="%s"' % path_data, gc, rgbFace) + + def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation): + """ + Ignores angles for now + """ + details = 'cx="%s" cy="%s" rx="%s" ry="%s" transform="rotate(%1.1f %s %s)"' % \ + (x, self.height-y, width/2.0, height/2.0, -rotation, x, self.height-y) + self._draw_svg_element('ellipse', details, gc, rgbFace) + +>>>>>>> .merge-right.r4686 def option_image_nocomposite(self): """ if svg.image_noscale is True, compositing multiple images into one is prohibited @@ -327,7 +371,7 @@ svg.append(' x="%s"' % (currx * (self.FONT_SCALE / fontsize))) svg.append('/>\n') - currx += (glyph.linearHoriAdvance / 65536.0) + currx += (glyph.linearHoriAdvance / 65536.0) / (self.FONT_SCALE / fontsize) svg.append('</g>\n') svg = ''.join(svg) else: Modified: branches/transforms/lib/matplotlib/font_manager.py =================================================================== --- branches/transforms/lib/matplotlib/font_manager.py 2007-12-10 16:17:42 UTC (rev 4688) +++ branches/transforms/lib/matplotlib/font_manager.py 2007-12-10 16:21:36 UTC (rev 4689) @@ -109,9 +109,10 @@ else: user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders) try: - return _winreg.QueryValueEx(user, 'Fonts')[0] - except OSError: - pass # Fall through to default + try: + return _winreg.QueryValueEx(user, 'Fonts')[0] + except OSError: + pass # Fall through to default finally: _winreg.CloseKey(user) return os.path.join(os.environ['WINDIR'], 'Fonts') Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-12-10 16:17:42 UTC (rev 4688) +++ branches/transforms/lib/matplotlib/patches.py 2007-12-10 16:21:36 UTC (rev 4689) @@ -820,49 +820,6 @@ """ A scale-free ellipse """ -<<<<<<< .working -======= - MAGIC = 0.2652031 - SQRT2 = npy.sqrt(0.5) - MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0) - - circle = npy.array( - [[0.0, -1.0], - - [MAGIC, -1.0], - [SQRT2-MAGIC45, -SQRT2-MAGIC45], - [SQRT2, -SQRT2], - - [SQRT2+MAGIC45, -SQRT2+MAGIC45], - [1.0, -MAGIC], - [1.0, 0.0], - - [1.0, MAGIC], - [SQRT2+MAGIC45, SQRT2-MAGIC45], - [SQRT2, SQRT2], - - [SQRT2-MAGIC45, SQRT2+MAGIC45], - [MAGIC, 1.0], - [0.0, 1.0], - - [-MAGIC, 1.0], - [-SQRT2+MAGIC45, SQRT2+MAGIC45], - [-SQRT2, SQRT2], - - [-SQRT2-MAGIC45, SQRT2-MAGIC45], - [-1.0, MAGIC], - [-1.0, 0.0], - - [-1.0, -MAGIC], - [-SQRT2-MAGIC45, -SQRT2+MAGIC45], - [-SQRT2, -SQRT2], - - [-SQRT2+MAGIC45, -SQRT2-MAGIC45], - [-MAGIC, -1.0], - [0.0, -1.0]], - npy.float_) - ->>>>>>> .merge-right.r4679 def __str__(self): return "Ellipse(%d,%d;%dx%d)"%(self.center[0],self.center[1],self.width,self.height) @@ -898,17 +855,10 @@ def get_patch_transform(self): return self._patch_transform -<<<<<<< .working def contains(self,ev): if ev.x is None or ev.y is None: return False,{} x, y = self.get_transform().inverted().transform_point((ev.x, ev.y)) return (x*x + y*y) <= 1.0, {} -======= - xcenter = self.convert_xunits(xcenter) - width = self.convert_xunits(width) - ycenter = self.convert_yunits(ycenter) - height = self.convert_xunits(height) ->>>>>>> .merge-right.r4679 def _get_center(self): return self._center @@ -932,105 +882,6 @@ angle = property(_get_angle, _set_angle) -<<<<<<< .working -======= - rtheta = angle*npy.pi/180. - R = npy.array([ - [npy.cos(rtheta), -npy.sin(rtheta)], - [npy.sin(rtheta), npy.cos(rtheta)], - ]) - - - x, y = npy.dot(R, npy.array([x, y])) - x += xcenter - y += ycenter - - return zip(x, y) - - def draw(self, renderer): - if not self.get_visible(): return - #renderer.open_group('patch') - gc = renderer.new_gc() - gc.set_foreground(self._edgecolor) - gc.set_linewidth(self._linewidth) - gc.set_alpha(self._alpha) - gc.set_antialiased(self._antialiased) - self._set_gc_clip(gc) - - gc.set_capstyle('projecting') - - if not self.fill or self._facecolor is None: rgbFace = None - else: rgbFace = colors.colorConverter.to_rgb(self._facecolor) - - if self._hatch: - gc.set_hatch(self._hatch ) - - - if not hasattr(renderer, 'draw_path'): - mpl.verbose.report('patches.Ellipse renderer does not support path drawing; falling back on vertex approximation for nonlinear transformation') - renderer.draw_polygon(gc, rgbFace, self.get_verts()) - return - - - x, y = self.center - x = self.convert_xunits(x) - y = self.convert_yunits(y) - w = self.convert_xunits(self.width)/2. - h = self.convert_yunits(self.height)/2. - - theta = self.angle * npy.pi/180. - T = npy.array([ - [1, 0, x], - [0, 1, y], - [0, 0, 1]]) - - - - - S = npy.array([ - [w, 0, 0], - [0, h, 0], - [0, 0, 1]]) - - - - # rotate by theta - R = npy.array([ - [npy.cos(theta), -npy.sin(theta), 0], - [npy.sin(theta), npy.cos(theta), 0], - [0, 0, 1]]) - - # transform unit circle into ellipse - E = npy.dot(T, npy.dot(R, S)) - - - # Apply the display affine - sx, b, c, sy, tx, ty = self.get_transform().as_vec6_val() - - # display coords - D = npy.array([ - [sx, b, tx], - [c, sy, ty], - [0, 0, 1]], npy.float_) - - M = npy.dot(D,E) - - C = npy.ones((3, len(self.circle))) - C[0:2,:] = self.circle.T - - ellipse = npy.dot(M, C).T[:,:2] - - path = agg.path_storage() - path.move_to(*ellipse[0]) - for i in range(1, 25, 3): - path.curve4(*ellipse[i:i+3].flat) - path.close_polygon() - - renderer.draw_path(gc, rgbFace, path) - - ->>>>>>> .merge-right.r4679 - class Circle(Ellipse): """ A circle patch This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 16:17:46
|
Revision: 4688 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4688&view=rev Author: mdboom Date: 2007-12-10 08:17:42 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Merged revisions 4669-4682 via svnmerge from http://matplotlib.svn.sf.net/svnroot/matplotlib/trunk/matplotlib ........ r4670 | mdboom | 2007-12-07 14:18:58 -0500 (Fri, 07 Dec 2007) | 2 lines Updating CHANGELOG. ........ r4679 | mdboom | 2007-12-10 09:50:40 -0500 (Mon, 10 Dec 2007) | 2 lines Use an 8-spline approximation of an ellipse instead of a 4-spline one. ........ Modified Paths: -------------- branches/transforms/CHANGELOG branches/transforms/lib/matplotlib/backends/backend_ps.py branches/transforms/lib/matplotlib/patches.py Added Paths: ----------- branches/transforms/unit/ellipse_large.py Property Changed: ---------------- branches/transforms/ Property changes on: branches/transforms ___________________________________________________________________ Name: svnmerge-integrated - /trunk/matplotlib:1-4668 + /trunk/matplotlib:1-4682 Modified: branches/transforms/CHANGELOG =================================================================== --- branches/transforms/CHANGELOG 2007-12-10 16:17:16 UTC (rev 4687) +++ branches/transforms/CHANGELOG 2007-12-10 16:17:42 UTC (rev 4688) @@ -1,3 +1,5 @@ +2007-12-07 Issue a warning when drawing an image on a non-linear axis. - MGD + 2007-12-06 let widgets.Cursor initialize to the lower x and y bounds rather than 0,0, which can cause havoc for dates and other transforms - DSD @@ -6,6 +8,10 @@ 2007-12-06 fixed a bug in rcsetup, see bug 1845057 - DSD +2007-12-05 Fix how fonts are cached to avoid loading the same one multiple times. + (This was a regression since 0.90 caused by the refactoring of + font_manager.py) - MGD + =============================================================== 2007-11-27 Released 0.91.1 at revision 4517 Modified: branches/transforms/lib/matplotlib/backends/backend_ps.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-12-10 16:17:16 UTC (rev 4687) +++ branches/transforms/lib/matplotlib/backends/backend_ps.py 2007-12-10 16:17:42 UTC (rev 4688) @@ -1430,4 +1430,31 @@ clip newpath } bind def""", +<<<<<<< .working +======= + # angle1 angle2 rx ry x y *ellipse* - + """/ellipse { + newpath + matrix currentmatrix 7 1 roll + translate + scale + 0 0 1 5 3 roll arc + setmatrix + closepath + } bind def""", + """/unitcircle { + newpath +0. -1. moveto +0.2652031 -1.0 0.519579870785 -0.894633691588 0.707106781187 -0.707106781187 curveto +0.894633691588 -0.519579870785 1.0 -0.2652031 1.0 0.0 curveto +1.0 0.2652031 0.894633691588 0.519579870785 0.707106781187 0.707106781187 curveto +0.519579870785 0.894633691588 0.2652031 1.0 0.0 1.0 curveto +-0.2652031 1.0 -0.519579870785 0.894633691588 -0.707106781187 0.707106781187 curveto +-0.894633691588 0.519579870785 -1.0 0.2652031 -1.0 0.0 curveto +-1.0 -0.2652031 -0.894633691588 -0.519579870785 -0.707106781187 -0.707106781187 curveto +-0.519579870785 -0.894633691588 -0.2652031 -1.0 0.0 -1.0 curveto +closepath + } bind def""", + +>>>>>>> .merge-right.r4679 ] Modified: branches/transforms/lib/matplotlib/patches.py =================================================================== --- branches/transforms/lib/matplotlib/patches.py 2007-12-10 16:17:16 UTC (rev 4687) +++ branches/transforms/lib/matplotlib/patches.py 2007-12-10 16:17:42 UTC (rev 4688) @@ -820,6 +820,49 @@ """ A scale-free ellipse """ +<<<<<<< .working +======= + MAGIC = 0.2652031 + SQRT2 = npy.sqrt(0.5) + MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0) + + circle = npy.array( + [[0.0, -1.0], + + [MAGIC, -1.0], + [SQRT2-MAGIC45, -SQRT2-MAGIC45], + [SQRT2, -SQRT2], + + [SQRT2+MAGIC45, -SQRT2+MAGIC45], + [1.0, -MAGIC], + [1.0, 0.0], + + [1.0, MAGIC], + [SQRT2+MAGIC45, SQRT2-MAGIC45], + [SQRT2, SQRT2], + + [SQRT2-MAGIC45, SQRT2+MAGIC45], + [MAGIC, 1.0], + [0.0, 1.0], + + [-MAGIC, 1.0], + [-SQRT2+MAGIC45, SQRT2+MAGIC45], + [-SQRT2, SQRT2], + + [-SQRT2-MAGIC45, SQRT2-MAGIC45], + [-1.0, MAGIC], + [-1.0, 0.0], + + [-1.0, -MAGIC], + [-SQRT2-MAGIC45, -SQRT2+MAGIC45], + [-SQRT2, -SQRT2], + + [-SQRT2+MAGIC45, -SQRT2-MAGIC45], + [-MAGIC, -1.0], + [0.0, -1.0]], + npy.float_) + +>>>>>>> .merge-right.r4679 def __str__(self): return "Ellipse(%d,%d;%dx%d)"%(self.center[0],self.center[1],self.width,self.height) @@ -855,10 +898,17 @@ def get_patch_transform(self): return self._patch_transform +<<<<<<< .working def contains(self,ev): if ev.x is None or ev.y is None: return False,{} x, y = self.get_transform().inverted().transform_point((ev.x, ev.y)) return (x*x + y*y) <= 1.0, {} +======= + xcenter = self.convert_xunits(xcenter) + width = self.convert_xunits(width) + ycenter = self.convert_yunits(ycenter) + height = self.convert_xunits(height) +>>>>>>> .merge-right.r4679 def _get_center(self): return self._center @@ -882,6 +932,105 @@ angle = property(_get_angle, _set_angle) +<<<<<<< .working +======= + rtheta = angle*npy.pi/180. + R = npy.array([ + [npy.cos(rtheta), -npy.sin(rtheta)], + [npy.sin(rtheta), npy.cos(rtheta)], + ]) + + + x, y = npy.dot(R, npy.array([x, y])) + x += xcenter + y += ycenter + + return zip(x, y) + + def draw(self, renderer): + if not self.get_visible(): return + #renderer.open_group('patch') + gc = renderer.new_gc() + gc.set_foreground(self._edgecolor) + gc.set_linewidth(self._linewidth) + gc.set_alpha(self._alpha) + gc.set_antialiased(self._antialiased) + self._set_gc_clip(gc) + + gc.set_capstyle('projecting') + + if not self.fill or self._facecolor is None: rgbFace = None + else: rgbFace = colors.colorConverter.to_rgb(self._facecolor) + + if self._hatch: + gc.set_hatch(self._hatch ) + + + if not hasattr(renderer, 'draw_path'): + mpl.verbose.report('patches.Ellipse renderer does not support path drawing; falling back on vertex approximation for nonlinear transformation') + renderer.draw_polygon(gc, rgbFace, self.get_verts()) + return + + + x, y = self.center + x = self.convert_xunits(x) + y = self.convert_yunits(y) + w = self.convert_xunits(self.width)/2. + h = self.convert_yunits(self.height)/2. + + theta = self.angle * npy.pi/180. + T = npy.array([ + [1, 0, x], + [0, 1, y], + [0, 0, 1]]) + + + + + S = npy.array([ + [w, 0, 0], + [0, h, 0], + [0, 0, 1]]) + + + + # rotate by theta + R = npy.array([ + [npy.cos(theta), -npy.sin(theta), 0], + [npy.sin(theta), npy.cos(theta), 0], + [0, 0, 1]]) + + # transform unit circle into ellipse + E = npy.dot(T, npy.dot(R, S)) + + + # Apply the display affine + sx, b, c, sy, tx, ty = self.get_transform().as_vec6_val() + + # display coords + D = npy.array([ + [sx, b, tx], + [c, sy, ty], + [0, 0, 1]], npy.float_) + + M = npy.dot(D,E) + + C = npy.ones((3, len(self.circle))) + C[0:2,:] = self.circle.T + + ellipse = npy.dot(M, C).T[:,:2] + + path = agg.path_storage() + path.move_to(*ellipse[0]) + for i in range(1, 25, 3): + path.curve4(*ellipse[i:i+3].flat) + path.close_polygon() + + renderer.draw_path(gc, rgbFace, path) + + +>>>>>>> .merge-right.r4679 + class Circle(Ellipse): """ A circle patch Copied: branches/transforms/unit/ellipse_large.py (from rev 4679, trunk/matplotlib/unit/ellipse_large.py) =================================================================== --- branches/transforms/unit/ellipse_large.py (rev 0) +++ branches/transforms/unit/ellipse_large.py 2007-12-10 16:17:42 UTC (rev 4688) @@ -0,0 +1,107 @@ + +# This example can be boiled down to a more simplistic example +# to show the problem, but bu including the upper and lower +# bound ellipses, it demonstrates how significant this error +# is to our plots. + +import math +from pylab import * +from matplotlib.patches import Ellipse + +# given a point x, y +x = 2692.440 +y = 6720.850 + +# get is the radius of a circle through this point +r = math.sqrt( x*x+y*y ) + +# show some comparative circles +delta = 6 + + +################################################## +def custom_ellipse( ax, x, y, major, minor, theta, numpoints = 750, **kwargs ): + xs = [] + ys = [] + incr = 2.0*math.pi / numpoints + incrTheta = 0.0 + while incrTheta <= (2.0*math.pi): + a = major * math.cos( incrTheta ) + b = minor * math.sin( incrTheta ) + l = math.sqrt( ( a**2 ) + ( b**2 ) ) + phi = math.atan2( b, a ) + incrTheta += incr + + xs.append( x + ( l * math.cos( theta + phi ) ) ) + ys.append( y + ( l * math.sin( theta + phi ) ) ) + # end while + + incrTheta = 2.0*math.pi + a = major * math.cos( incrTheta ) + b = minor * math.sin( incrTheta ) + l = sqrt( ( a**2 ) + ( b**2 ) ) + phi = math.atan2( b, a ) + xs.append( x + ( l * math.cos( theta + phi ) ) ) + ys.append( y + ( l * math.sin( theta + phi ) ) ) + + ellipseLine = ax.plot( xs, ys, **kwargs ) + + +################################################## +# make the axes +ax = subplot( 211, aspect='equal' ) +ax.set_aspect( 'equal', 'datalim' ) + +# make the lower-bound ellipse +diam = (r - delta) * 2.0 +lower_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkgreen" ) +ax.add_patch( lower_ellipse ) + +# make the target ellipse +diam = r * 2.0 +target_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkred" ) +ax.add_patch( target_ellipse ) + +# make the upper-bound ellipse +diam = (r + delta) * 2.0 +upper_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkblue" ) +ax.add_patch( upper_ellipse ) + +# make the target +diam = delta * 2.0 +target = Ellipse( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" ) +ax.add_patch( target ) + +# give it a big marker +ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +################################################## +# now lets do the same thing again using a custom ellipse function + +# make the axes +ax = subplot( 212, aspect='equal', sharex=ax, sharey=ax ) +ax.set_aspect( 'equal', 'datalim' ) + +# make the lower-bound ellipse +custom_ellipse( ax, 0.0, 0.0, r-delta, r-delta, 0.0, color="darkgreen" ) + +# make the target ellipse +custom_ellipse( ax, 0.0, 0.0, r, r, 0.0, color="darkred" ) + +# make the upper-bound ellipse +custom_ellipse( ax, 0.0, 0.0, r+delta, r+delta, 0.0, color="darkblue" ) + +# make the target +custom_ellipse( ax, x, y, delta, delta, 0.0, color="#BB1208" ) + +# give it a big marker +ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +################################################## +# lets zoom in to see the area of interest + +ax.set_xlim(2650, 2735) +ax.set_ylim(6705, 6735) +show() + +savefig("ellipse") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-10 16:17:21
|
Revision: 4687 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4687&view=rev Author: jswhit Date: 2007-12-10 08:17:16 -0800 (Mon, 10 Dec 2007) Log Message: ----------- setup.py now looks for GEOS lib in a few standard places if GEOS_DIR not set. Modified Paths: -------------- trunk/toolkits/basemap/Changelog Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2007-12-10 16:15:30 UTC (rev 4686) +++ trunk/toolkits/basemap/Changelog 2007-12-10 16:17:16 UTC (rev 4687) @@ -1,4 +1,9 @@ version 0.9.9 (not yet released) + * setup.py now looks for GEOS library in a few standard + places (/usr/local, /opt, $HOME, /sw) if the GEOS_DIR + environment variable not set. This is a workaround for a + new Leopard 'feature' (sudo does not inherit enviroment + variables). * added support for reading Point and MultiPoint shapes from ESRI shapefiles. * now automatically draws figure if running in This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 16:15:33
|
Revision: 4686 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4686&view=rev Author: mdboom Date: 2007-12-10 08:15:30 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Support draw_path (importantly for ellipses) in Pdf, Svg and Cairo backends. Fix SVG text rendering bug. Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py trunk/matplotlib/lib/matplotlib/backends/backend_svg.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/CHANGELOG 2007-12-10 16:15:30 UTC (rev 4686) @@ -1,3 +1,9 @@ +2007-12-10 Fix SVG text rendering bug. + +2007-12-10 Increase accuracy of circle and ellipse drawing by using an 8-piece + bezier approximation, rather than a 4-piece one. Fix PDF, SVG and + Cairo backends so they can draw paths (meaning ellipses as well). + 2007-12-07 Issue a warning when drawing an image on a non-linear axis. - MGD 2007-12-06 let widgets.Cursor initialize to the lower x and y bounds Modified: trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/lib/matplotlib/backends/backend_cairo.py 2007-12-10 16:15:30 UTC (rev 4686) @@ -34,6 +34,7 @@ backend_version = cairo.version del _version_required +from matplotlib import agg from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase from matplotlib.cbook import enumerate, izip, is_string_like @@ -124,7 +125,35 @@ #_.ctx.restore() # revert to the default attributes + def draw_path(self, gc, rgbFace, path): + ctx = gc.ctx + ctx.new_path() + while 1: + code, xp, yp = path.vertex() + yp = self.height - yp + + if code == agg.path_cmd_stop: + ctx.close_path() + break + elif code == agg.path_cmd_move_to: + ctx.move_to(xp, yp) + elif code == agg.path_cmd_line_to: + ctx.line_to(xp, yp) + elif code == agg.path_cmd_curve3: + _, xp1, yp1 = path.vertex() + yp1 = self.height - yp1 + ctx.curve_to(xp, yp, xp, yp, xp1, yp1) + elif code == agg.path_cmd_curve4: + _, xp1, yp1 = path.vertex() + yp1 = self.height - yp1 + _, xp2, yp2 = path.vertex() + yp2 = self.height - yp2 + ctx.curve_to(xp, yp, xp1, yp1, xp2, yp2) + elif code == agg.path_cmd_end_poly: + ctx.close_path() + self._fill_and_stroke(ctx, rgbFace) + def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation): if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) @@ -307,11 +336,11 @@ ctx.translate(x, y) if angle: ctx.rotate (-angle * npy.pi / 180) - + for font, fontsize, s, ox, oy in glyphs: ctx.new_path() ctx.move_to(ox, oy) - + fontProp = ttfFontProperty(font) ctx.save() ctx.select_font_face (fontProp.name, @@ -332,7 +361,7 @@ ctx.restore() - + def flipy(self): if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name()) return True @@ -494,7 +523,7 @@ self.figure.draw (renderer) surface.write_to_png (fobj) - + def print_pdf(self, fobj, *args, **kwargs): return self._save(fobj, 'pdf', *args, **kwargs) @@ -506,10 +535,10 @@ def print_svgz(self, fobj, *args, **kwargs): return self._save(fobj, 'svgz', *args, **kwargs) - + def get_default_filetype(self): return rcParams['cairo.format'] - + def _save (self, fo, format, **kwargs): # save PDF/PS/SVG orientation = kwargs.get('orientation', 'portrait') Modified: trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/lib/matplotlib/backends/backend_pdf.py 2007-12-10 16:15:30 UTC (rev 4686) @@ -1249,6 +1249,36 @@ self.file.output(self.gc.close_and_paint()) + def draw_path(self, gc, rgbFace, path): + self.check_gc(gc, rgbFace) + + cmds = [] + + while 1: + code, xp, yp = path.vertex() + + if code == agg.path_cmd_stop: + cmds.append(Op.closepath) + break + elif code == agg.path_cmd_move_to: + cmds.extend([xp, yp, Op.moveto]) + elif code == agg.path_cmd_line_to: + cmds.extend([xp, yp, Op.lineto]) + elif code == agg.path_cmd_curve3: + cmds.extend([xp, yp]) + cmds.extend([xp, yp]) + cmds.extend(path.vertex()[1:]) + cmds.append(Op.curveto) + elif code == agg.path_cmd_curve4: + cmds.extend([xp, yp]) + cmds.extend(path.vertex()[1:]) + cmds.extend(path.vertex()[1:]) + cmds.append(Op.curveto) + elif code == agg.path_cmd_end_poly: + cmds.append(Op.closepath) + self.file.output(*cmds) + self.file.output(self.gc.paint()) + def get_image_magnification(self): return self.image_magnification Modified: trunk/matplotlib/lib/matplotlib/backends/backend_svg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-12-10 15:34:29 UTC (rev 4685) +++ trunk/matplotlib/lib/matplotlib/backends/backend_svg.py 2007-12-10 16:15:30 UTC (rev 4686) @@ -2,6 +2,7 @@ import os, codecs, base64, tempfile, urllib, gzip +from matplotlib import agg from matplotlib import verbose, __version__, rcParams from matplotlib.backend_bases import RendererBase, GraphicsContextBase,\ FigureManagerBase, FigureCanvasBase @@ -137,6 +138,38 @@ def close_group(self, s): self._svgwriter.write('</g>\n') + def draw_path(self, gc, rgbFace, path): + cmd = [] + + while 1: + code, xp, yp = path.vertex() + yp = self.height - yp + + if code == agg.path_cmd_stop: + cmd.append('z') # Hack, path_cmd_end_poly not found + break + elif code == agg.path_cmd_move_to: + cmd.append('M%g %g' % (xp, yp)) + elif code == agg.path_cmd_line_to: + cmd.append('L%g %g' % (xp, yp)) + elif code == agg.path_cmd_curve3: + verts = [xp, yp] + verts.extent(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + cmd.append('Q%g %g %g %g' % tuple(verts)) + elif code == agg.path_cmd_curve4: + verts = [xp, yp] + verts.extend(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + verts.extend(path.vertex()[1:]) + verts[-1] = self.height - verts[-1] + cmd.append('C%g %g %g %g %g %g'%tuple(verts)) + elif code == agg.path_cmd_end_poly: + cmd.append('z') + + path_data = "".join(cmd) + self._draw_svg_element("path", 'd="%s"' % path_data, gc, rgbFace) + def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation): """ Ignores angles for now @@ -284,7 +317,7 @@ svg.append(' transform="translate(%s)"' % (currx * (self.FONT_SCALE / fontsize))) svg.append('/>\n') - currx += (glyph.linearHoriAdvance / 65536.0) + currx += (glyph.linearHoriAdvance / 65536.0) / (self.FONT_SCALE / fontsize) svg.append('</g>\n') svg = ''.join(svg) else: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 15:34:35
|
Revision: 4685 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4685&view=rev Author: mdboom Date: 2007-12-10 07:34:29 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Fix syntax for pre-Python 2.5 Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/font_manager.py Modified: trunk/matplotlib/lib/matplotlib/font_manager.py =================================================================== --- trunk/matplotlib/lib/matplotlib/font_manager.py 2007-12-10 15:23:08 UTC (rev 4684) +++ trunk/matplotlib/lib/matplotlib/font_manager.py 2007-12-10 15:34:29 UTC (rev 4685) @@ -109,9 +109,10 @@ else: user = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, MSFolders) try: - return _winreg.QueryValueEx(user, 'Fonts')[0] - except OSError: - pass # Fall through to default + try: + return _winreg.QueryValueEx(user, 'Fonts')[0] + except OSError: + pass # Fall through to default finally: _winreg.CloseKey(user) return os.path.join(os.environ['WINDIR'], 'Fonts') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 15:23:33
|
Revision: 4684 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4684&view=rev Author: mdboom Date: 2007-12-10 07:23:08 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Fix variable name. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/patches.py Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2007-12-10 15:21:58 UTC (rev 4683) +++ trunk/matplotlib/lib/matplotlib/patches.py 2007-12-10 15:23:08 UTC (rev 4684) @@ -765,41 +765,41 @@ A scale-free ellipse """ MAGIC = 0.2652031 - SQRT2 = npy.sqrt(0.5) + SQRTHALF = npy.sqrt(0.5) MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0) circle = npy.array( [[0.0, -1.0], [MAGIC, -1.0], - [SQRT2-MAGIC45, -SQRT2-MAGIC45], - [SQRT2, -SQRT2], + [SQRTHALF-MAGIC45, -SQRTHALF-MAGIC45], + [SQRTHALF, -SQRTHALF], - [SQRT2+MAGIC45, -SQRT2+MAGIC45], + [SQRTHALF+MAGIC45, -SQRTHALF+MAGIC45], [1.0, -MAGIC], [1.0, 0.0], [1.0, MAGIC], - [SQRT2+MAGIC45, SQRT2-MAGIC45], - [SQRT2, SQRT2], + [SQRTHALF+MAGIC45, SQRTHALF-MAGIC45], + [SQRTHALF, SQRTHALF], - [SQRT2-MAGIC45, SQRT2+MAGIC45], + [SQRTHALF-MAGIC45, SQRTHALF+MAGIC45], [MAGIC, 1.0], [0.0, 1.0], [-MAGIC, 1.0], - [-SQRT2+MAGIC45, SQRT2+MAGIC45], - [-SQRT2, SQRT2], + [-SQRTHALF+MAGIC45, SQRTHALF+MAGIC45], + [-SQRTHALF, SQRTHALF], - [-SQRT2-MAGIC45, SQRT2-MAGIC45], + [-SQRTHALF-MAGIC45, SQRTHALF-MAGIC45], [-1.0, MAGIC], [-1.0, 0.0], [-1.0, -MAGIC], - [-SQRT2-MAGIC45, -SQRT2+MAGIC45], - [-SQRT2, -SQRT2], + [-SQRTHALF-MAGIC45, -SQRTHALF+MAGIC45], + [-SQRTHALF, -SQRTHALF], - [-SQRT2+MAGIC45, -SQRT2-MAGIC45], + [-SQRTHALF+MAGIC45, -SQRTHALF-MAGIC45], [-MAGIC, -1.0], [0.0, -1.0]], npy.float_) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 15:22:11
|
Revision: 4683 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4683&view=rev Author: mdboom Date: 2007-12-10 07:21:58 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Fix variable name. Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-12-10 15:03:33 UTC (rev 4682) +++ branches/transforms/lib/matplotlib/path.py 2007-12-10 15:21:58 UTC (rev 4683) @@ -358,41 +358,41 @@ """ if cls._unit_circle is None: MAGIC = 0.2652031 - SQRT2 = npy.sqrt(0.5) + SQRTHALF = npy.sqrt(0.5) MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0) vertices = npy.array( [[0.0, -1.0], [MAGIC, -1.0], - [SQRT2-MAGIC45, -SQRT2-MAGIC45], - [SQRT2, -SQRT2], + [SQRTHALF-MAGIC45, -SQRTHALF-MAGIC45], + [SQRTHALF, -SQRTHALF], - [SQRT2+MAGIC45, -SQRT2+MAGIC45], + [SQRTHALF+MAGIC45, -SQRTHALF+MAGIC45], [1.0, -MAGIC], [1.0, 0.0], [1.0, MAGIC], - [SQRT2+MAGIC45, SQRT2-MAGIC45], - [SQRT2, SQRT2], + [SQRTHALF+MAGIC45, SQRTHALF-MAGIC45], + [SQRTHALF, SQRTHALF], - [SQRT2-MAGIC45, SQRT2+MAGIC45], + [SQRTHALF-MAGIC45, SQRTHALF+MAGIC45], [MAGIC, 1.0], [0.0, 1.0], [-MAGIC, 1.0], - [-SQRT2+MAGIC45, SQRT2+MAGIC45], - [-SQRT2, SQRT2], + [-SQRTHALF+MAGIC45, SQRTHALF+MAGIC45], + [-SQRTHALF, SQRTHALF], - [-SQRT2-MAGIC45, SQRT2-MAGIC45], + [-SQRTHALF-MAGIC45, SQRTHALF-MAGIC45], [-1.0, MAGIC], [-1.0, 0.0], [-1.0, -MAGIC], - [-SQRT2-MAGIC45, -SQRT2+MAGIC45], - [-SQRT2, -SQRT2], + [-SQRTHALF-MAGIC45, -SQRTHALF+MAGIC45], + [-SQRTHALF, -SQRTHALF], - [-SQRT2+MAGIC45, -SQRT2-MAGIC45], + [-SQRTHALF+MAGIC45, -SQRTHALF-MAGIC45], [-MAGIC, -1.0], [0.0, -1.0], This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 15:03:41
|
Revision: 4682 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4682&view=rev Author: mdboom Date: 2007-12-10 07:03:33 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Draw aligned lines more often than before. Modified Paths: -------------- branches/transforms/src/_backend_agg.cpp Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-12-10 15:00:03 UTC (rev 4681) +++ branches/transforms/src/_backend_agg.cpp 2007-12-10 15:03:33 UTC (rev 4682) @@ -352,8 +352,6 @@ // pixels double x0, y0, x1, y1; unsigned code; - if (path.total_vertices() > 5) - return false; code = path.vertex(&x0, &y0); trans.transform(&x0, &y0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 15:00:30
|
Revision: 4681 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4681&view=rev Author: mdboom Date: 2007-12-10 07:00:03 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Bugfix. Modified Paths: -------------- branches/transforms/lib/matplotlib/backends/backend_mixed.py Modified: branches/transforms/lib/matplotlib/backends/backend_mixed.py =================================================================== --- branches/transforms/lib/matplotlib/backends/backend_mixed.py 2007-12-10 14:59:49 UTC (rev 4680) +++ branches/transforms/lib/matplotlib/backends/backend_mixed.py 2007-12-10 15:00:03 UTC (rev 4681) @@ -30,7 +30,7 @@ self._raster_renderer_class = raster_renderer_class self._width = width self._height = height - self._dpi = dpi + self.dpi = dpi assert not vector_renderer.option_image_nocomposite() self._vector_renderer = vector_renderer @@ -55,7 +55,7 @@ setattr(self, method, getattr(renderer, method)) renderer.start_rasterizing = self.start_rasterizing renderer.stop_rasterizing = self.stop_rasterizing - + def start_rasterizing(self): """ Enter "raster" mode. All subsequent drawing commands (until @@ -70,7 +70,7 @@ self._width*self._dpi, self._height*self._dpi, self._dpi) self._set_current_renderer(self._raster_renderer) self._rasterizing = True - + def stop_rasterizing(self): """ Exit "raster" mode. All of the drawing that was done since This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 15:00:11
|
Revision: 4680 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4680&view=rev Author: mdboom Date: 2007-12-10 06:59:49 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Use an 8-spline approximation of an ellipse instead of a 4-spline one. Modified Paths: -------------- branches/transforms/lib/matplotlib/path.py Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-12-10 14:50:40 UTC (rev 4679) +++ branches/transforms/lib/matplotlib/path.py 2007-12-10 14:59:49 UTC (rev 4680) @@ -15,8 +15,6 @@ path_in_path, path_intersects_path, convert_path_to_polygons from matplotlib.cbook import simple_linear_interpolation -KAPPA = 4.0 * (npy.sqrt(2) - 1) / 3.0 - class Path(object): """ Path represents a series of possibly disconnected, possibly @@ -350,33 +348,58 @@ def unit_circle(cls): """ Returns a Path of the unit circle. The circle is approximated - using cubic Bezier curves. + using cubic Bezier curves. This uses 8 splines around the + circle using the approach presented here: + + Lancaster, Don. Approximating a Circle or an Ellipse Using Four + Bezier Cubic Splines. + + http://www.tinaja.com/glib/ellipse4.pdf """ if cls._unit_circle is None: - offset = KAPPA + MAGIC = 0.2652031 + SQRT2 = npy.sqrt(0.5) + MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0) + vertices = npy.array( - [[-1.0, 0.0], + [[0.0, -1.0], - [-1.0, offset], - [-offset, 1.0], - [0.0, 1.0], + [MAGIC, -1.0], + [SQRT2-MAGIC45, -SQRT2-MAGIC45], + [SQRT2, -SQRT2], - [offset, 1.0], - [1.0, offset], - [1.0, 0.0], + [SQRT2+MAGIC45, -SQRT2+MAGIC45], + [1.0, -MAGIC], + [1.0, 0.0], - [1.0, -offset], - [offset, -1.0], - [0.0, -1.0], + [1.0, MAGIC], + [SQRT2+MAGIC45, SQRT2-MAGIC45], + [SQRT2, SQRT2], - [-offset, -1.0], - [-1.0, -offset], - [-1.0, 0.0], + [SQRT2-MAGIC45, SQRT2+MAGIC45], + [MAGIC, 1.0], + [0.0, 1.0], - [-1.0, 0.0]], + [-MAGIC, 1.0], + [-SQRT2+MAGIC45, SQRT2+MAGIC45], + [-SQRT2, SQRT2], + + [-SQRT2-MAGIC45, SQRT2-MAGIC45], + [-1.0, MAGIC], + [-1.0, 0.0], + + [-1.0, -MAGIC], + [-SQRT2-MAGIC45, -SQRT2+MAGIC45], + [-SQRT2, -SQRT2], + + [-SQRT2+MAGIC45, -SQRT2-MAGIC45], + [-MAGIC, -1.0], + [0.0, -1.0], + + [0.0, -1.0]], npy.float_) - codes = cls.CURVE4 * npy.ones(14) + codes = cls.CURVE4 * npy.ones(26) codes[0] = cls.MOVETO codes[-1] = cls.CLOSEPOLY This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-12-10 14:50:59
|
Revision: 4679 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4679&view=rev Author: mdboom Date: 2007-12-10 06:50:40 -0800 (Mon, 10 Dec 2007) Log Message: ----------- Use an 8-spline approximation of an ellipse instead of a 4-spline one. Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py trunk/matplotlib/lib/matplotlib/patches.py Added Paths: ----------- trunk/matplotlib/unit/ellipse_large.py Modified: trunk/matplotlib/lib/matplotlib/backends/backend_ps.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-12-09 00:48:27 UTC (rev 4678) +++ trunk/matplotlib/lib/matplotlib/backends/backend_ps.py 2007-12-10 14:50:40 UTC (rev 4679) @@ -1644,11 +1644,15 @@ } bind def""", """/unitcircle { newpath --1. 0. moveto --1.0 0.552284749831 -0.552284749831 1.0 0.0 1.0 curveto -0.552284749831 1.0 1.0 0.552284749831 1.0 0.0 curveto -1.0 -0.552284749831 0.552284749831 -1.0 0.0 -1.0 curveto --0.552284749831 -1.0 -1.0 -0.552284749831 -1.0 0.0 curveto +0. -1. moveto +0.2652031 -1.0 0.519579870785 -0.894633691588 0.707106781187 -0.707106781187 curveto +0.894633691588 -0.519579870785 1.0 -0.2652031 1.0 0.0 curveto +1.0 0.2652031 0.894633691588 0.519579870785 0.707106781187 0.707106781187 curveto +0.519579870785 0.894633691588 0.2652031 1.0 0.0 1.0 curveto +-0.2652031 1.0 -0.519579870785 0.894633691588 -0.707106781187 0.707106781187 curveto +-0.894633691588 0.519579870785 -1.0 0.2652031 -1.0 0.0 curveto +-1.0 -0.2652031 -0.894633691588 -0.519579870785 -0.707106781187 -0.707106781187 curveto +-0.519579870785 -0.894633691588 -0.2652031 -1.0 0.0 -1.0 curveto closepath } bind def""", Modified: trunk/matplotlib/lib/matplotlib/patches.py =================================================================== --- trunk/matplotlib/lib/matplotlib/patches.py 2007-12-09 00:48:27 UTC (rev 4678) +++ trunk/matplotlib/lib/matplotlib/patches.py 2007-12-10 14:50:40 UTC (rev 4679) @@ -201,7 +201,7 @@ if cbook.is_string_like(self._edgecolor) and self._edgecolor.lower()=='none': gc.set_linewidth(0) - else: + else: gc.set_foreground(self._edgecolor) gc.set_linewidth(self._linewidth) @@ -764,32 +764,46 @@ """ A scale-free ellipse """ - offset = 4.0 * (npy.sqrt(2) - 1) / 3.0 + MAGIC = 0.2652031 + SQRT2 = npy.sqrt(0.5) + MAGIC45 = npy.sqrt((MAGIC*MAGIC) / 2.0) - circle = npy.array([ - [-1.0, 0.0], + circle = npy.array( + [[0.0, -1.0], - [-1.0, offset], - [-offset, 1.0], - [0.0, 1.0], + [MAGIC, -1.0], + [SQRT2-MAGIC45, -SQRT2-MAGIC45], + [SQRT2, -SQRT2], - [offset, 1.0], - [1.0, offset], - [1.0, 0.0], + [SQRT2+MAGIC45, -SQRT2+MAGIC45], + [1.0, -MAGIC], + [1.0, 0.0], - [1.0, -offset], - [offset, -1.0], - [0.0, -1.0], + [1.0, MAGIC], + [SQRT2+MAGIC45, SQRT2-MAGIC45], + [SQRT2, SQRT2], - [-offset, -1.0], - [-1.0, -offset], - [-1.0, 0.0], + [SQRT2-MAGIC45, SQRT2+MAGIC45], + [MAGIC, 1.0], + [0.0, 1.0], - [-1.0, 0.0] - ], - npy.float_) + [-MAGIC, 1.0], + [-SQRT2+MAGIC45, SQRT2+MAGIC45], + [-SQRT2, SQRT2], - + [-SQRT2-MAGIC45, SQRT2-MAGIC45], + [-1.0, MAGIC], + [-1.0, 0.0], + + [-1.0, -MAGIC], + [-SQRT2-MAGIC45, -SQRT2+MAGIC45], + [-SQRT2, -SQRT2], + + [-SQRT2+MAGIC45, -SQRT2-MAGIC45], + [-MAGIC, -1.0], + [0.0, -1.0]], + npy.float_) + def __str__(self): return "Ellipse(%d,%d;%dx%d)"%(self.center[0],self.center[1],self.width,self.height) @@ -823,9 +837,9 @@ width, height = self.width, self.height xcenter = self.convert_xunits(xcenter) - width = self.convert_xunits(width) + width = self.convert_xunits(width) ycenter = self.convert_yunits(ycenter) - height = self.convert_xunits(height) + height = self.convert_xunits(height) @@ -871,8 +885,8 @@ mpl.verbose.report('patches.Ellipse renderer does not support path drawing; falling back on vertex approximation for nonlinear transformation') renderer.draw_polygon(gc, rgbFace, self.get_verts()) return - + x, y = self.center x = self.convert_xunits(x) y = self.convert_yunits(y) @@ -887,14 +901,14 @@ - + S = npy.array([ [w, 0, 0], [0, h, 0], [0, 0, 1]]) - + # rotate by theta R = npy.array([ [npy.cos(theta), -npy.sin(theta), 0], @@ -903,8 +917,8 @@ # transform unit circle into ellipse E = npy.dot(T, npy.dot(R, S)) - + # Apply the display affine sx, b, c, sy, tx, ty = self.get_transform().as_vec6_val() @@ -918,25 +932,19 @@ C = npy.ones((3, len(self.circle))) C[0:2,:] = self.circle.T - + ellipse = npy.dot(M, C).T[:,:2] path = agg.path_storage() path.move_to(*ellipse[0]) - verts = ellipse[1:4].flat - path.curve4(*verts) - verts = ellipse[4:7].flat - path.curve4(*verts) - verts = ellipse[7:10].flat - path.curve4(*verts) - verts = ellipse[10:13].flat - path.curve4(*verts) + for i in range(1, 25, 3): + path.curve4(*ellipse[i:i+3].flat) path.close_polygon() renderer.draw_path(gc, rgbFace, path) - + class Circle(Ellipse): """ A circle patch Added: trunk/matplotlib/unit/ellipse_large.py =================================================================== --- trunk/matplotlib/unit/ellipse_large.py (rev 0) +++ trunk/matplotlib/unit/ellipse_large.py 2007-12-10 14:50:40 UTC (rev 4679) @@ -0,0 +1,107 @@ + +# This example can be boiled down to a more simplistic example +# to show the problem, but bu including the upper and lower +# bound ellipses, it demonstrates how significant this error +# is to our plots. + +import math +from pylab import * +from matplotlib.patches import Ellipse + +# given a point x, y +x = 2692.440 +y = 6720.850 + +# get is the radius of a circle through this point +r = math.sqrt( x*x+y*y ) + +# show some comparative circles +delta = 6 + + +################################################## +def custom_ellipse( ax, x, y, major, minor, theta, numpoints = 750, **kwargs ): + xs = [] + ys = [] + incr = 2.0*math.pi / numpoints + incrTheta = 0.0 + while incrTheta <= (2.0*math.pi): + a = major * math.cos( incrTheta ) + b = minor * math.sin( incrTheta ) + l = math.sqrt( ( a**2 ) + ( b**2 ) ) + phi = math.atan2( b, a ) + incrTheta += incr + + xs.append( x + ( l * math.cos( theta + phi ) ) ) + ys.append( y + ( l * math.sin( theta + phi ) ) ) + # end while + + incrTheta = 2.0*math.pi + a = major * math.cos( incrTheta ) + b = minor * math.sin( incrTheta ) + l = sqrt( ( a**2 ) + ( b**2 ) ) + phi = math.atan2( b, a ) + xs.append( x + ( l * math.cos( theta + phi ) ) ) + ys.append( y + ( l * math.sin( theta + phi ) ) ) + + ellipseLine = ax.plot( xs, ys, **kwargs ) + + +################################################## +# make the axes +ax = subplot( 211, aspect='equal' ) +ax.set_aspect( 'equal', 'datalim' ) + +# make the lower-bound ellipse +diam = (r - delta) * 2.0 +lower_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkgreen" ) +ax.add_patch( lower_ellipse ) + +# make the target ellipse +diam = r * 2.0 +target_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkred" ) +ax.add_patch( target_ellipse ) + +# make the upper-bound ellipse +diam = (r + delta) * 2.0 +upper_ellipse = Ellipse( (0.0, 0.0), diam, diam, 0.0, fill=False, edgecolor="darkblue" ) +ax.add_patch( upper_ellipse ) + +# make the target +diam = delta * 2.0 +target = Ellipse( (x, y), diam, diam, 0.0, fill=False, edgecolor="#DD1208" ) +ax.add_patch( target ) + +# give it a big marker +ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +################################################## +# now lets do the same thing again using a custom ellipse function + +# make the axes +ax = subplot( 212, aspect='equal', sharex=ax, sharey=ax ) +ax.set_aspect( 'equal', 'datalim' ) + +# make the lower-bound ellipse +custom_ellipse( ax, 0.0, 0.0, r-delta, r-delta, 0.0, color="darkgreen" ) + +# make the target ellipse +custom_ellipse( ax, 0.0, 0.0, r, r, 0.0, color="darkred" ) + +# make the upper-bound ellipse +custom_ellipse( ax, 0.0, 0.0, r+delta, r+delta, 0.0, color="darkblue" ) + +# make the target +custom_ellipse( ax, x, y, delta, delta, 0.0, color="#BB1208" ) + +# give it a big marker +ax.plot( [x], [y], marker='x', linestyle='None', mfc='red', mec='red', markersize=10 ) + +################################################## +# lets zoom in to see the area of interest + +ax.set_xlim(2650, 2735) +ax.set_ylim(6705, 6735) +show() + +savefig("ellipse") This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-09 00:48:56
|
Revision: 4678 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4678&view=rev Author: jdh2358 Date: 2007-12-08 16:48:27 -0800 (Sat, 08 Dec 2007) Log Message: ----------- minor reorg f prex dir Added Paths: ----------- trunk/py4science/examples/pyrex/simple_numpy/ trunk/py4science/examples/pyrex/trailstats/ Removed Paths: ------------- trunk/py4science/examples/pyrex/movavg/ trunk/py4science/examples/pyrex/sums/ Copied: trunk/py4science/examples/pyrex/simple_numpy (from rev 4677, trunk/py4science/examples/pyrex/sums) Copied: trunk/py4science/examples/pyrex/trailstats (from rev 4677, trunk/py4science/examples/pyrex/movavg) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-08 17:05:57
|
Revision: 4677 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4677&view=rev Author: jswhit Date: 2007-12-08 09:05:53 -0800 (Sat, 08 Dec 2007) Log Message: ----------- search in lib64 too. Modified Paths: -------------- trunk/toolkits/basemap/setup.py Modified: trunk/toolkits/basemap/setup.py =================================================================== --- trunk/toolkits/basemap/setup.py 2007-12-08 17:00:28 UTC (rev 4676) +++ trunk/toolkits/basemap/setup.py 2007-12-08 17:05:53 UTC (rev 4677) @@ -75,7 +75,7 @@ that says "set GEOS_dir manually here".""") else: geos_include_dirs=[os.path.join(GEOS_dir,'include'),numpy.get_include()] - geos_library_dirs=[os.path.join(GEOS_dir,'lib')] + geos_library_dirs=[os.path.join(GEOS_dir,'lib'),os.path.join(GEOS_dir,'lib64')] # proj4 and geos extensions. deps = glob.glob('src/*.c') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-08 17:00:30
|
Revision: 4676 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4676&view=rev Author: jdh2358 Date: 2007-12-08 09:00:28 -0800 (Sat, 08 Dec 2007) Log Message: ----------- added primes demo Added Paths: ----------- trunk/py4science/examples/pyrex/primes/ trunk/py4science/examples/pyrex/primes/Makefile trunk/py4science/examples/pyrex/primes/primes.pyx trunk/py4science/examples/pyrex/primes/pyprimes.py trunk/py4science/examples/pyrex/primes/run_primes.py trunk/py4science/examples/pyrex/primes/setup.py Added: trunk/py4science/examples/pyrex/primes/Makefile =================================================================== --- trunk/py4science/examples/pyrex/primes/Makefile (rev 0) +++ trunk/py4science/examples/pyrex/primes/Makefile 2007-12-08 17:00:28 UTC (rev 4676) @@ -0,0 +1,11 @@ +all: + python setup.py build_ext --inplace + +test: all + python run_primes.py 20 + +clean: + @echo Cleaning Primes + @rm -f *.c *.o *.so *~ *.pyc + @rm -rf build + Added: trunk/py4science/examples/pyrex/primes/primes.pyx =================================================================== --- trunk/py4science/examples/pyrex/primes/primes.pyx (rev 0) +++ trunk/py4science/examples/pyrex/primes/primes.pyx 2007-12-08 17:00:28 UTC (rev 4676) @@ -0,0 +1,18 @@ +def primes(int kmax): + cdef int n, k, i + cdef int p[1000] + result = [] + if kmax > 1000: + kmax = 1000 + k = 0 + n = 2 + while k < kmax: + i = 0 + while i < k and n % p[i] <> 0: + i = i + 1 + if i == k: + p[k] = n + k = k + 1 + result.append(n) + n = n + 1 + return result Added: trunk/py4science/examples/pyrex/primes/pyprimes.py =================================================================== --- trunk/py4science/examples/pyrex/primes/pyprimes.py (rev 0) +++ trunk/py4science/examples/pyrex/primes/pyprimes.py 2007-12-08 17:00:28 UTC (rev 4676) @@ -0,0 +1,13 @@ +def primes(kmax): + p = [] + k = 0 + n = 2 + while k < kmax: + i = 0 + while i < k and n % p[i] <> 0: + i = i + 1 + if i == k: + p.append(n) + k = k + 1 + n = n + 1 + return p Added: trunk/py4science/examples/pyrex/primes/run_primes.py =================================================================== --- trunk/py4science/examples/pyrex/primes/run_primes.py (rev 0) +++ trunk/py4science/examples/pyrex/primes/run_primes.py 2007-12-08 17:00:28 UTC (rev 4676) @@ -0,0 +1,4 @@ +import sys +from primes import primes +n = 1000 +print primes(n) Added: trunk/py4science/examples/pyrex/primes/setup.py =================================================================== --- trunk/py4science/examples/pyrex/primes/setup.py (rev 0) +++ trunk/py4science/examples/pyrex/primes/setup.py 2007-12-08 17:00:28 UTC (rev 4676) @@ -0,0 +1,12 @@ +from distutils.core import setup +#from distutils.extension import Extension +from Pyrex.Distutils.extension import Extension +from Pyrex.Distutils import build_ext + +setup( + name = 'Demos', + ext_modules=[ + Extension("primes", ["primes.pyx"]), + ], + cmdclass = {'build_ext': build_ext} +) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-08 16:35:27
|
Revision: 4675 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4675&view=rev Author: jdh2358 Date: 2007-12-08 08:35:17 -0800 (Sat, 08 Dec 2007) Log Message: ----------- added filter examples Modified Paths: -------------- trunk/py4science/examples/butter_filter.py Added Paths: ----------- trunk/py4science/examples/skel/butter_filter_skel.py Modified: trunk/py4science/examples/butter_filter.py =================================================================== --- trunk/py4science/examples/butter_filter.py 2007-12-08 16:23:40 UTC (rev 4674) +++ trunk/py4science/examples/butter_filter.py 2007-12-08 16:35:17 UTC (rev 4675) @@ -9,26 +9,38 @@ # sine corrupted wih gaussian white noise sn = s + 0.1*n.random.randn(len(s)) # noisy sine -# the nyquist frequency 1/(2dt) +# the nyquist frequency 1/(2dt) is the maximum frequency in a sampled +# signal Nyq = 0.5/dt +#the corner frequency represents a boundary in the system response at +#which energy entering the system begins to be attenuate, and the stop +#frequency is the frequency at which the signal is (practically) +#completely attenuated cornerfreq = 2. # the corner frequency stopfreq = 5. # the stop frequency -# the corner and stop freqs as fractions of the nyquist +# the scipy.signal routines accept corner an stop frequencies as a +# *fraction* of the nyquist ws = cornerfreq/Nyq wp = stopfreq/Nyq -# the order and butterworth natural frequency for use with butter +# call scipy.buttord to compute the order and natural frequency of the +# butterorth filter. See the help for signal.buttord. You will pass +# in ws and wp, as well as the attenuation in the pass and stop bands N, wn = signal.buttord(wp, ws, 3, 16) -# return the butterworth filter coeffs for the given order and frequency +# scipy.butter will take the output from buttord and return the +# lfilter coeefs for that filter b, a = signal.butter(N, wn) -# filter the data +# Now lfilter will filter the noisy sine with the filter parameters +# from butter sf = signal.lfilter(b, a, sn) +# plot the original, noisy and filtered sine, all on the same axes in +# pylab, and make a legend fig = figure() ax = fig.add_subplot(111) ax.plot(t, s, label='original signal') Added: trunk/py4science/examples/skel/butter_filter_skel.py =================================================================== --- trunk/py4science/examples/skel/butter_filter_skel.py (rev 0) +++ trunk/py4science/examples/skel/butter_filter_skel.py 2007-12-08 16:35:17 UTC (rev 4675) @@ -0,0 +1,46 @@ +import numpy as n +import scipy.signal as signal +from pylab import figure, show + +XXX = 0. # just so he XXX blanks will not crash +dt = 0.01 +t = n.arange(0, 2, dt) +s = XXX # a 1 Hz sine wave over t + +# sine corrupted wih gaussian white noise the sine wave s corrupted +# with gaussian white noise with sigma=0.1. See numpy.random.randn + +sn = XXX +# the nyquist frequency 1/(2dt) is the maximum frequency in a sampled +# signal +Nyq = XXX + +#the corner frequency represents a boundary in the system response at +#which energy entering the system begins to be attenuate, and the stop +#frequency is the frequency at which the signal is (practically) +#completely attenuated +cornerfreq = 2. # the corner frequency +stopfreq = 5. # the stop frequency + +# the scipy.signal routines accept corner an stop frequencies as a +# *fraction* of the nyquist +ws = XXX +wp = XXX + + +# call scipy.buttord to compute the order and natural frequency of the +# butterorth filter. See the help for signal.buttord. You will pass +# in ws and wp, as well as the attenuation in the pass and stop bands +N, wn = XXX, XXX # the output of signal.buttord + +# scipy.butter will take the output from buttord and return the +# lfilter coeefs for that filter. See help signal.butter +b, a = XXX, XXX # the output of signal.butter + +# Now lfilter will filter the noisy sine with the filter parameters +# from butter. See help signal.lfilter +sf = XXX # the filtered signal returned from lfi,ter + +# plot the original, noisy and filtered sine, all on the same axes in +# pylab, and make a legend +XXX This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-12-08 16:23:50
|
Revision: 4674 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4674&view=rev Author: jdh2358 Date: 2007-12-08 08:23:40 -0800 (Sat, 08 Dec 2007) Log Message: ----------- added butter and filtfilt Modified Paths: -------------- trunk/py4science/examples/pyrex/movavg/movavg_ringbuf.py trunk/py4science/examples/pyrex/sums/numpyx.pyx Added Paths: ----------- trunk/py4science/examples/butter_filter.py trunk/py4science/examples/filtilt_demo.py Added: trunk/py4science/examples/butter_filter.py =================================================================== --- trunk/py4science/examples/butter_filter.py (rev 0) +++ trunk/py4science/examples/butter_filter.py 2007-12-08 16:23:40 UTC (rev 4674) @@ -0,0 +1,41 @@ +import numpy as n +import scipy.signal as signal +from pylab import figure, show + +dt = 0.01 +t = n.arange(0, 2, dt) +s = n.sin(2*n.pi*t) + +# sine corrupted wih gaussian white noise +sn = s + 0.1*n.random.randn(len(s)) # noisy sine + +# the nyquist frequency 1/(2dt) +Nyq = 0.5/dt + +cornerfreq = 2. # the corner frequency +stopfreq = 5. # the stop frequency + +# the corner and stop freqs as fractions of the nyquist +ws = cornerfreq/Nyq +wp = stopfreq/Nyq + + +# the order and butterworth natural frequency for use with butter +N, wn = signal.buttord(wp, ws, 3, 16) + +# return the butterworth filter coeffs for the given order and frequency +b, a = signal.butter(N, wn) + +# filter the data +sf = signal.lfilter(b, a, sn) + +fig = figure() +ax = fig.add_subplot(111) +ax.plot(t, s, label='original signal') +ax.plot(t, sn, label='noisy signal') +ax.plot(t, sf, label='filtered signal') +ax.legend() +ax.set_title('low pass butterworth filter of sine') +ax.set_xlabel('time (s)') +ax.grid() +show() Added: trunk/py4science/examples/filtilt_demo.py =================================================================== --- trunk/py4science/examples/filtilt_demo.py (rev 0) +++ trunk/py4science/examples/filtilt_demo.py 2007-12-08 16:23:40 UTC (rev 4674) @@ -0,0 +1,102 @@ +""" +Cookbook / FiltFilt : http://www.scipy.org/Cookbook/FiltFilt + +This sample code implements a zero phase delay filter that processes +the signal in the forward and backward direction removing the phase +delay. The order of the filter is the double of the original filter +order. The function also computes the initial filter parameters in +order to provide a more stable response (via lfilter_zi). The +following code has been tested with Python 2.4.4 and Scipy 0.5.1. + +""" +from numpy import vstack, hstack, eye, ones, zeros, linalg, \ +newaxis, r_, flipud, convolve, matrix, array +from scipy.signal import lfilter + +def lfilter_zi(b,a): + + #compute the zi state from the filter parameters. see [Gust96]. + + #Based on: [Gust96] Fredrik Gustafsson, Determining the initial + # states in forward-backward filtering, IEEE Transactions on + # Signal Processing, pp. 988--992, April 1996, Volume 44, Issue 4 + + n=max(len(a),len(b)) + + zin = ( eye(n-1) - hstack( (-a[1:n,newaxis], + vstack((eye(n-2), zeros(n-2)))))) + + zid = b[1:n] - a[1:n]*b[0] + + zi_matrix=linalg.inv(zin)*(matrix(zid).transpose()) + zi_return=[] + + #convert the result into a regular array (not a matrix) + for i in range(len(zi_matrix)): + zi_return.append(float(zi_matrix[i][0])) + + return array(zi_return) + + + + +def filtfilt(b,a,x): + #For now only accepting 1d arrays + ntaps=max(len(a),len(b)) + edge=ntaps*3 + + if x.ndim != 1: + raise ValueError, "Filiflit is only accepting 1 dimension arrays." + + #x must be bigger than edge + if x.size < edge: + raise ValueError, "Input vector needs to be bigger than 3 * max(len(a),len(b)." + + if len(a) < ntaps: + a=r_[a,zeros(len(b)-len(a))] + + if len(b) < ntaps: + b=r_[b,zeros(len(a)-len(b))] + + zi=lfilter_zi(b,a) + + #Grow the signal to have edges for stabilizing + #the filter with inverted replicas of the signal + s=r_[2*x[0]-x[edge:1:-1],x,2*x[-1]-x[-1:-edge:-1]] + #in the case of one go we only need one of the extrems + # both are needed for filtfilt + + (y,zf)=lfilter(b,a,s,-1,zi*s[0]) + + (y,zf)=lfilter(b,a,flipud(y),-1,zi*y[-1]) + + return flipud(y[edge-1:-edge+1]) + + + +if __name__=='__main__': + + import scipy.signal as signal + from scipy import sin, arange, pi, randn + + from pylab import plot, legend, show, hold + + t = arange(-1,1,.01) + x = sin(2*pi*t*.5+2) + + # add some noise to the signa + xn = x+randn(len(t))*0.05 + + # parameters for a butterworth lowpass filter + [b,a] = signal.butter(3,0.05) + + z = lfilter(b, a, xn) + y = filtfilt(b, a, xn) + + plot(x, 'c', label='original') + plot(xn, 'k', label='noisy signal') + plot(z, 'r', label='lfilter - butter 3 order') + plot(y, 'g', label='filtfilt - butter 3 order') + legend(loc='best') + show() + Modified: trunk/py4science/examples/pyrex/movavg/movavg_ringbuf.py =================================================================== --- trunk/py4science/examples/pyrex/movavg/movavg_ringbuf.py 2007-12-08 14:00:28 UTC (rev 4673) +++ trunk/py4science/examples/pyrex/movavg/movavg_ringbuf.py 2007-12-08 16:23:40 UTC (rev 4674) @@ -4,7 +4,7 @@ import numpy import ringbuf -r = ringbuf.Ringbuf(30) +r = ringbuf.Ringbuf(31) x = numpy.random.rand(10000) data = [] Modified: trunk/py4science/examples/pyrex/sums/numpyx.pyx =================================================================== --- trunk/py4science/examples/pyrex/sums/numpyx.pyx 2007-12-08 14:00:28 UTC (rev 4673) +++ trunk/py4science/examples/pyrex/sums/numpyx.pyx 2007-12-08 16:23:40 UTC (rev 4674) @@ -26,31 +26,6 @@ -def sum_elements(c_numpy.ndarray arr): - cdef int i - cdef double x, val - - x = 0. - val = 0. - for i from 0<=i<arr.dimensions[0]: - val = (<double*>(arr.data + i*arr.strides[0]))[0] - x = x + val - - return x - - -def scale_elements(int N): - cdef int i - cdef double x, val - - x = 0. - val = 0. - for i from 0<=i<N: - val = 2.5 * i - x = x + val - return x - - cdef print_elements(char *data, c_python.Py_intptr_t* strides, c_python.Py_intptr_t* dimensions, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-12-08 14:00:48
|
Revision: 4673 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4673&view=rev Author: jswhit Date: 2007-12-08 06:00:28 -0800 (Sat, 08 Dec 2007) Log Message: ----------- add to contributors list Modified Paths: -------------- trunk/toolkits/basemap/README Modified: trunk/toolkits/basemap/README =================================================================== --- trunk/toolkits/basemap/README 2007-12-08 13:58:50 UTC (rev 4672) +++ trunk/toolkits/basemap/README 2007-12-08 14:00:28 UTC (rev 4673) @@ -104,5 +104,6 @@ Rob Hetland Scott Sinclair Ivan Lima +Erik Andersen for valuable contributions. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |