From: Jeff W. <js...@fa...> - 2005-02-10 13:04:46
|
The first matplotlib toolkit has been released. Matplotlib toolkits are collections of application-specific functions that extend matplotlib. This is hopefully the first of many - additional contributions are encouraged! The basemap toolkit allows matplotlib to plot regularly-space latitiude/longitude grids on map projections, including drawing coastlines, political boundaries, parallels and meridians. It currently supports six map projections (cylindrical equidistant, mercator, lambert conformal conic, lambert azimuthal equal area, albers equal area and stereographic). It uses routines from the proj.4 library (http://proj.maptools.org) to perform cartographic transformations. Documentation - http://matplotlib.sourceforge.net/toolkits.html. Screenshot - http://matplotlib.sourceforge.net/screenshots/plotmap_large.png Example Code - http://matplotlib.sourceforge.net/screenshots/plotmap.py Examples for each map projection are included in the source release (available at the sf download page (http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792). Windows binaries are provided (thanks John!) - but they do not include the examples. Comments/bug reports/suggestions are welcome. -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 325 Broadway Web : http://www.cdc.noaa.gov/~jsw Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 |
From: Ted D. <ted...@jp...> - 2005-02-10 16:31:51
|
Jeff, Great timing! I was just reviewing some requirements from our users to be able to create ground track plots of spacecraft right after launch. Your package looks like it should easily do most of the work for us! One thing I do need to be able to do is to create line plots that "wrap around" a map. We generate a lot of ground tracks that use a Mercator projection covering the whole globe (x=-180->180, y=-90->90) and if the line goes off one edge, we need to wrap it around to the other edge instead of drawing a line segment all the way across the page. I had planning on creating a front end script to pre-process the data to handle this type of capability. The only issue with this approach is that it requires multiple lines be drawn (as if you're plotting multiple curves) but only one of them should show up in the legend. I was wondering anyone else has need of this and if there is a better way to implement this wrapping feature when doing map plots? Ted ps: John I promise I'll get you a Qt backend this week. We hit a few delays but I should be able to get you something this afternoon. It's basically a refactorization of the Qt backend that's in CVS right now with some drawing improvements to reduce flickering. At 05:04 AM 2/10/2005, Jeff Whitaker wrote: >The first matplotlib toolkit has been released. > >Matplotlib toolkits are collections of application-specific functions that >extend matplotlib. > >This is hopefully the first of many - additional contributions are encouraged! > >The basemap toolkit allows matplotlib to plot regularly-space >latitiude/longitude grids on map projections, including drawing >coastlines, political boundaries, parallels and meridians. It currently >supports six map projections (cylindrical equidistant, mercator, lambert >conformal conic, lambert azimuthal equal area, albers equal area and >stereographic). > >It uses routines from the proj.4 library (http://proj.maptools.org) to >perform cartographic transformations. > >Documentation - http://matplotlib.sourceforge.net/toolkits.html. > >Screenshot - http://matplotlib.sourceforge.net/screenshots/plotmap_large.png > >Example Code - http://matplotlib.sourceforge.net/screenshots/plotmap.py > >Examples for each map projection are included in the source release >(available at the sf download page >(http://sourceforge.net/project/showfiles.php?group_id=80706&package_id=142792). > >Windows binaries are provided (thanks John!) - but they do not include the >examples. > >Comments/bug reports/suggestions are welcome. > >-Jeff > >-- >Jeffrey S. Whitaker Phone : (303)497-6313 >NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 >325 Broadway Web : http://www.cdc.noaa.gov/~jsw >Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 > > > >------------------------------------------------------- >SF email is sponsored by - The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >_______________________________________________ >Matplotlib-users mailing list >Mat...@li... >https://lists.sourceforge.net/lists/listinfo/matplotlib-users |
From: Chris B. <Chr...@no...> - 2005-02-10 17:53:39
|
Ted Drain wrote: > Jeff, > One thing I do need to be able to do is to create line plots that "wrap > around" a map. We generate a lot of ground tracks that use a Mercator > projection covering the whole globe (x=-180->180, y=-90->90) and if the > line goes off one edge, we need to wrap it around to the other edge > instead of drawing a line segment all the way across the page. Yes, this really is a pain. If you work out a good solution, please let me know, or post it to the list. I'd love to have a similar feature in my wxPython FloatCanvas. -Chris -- Christopher Barker, Ph.D. Oceanographer NOAA/OR&R/HAZMAT (206) 526-6959 voice 7600 Sand Point Way NE (206) 526-6329 fax Seattle, WA 98115 (206) 526-6317 main reception Chr...@no... |
From: Ted D. <ted...@jp...> - 2005-02-10 17:59:47
|
What I did in the past was to use a heuristic that said something like: if the next point jumps more than 80% (or something like that) of the full map range, then do a linear interpolation to find the point at the boundary and add that to the line. Then split the line and start a new curve on the other side. We probably won't get to working on this until Apr-May but I'll let you know what we come up with. I'll try to set up some type of general purpose functions and then you can decide if they have a place in the basemap module. Ted At 09:52 AM 2/10/2005, Chris Barker wrote: >Ted Drain wrote: >>Jeff, >>One thing I do need to be able to do is to create line plots that "wrap >>around" a map. We generate a lot of ground tracks that use a Mercator >>projection covering the whole globe (x=-180->180, y=-90->90) and if the >>line goes off one edge, we need to wrap it around to the other edge >>instead of drawing a line segment all the way across the page. > >Yes, this really is a pain. If you work out a good solution, please let me >know, or post it to the list. I'd love to have a similar feature in my >wxPython FloatCanvas. > >-Chris > > >-- >Christopher Barker, Ph.D. >Oceanographer > >NOAA/OR&R/HAZMAT (206) 526-6959 voice >7600 Sand Point Way NE (206) 526-6329 fax >Seattle, WA 98115 (206) 526-6317 main reception > >Chr...@no... |
From: Jeff W. <js...@fa...> - 2005-02-10 18:57:21
|
Ted Drain wrote: > Jeff, > Great timing! I was just reviewing some requirements from our users > to be able to create ground track plots of spacecraft right after > launch. Your package looks like it should easily do most of the work > for us! > > One thing I do need to be able to do is to create line plots that > "wrap around" a map. We generate a lot of ground tracks that use a > Mercator projection covering the whole globe (x=-180->180, y=-90->90) > and if the line goes off one edge, we need to wrap it around to the > other edge instead of drawing a line segment all the way across the page. Ted: That is a pain - I had to work around this a couple of times in the basemap code (when drawing coastlines and when drawing parallels and meridians). BTW: You won't be able to define a mercator projection that goes from -90 to 90 (it's singular at the poles). You'll have to stop it at 80 or 85 degrees. > > I had planning on creating a front end script to pre-process the data > to handle this type of capability. The only issue with this approach > is that it requires multiple lines be drawn (as if you're plotting > multiple curves) but only one of them should show up in the legend. I > was wondering anyone else has need of this and if there is a better > way to implement this wrapping feature when doing map plots? That would be useful for lots of people I think - I don't know of any better way (other than using a non-cylindrical projection, like a polar stereographic). -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX : (303)497-6449 NOAA/OAR/CDC R/CDC1 Email : Jef...@no... 325 Broadway Office : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg |
From: Jeff W. <js...@fa...> - 2005-02-11 13:28:36
|
Ted Drain wrote: > > One thing I do need to be able to do is to create line plots that > "wrap around" a map. We generate a lot of ground tracks that use a > Mercator projection covering the whole globe (x=-180->180, y=-90->90) > and if the line goes off one edge, we need to wrap it around to the > other edge instead of drawing a line segment all the way across the page. Ted: It just occured to me that if you plot the track as a scatterplot of points instead of a line then this is not a problem (i.e. you won't get that line segment running across the page) -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 325 Broadway Web : http://www.cdc.noaa.gov/~jsw Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 |
From: Ted D. <ted...@jp...> - 2005-02-11 20:39:50
|
I could use a scatter plot but user's actually want a line drawn so that's out. I think either the plot has to be really smart about it (which is probably a bad idea), or this type of functionality has to be in a utility or wrapper that can be used. I think I'm stuck doing linear interpolation and somehow separating the line segments at the boundary of the map. Is there an easy way to plot multiple collections of points connected by a line and have only a single legend entry show up? It would also be nice if any modifications to that entry (marker, color, etc) would affect all the line segments. Ted PS: we also need some way to draw only the n'th marker in a line plot. We plot a lot of trajectories where time is progressing along the line so it's useful to generate the plot using 1 minute data (for example) and then have a marker be displayed every 60'th point. At 05:28 AM 2/11/2005, Jeff Whitaker wrote: >Ted Drain wrote: > >> >>One thing I do need to be able to do is to create line plots that "wrap >>around" a map. We generate a lot of ground tracks that use a Mercator >>projection covering the whole globe (x=-180->180, y=-90->90) and if the >>line goes off one edge, we need to wrap it around to the other edge >>instead of drawing a line segment all the way across the page. > >Ted: It just occured to me that if you plot the track as a scatterplot of >points instead of a line then this is not a problem (i.e. you won't get >that line segment running across the page) > >-Jeff > >-- >Jeffrey S. Whitaker Phone : (303)497-6313 >NOAA/OAR/CDC R/CDC1 FAX : (303)497-6449 >325 Broadway Web : http://www.cdc.noaa.gov/~jsw >Boulder, CO, USA 80305-3328 Office: Skaggs Research Cntr 1D-124 > > > >------------------------------------------------------- >SF email is sponsored by - The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >_______________________________________________ >Matplotlib-users mailing list >Mat...@li... >https://lists.sourceforge.net/lists/listinfo/matplotlib-users Ted Drain Jet Propulsion Laboratory ted...@jp... |
From: John H. <jdh...@ac...> - 2005-02-11 20:52:27
|
>>>>> "Ted" == Ted Drain <ted...@jp...> writes: Ted> Is there an easy way to plot multiple collections of points Ted> connected by a line and have only a single legend entry show Ted> up? It would also be nice if any modifications to that entry Ted> (marker, color, etc) would affect all the line segments. Not 100% sure what you are after here. You can control which lines and patches get passed to the legend by explicitly passing them (as opposed to using the autolegend capabilities). Eg ax.legend((l1, p1), ('A line, 'A patch') Also, have you looked into the LineCollection class -- this sounds like it would support some of what you are describing. Perhaps if you explain a bit more. Ted> Ted PS: we also need some way to draw only the n'th marker in Ted> a line plot. We plot a lot of trajectories where time is Ted> progressing along the line so it's useful to generate the Ted> plot using 1 minute data (for example) and then have a marker Ted> be displayed every 60'th point. Look at subplot(211) in examples/subplot_demo.py. There a line is plotted with one temporal resolution, and markers are placed along the line at subsampled points. Basically two lines are added with different sampling frequencies. Does this suffice? JDH |
From: Ted D. <ted...@jp...> - 2005-02-11 21:25:07
|
Inlined comments below... At 12:41 PM 2/11/2005, John Hunter wrote: > >>>>> "Ted" == Ted Drain <ted...@jp...> writes: > > Ted> Is there an easy way to plot multiple collections of points > Ted> connected by a line and have only a single legend entry show > Ted> up? It would also be nice if any modifications to that entry > Ted> (marker, color, etc) would affect all the line segments. > >Not 100% sure what you are after here. You can control which lines >and patches get passed to the legend by explicitly passing them (as >opposed to using the autolegend capabilities). Eg > > ax.legend((l1, p1), ('A line, 'A patch') > >Also, have you looked into the LineCollection class -- this sounds >like it would support some of what you are describing. Perhaps if you >explain a bit more. What's happening here is that we have a plot that's a map of the earth going from -180 to 180 longitude and pole to pole. A spacecraft ground trajectory goes around and around so when it hit's the +180 longitude, it needs to wrap around to -180. We want this to be a line plot. If you just put in the x,y coordinates as a line plot, you get a long line segment when it goes from say: (175,20) -> (-175,30) What we've done in the past is to use a heuristic to detect this case. For example, I might say if the delta x is greater than 90% of the total longitude, it's a wrap around case. In that case, I do linear interpolation to get a point at the edge of the map (in this case 180, 25), insert this point, and split the line into two pieces at this point. For example, if I have a data set that looks like this: [155,2] [165,4] [175,6] [-175,8] [-165,10] [-155,12] I really need this data to be drawn as two separate lines: [155,2] [165,4] [175,6] [180,7] and [-180,7] [-175,8] [-165,10] [-155,12] Ideally these two segments should be treated as a single line wherever applicable (legend, style, etc). > Ted> Ted PS: we also need some way to draw only the n'th marker in > Ted> a line plot. We plot a lot of trajectories where time is > Ted> progressing along the line so it's useful to generate the > Ted> plot using 1 minute data (for example) and then have a marker > Ted> be displayed every 60'th point. > >Look at subplot(211) in examples/subplot_demo.py. There a line is >plotted with one temporal resolution, and markers are placed along the >line at subsampled points. Basically two lines are added with >different sampling frequencies. > >Does this suffice? I'd probably label this as a "mostly acceptable work-around" since it requires generating two data arrays. In my case, the data is expensive to compute so we'd probably have to generate a second array by selectively copying points from the first array which is kind of annoying. I was hoping for a keyword that said how often to generate the markers for an existing line (with the default as one of course). Probably not a huge deal though. >JDH Ted Drain Jet Propulsion Laboratory ted...@jp... |
From: John H. <jdh...@ac...> - 2005-02-11 21:36:38
|
>>>>> "Ted" == Ted Drain <ted...@jp...> writes: Ted> For example, if I have a data set that looks like this: Ted> [155,2] [165,4] [175,6] [-175,8] [-165,10] [-155,12] Ted> I really need this data to be drawn as two separate lines: Ted> [155,2] [165,4] [175,6] [180,7] Ted> and [-180,7] [-175,8] [-165,10] [-155,12] Ted> Ideally these two segments should be treated as a single line Ted> wherever applicable (legend, style, etc). Got it -- what comes immediately to mind is for you to create a new class derived from Line2D, that contains your 2...N lines as private attrs, defines __getattr__ to return the attr of line[0], and calls the Line2D parent setattr on each of your contained line instances. You can then add this line to the Axes with add_line. You would have to be a little clever with the get_xdata and get_ydata attrs, which are used for autoscaling. If this looks like a good way to go, I can help you with it if you want - it could be tricky to get just right. The other possibility would be to setup an observer pattern on the line0 properties, such that any changes would be fired off to the observers. This is an area where it would be nice to have enthought traits built-in, since all trains support observers. As you may have noticed on the dev list, this is an area of active discussion. Ted> I'd probably label this as a "mostly acceptable work-around" Ted> since it requires generating two data arrays. In my case, Ted> the data is expensive to compute so we'd probably have to Ted> generate a second array by selectively copying points from Ted> the first array which is kind of annoying. I was hoping for Ted> a keyword that said how often to generate the markers for an Ted> existing line (with the default as one of course). Probably Ted> not a huge deal though. If this becomes a performance problem for you, another idea would be to use a marker mask. Eg add an additional property to the line class which are the indices at which to write markers. Currently the line class is hairy in CVS, mainly because it is supporting the old and newstyle backend drawing interfaces. The newstyle interface has only two renderer methods that it calls (draw_lines and draw_markers). It would be fairly easy to subclass Line2D to support a marker mask, possibly passing it on as a kwarg to the renderer.draw_markers method. One could do it in Numeric a the python level; if you are looking for optimal performance, it would be barely more than a no-op at the backend level. JDH |
From: Ted D. <ted...@jp...> - 2005-02-11 21:46:33
|
Thanks for all the advice! We're going to start working on this ground track plotting package in the March-April time frame so I'm going to save off these notes for the implementor. We'll let you know if we need any more help then. Thanks, Ted At 01:25 PM 2/11/2005, John Hunter wrote: > >>>>> "Ted" == Ted Drain <ted...@jp...> writes: > Ted> For example, if I have a data set that looks like this: > > Ted> [155,2] [165,4] [175,6] [-175,8] [-165,10] [-155,12] > > Ted> I really need this data to be drawn as two separate lines: > Ted> [155,2] [165,4] [175,6] [180,7] > > Ted> and [-180,7] [-175,8] [-165,10] [-155,12] > > Ted> Ideally these two segments should be treated as a single line > Ted> wherever applicable (legend, style, etc). > >Got it -- what comes immediately to mind is for you to create a new >class derived from Line2D, that contains your 2...N lines as private >attrs, defines __getattr__ to return the attr of line[0], and calls >the Line2D parent setattr on each of your contained line instances. >You can then add this line to the Axes with add_line. > >You would have to be a little clever with the get_xdata and get_ydata >attrs, which are used for autoscaling. If this looks like a good way >to go, I can help you with it if you want - it could be tricky to get >just right. > >The other possibility would be to setup an observer pattern on the >line0 properties, such that any changes would be fired off to the >observers. This is an area where it would be nice to have enthought >traits built-in, since all trains support observers. As you may have >noticed on the dev list, this is an area of active discussion. > > > Ted> I'd probably label this as a "mostly acceptable work-around" > Ted> since it requires generating two data arrays. In my case, > Ted> the data is expensive to compute so we'd probably have to > Ted> generate a second array by selectively copying points from > Ted> the first array which is kind of annoying. I was hoping for > Ted> a keyword that said how often to generate the markers for an > Ted> existing line (with the default as one of course). Probably > Ted> not a huge deal though. > >If this becomes a performance problem for you, another idea would be >to use a marker mask. Eg add an additional property to the line class >which are the indices at which to write markers. > >Currently the line class is hairy in CVS, mainly because it is >supporting the old and newstyle backend drawing interfaces. The >newstyle interface has only two renderer methods that it calls >(draw_lines and draw_markers). It would be fairly easy to subclass >Line2D to support a marker mask, possibly passing it on as a kwarg to >the renderer.draw_markers method. One could do it in Numeric a the >python level; if you are looking for optimal performance, it would be >barely more than a no-op at the backend level. > > >JDH > > >------------------------------------------------------- >SF email is sponsored by - The IT Product Guide >Read honest & candid reviews on hundreds of IT Products from real users. >Discover which products truly live up to the hype. Start reading now. >http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click >_______________________________________________ >Matplotlib-users mailing list >Mat...@li... >https://lists.sourceforge.net/lists/listinfo/matplotlib-users Ted Drain Jet Propulsion Laboratory ted...@jp... |