-
Notifications
You must be signed in to change notification settings - Fork 3
Introduce rasterized plotting #16
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
Draft
mkavulich
wants to merge
11
commits into
main
Choose a base branch
from
feature/rasterization_without_pixelmap
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…polycollection method with plot:polycollection:True - Had to rearrange a lot of logic in plotit(), so the changes look way more invasive than they actually are - Had to implement manual setting of domain bounds using new custom function get_data_extent(), though it needs more work - Also changed default image size and resolution to be a bit smaller
…n get_data_extent() function; also fix level 0 error. Currently may not work for polycollection
- Add back in mpl.use("Agg"); not sure how I dropped that at some point
- Better error handling to hopefully not hang on Ctrl-C
- Set axes extent before calls to to_polycollection or to_raster; this should speed things up a lot when only plotting part of a domain
- "colorbins" setting now works for built-in colormaps in addition to custom ones - remove many unnecessary prints and commented code - Add timer for full script in addition to individual plots
…dges may be cut off
Collaborator
Author
|
Important note: I have not yet fixed global plots with alternate projections; hopefully I will find time to add this in later. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR revamps mpas_plot to use the latest and greatest UXarray version 2025.09, which includes rasterized plotting rather than constructing polygons from the original grid. Rasterized plotting is an order of magnitude (or more) faster than the polycollection method, especially for large domains and alternate projections where it was essentially impossible to produce plots in a reasonable amount of time.
New settings
New setting
polycollectionFalse by default, the
polycollectionoption will allow users to use the old method of plotting that plots the true polygons of the input unstructured grids. This is retained for back-compatibility (and the retaining of a few features that are not yet supported for rasterization, such as plotting the grid edges) but is not recommended due to its slowness, and due to a known issue with plotting periodic (global) data in the latest UXarray libraries; see UXARRAY/uxarray#1386 for more detailsPixel ratio
Rasterization is an inherently lossy process, but we can control the quality of the output using the setting
pixel_ratio. The default value is 1, which will result in very good plots for most domains, but may look "pixelated" at small scales for very large/high resolution domains. Increasing this value will result in finer quality images, resolving the true polygons of the native grid data, but will take longer to create. Conversely, for plots where fine detail is not important, you can decreasepixel_ratiofor an increase in plotting speed.maxvalandminvalNew in this PR,
maxvalandminvalare added as substitutable keys in plot titles, names, etc. This is the maximum and minimum numerical values respectively for the given plotted domain.New custom function:
sum_of_magnitudesThis new function allows the input of a u and v wind vector (or any two perpendicular vector fields) and outputs the magnitude of the vector field (wind speed from wind vectors, for example).
Other changes
mpl.use("Agg")that was accidentally removed in an earlier PR; this fixes some memory problems when creating large numbers of of plots.Example plot