Fixing a problem with lost resolution in imshow #1645
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.
imshow would assume an image would cover the whole plot which sometimes,
when the intent was to just plot in a small part of the image resulted in
a lot of lost resolution.
This happened because the created mesh grid was stretched to cover the
whole screen, and then only a small part of the mesh was actually used.
The lost resolution was proportional to the amount of space the image
used in the plot, so an image that was set to show in 10% of the width,
only kept 10% of its horizontal resolution.
There are other factors, like regrid_shape, that can also affect the
resolution of the output and a very, very large regrid_shape could
compensate for this problem at the cost of computation time.
Rationale
I was trying to plot lots of very high resolution images on a map where they each covered just a small fraction of the full plot. This turned out to result in 95% of the original pixels getting lost. I think it's better to not lose pixels.
Implications
This should have very little effect when images cover most of the plot, but when they don't, it can either result in higher resolution or the same resolution. If extent is larger than the visible area it will result in a more sparse remesh grid but in those cases the source data did not have enough pixels anyway so I think it will primarily result in fewer duplicate pixels (and maybe higher performance).
There is also the risk that there is a logical bug in what I have done that will result in the earth imploding.
I don't know enough about testing in cartopy, or testing coverage, to make a test for it, but maybe someone can assist me.