You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(115) |
Aug
(120) |
Sep
(137) |
Oct
(170) |
Nov
(461) |
Dec
(263) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(120) |
Feb
(74) |
Mar
(35) |
Apr
(74) |
May
(245) |
Jun
(356) |
Jul
(240) |
Aug
(115) |
Sep
(78) |
Oct
(225) |
Nov
(98) |
Dec
(271) |
2009 |
Jan
(132) |
Feb
(84) |
Mar
(74) |
Apr
(56) |
May
(90) |
Jun
(79) |
Jul
(83) |
Aug
(296) |
Sep
(214) |
Oct
(76) |
Nov
(82) |
Dec
(66) |
2010 |
Jan
(46) |
Feb
(58) |
Mar
(51) |
Apr
(77) |
May
(58) |
Jun
(126) |
Jul
(128) |
Aug
(64) |
Sep
(50) |
Oct
(44) |
Nov
(48) |
Dec
(54) |
2011 |
Jan
(68) |
Feb
(52) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jd...@us...> - 2007-11-28 18:11:28
|
Revision: 4486 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4486&view=rev Author: jdh2358 Date: 2007-11-28 10:11:27 -0800 (Wed, 28 Nov 2007) Log Message: ----------- updated coding guide with trailing whitespace config suggestion Modified Paths: -------------- trunk/matplotlib/CODING_GUIDE Modified: trunk/matplotlib/CODING_GUIDE =================================================================== --- trunk/matplotlib/CODING_GUIDE 2007-11-28 17:19:16 UTC (rev 4485) +++ trunk/matplotlib/CODING_GUIDE 2007-11-28 18:11:27 UTC (rev 4486) @@ -39,6 +39,8 @@ * If you have altered extension code, do you pass unit/memleak_hawaii.py? + + == Importing and name spaces == For numpy, use: @@ -103,7 +105,26 @@ to replace a single long line with two shorter and more readable lines. +Please do not commit lines with trailing white space, as it causes +noise in svn diffs. If you are an emacs user, the following in your +.emacs will cause emacs to strip trailing white space on save for +python, C and C++ +; and similarly for c++-mode-hook and c-mode-hook +(add-hook 'python-mode-hook + (lambda () + (add-hook 'local-write-file-hooks 'delete-trailing-whitespace))) + + +for older versions of emacs (emacs<23) you may need to do + +(add-hook 'python-mode-hook + (lambda () + (add-hook 'write-file-functions 'delete-trailing-whitespace))) + + + + == Licenses == matplotlib only uses BSD compatible code. If you bring in code from This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-28 17:19:20
|
Revision: 4485 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4485&view=rev Author: jswhit Date: 2007-11-28 09:19:16 -0800 (Wed, 28 Nov 2007) Log Message: ----------- more orthographic fixes 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-11-28 15:58:28 UTC (rev 4484) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-28 17:19:16 UTC (rev 4485) @@ -689,10 +689,11 @@ lat_0=self.projparams['lat_0'] re = self.projparams['R'] # center of stereographic projection restricted to be - # nearest one of 60 points on the sphere (every 45 deg lat/lon). - lon0 = 45.*(npy.around(lon_0/45.)) - lat0 = 45.*(npy.around(lat_0/45.)) - maptran = pyproj.Proj(proj='stere',lon_0=lon0,lat0=lat_0,R=re) + # nearest one of 6 points on the sphere (every 90 deg lat/lon). + lon0 = 90.*(npy.around(lon_0/90.)) + lat0 = 90.*(npy.around(lat_0/90.)) + if npy.abs(int(lat0)) == 90: lon0=0. + maptran = pyproj.Proj(proj='stere',lon_0=lon0,lat_0=lat0,R=re) # boundary polygon for orthographic projection # in stereographic coorindates. b = self._boundarypolyll.boundary This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-28 15:58:36
|
Revision: 4484 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4484&view=rev Author: jswhit Date: 2007-11-28 07:58:28 -0800 (Wed, 28 Nov 2007) Log Message: ----------- more fixes for orthographic 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-11-28 15:50:58 UTC (rev 4483) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-28 15:58:28 UTC (rev 4484) @@ -688,9 +688,10 @@ lon_0=self.projparams['lon_0'] lat_0=self.projparams['lat_0'] re = self.projparams['R'] - # center of stereographic projection restricted - # to be one of 60 points on the sphere (every 45 deg lat/lon). - lon0 = 45*(int(lon_0)/45); lat0 = 45*(int(lat_0)/45) + # center of stereographic projection restricted to be + # nearest one of 60 points on the sphere (every 45 deg lat/lon). + lon0 = 45.*(npy.around(lon_0/45.)) + lat0 = 45.*(npy.around(lat_0/45.)) maptran = pyproj.Proj(proj='stere',lon_0=lon0,lat0=lat_0,R=re) # boundary polygon for orthographic projection # in stereographic coorindates. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-28 15:50:59
|
Revision: 4483 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4483&view=rev Author: jswhit Date: 2007-11-28 07:50:58 -0800 (Wed, 28 Nov 2007) Log Message: ----------- fix for orthographic projection. 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-11-28 15:18:41 UTC (rev 4482) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-28 15:50:58 UTC (rev 4483) @@ -688,7 +688,10 @@ lon_0=self.projparams['lon_0'] lat_0=self.projparams['lat_0'] re = self.projparams['R'] - maptran = pyproj.Proj(proj='stere',lon_0=lon_0,lat_0=lat_0,R=re) + # center of stereographic projection restricted + # to be one of 60 points on the sphere (every 45 deg lat/lon). + lon0 = 45*(int(lon_0)/45); lat0 = 45*(int(lat_0)/45) + maptran = pyproj.Proj(proj='stere',lon_0=lon0,lat0=lat_0,R=re) # boundary polygon for orthographic projection # in stereographic coorindates. b = self._boundarypolyll.boundary This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-28 15:18:47
|
Revision: 4482 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4482&view=rev Author: mdboom Date: 2007-11-28 07:18:41 -0800 (Wed, 28 Nov 2007) Log Message: ----------- Remove fonts/otf directory in list of data files. Modified Paths: -------------- trunk/matplotlib/setup.py Modified: trunk/matplotlib/setup.py =================================================================== --- trunk/matplotlib/setup.py 2007-11-28 13:42:39 UTC (rev 4481) +++ trunk/matplotlib/setup.py 2007-11-28 15:18:41 UTC (rev 4482) @@ -88,7 +88,6 @@ 'mpl-data/fonts/pdfcorefonts/*.afm', 'mpl-data/fonts/pdfcorefonts/*.txt', 'mpl-data/fonts/ttf/*.ttf', - 'mpl-data/fonts/otf/*.otf', 'mpl-data/images/*.xpm', 'mpl-data/images/*.svg', 'mpl-data/images/*.png', This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-28 13:42:46
|
Revision: 4481 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4481&view=rev Author: mdboom Date: 2007-11-28 05:42:39 -0800 (Wed, 28 Nov 2007) Log Message: ----------- Major speed improvements for auto-placing of legends. Modified Paths: -------------- branches/transforms/lib/matplotlib/legend.py branches/transforms/lib/matplotlib/lines.py branches/transforms/lib/matplotlib/path.py branches/transforms/lib/matplotlib/transforms.py branches/transforms/src/_path.cpp Modified: branches/transforms/lib/matplotlib/legend.py =================================================================== --- branches/transforms/lib/matplotlib/legend.py 2007-11-28 13:40:54 UTC (rev 4480) +++ branches/transforms/lib/matplotlib/legend.py 2007-11-28 13:42:39 UTC (rev 4481) @@ -36,33 +36,6 @@ from text import Text from transforms import Affine2D, Bbox, BboxTransformTo -def line_cuts_bbox(line, bbox): - """ Return True if and only if line cuts bbox. """ - minx, miny, width, height = bbox.bounds - maxx = minx + width - maxy = miny + height - - n = len(line) - if n == 0: - return False - - if n == 1: - return bbox.contains(line[0][0], line[0][1]) - p1 = line[0] - for p2 in line[1:]: - segment = (p1, p2) - # See if the segment cuts any of the edges of bbox - for edge in (((minx, miny), (minx, maxy)), - ((minx, miny), (maxx, miny)), - ((maxx, miny), (maxx, maxy)), - ((minx, maxy), (maxx, maxy))): - if segments_intersect(segment, edge): - return True - p1=p2 - - return False - - class Legend(Artist): """ Place a legend on the axes at location loc. Labels are a @@ -344,11 +317,11 @@ for handle in ax.lines: assert isinstance(handle, Line2D) - data = handle.get_xydata() + path = handle.get_path() trans = handle.get_transform() - tdata = trans.transform(data) - averts = inverse_transform.transform(tdata) - lines.append(averts) + tpath = trans.transform_path(path) + apath = inverse_transform.transform_path(tpath) + lines.append(apath) for handle in ax.patches: assert isinstance(handle, Patch) @@ -435,7 +408,7 @@ badness = legendBox.count_contains(verts) badness += legendBox.count_overlaps(bboxes) for line in lines: - if line_cuts_bbox(line, legendBox): + if line.intersects_bbox(legendBox): badness += 1 ox, oy = l-tx, b-ty Modified: branches/transforms/lib/matplotlib/lines.py =================================================================== --- branches/transforms/lib/matplotlib/lines.py 2007-11-28 13:40:54 UTC (rev 4480) +++ branches/transforms/lib/matplotlib/lines.py 2007-11-28 13:42:39 UTC (rev 4481) @@ -285,6 +285,7 @@ self._xorig = npy.asarray([]) self._yorig = npy.asarray([]) + self._invalid = True self.set_data(xdata, ydata) def contains(self, mouseevent): @@ -353,7 +354,7 @@ def get_window_extent(self, renderer): bbox = Bbox.unit() - bbox.update_from_data_xy(self.get_transform().transform(self._xy), + bbox.update_from_data_xy(self.get_transform().transform(self.get_xydata()), ignore=True) # correct for marker size, if any if self._marker is not None: @@ -394,9 +395,10 @@ (y.shape != self._yorig.shape or npy.any(y != self._yorig)))): self._xorig = x self._yorig = y - self.recache() + self._invalid = True else: - self._transformed_path._invalid = self._transformed_path.INVALID_NON_AFFINE + if hasattr(self, "_transformed_path"): + self._transformed_path._invalid = self._transformed_path.INVALID_NON_AFFINE def recache(self): #if self.axes is None: print 'recache no axes' @@ -434,6 +436,7 @@ self._path = Path(self._xy) self._transformed_path = TransformedPath(self._path, self.get_transform()) + self._invalid = False def set_transform(self, t): """ @@ -442,7 +445,8 @@ ACCEPTS: a matplotlib.transforms.Transform instance """ Artist.set_transform(self, t) - self._transformed_path = TransformedPath(self._path, self.get_transform()) + self._invalid = True + # self._transformed_path = TransformedPath(self._path, self.get_transform()) def _is_sorted(self, x): "return true if x is sorted" @@ -450,6 +454,9 @@ return npy.alltrue(x[1:]-x[0:-1]>=0) def draw(self, renderer): + if self._invalid: + self.recache() + renderer.open_group('line2d') if not self._visible: return @@ -531,6 +538,8 @@ """ if orig: return self._xorig + if self._invalid: + self.recache() return self._x def get_ydata(self, orig=True): @@ -540,9 +549,21 @@ """ if orig: return self._yorig + if self._invalid: + self.recache() return self._y + def get_path(self): + """ + Return the Path object associated with this line. + """ + if self._invalid: + self.recache() + return self._path + def get_xydata(self): + if self._invalid: + self.recache() return self._xy def set_antialiased(self, b): Modified: branches/transforms/lib/matplotlib/path.py =================================================================== --- branches/transforms/lib/matplotlib/path.py 2007-11-28 13:40:54 UTC (rev 4480) +++ branches/transforms/lib/matplotlib/path.py 2007-11-28 13:42:39 UTC (rev 4481) @@ -12,7 +12,7 @@ from matplotlib._path import point_in_path, get_path_extents, \ point_in_path_collection, get_path_collection_extents, \ - path_in_path + path_in_path, path_intersects_path from matplotlib.cbook import simple_linear_interpolation KAPPA = 4.0 * (npy.sqrt(2) - 1) / 3.0 @@ -237,6 +237,22 @@ transform = Affine2D() return Bbox.from_extents(*get_path_extents(self, transform)) + def intersects_path(self, other): + """ + Returns True if this path intersects another given path. + """ + return path_intersects_path(self, other) + + def intersects_bbox(self, bbox): + """ + Returns True if this path intersects a given Bbox. + """ + from transforms import BboxTransformTo + rectangle = self.unit_rectangle().transformed( + BboxTransformTo(bbox)) + result = self.intersects_path(rectangle) + return result + def interpolated(self, steps): """ Returns a new path resampled to length N x steps. Modified: branches/transforms/lib/matplotlib/transforms.py =================================================================== --- branches/transforms/lib/matplotlib/transforms.py 2007-11-28 13:40:54 UTC (rev 4480) +++ branches/transforms/lib/matplotlib/transforms.py 2007-11-28 13:42:39 UTC (rev 4481) @@ -508,26 +508,8 @@ bboxes is a sequence of Bbox objects """ - ax1, ay1, ax2, ay2 = self._get_extents() - if ax2 < ax1: - ax2, ax1 = ax1, ax2 - if ay2 < ay1: - ay2, ay1 = ay1, ay2 + return count_bboxes_overlapping_bbox(self, bboxes) - count = 0 - for bbox in bboxes: - # bx1, by1, bx2, by2 = bbox._get_extents() ... inlined... - bx1, by1, bx2, by2 = bbox.get_points().flatten() - if bx2 < bx1: - bx2, bx1 = bx1, bx2 - if by2 < by1: - by2, by1 = by1, by2 - count += (not ((bx2 <= ax1) or - (by2 <= ay1) or - (bx1 >= ax2) or - (by1 >= ay2))) - return count - def expanded(self, sw, sh): """ Return a new Bbox which is this Bbox expanded around its Modified: branches/transforms/src/_path.cpp =================================================================== --- branches/transforms/src/_path.cpp 2007-11-28 13:40:54 UTC (rev 4480) +++ branches/transforms/src/_path.cpp 2007-11-28 13:42:39 UTC (rev 4481) @@ -36,13 +36,15 @@ add_varargs_method("point_in_path_collection", &_path_module::point_in_path_collection, "point_in_path_collection(x, y, r, trans, paths, transforms, offsets, offsetTrans, filled)"); add_varargs_method("path_in_path", &_path_module::path_in_path, - "point_in_path_collection(a, atrans, b, btrans)"); + "path_in_path(a, atrans, b, btrans)"); add_varargs_method("clip_path_to_rect", &_path_module::clip_path_to_rect, "clip_path_to_rect(path, bbox, inside)"); add_varargs_method("affine_transform", &_path_module::affine_transform, "affine_transform(vertices, transform)"); add_varargs_method("count_bboxes_overlapping_bbox", &_path_module::count_bboxes_overlapping_bbox, "count_bboxes_overlapping_bbox(bbox, bboxes)"); + add_varargs_method("path_intersects_path", &_path_module::path_intersects_path, + "path_intersects_path(p1, p2)"); initialize("Helper functions for paths"); } @@ -60,6 +62,7 @@ Py::Object clip_path_to_rect(const Py::Tuple& args); Py::Object affine_transform(const Py::Tuple& args); Py::Object count_bboxes_overlapping_bbox(const Py::Tuple& args); + Py::Object path_intersects_path(const Py::Tuple& args); }; // @@ -673,7 +676,8 @@ transform = (PyArrayObject*) PyArray_FromObject (transform_obj.ptr(), PyArray_DOUBLE, 2, 2); - if (!transform || PyArray_NDIM(transform) != 2 || PyArray_DIM(transform, 0) != 3 || PyArray_DIM(transform, 1) != 3) + if (!transform || PyArray_NDIM(transform) != 2 || + PyArray_DIM(transform, 0) != 3 || PyArray_DIM(transform, 1) != 3) throw Py::ValueError("Invalid transform."); double a, b, c, d, e, f; @@ -783,6 +787,70 @@ return Py::Int(count); } +bool segments_intersect(const double& x1, const double &y1, + const double& x2, const double &y2, + const double& x3, const double &y3, + const double& x4, const double &y4) { + double den = ((y4-y3) * (x2-x1)) - ((x4-x3)*(y2-y1)); + if (den == 0.0) + return false; + + double n1 = ((x4-x3) * (y1-y3)) - ((y4-y3)*(x1-x3)); + double n2 = ((x2-x1) * (y1-y3)) - ((y2-y1)*(x1-x3)); + + double u1 = n1/den; + double u2 = n2/den; + + return (u1 >= 0.0 && u1 <= 1.0 && + u2 >= 0.0 && u2 <= 1.0); +} + +bool path_intersects_path(PathIterator& p1, PathIterator& p2) { + typedef agg::conv_curve<PathIterator> curve_t; + + if (p1.total_vertices() < 2 || p2.total_vertices() < 2) + return false; + + curve_t c1(p1); + curve_t c2(p2); + + double x11, y11, x12, y12; + double x21, y21, x22, y22; + + c1.vertex(&x11, &y11); + while (c1.vertex(&x12, &y12) != agg::path_cmd_stop) { + c2.rewind(0); + c2.vertex(&x21, &y21); + while (c2.vertex(&x22, &y22) != agg::path_cmd_stop) { + if (segments_intersect(x11, y11, x12, y12, x21, y21, x22, y22)) + return true; + x21 = x22; y21 = y22; + } + x11 = x12; y11 = y12; + } + + return false; +} + +Py::Object _path_module::path_intersects_path(const Py::Tuple& args) { + args.verify_length(2); + + PathIterator p1(args[0]); + PathIterator p2(args[1]); + + bool intersects = ::path_intersects_path(p1, p2); + if (!intersects) { + intersects = ::path_in_path(p1, agg::trans_affine(), p2, agg::trans_affine()); + if (!intersects) { + intersects = ::path_in_path(p2, agg::trans_affine(), p1, agg::trans_affine()); + if (!intersects) { + return Py::Int(0); + } + } + } + return Py::Int(1); +} + extern "C" DL_EXPORT(void) init_path(void) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-28 13:40:56
|
Revision: 4480 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4480&view=rev Author: mdboom Date: 2007-11-28 05:40:54 -0800 (Wed, 28 Nov 2007) Log Message: ----------- Fix marker drawing bug, and improve speed (by using buffers on the stack if possible). Modified Paths: -------------- branches/transforms/src/_backend_agg.cpp Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-28 12:34:04 UTC (rev 4479) +++ branches/transforms/src/_backend_agg.cpp 2007-11-28 13:40:54 UTC (rev 4480) @@ -462,6 +462,8 @@ return has_clippath; } +#define MARKER_CACHE_SIZE 512 + Py::Object RendererAgg::draw_markers(const Py::Tuple& args) { typedef agg::conv_transform<PathIterator> transformed_path_t; @@ -505,6 +507,8 @@ agg::scanline_storage_aa8 scanlines; theRasterizer->reset(); + agg::int8u staticFillCache[MARKER_CACHE_SIZE]; + agg::int8u staticStrokeCache[MARKER_CACHE_SIZE]; agg::int8u* fillCache = NULL; agg::int8u* strokeCache = NULL; @@ -514,7 +518,10 @@ theRasterizer->add_path(marker_path_curve); agg::render_scanlines(*theRasterizer, *slineP8, scanlines); fillSize = scanlines.byte_size(); - fillCache = new agg::int8u[fillSize]; // or any container + if (fillSize < MARKER_CACHE_SIZE) + fillCache = staticFillCache; + else + fillCache = new agg::int8u[fillSize]; scanlines.serialize(fillCache); } @@ -526,7 +533,10 @@ theRasterizer->add_path(stroke); agg::render_scanlines(*theRasterizer, *slineP8, scanlines); unsigned strokeSize = scanlines.byte_size(); - strokeCache = new agg::int8u[strokeSize]; // or any container + if (strokeSize < MARKER_CACHE_SIZE) + strokeCache = staticStrokeCache; + else + strokeCache = new agg::int8u[strokeSize]; scanlines.serialize(strokeCache); theRasterizer->reset_clipping(); @@ -539,52 +549,44 @@ agg::serialized_scanlines_adaptor_aa8 sa; agg::serialized_scanlines_adaptor_aa8::embedded_scanline sl; - if (face.first) { - // render the fill + while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { if (has_clippath) { pixfmt_amask_type pfa(*pixFmt, *alphaMask); amask_ren_type r(pfa); amask_aa_renderer_type ren(r); - ren.color(face.second); - while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { + + if (face.first) { + ren.color(face.second); sa.init(fillCache, fillSize, x, y); agg::render_scanlines(sa, sl, ren); } + ren.color(gc.color); + sa.init(strokeCache, strokeSize, x, y); + agg::render_scanlines(sa, sl, ren); } else { - rendererAA->color(face.second); - while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { + if (face.first) { + rendererAA->color(face.second); sa.init(fillCache, fillSize, x, y); agg::render_scanlines(sa, sl, *rendererAA); } - } - path_quantized.rewind(0); - } - //render the stroke - if (has_clippath) { - pixfmt_amask_type pfa(*pixFmt, *alphaMask); - amask_ren_type r(pfa); - amask_aa_renderer_type ren(r); - ren.color(gc.color); - while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { + rendererAA->color(gc.color); sa.init(strokeCache, strokeSize, x, y); - agg::render_scanlines(sa, sl, ren); - } - } else { - rendererAA->color(gc.color); - while (path_quantized.vertex(&x, &y) != agg::path_cmd_stop) { - sa.init(strokeCache, strokeSize, x, y); agg::render_scanlines(sa, sl, *rendererAA); } } } catch(...) { - delete[] fillCache; - delete[] strokeCache; + if (fillCache != staticFillCache) + delete[] fillCache; + if (strokeCache != staticStrokeCache) + delete[] strokeCache; throw; } - delete [] fillCache; - delete [] strokeCache; + if (fillCache != staticFillCache) + delete[] fillCache; + if (strokeCache != staticStrokeCache) + delete[] strokeCache; return Py::Object(); @@ -945,9 +947,6 @@ size_t i = 0; // Convert all of the transforms up front - master_transform *= agg::trans_affine_scaling(1.0, -1.0); - master_transform *= agg::trans_affine_translation(0.0, (double)height); - typedef std::vector<agg::trans_affine> transforms_t; transforms_t transforms; transforms.reserve(Ntransforms); @@ -955,6 +954,7 @@ agg::trans_affine trans = py_to_agg_transformation_matrix (transforms_obj[i], false); trans *= master_transform; + transforms.push_back(trans); } @@ -996,6 +996,10 @@ trans *= agg::trans_affine_translation(xo, yo); } + // These transformations must be done post-offsets + trans *= agg::trans_affine_scaling(1.0, -1.0); + trans *= agg::trans_affine_translation(0.0, (double)height); + if (Nfacecolors) { size_t fi = i % Nfacecolors; face.second = agg::rgba(*(double*)PyArray_GETPTR2(facecolors, fi, 0), This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-28 12:34:27
|
Revision: 4479 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4479&view=rev Author: jswhit Date: 2007-11-28 04:34:04 -0800 (Wed, 28 Nov 2007) Log Message: ----------- use fill_color kwarg to mapboundary to color oceans (instead of axes background) Modified Paths: -------------- trunk/toolkits/basemap/examples/hurrtracks.py Modified: trunk/toolkits/basemap/examples/hurrtracks.py =================================================================== --- trunk/toolkits/basemap/examples/hurrtracks.py 2007-11-28 02:48:38 UTC (rev 4478) +++ trunk/toolkits/basemap/examples/hurrtracks.py 2007-11-28 12:34:04 UTC (rev 4479) @@ -9,9 +9,8 @@ m = Basemap(llcrnrlon=-100.,llcrnrlat=0.,urcrnrlon=-20.,urcrnrlat=57., projection='lcc',lat_1=20.,lat_2=40.,lon_0=-60., resolution ='l',area_thresh=1000.) -# create figure, add axes. +# create figure. fig=p.figure() -fig.add_axes([0.1,0.1,0.8,0.8],axisbg='#99ffff') # read shapefile. shp_info = m.readshapefile('huralll020','hurrtracks',drawbounds=False) print shp_info @@ -39,7 +38,8 @@ # draw coastlines, meridians and parallels. m.drawcoastlines() m.drawcountries() -m.fillcontinents(color='#cc9966') +m.drawmapboundary(fill_color='#99ffff') +m.fillcontinents(color='#cc9966',lake_color='#99ffff') m.drawparallels(p.arange(10,70,20),labels=[1,1,0,0]) m.drawmeridians(p.arange(-100,0,20),labels=[0,0,0,1]) p.title('Atlantic Hurricane Tracks (Storms Reaching Category 4, 1851-2004)') This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2007-11-28 02:48:40
|
Revision: 4478 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4478&view=rev Author: cmoad Date: 2007-11-27 18:48:38 -0800 (Tue, 27 Nov 2007) Log Message: ----------- reverting WrapPython.h inclusion Modified Paths: -------------- trunk/matplotlib/CHANGELOG trunk/matplotlib/setupext.py Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-11-28 02:25:06 UTC (rev 4477) +++ trunk/matplotlib/CHANGELOG 2007-11-28 02:48:38 UTC (rev 4478) @@ -1,5 +1,5 @@ =============================================================== -2007-11-27 Released 0.91.0 at revision 4477 +2007-11-27 Released 0.91.0 at revision 4478 2007-11-13 All backends now support writing to a file-like object, not just a regular file. savefig() can be passed a file-like Modified: trunk/matplotlib/setupext.py =================================================================== --- trunk/matplotlib/setupext.py 2007-11-28 02:25:06 UTC (rev 4477) +++ trunk/matplotlib/setupext.py 2007-11-28 02:48:38 UTC (rev 4478) @@ -980,7 +980,6 @@ deps = ['src/ft2font.cpp', 'src/mplutils.cpp'] deps.extend(glob.glob('CXX/*.cxx')) deps.extend(glob.glob('CXX/*.c')) - deps.extend(glob.glob('CXX/*.h')) module = Extension('matplotlib.ft2font', deps) add_ft2font_flags(module) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2007-11-28 02:25:07
|
Revision: 4477 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4477&view=rev Author: cmoad Date: 2007-11-27 18:25:06 -0800 (Tue, 27 Nov 2007) Log Message: ----------- rev bump for new bug Modified Paths: -------------- trunk/matplotlib/CHANGELOG Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-11-28 02:24:40 UTC (rev 4476) +++ trunk/matplotlib/CHANGELOG 2007-11-28 02:25:06 UTC (rev 4477) @@ -1,5 +1,5 @@ =============================================================== -2007-11-27 Released 0.91.0 at revision 4474 +2007-11-27 Released 0.91.0 at revision 4477 2007-11-13 All backends now support writing to a file-like object, not just a regular file. savefig() can be passed a file-like This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2007-11-28 02:24:42
|
Revision: 4476 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4476&view=rev Author: cmoad Date: 2007-11-27 18:24:40 -0800 (Tue, 27 Nov 2007) Log Message: ----------- CXX/WrapPython.h was missing from sdist build Modified Paths: -------------- trunk/matplotlib/setupext.py Modified: trunk/matplotlib/setupext.py =================================================================== --- trunk/matplotlib/setupext.py 2007-11-28 01:33:15 UTC (rev 4475) +++ trunk/matplotlib/setupext.py 2007-11-28 02:24:40 UTC (rev 4476) @@ -980,6 +980,7 @@ deps = ['src/ft2font.cpp', 'src/mplutils.cpp'] deps.extend(glob.glob('CXX/*.cxx')) deps.extend(glob.glob('CXX/*.c')) + deps.extend(glob.glob('CXX/*.h')) module = Extension('matplotlib.ft2font', deps) add_ft2font_flags(module) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2007-11-28 01:33:16
|
Revision: 4475 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4475&view=rev Author: cmoad Date: 2007-11-27 17:33:15 -0800 (Tue, 27 Nov 2007) Log Message: ----------- rev typo fixed for 0.91 release Modified Paths: -------------- trunk/matplotlib/CHANGELOG Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-11-28 01:31:59 UTC (rev 4474) +++ trunk/matplotlib/CHANGELOG 2007-11-28 01:33:15 UTC (rev 4475) @@ -1,5 +1,5 @@ =============================================================== -2007-11-27 Released 0.91.0 at revision 4244 +2007-11-27 Released 0.91.0 at revision 4474 2007-11-13 All backends now support writing to a file-like object, not just a regular file. savefig() can be passed a file-like This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <cm...@us...> - 2007-11-28 01:32:00
|
Revision: 4474 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4474&view=rev Author: cmoad Date: 2007-11-27 17:31:59 -0800 (Tue, 27 Nov 2007) Log Message: ----------- version bumps Modified Paths: -------------- trunk/matplotlib/API_CHANGES trunk/matplotlib/CHANGELOG trunk/matplotlib/license/LICENSE Modified: trunk/matplotlib/API_CHANGES =================================================================== --- trunk/matplotlib/API_CHANGES 2007-11-27 20:03:48 UTC (rev 4473) +++ trunk/matplotlib/API_CHANGES 2007-11-28 01:31:59 UTC (rev 4474) @@ -1,3 +1,5 @@ +0.91.0 Released + Changed cbook.is_file_like to cbook.is_writable_file_like and corrected behavior. Modified: trunk/matplotlib/CHANGELOG =================================================================== --- trunk/matplotlib/CHANGELOG 2007-11-27 20:03:48 UTC (rev 4473) +++ trunk/matplotlib/CHANGELOG 2007-11-28 01:31:59 UTC (rev 4474) @@ -1,3 +1,6 @@ +=============================================================== +2007-11-27 Released 0.91.0 at revision 4244 + 2007-11-13 All backends now support writing to a file-like object, not just a regular file. savefig() can be passed a file-like object in place of a file path. - MGD Modified: trunk/matplotlib/license/LICENSE =================================================================== --- trunk/matplotlib/license/LICENSE 2007-11-27 20:03:48 UTC (rev 4473) +++ trunk/matplotlib/license/LICENSE 2007-11-28 01:31:59 UTC (rev 4474) @@ -1,4 +1,4 @@ -LICENSE AGREEMENT FOR MATPLOTLIB 0.90 +LICENSE AGREEMENT FOR MATPLOTLIB 0.91 -------------------------------------- 1. This LICENSE AGREEMENT is between John D. Hunter ("JDH"), and the @@ -9,30 +9,30 @@ 2. Subject to the terms and conditions of this License Agreement, JDH hereby grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce, analyze, test, perform and/or display publicly, prepare -derivative works, distribute, and otherwise use matplotlib 0.90 +derivative works, distribute, and otherwise use matplotlib 0.91 alone or in any derivative version, provided, however, that JDH's License Agreement and JDH's notice of copyright, i.e., "Copyright (c) 2002-2007 John D. Hunter; All Rights Reserved" are retained in -matplotlib 0.90 alone or in any derivative version prepared by +matplotlib 0.91 alone or in any derivative version prepared by Licensee. 3. In the event Licensee prepares a derivative work that is based on or -incorporates matplotlib 0.90 or any part thereof, and wants to +incorporates matplotlib 0.91 or any part thereof, and wants to make the derivative work available to others as provided herein, then Licensee hereby agrees to include in any such work a brief summary of -the changes made to matplotlib 0.90. +the changes made to matplotlib 0.91. -4. JDH is making matplotlib 0.90 available to Licensee on an "AS +4. JDH is making matplotlib 0.91 available to Licensee on an "AS IS" basis. JDH MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, JDH MAKES NO AND DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS -FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.90 +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF MATPLOTLIB 0.91 WILL NOT INFRINGE ANY THIRD PARTY RIGHTS. 5. JDH SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF MATPLOTLIB -0.90 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR +0.91 FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING -MATPLOTLIB 0.90, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF +MATPLOTLIB 0.91, OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF. 6. This License Agreement will automatically terminate upon a material @@ -44,6 +44,6 @@ trademarks or trade name in a trademark sense to endorse or promote products or services of Licensee, or any third party. -8. By copying, installing or otherwise using matplotlib 0.90, +8. By copying, installing or otherwise using matplotlib 0.91, Licensee agrees to be bound by the terms and conditions of this License Agreement. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-27 20:03:50
|
Revision: 4473 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4473&view=rev Author: mdboom Date: 2007-11-27 12:03:48 -0800 (Tue, 27 Nov 2007) Log Message: ----------- Improve speed of quad mesh drawing (by about 25%) Modified Paths: -------------- branches/transforms/src/_backend_agg.cpp branches/transforms/src/_backend_agg.h Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-27 18:34:38 UTC (rev 4472) +++ branches/transforms/src/_backend_agg.cpp 2007-11-27 20:03:48 UTC (rev 4473) @@ -348,10 +348,13 @@ template<class Path> bool should_snap(Path& path, const agg::trans_affine& trans) { - // If this is a straight horizontal or vertical line, quantize to nearest + // If this contains only straight horizontal or vertical lines, quantize to nearest // pixels double x0, y0, x1, y1; unsigned code; + if (path.total_vertices() > 5) + return false; + code = path.vertex(&x0, &y0); trans.transform(&x0, &y0); @@ -742,38 +745,20 @@ return Py::Object(); } -template<class PathIteratorType> -void RendererAgg::_draw_path(PathIteratorType& path, agg::trans_affine trans, - bool has_clippath, const facepair_t& face, - const GCAgg& gc, bool check_snap) { - typedef agg::conv_transform<PathIteratorType> transformed_path_t; - typedef conv_quantize<transformed_path_t> quantize_t; - typedef agg::conv_curve<quantize_t> curve_t; - typedef agg::conv_stroke<curve_t> stroke_t; - typedef agg::conv_dash<curve_t> dash_t; +template<class path_t> +void RendererAgg::_draw_path(path_t& path, bool has_clippath, + const facepair_t& face, const GCAgg& gc) { + typedef agg::conv_stroke<path_t> stroke_t; + typedef agg::conv_dash<path_t> dash_t; typedef agg::conv_stroke<dash_t> stroke_dash_t; typedef agg::pixfmt_amask_adaptor<pixfmt, alpha_mask_type> pixfmt_amask_type; typedef agg::renderer_base<pixfmt_amask_type> amask_ren_type; typedef agg::renderer_scanline_aa_solid<amask_ren_type> amask_aa_renderer_type; typedef agg::renderer_scanline_bin_solid<amask_ren_type> amask_bin_renderer_type; - trans *= agg::trans_affine_scaling(1.0, -1.0); - trans *= agg::trans_affine_translation(0.0, (double)height); - - // Build the transform stack - bool snap = false; - if (check_snap) - snap = should_snap(path, trans); - transformed_path_t tpath(path, trans); - quantize_t quantized(tpath, snap); - // Benchmarking shows that there is no noticable slowdown to always - // treating paths as having curved segments. Doing so greatly - // simplifies the code - curve_t curve(quantized); - // Render face if (face.first) { - theRasterizer->add_path(curve); + theRasterizer->add_path(path); if (gc.isaa) { if (has_clippath) { @@ -803,22 +788,21 @@ // Render stroke if (gc.linewidth != 0.0) { double linewidth = gc.linewidth; - if (snap) + if (!gc.isaa) linewidth = round(linewidth); - if (gc.dashes.size() == 0) { - stroke_t stroke(curve); + stroke_t stroke(path); stroke.width(linewidth); stroke.line_cap(gc.cap); stroke.line_join(gc.join); theRasterizer->add_path(stroke); } else { - dash_t dash(curve); + dash_t dash(path); for (GCAgg::dash_t::const_iterator i = gc.dashes.begin(); i != gc.dashes.end(); ++i) { double val0 = i->first; double val1 = i->second; - if (snap) { + if (!gc.isaa) { val0 = (int)val0 + 0.5; val1 = (int)val1 + 0.5; } @@ -831,7 +815,7 @@ theRasterizer->add_path(stroke); } - if (gc.isaa && !(snap)) { + if (gc.isaa) { if (has_clippath) { pixfmt_amask_type pfa(*pixFmt, *alphaMask); amask_ren_type r(pfa); @@ -859,6 +843,10 @@ Py::Object RendererAgg::draw_path(const Py::Tuple& args) { + typedef agg::conv_transform<PathIterator> transformed_path_t; + typedef conv_quantize<transformed_path_t> quantize_t; + typedef agg::conv_curve<quantize_t> curve_t; + _VERBOSE("RendererAgg::draw_path"); args.verify_length(3, 4); @@ -878,15 +866,24 @@ set_clipbox(gc.cliprect, theRasterizer); bool has_clippath = render_clippath(gc.clippath, gc.clippath_trans); - _draw_path(path, trans, has_clippath, face, gc, true); + trans *= agg::trans_affine_scaling(1.0, -1.0); + trans *= agg::trans_affine_translation(0.0, (double)height); + bool snap = should_snap(path, trans); + transformed_path_t tpath(path, trans); + quantize_t quantized(tpath, snap); + curve_t curve(quantized); + if (snap) + gc.isaa = false; + _draw_path(curve, has_clippath, face, gc); + return Py::Object(); } -template<class PathGenerator> +template<class PathGenerator, int check_snap, int has_curves> Py::Object RendererAgg::_draw_path_collection_generic - (const agg::trans_affine& master_transform, + (agg::trans_affine master_transform, const Py::Object& cliprect, const Py::Object& clippath, const agg::trans_affine& clippath_trans, @@ -898,8 +895,12 @@ const Py::Object& edgecolors_obj, const Py::SeqBase<Py::Float>& linewidths, const Py::SeqBase<Py::Object>& linestyles_obj, - const Py::SeqBase<Py::Int>& antialiaseds, - bool check_snap) { + const Py::SeqBase<Py::Int>& antialiaseds) { + typedef agg::conv_transform<typename PathGenerator::path_iterator> transformed_path_t; + typedef conv_quantize<transformed_path_t> quantize_t; + typedef agg::conv_curve<quantize_t> quantized_curve_t; + typedef agg::conv_curve<transformed_path_t> curve_t; + GCAgg gc(dpi); PyArrayObject* offsets = NULL; @@ -944,6 +945,9 @@ size_t i = 0; // Convert all of the transforms up front + master_transform *= agg::trans_affine_scaling(1.0, -1.0); + master_transform *= agg::trans_affine_translation(0.0, (double)height); + typedef std::vector<agg::trans_affine> transforms_t; transforms_t transforms; transforms.reserve(Ntransforms); @@ -975,6 +979,7 @@ facepair_t face; face.first = Nfacecolors != 0; agg::trans_affine trans; + bool snap = false; for (i = 0; i < N; ++i) { typename PathGenerator::path_iterator path = path_generator(i); @@ -1016,9 +1021,32 @@ } } - gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); + if (check_snap) { + snap = should_snap(path, trans); + if (snap) + gc.isaa = false; + else + gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); - _draw_path(path, trans, has_clippath, face, gc, check_snap); + transformed_path_t tpath(path, trans); + quantize_t quantized(tpath, snap); + if (has_curves) { + quantized_curve_t curve(quantized); + _draw_path(curve, has_clippath, face, gc); + } else { + _draw_path(quantized, has_clippath, face, gc); + } + } else { + gc.isaa = bool(Py::Int(antialiaseds[i % Naa])); + + transformed_path_t tpath(path, trans); + if (has_curves) { + curve_t curve(tpath); + _draw_path(curve, has_clippath, face, gc); + } else { + _draw_path(tpath, has_clippath, face, gc); + } + } } } catch (...) { Py_XDECREF(offsets); @@ -1075,7 +1103,7 @@ PathListGenerator path_generator(paths); - _draw_path_collection_generic + _draw_path_collection_generic<PathListGenerator, 1, 1> (master_transform, cliprect, clippath, @@ -1088,8 +1116,7 @@ edgecolors_obj, linewidths, linestyles_obj, - antialiaseds, - true); + antialiaseds); return Py::Object(); } @@ -1108,19 +1135,18 @@ m_iterator(0), m_m(m), m_n(n), m_coordinates(coordinates) { } - static const size_t offsets[5][2]; - inline unsigned vertex(unsigned idx, double* x, double* y) { - size_t m = m_m + offsets[idx][0]; - size_t n = m_n + offsets[idx][1]; + size_t m = (idx & 0x2) ? (m_m + 1) : m_m; + size_t n = (idx+1 & 0x2) ? (m_n + 1) : m_n; double* pair = (double*)PyArray_GETPTR2(m_coordinates, m, n); *x = *pair++; *y = *pair; - return (idx == 0) ? agg::path_cmd_move_to : agg::path_cmd_line_to; + return (idx) ? agg::path_cmd_line_to : agg::path_cmd_move_to; } inline unsigned vertex(double* x, double* y) { - if (m_iterator >= total_vertices()) return agg::path_cmd_stop; + if (m_iterator >= total_vertices()) + return agg::path_cmd_stop; return vertex(m_iterator++, x, y); } @@ -1159,13 +1185,6 @@ } }; -const size_t QuadMeshGenerator::QuadMeshPathIterator::offsets[5][2] = { - { 0, 0 }, - { 0, 1 }, - { 1, 1 }, - { 1, 0 }, - { 0, 0 } }; - Py::Object RendererAgg::draw_quad_mesh(const Py::Tuple& args) { _VERBOSE("RendererAgg::draw_quad_mesh"); @@ -1208,7 +1227,7 @@ } } - _draw_path_collection_generic + _draw_path_collection_generic<QuadMeshGenerator, 0, 0> (master_transform, cliprect, clippath, @@ -1221,8 +1240,7 @@ edgecolors_obj, linewidths, linestyles_obj, - antialiaseds, - false); + antialiaseds); return Py::Object(); } Modified: branches/transforms/src/_backend_agg.h =================================================================== --- branches/transforms/src/_backend_agg.h 2007-11-27 18:34:38 UTC (rev 4472) +++ branches/transforms/src/_backend_agg.h 2007-11-27 20:03:48 UTC (rev 4473) @@ -226,16 +226,16 @@ void set_clipbox(const Py::Object& cliprect, R rasterizer); bool render_clippath(const Py::Object& clippath, const agg::trans_affine& clippath_trans); template<class PathIteratorType> - void _draw_path(PathIteratorType& path, agg::trans_affine trans, - bool has_clippath, const facepair_t& face, const GCAgg& gc, bool check_snap); - template<class PathGenerator> + void _draw_path(PathIteratorType& path, bool has_clippath, + const facepair_t& face, const GCAgg& gc); + template<class PathGenerator, int check_snap, int has_curves> Py::Object _draw_path_collection_generic - (const agg::trans_affine& master_transform, + (agg::trans_affine master_transform, const Py::Object& cliprect, const Py::Object& clippath, const agg::trans_affine& clippath_trans, - const PathGenerator& path_finder, + const PathGenerator& path_generator, const Py::SeqBase<Py::Object>& transforms_obj, const Py::Object& offsets_obj, const agg::trans_affine& offset_trans, @@ -243,8 +243,7 @@ const Py::Object& edgecolors_obj, const Py::SeqBase<Py::Float>& linewidths, const Py::SeqBase<Py::Object>& linestyles_obj, - const Py::SeqBase<Py::Int>& antialiaseds, - bool check_snap); + const Py::SeqBase<Py::Int>& antialiaseds); private: Py::Object lastclippath; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jd...@us...> - 2007-11-27 18:34:45
|
Revision: 4472 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4472&view=rev Author: jdh2358 Date: 2007-11-27 10:34:38 -0800 (Tue, 27 Nov 2007) Log Message: ----------- tagged version 91.0 for release Modified Paths: -------------- trunk/matplotlib/lib/matplotlib/__init__.py Modified: trunk/matplotlib/lib/matplotlib/__init__.py =================================================================== --- trunk/matplotlib/lib/matplotlib/__init__.py 2007-11-27 18:07:01 UTC (rev 4471) +++ trunk/matplotlib/lib/matplotlib/__init__.py 2007-11-27 18:34:38 UTC (rev 4472) @@ -51,11 +51,11 @@ pylab (if pylab is imported). matplotlib is written by John D. Hunter (jdh2358 at -gmail.com). +gmail.com and a host of others). """ from __future__ import generators -__version__ = '0.90.1' +__version__ = '0.91.0' __revision__ = '$Revision$' __date__ = '$Date$' This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 18:07:06
|
Revision: 4471 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4471&view=rev Author: jswhit Date: 2007-11-27 10:07:01 -0800 (Tue, 27 Nov 2007) Log Message: ----------- add maskandscale kwarg to NetCDFFile:wq Modified Paths: -------------- trunk/toolkits/basemap/Changelog Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2007-11-27 18:05:25 UTC (rev 4470) +++ trunk/toolkits/basemap/Changelog 2007-11-27 18:07:01 UTC (rev 4471) @@ -1,4 +1,11 @@ version 0.9.8 (not yet released) + * added 'maskandscale' kwarg to NetCDFFile to + optionally turn off automatic masking and rescaling + of variable data. + * NetCDFFile will try to use PyNIO if it installed + and the file cannot be read with pupynere. This + allows GRIB1,GRIB2,HDF4 and HDFEOS2 files to + be read. * 'fmt' kwarg to drawparallels and drawmeridians can now be a custom string formatting function (example customticks.py demonstrates usage). This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 18:05:28
|
Revision: 4470 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4470&view=rev Author: jswhit Date: 2007-11-27 10:05:25 -0800 (Tue, 27 Nov 2007) Log Message: ----------- make automatic masking and rescaling of variable data optional in NetCDFFile. Modified Paths: -------------- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-11-27 17:40:45 UTC (rev 4469) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-11-27 18:05:25 UTC (rev 4470) @@ -56,7 +56,7 @@ _typecodes = dict([[_v,_k] for _k,_v in typemap.items()]) -def NetCDFFile(file): +def NetCDFFile(file, maskandscale=True): """NetCDF File reader. API is the same as Scientific.IO.NetCDF. If 'file' is a URL that starts with 'http', it is assumed to be a remote OPenDAP dataset, and the python dap client is used @@ -66,9 +66,18 @@ with a pure python NetCDF reader, otherwise PyNIO (http://www.pyngl.ucar.edu/Nio.shtml) will be used (if it is installed). PyNIO supports NetCDF version 4, GRIB1, GRIB2, HDF4 and HDFEOS2 files. + Data read from OPenDAP and NetCDF version 3 datasets will + automatically be converted to masked arrays if the variable has either + a 'missing_value' or '_FillValue' attribute, and some data points + are equal to the value specified by that attribute. In addition, + variables stored as integers that have the 'scale_factor' and + 'add_offset' attribute will automatically be rescaled to floats when + read. If PyNIO is used, neither of the automatic conversions will + be performed. To suppress these automatic conversions, set the + maskandscale keyword to False. """ if file.startswith('http'): - return _RemoteFile(file) + return _RemoteFile(file,maskandscale) else: # use pynio if it is installed and the file cannot # be read with the pure python netCDF reader. This allows @@ -76,13 +85,13 @@ # to be read. if has_pynio: try: - f = _LocalFile(file) + f = _LocalFile(file,maskandscale) except: f = nio.open_file(file) # otherwise, use the pupynere netCDF 3 pure python reader. # (will fail if file is not a netCDF version 3 file). else: - f = _LocalFile(file) + f = _LocalFile(file,maskandscale) return f def _maskandscale(var,datout): @@ -99,8 +108,9 @@ class _RemoteFile(object): """A NetCDF file reader. API is the same as Scientific.IO.NetCDF.""" - def __init__(self, file): + def __init__(self, file, maskandscale): self._buffer = open_remote(file) + self._maskandscale = maskandscale self._parse() def read(self, size=-1): @@ -136,7 +146,7 @@ for k,d in self._buffer.iteritems(): if isinstance(d, GridType) or isinstance(d, ArrayType): name = k - self.variables[name] = _RemoteVariable(d) + self.variables[name] = _RemoteVariable(d,self._maskandscale) def close(self): # this is a no-op provided for compatibility @@ -144,8 +154,9 @@ class _RemoteVariable(object): - def __init__(self, var): + def __init__(self, var, maskandscale): self._var = var + self._maskandscale = maskandscale self.dtype = var.type self.shape = var.shape self.dimensions = var.dimensions @@ -157,7 +168,10 @@ # - remove singleton dimensions # - create a masked array using missing_value or _FillValue attribute # - apply scale_factor and add_offset to packed integer data - return _maskandscale(self,datout) + if self._maskandscale: + return _maskandscale(self,datout) + else: + return datout def typecode(self): return _typecodes[self.dtype] @@ -166,8 +180,9 @@ class _LocalFile(object): """A NetCDF file reader. API is the same as Scientific.IO.NetCDF.""" - def __init__(self, file): + def __init__(self, file, maskandscale): self._buffer = open(file, 'rb') + self._maskandscale = maskandscale self._parse() def read(self, size=-1): @@ -295,7 +310,7 @@ # Read offset. begin = [self._unpack_int, self._unpack_int64][self.version_byte-1]() - return _LocalVariable(self._buffer.fileno(), nc_type, vsize, begin, shape, dimensions, attributes, isrec, self._recsize) + return _LocalVariable(self._buffer.fileno(), nc_type, vsize, begin, shape, dimensions, attributes, isrec, self._recsize, maskandscale=self._maskandscale) def _read_values(self, n, nc_type): bytes = [1, 1, 2, 4, 4, 8] @@ -335,7 +350,7 @@ class _LocalVariable(object): - def __init__(self, fileno, nc_type, vsize, begin, shape, dimensions, attributes, isrec=False, recsize=0): + def __init__(self, fileno, nc_type, vsize, begin, shape, dimensions, attributes, isrec=False, recsize=0, maskandscale=True): self._nc_type = nc_type self._vsize = vsize self._begin = begin @@ -344,6 +359,7 @@ self.attributes = attributes # for ``dap.plugins.netcdf`` self.__dict__.update(attributes) self._is_record = isrec + self._maskandscale = maskandscale # Number of bytes and type. self._bytes = [1, 1, 2, 4, 4, 8][self._nc_type-1] @@ -378,7 +394,10 @@ # - remove singleton dimensions # - create a masked array using missing_value or _FillValue attribute # - apply scale_factor and add_offset to packed integer data - return _maskandscale(self,datout) + if self._maskandscale: + return _maskandscale(self,datout) + else: + return datout def getValue(self): """For scalars.""" This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <md...@us...> - 2007-11-27 17:40:47
|
Revision: 4469 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4469&view=rev Author: mdboom Date: 2007-11-27 09:40:45 -0800 (Tue, 27 Nov 2007) Log Message: ----------- Fix memory leak and increase performance in quadmesh drawing (Agg) Modified Paths: -------------- branches/transforms/lib/matplotlib/collections.py branches/transforms/src/_backend_agg.cpp Modified: branches/transforms/lib/matplotlib/collections.py =================================================================== --- branches/transforms/lib/matplotlib/collections.py 2007-11-27 17:34:20 UTC (rev 4468) +++ branches/transforms/lib/matplotlib/collections.py 2007-11-27 17:40:45 UTC (rev 4469) @@ -163,10 +163,8 @@ xs = self.convert_xunits(self._offsets[:0]) ys = self.convert_yunits(self._offsets[:1]) offsets = zip(xs, ys) - if len(offsets) == 0: - offsets = npy.array([], npy.float_) - else: - offsets = npy.asarray(offsets, npy.float_) + + offsets = npy.asarray(offsets, npy.float_) self.update_scalarmappable() @@ -389,10 +387,12 @@ self._bbox = transforms.Bbox.unit() self._bbox.update_from_data_xy(coordinates.reshape( ((meshWidth + 1) * (meshHeight + 1), 2))) + + # By converting to floats now, we can avoid that on every draw. + self._coordinates = self._coordinates.reshape((meshHeight + 1, meshWidth + 1, 2)) + self._coordinates = npy.array(self._coordinates, npy.float_) def get_paths(self, dataTrans=None): - import pdb - pdb.set_trace() if self._paths is None: self._paths = self.convert_mesh_to_paths( self._meshWidth, self._meshHeight, self._coordinates) @@ -402,7 +402,7 @@ def convert_mesh_to_paths(meshWidth, meshHeight, coordinates): Path = mpath.Path - c = coordinates.reshape((meshHeight + 1, meshWidth + 1, 2)) + c = coordinates # We could let the Path constructor generate the codes for us, # but this is faster, since we know they'll always be the same codes = npy.array( @@ -436,10 +436,7 @@ ys = self.convert_yunits(self._offsets[:1]) offsets = zip(xs, ys) - if len(offsets) == 0: - offsets = npy.array([], npy.float_) - else: - offsets = npy.asarray(offsets, npy.float_) + offsets = npy.asarray(offsets, npy.float_) if self.check_update('array'): self.update_scalarmappable() Modified: branches/transforms/src/_backend_agg.cpp =================================================================== --- branches/transforms/src/_backend_agg.cpp 2007-11-27 17:34:20 UTC (rev 4468) +++ branches/transforms/src/_backend_agg.cpp 2007-11-27 17:40:45 UTC (rev 4469) @@ -1113,8 +1113,9 @@ inline unsigned vertex(unsigned idx, double* x, double* y) { size_t m = m_m + offsets[idx][0]; size_t n = m_n + offsets[idx][1]; - *x = *(double*)PyArray_GETPTR3(m_coordinates, m, n, 0); - *y = *(double*)PyArray_GETPTR3(m_coordinates, m, n, 1); + double* pair = (double*)PyArray_GETPTR2(m_coordinates, m, n); + *x = *pair++; + *y = *pair; return (idx == 0) ? agg::path_cmd_move_to : agg::path_cmd_line_to; } @@ -1130,10 +1131,6 @@ inline unsigned total_vertices() { return 5; } - - inline bool has_curves() { - return false; - } }; public: @@ -1146,11 +1143,7 @@ throw Py::ValueError("Invalid coordinates array."); } - PyArray_Dims shape; - npy_intp dims[] = { meshHeight + 1, meshWidth + 1, 2 }; - shape.ptr = dims; - shape.len = 3; - m_coordinates = (PyArrayObject*)PyArray_Newshape(coordinates_array, &shape, PyArray_CORDER); + m_coordinates = coordinates_array; } inline ~QuadMeshGenerator() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 17:34:33
|
Revision: 4468 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4468&view=rev Author: jswhit Date: 2007-11-27 09:34:20 -0800 (Tue, 27 Nov 2007) Log Message: ----------- use PyNIO to read data if the pure python NetCDF reader fails (PyNIO can read GRIB1+2, HDF4, NetCDF4 and HDFEOS2). Modified Paths: -------------- trunk/toolkits/basemap/examples/plotprecip.py trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py Modified: trunk/toolkits/basemap/examples/plotprecip.py =================================================================== --- trunk/toolkits/basemap/examples/plotprecip.py 2007-11-27 17:07:38 UTC (rev 4467) +++ trunk/toolkits/basemap/examples/plotprecip.py 2007-11-27 17:34:20 UTC (rev 4468) @@ -13,7 +13,6 @@ # data from http://www.srh.noaa.gov/rfcshare/precip_analysis_new.php prcpvar = nc.variables['amountofprecip'] data = 0.01*prcpvar[:] -data = pylab.clip(data,0,10000) latcorners = nc.variables['lat'][:] loncorners = -nc.variables['lon'][:] plottitle = prcpvar.long_name+' for period ending '+prcpvar.dateofdata Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-11-27 17:07:38 UTC (rev 4467) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/pupynere.py 2007-11-27 17:34:20 UTC (rev 4468) @@ -36,6 +36,11 @@ from dap.client import open as open_remote from dap.dtypes import ArrayType, GridType, typemap +has_pynio = True +try: + from PyNGL import nio +except ImportError: + has_pynio = False ABSENT = '\x00' * 8 ZERO = '\x00' * 4 @@ -54,14 +59,31 @@ def NetCDFFile(file): """NetCDF File reader. API is the same as Scientific.IO.NetCDF. If 'file' is a URL that starts with 'http', it is assumed - to be a remote OPenDAP dataest, and the python dap client is used + to be a remote OPenDAP dataset, and the python dap client is used to retrieve the data. Only the OPenDAP Array and Grid data types are recognized. If file does not start with 'http', it - is assumed to be a local NetCDF file.""" + is assumed to be a local file. If possible, the file will be read + with a pure python NetCDF reader, otherwise PyNIO + (http://www.pyngl.ucar.edu/Nio.shtml) will be used (if it is installed). + PyNIO supports NetCDF version 4, GRIB1, GRIB2, HDF4 and HDFEOS2 files. + """ if file.startswith('http'): return _RemoteFile(file) else: - return _LocalFile(file) + # use pynio if it is installed and the file cannot + # be read with the pure python netCDF reader. This allows + # netCDF version 4, GRIB1, GRIB2, HDF4 and HDFEOS files + # to be read. + if has_pynio: + try: + f = _LocalFile(file) + except: + f = nio.open_file(file) + # otherwise, use the pupynere netCDF 3 pure python reader. + # (will fail if file is not a netCDF version 3 file). + else: + f = _LocalFile(file) + return f def _maskandscale(var,datout): if hasattr(var, 'missing_value') and (datout == var.missing_value).any(): This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 17:07:41
|
Revision: 4467 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4467&view=rev Author: jswhit Date: 2007-11-27 09:07:38 -0800 (Tue, 27 Nov 2007) Log Message: ----------- fix bug in drawparallels introduced in last commit 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-11-27 16:28:30 UTC (rev 4466) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-27 17:07:38 UTC (rev 4467) @@ -1519,7 +1519,6 @@ nl = _searchlist(lats,lat) nr = _searchlist(lats[::-1],lat) if nr != -1: nr = len(lons)-nr-1 - latlab = fmt(lat) try: # fmt is a function that returns a formatted string latlab = fmt(lat) except: # fmt is a format string. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 16:28:47
|
Revision: 4466 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4466&view=rev Author: jswhit Date: 2007-11-27 08:28:30 -0800 (Tue, 27 Nov 2007) Log Message: ----------- use dashes kwarg Modified Paths: -------------- trunk/toolkits/basemap/examples/customticks.py Modified: trunk/toolkits/basemap/examples/customticks.py =================================================================== --- trunk/toolkits/basemap/examples/customticks.py 2007-11-27 16:25:04 UTC (rev 4465) +++ trunk/toolkits/basemap/examples/customticks.py 2007-11-27 16:28:30 UTC (rev 4466) @@ -73,8 +73,8 @@ m.drawmapboundary(fill_color='aqua') # label meridians and parallels, passing string formatting function # with 'fmt' keyword. -m.drawparallels(numpy.linspace(18,21,7),labels=[1,0,0,0],fmt=lat2str) -m.drawmeridians(numpy.linspace(-157,-154,7),labels=[0,0,0,1],fmt=lon2str) +m.drawparallels(numpy.linspace(18,21,7),labels=[1,0,0,0],fmt=lat2str,dashes=[2,2]) +m.drawmeridians(numpy.linspace(-157,-154,7),labels=[0,0,0,1],fmt=lon2str,dashes=[2,2]) pylab.title('Hawaii') pylab.show() This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 16:25:09
|
Revision: 4465 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4465&view=rev Author: jswhit Date: 2007-11-27 08:25:04 -0800 (Tue, 27 Nov 2007) Log Message: ----------- fix typos Modified Paths: -------------- trunk/toolkits/basemap/examples/customticks.py Modified: trunk/toolkits/basemap/examples/customticks.py =================================================================== --- trunk/toolkits/basemap/examples/customticks.py 2007-11-27 16:21:11 UTC (rev 4464) +++ trunk/toolkits/basemap/examples/customticks.py 2007-11-27 16:25:04 UTC (rev 4465) @@ -6,7 +6,6 @@ # projection. def lat2str(deg): - fmt = "%d" min = 60 * (deg - numpy.floor(deg)) deg = numpy.floor(deg) dir = 'N' @@ -14,8 +13,8 @@ if min != 0.0: deg += 1.0 min -= 60.0 - dir='S' - return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg), numpy.abs(min), dir) + dir = 'S' + return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg),numpy.abs(min),dir) def lon2str(deg): min = 60 * (deg - numpy.floor(deg)) @@ -25,8 +24,8 @@ if min != 0.0: deg += 1.0 min -= 60.0 - dir='W' - return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg), numpy.abs(min), dir) + dir = 'W' + return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg),numpy.abs(min),dir) # (1) use matplotlib custom tick formatter # instead of Basemap labelling methods. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 16:21:14
|
Revision: 4464 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4464&view=rev Author: jswhit Date: 2007-11-27 08:21:11 -0800 (Tue, 27 Nov 2007) Log Message: ----------- fmt kwarg to drawparallels and drawmeridians can now be a string formatting function. Modified Paths: -------------- trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/examples/customticks.py trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2007-11-27 13:12:10 UTC (rev 4463) +++ trunk/toolkits/basemap/Changelog 2007-11-27 16:21:11 UTC (rev 4464) @@ -1,4 +1,7 @@ version 0.9.8 (not yet released) + * 'fmt' kwarg to drawparallels and drawmeridians can + now be a custom string formatting function (example + customticks.py demonstrates usage). * remove 'linestyle' kwarg from drawparallels and drawmeridians (it never did anything anyway since it was overridden by the 'dashes' kwarg). Modified: trunk/toolkits/basemap/examples/customticks.py =================================================================== --- trunk/toolkits/basemap/examples/customticks.py 2007-11-27 13:12:10 UTC (rev 4463) +++ trunk/toolkits/basemap/examples/customticks.py 2007-11-27 16:21:11 UTC (rev 4464) @@ -5,19 +5,32 @@ # example showing how to create custom tick labels for a cylindrical # projection. -def deg2str(deg, dir='E', fmt="%3.1f"): +def lat2str(deg): + fmt = "%d" min = 60 * (deg - numpy.floor(deg)) deg = numpy.floor(deg) + dir = 'N' if deg < 0: if min != 0.0: deg += 1.0 min -= 60.0 - if dir=='E': - dir='W' - if dir=='N': - dir='S' - return (u"%d\N{DEGREE SIGN}" + fmt + "' %s") % (numpy.abs(deg), numpy.abs(min), dir) + dir='S' + return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg), numpy.abs(min), dir) +def lon2str(deg): + min = 60 * (deg - numpy.floor(deg)) + deg = numpy.floor(deg) + dir = 'E' + if deg < 0: + if min != 0.0: + deg += 1.0 + min -= 60.0 + dir='W' + return (u"%d\N{DEGREE SIGN} %g' %s") % (numpy.abs(deg), numpy.abs(min), dir) + +# (1) use matplotlib custom tick formatter +# instead of Basemap labelling methods. + # create figure. fig=pylab.figure() # create Basemap instance (regular lat/lon projection). @@ -35,14 +48,34 @@ ax = pylab.gca() # add custom ticks. # This only works for projection='cyl'. -def xformat(x, pos=None): return deg2str(x, 'E', fmt="%2.0f") +def xformat(x, pos=None): return lon2str(x) xformatter = FuncFormatter(xformat) ax.xaxis.set_major_formatter(xformatter) -def yformat(y, pos=None): return deg2str(y, 'N', fmt="%2.0f") +def yformat(y, pos=None): return lat2str(y) yformatter = FuncFormatter(yformat) ax.yaxis.set_major_formatter(yformatter) -ax.fmt_xdata = lambda x: deg2str(x, 'E', fmt="%5.3f") -ax.fmt_ydata = lambda y: deg2str(y, 'N', fmt="%5.3f") +ax.fmt_xdata = lambda x: lon2str(x) +ax.fmt_ydata = lambda y: lat2str(y) ax.grid() ax.set_title('Hawaii') + +# (2) use Basemap labelling methods, but pass a +# custom formatting function with the 'fmt' keyword. + +# create figure. +fig = pylab.figure() +# create Basemap instance. +m = Basemap(llcrnrlon=-156.5,llcrnrlat=18.75,urcrnrlon=-154.5,urcrnrlat=20.5, + resolution='h',projection='cyl') +# draw coastlines, fill land and lake areas. +m.drawcoastlines() +m.fillcontinents(color='coral',lake_color='aqua') +# background color will be used for oceans. +m.drawmapboundary(fill_color='aqua') +# label meridians and parallels, passing string formatting function +# with 'fmt' keyword. +m.drawparallels(numpy.linspace(18,21,7),labels=[1,0,0,0],fmt=lat2str) +m.drawmeridians(numpy.linspace(-157,-154,7),labels=[0,0,0,1],fmt=lon2str) +pylab.title('Hawaii') + pylab.show() Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-27 13:12:10 UTC (rev 4463) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-27 16:21:11 UTC (rev 4464) @@ -1375,7 +1375,9 @@ but not the right and top. labelstyle - if set to "+/-", north and south latitudes are labelled with "+" and "-", otherwise they are labelled with "N" and "S". - fmt is a format string to format the parallel labels (default '%g'). + fmt can be is a format string to format the parallel labels + (default '%g') or a function that takes a latitude value + in degrees as it's only argument and returns a formatted string. xoffset - label offset from edge of map in x-direction (default is 0.01 times width of map in map projection coordinates). yoffset - label offset from edge of map in y-direction @@ -1517,36 +1519,40 @@ nl = _searchlist(lats,lat) nr = _searchlist(lats[::-1],lat) if nr != -1: nr = len(lons)-nr-1 - if lat<0: - if rcParams['text.usetex']: - if labelstyle=='+/-': - latlabstr = r'${\/-%s\/^{\circ}}$'%fmt + latlab = fmt(lat) + try: # fmt is a function that returns a formatted string + latlab = fmt(lat) + except: # fmt is a format string. + if lat<0: + if rcParams['text.usetex']: + if labelstyle=='+/-': + latlabstr = r'${\/-%s\/^{\circ}}$'%fmt + else: + latlabstr = r'${%s\/^{\circ}\/S}$'%fmt else: - latlabstr = r'${%s\/^{\circ}\/S}$'%fmt - else: - if labelstyle=='+/-': - latlabstr = u'-%s\N{DEGREE SIGN}'%fmt + if labelstyle=='+/-': + latlabstr = u'-%s\N{DEGREE SIGN}'%fmt + else: + latlabstr = u'%s\N{DEGREE SIGN}S'%fmt + latlab = latlabstr%npy.fabs(lat) + elif lat>0: + if rcParams['text.usetex']: + if labelstyle=='+/-': + latlabstr = r'${\/+%s\/^{\circ}}$'%fmt + else: + latlabstr = r'${%s\/^{\circ}\/N}$'%fmt else: - latlabstr = u'%s\N{DEGREE SIGN}S'%fmt - latlab = latlabstr%npy.fabs(lat) - elif lat>0: - if rcParams['text.usetex']: - if labelstyle=='+/-': - latlabstr = r'${\/+%s\/^{\circ}}$'%fmt - else: - latlabstr = r'${%s\/^{\circ}\/N}$'%fmt + if labelstyle=='+/-': + latlabstr = u'+%s\N{DEGREE SIGN}'%fmt + else: + latlabstr = u'%s\N{DEGREE SIGN}N'%fmt + latlab = latlabstr%lat else: - if labelstyle=='+/-': - latlabstr = u'+%s\N{DEGREE SIGN}'%fmt + if rcParams['text.usetex']: + latlabstr = r'${%s\/^{\circ}}$'%fmt else: - latlabstr = u'%s\N{DEGREE SIGN}N'%fmt - latlab = latlabstr%lat - else: - if rcParams['text.usetex']: - latlabstr = r'${%s\/^{\circ}}$'%fmt - else: - latlabstr = u'%s\N{DEGREE SIGN}'%fmt - latlab = latlabstr%lat + latlabstr = u'%s\N{DEGREE SIGN}'%fmt + latlab = latlabstr%lat # parallels can intersect each map edge twice. for i,n in enumerate([nl,nr]): # don't bother if close to the first label. @@ -1594,7 +1600,9 @@ but not the right and top. labelstyle - if set to "+/-", east and west longitudes are labelled with "+" and "-", otherwise they are labelled with "E" and "W". - fmt is a format string to format the meridian labels (default '%g'). + fmt can be is a format string to format the meridian labels + (default '%g') or a function that takes a longitude value + in degrees as it's only argument and returns a formatted string. xoffset - label offset from edge of map in x-direction (default is 0.01 times width of map in map projection coordinates). yoffset - label offset from edge of map in y-direction @@ -1721,42 +1729,45 @@ lons = [(lon+360) % 360 for lon in lons] for lon in meridians: # adjust so 0 <= lon < 360 - lon = (lon+360) % 360 + lon2 = (lon+360) % 360 # find index of meridian (there may be two, so # search from left and right). - nl = _searchlist(lons,lon) - nr = _searchlist(lons[::-1],lon) + nl = _searchlist(lons,lon2) + nr = _searchlist(lons[::-1],lon2) if nr != -1: nr = len(lons)-nr-1 - if lon>180: - if rcParams['text.usetex']: - if labelstyle=='+/-': - lonlabstr = r'${\/-%s\/^{\circ}}$'%fmt + try: # fmt is a function that returns a formatted string + lonlab = fmt(lon) + except: # fmt is a format string. + if lon2>180: + if rcParams['text.usetex']: + if labelstyle=='+/-': + lonlabstr = r'${\/-%s\/^{\circ}}$'%fmt + else: + lonlabstr = r'${%s\/^{\circ}\/W}$'%fmt else: - lonlabstr = r'${%s\/^{\circ}\/W}$'%fmt - else: - if labelstyle=='+/-': - lonlabstr = u'-%s\N{DEGREE SIGN}'%fmt + if labelstyle=='+/-': + lonlabstr = u'-%s\N{DEGREE SIGN}'%fmt + else: + lonlabstr = u'%s\N{DEGREE SIGN}W'%fmt + lonlab = lonlabstr%npy.fabs(lon2-360) + elif lon2<180 and lon2 != 0: + if rcParams['text.usetex']: + if labelstyle=='+/-': + lonlabstr = r'${\/+%s\/^{\circ}}$'%fmt + else: + lonlabstr = r'${%s\/^{\circ}\/E}$'%fmt else: - lonlabstr = u'%s\N{DEGREE SIGN}W'%fmt - lonlab = lonlabstr%npy.fabs(lon-360) - elif lon<180 and lon != 0: - if rcParams['text.usetex']: - if labelstyle=='+/-': - lonlabstr = r'${\/+%s\/^{\circ}}$'%fmt - else: - lonlabstr = r'${%s\/^{\circ}\/E}$'%fmt + if labelstyle=='+/-': + lonlabstr = u'+%s\N{DEGREE SIGN}'%fmt + else: + lonlabstr = u'%s\N{DEGREE SIGN}E'%fmt + lonlab = lonlabstr%lon2 else: - if labelstyle=='+/-': - lonlabstr = u'+%s\N{DEGREE SIGN}'%fmt + if rcParams['text.usetex']: + lonlabstr = r'${%s\/^{\circ}}$'%fmt else: - lonlabstr = u'%s\N{DEGREE SIGN}E'%fmt - lonlab = lonlabstr%lon - else: - if rcParams['text.usetex']: - lonlabstr = r'${%s\/^{\circ}}$'%fmt - else: - lonlabstr = u'%s\N{DEGREE SIGN}'%fmt - lonlab = lonlabstr%lon + lonlabstr = u'%s\N{DEGREE SIGN}'%fmt + lonlab = lonlabstr%lon2 # meridians can intersect each map edge twice. for i,n in enumerate([nl,nr]): lat = lats[n]/100. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <js...@us...> - 2007-11-27 13:12:15
|
Revision: 4463 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4463&view=rev Author: jswhit Date: 2007-11-27 05:12:10 -0800 (Tue, 27 Nov 2007) Log Message: ----------- remove linestyle kwarg from drawparallels and drawmeridians. Modified Paths: -------------- trunk/toolkits/basemap/API_CHANGES trunk/toolkits/basemap/Changelog trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py Modified: trunk/toolkits/basemap/API_CHANGES =================================================================== --- trunk/toolkits/basemap/API_CHANGES 2007-11-27 08:07:07 UTC (rev 4462) +++ trunk/toolkits/basemap/API_CHANGES 2007-11-27 13:12:10 UTC (rev 4463) @@ -1,5 +1,11 @@ -version 0.9.2: width, height keywords added to Basemap.__init__. -version 0.9.1: createfigure method removed. +version 0.9.8: remove linestyle kwarg from drawparallels and drawmeridians. + add fill_color kwarg to drawmapboundary. +version 0.9.7: added lake_color kwarg to fillcontinents. +version 0.9.6: added "labelstyle" keyword to drawparallels and drawmeridians. + added "zorder" kwarg to drawparallels, drawmeridians, + drawcoastlines, drawstates, drawcountries, drawrivers, +version 0.9.2: width, height keywords added to Basemap.__init__. +version 0.9.1: createfigure method removed. version 0.9: creatfigure method deprecated, new set_aspect axes method used to ensure maps have right aspect ratio. pcolormesh, drawlsmask methods added. Modified: trunk/toolkits/basemap/Changelog =================================================================== --- trunk/toolkits/basemap/Changelog 2007-11-27 08:07:07 UTC (rev 4462) +++ trunk/toolkits/basemap/Changelog 2007-11-27 13:12:10 UTC (rev 4463) @@ -1,4 +1,7 @@ version 0.9.8 (not yet released) + * remove 'linestyle' kwarg from drawparallels and + drawmeridians (it never did anything anyway since + it was overridden by the 'dashes' kwarg). * modify NetCDFFile to use dap module to read remote datasets over http. Include dap and httplib2 modules. * modify NetCDFFile to automatically apply scale_factor Modified: trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py =================================================================== --- trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-27 08:07:07 UTC (rev 4462) +++ trunk/toolkits/basemap/lib/matplotlib/toolkits/basemap/basemap.py 2007-11-27 13:12:10 UTC (rev 4463) @@ -1356,7 +1356,7 @@ return info def drawparallels(self,circles,color='k',linewidth=1.,zorder=None, \ - linestyle='--',dashes=[1,1],labels=[0,0,0,0],labelstyle=None, \ + dashes=[1,1],labels=[0,0,0,0],labelstyle=None, \ fmt='%g',xoffset=None,yoffset=None,ax=None,**kwargs): """ draw parallels (latitude lines). @@ -1366,7 +1366,6 @@ linewidth - line width for parallels (default 1.) zorder - sets the zorder for parallels (if not specified, uses default zorder for Line2D class). - linestyle - line style for parallels (default '--', i.e. dashed). dashes - dash pattern for parallels (default [1,1], i.e. 1 pixel on, 1 pixel off). labels - list of 4 values (default [0,0,0,0]) that control whether @@ -1461,7 +1460,7 @@ for x,y in zip(xl,yl): # skip if only a point. if len(x) > 1 and len(y) > 1: - l = Line2D(x,y,linewidth=linewidth,linestyle=linestyle) + l = Line2D(x,y,linewidth=linewidth) l.set_color(color) l.set_dashes(dashes) if zorder is not None: @@ -1576,7 +1575,7 @@ self.set_axes_limits(ax=ax) def drawmeridians(self,meridians,color='k',linewidth=1., zorder=None,\ - linestyle='--',dashes=[1,1],labels=[0,0,0,0],labelstyle=None,\ + dashes=[1,1],labels=[0,0,0,0],labelstyle=None,\ fmt='%g',xoffset=None,yoffset=None,ax=None,**kwargs): """ draw meridians (longitude lines). @@ -1586,7 +1585,6 @@ linewidth - line width for meridians (default 1.) zorder - sets the zorder for meridians (if not specified, uses default zorder for Line2D class). - linestyle - line style for meridians (default '--', i.e. dashed). dashes - dash pattern for meridians (default [1,1], i.e. 1 pixel on, 1 pixel off). labels - list of 4 values (default [0,0,0,0]) that control whether @@ -1667,7 +1665,7 @@ for x,y in zip(xl,yl): # skip if only a point. if len(x) > 1 and len(y) > 1: - l = Line2D(x,y,linewidth=linewidth,linestyle=linestyle) + l = Line2D(x,y,linewidth=linewidth) l.set_color(color) l.set_dashes(dashes) if zorder is not None: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fer...@us...> - 2007-11-27 08:07:10
|
Revision: 4462 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=4462&view=rev Author: fer_perez Date: 2007-11-27 00:07:07 -0800 (Tue, 27 Nov 2007) Log Message: ----------- Update NCAR agenda Modified Paths: -------------- trunk/py4science/classes/0712_ncar_agenda.txt Modified: trunk/py4science/classes/0712_ncar_agenda.txt =================================================================== --- trunk/py4science/classes/0712_ncar_agenda.txt 2007-11-27 02:24:22 UTC (rev 4461) +++ trunk/py4science/classes/0712_ncar_agenda.txt 2007-11-27 08:07:07 UTC (rev 4462) @@ -12,7 +12,7 @@ Day 1 (Friday December 7) ========================= -830-900 Installation +830-900 Installation and configuration (optional) This half hour will be spent helping with installation issues, before the real workshop begins. If you've already set things up on your system (meaning you have ipython, numpy, matplotlib and scipy installed and @@ -21,11 +21,16 @@ 900-905 Introduction Official start of the workshop, introduce instructors. -905-945 FP: Python for scientific computing +905-945 JDH: Python for scientific computing A high-level overview of the topic of Python in a scientific context. -950-1045 JDH: Workflow. +950-1045 FP: Workflow, guided by a simple example: trapezoid integration. +This section will be used to illustrate basic workflow for students, by having +them 'type along' a very simple exercise, trapezoid rule integration. We'll +discuss the basics of numpy arrays and will solve the trapezoid integration +exercise together. + Editor: (X)Emacs, Vi(m), etc. ipython. Saving and reloading files, interactive use of variables, %run, @@ -41,97 +46,105 @@ - The open source process: mailing lists, wikis, svn. Python cookbook. Participate! - Basic setup: - ipython - matplotlib (latex, etc). - Modules: import/reload, PYTHONPATH. +ToDo: Add numerical error measure of trapezoid rule. +ToDo Add in workflow comparison with scipy's integration. compare timing and + eror. + 1045:1100 --- Coffee break --- -1100:1215 FP: Introductory examples. +1100:1145 FP: Introductory examples. -* Qsort: lists, recursion. +We'll have two exercises, so students who finish the first one early don't get +bored and can do a second one. -* Define a simple function: Wallis' product for pi. Illustrates arbitrary -size integers. +FFTs: 2-d image denoising via FFT. -* Define a trapezoid rule integrator: function objects, arrays. +Numerical integration and root finding: Find t such that -1215:1315 --- Lunch Break --- - -1315:1400 JDH: Basic numpy/pylab - -* Record arrays - -* Timeseries - -1400:1430 FP: Numerical integration and root finding: Find t such that - \int_0^t{ f(s) ds} = u for a known, monotonically increasing f(s) and a fixed u. +1145:12:30 --- Lunch Break --- -1430:1500 FP: Univariate polynomials, root finding: poly1d objects, -convolutions, plotting. +1300:1400 JDH: Basic numpy/pylab -1500:1515 --- Coffee break --- +* Glass2 demo: linear algebra, event handling in interactive plots. +* Glass1 exercise: simplified version of the above as an exercise. +* ODEs - Lotka Volterra equations. -1515:1700: JDH/FP - Optional material (there's a Christmas party) +1400:1500 JW, Basemap: geographical datasets. -* Word frequencies: use of dictionaries and text processing. +1500 --- End of main work for Friday --- -* Getbibtex: fetching bibliographic information from the net (networking, - regular expressions, command-line scripting). +1500:1700: Optional material (there's a Christmas party) -* Beautiful soup: screen-scraping HTML for data extraction. +Web-based data sources, tabular data and record arrays, illustrated with Yahoo +Finance scraping, or PyDAP/OpenDAP. -* Possible 3d demos (not user exercises) using VPython and VTK/MayaVi. - Day 2 (Saturday December 8) =========================== -900:945 JDH: Data fitting/smoothing: least squares, cubic splines, polynomial -fitting. Basic linear algebra. +900:930 FP: Traits, Mayavi2 demo. Automatic GUI generation, VTK library, the +MayaVi visualization application. This is a demo of capabilities, not an +exercise. -945:1030 FP: FFTs: 2-d image denoising via FFT. +930:1030 FP - Lightweight tools for low-level code reuse +f2py: Fortran code wrapping exercise. +weave: C/C++ inlining exercise. + 1030:1045 --- Coffee break --- -1045:1130 JDH: Logistic map +1045:1200 JDH - Other tools for C/C++ code reuse, demos/slides. -1130:1200 FP: Bessel functions: special functions library, array manipulations -to check recursion relation. - +* ctypes: easy access to dynamically linked libraries. +* pyrex: blend of python/C for automatic generation of native code. +* SWIG: automatic wrapping of C/C++ libraries. +* Boost.Python: automatic wrapping of C++ libraries with template support. +* A tour of scipy's code base, which uses several of these techniques. + 1200:1300 --- Lunch break --- -1300:1345 JDH: Statistics & distributions +1300:1500 Menu of options: -1345:1445 FP: +* Data fitting/smoothing: least squares, cubic splines, polynomial fitting. +Basic linear algebra (30 min). -* Montecarlo integration to compute pi. +* Bessel functions: special functions library, array manipulations to check +recursion relation (30 min). -* Speed: weave.blitz, weave.inline. +* Descriptive statistics, statistical distributions (1 hr). -1445:1500 Wrapup, discussion, questions, coffee. +* SVD/eigenfaces (1 hr). +* Logistic map (1 hr). +* Sage intro/demo (20-30 min). +* Beautiful soup: screen-scraping HTML for data extraction (30 min). + +* Word frequencies: use of dictionaries and text processing (20 min). + +* Prime numbers: the Sieve of Erathostenes. Illustrates lists and sets (30 + min). + +* Wallis' pi: arbitrary precision integers (30 min). + + Unused examples and exercises, extra ideas ========================================== -* Prime numbers: the Sieve of Erathostenes. Illustrates lists and sets. - * Visual (VPython): Show some examples, explain. Target shooting exercise. -* Eigenfaces problem, part 1. - -* Eigenfaces problem, part 2. - * One-dimensional FFT - Bode plot. * Spectral interpolation. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |