-
Notifications
You must be signed in to change notification settings - Fork 421
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce Number of Wind Barbs for SkewT plot #99
Comments
I agree this is a nice to have. I think it's going to require digging into matplotlib to get the underlying collection object to handle such stuff at draw time. So not trivial, but very useful. |
I wrote a function and tested it on the simple and advanced sounding notebooks. It takes corresponding lists of pressure, u-wind, and v-wind and returns only those data closest to each step in a user defined interval. By default, I set this to every 50 mb between 1000 mb and 100 mb. This is all done on the front-end so it could be an acceptable alternative until a permanent back-end solution is implemented. Could potentially make it more generalized so it could accept very specific intervals.
You would use it like this:
|
I like the idea of having a generic version of this function (not specific to u, v or even pressure). It's essentially nearest neighbor resampling, but keeping the original coordinates. @ahaberlie would you be willing to submit a PR with the generic version? I think this function might even work to underpin a future dynamic downsample--though the more I think about how the matplotlib part of barbs works (one polygon collection) that sounds even more complicated. |
Sure. If you have an idea in mind where you need a nearest neighbor from a large array, it might be a better idea to use scipy.spatial's KDTree (http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.spatial.KDTree.html), as the looping in this function would not scale very well. I was initially thinking about using KDTree but decided that it would be overkill for this specific application. Thoughts? |
If the interface is properly done, then KDTree vs. loop is purely an implementation detail. I'd be happy to have a KDTree version, but it seems like you have something useful already. I do anticipate needing a kdtree-based reduction for things like surface data, but I don't think that will be taking a set of coordinates. |
What about the barbs that plot off the top of the plot? Should anything about 100 hPa be axed from the data prior to plotting? |
My only hesitation with something like that (which would have to be a plot parameter or setting on the SkewT) is panning/zooming--and it would break with standard matplotlib. Matplotlib's usual solution is clipping, but that could lead to partial barbs...ugh. Geez, right now the best solution that comes to mind is a patch to matplotlib to clip based on polygon positions (like scatter plot center points or barb pivot points). Other suggestions? |
And to be clear, I think we currently clip, just beyond the top. (I think) |
An added feature of MetPy that would be great would be to have a way to plot fewer wind barbs based on whether there is a wind barb close by.
Currently, the quick fix is to just plot every other or every third wind barb, but that doesn't really achieve the goal when there are four right on top of each other and then potentially getting rid of desired wind barbs elsewhere.
The text was updated successfully, but these errors were encountered: