Skip to content
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

Improve the performance of CompositeMap plotting #6085

Closed
wants to merge 1 commit into from
Closed

Improve the performance of CompositeMap plotting #6085

wants to merge 1 commit into from

Conversation

ooprathamm
Copy link

@ooprathamm ooprathamm commented Apr 16, 2022

Partial attempt at fixing #5894

@ooprathamm ooprathamm requested a review from a team as a code owner April 16, 2022 05:08
@nabobalis nabobalis added the map Affects the map submodule label Apr 16, 2022
@ConorMacBride ConorMacBride linked an issue Apr 16, 2022 that may be closed by this pull request
@ayshih ayshih marked this pull request as draft April 17, 2022 02:38
@ooprathamm ooprathamm marked this pull request as ready for review April 17, 2022 14:27
@@ -11,6 +11,8 @@
import sunpy.map
from sunpy.tests.helpers import figure_test

import test_plotting
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need this import.

Comment on lines +443 to 446
if wcsaxes_compat.gca_wcs(m.wcs)==axes.wcs:
params['autoalign'] = False
elif wcsaxes_compat.is_wcsaxes(axes):
params['autoalign'] = True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this speed up the plotting? I am not familiar with CompositeMap plotting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #5894. We get improved performance if we set autoalign=False when the map layer is being plotted onto axes with a matching WCS because then we use the faster imshow() instead of the slower pcolormesh().

Copy link
Contributor

@nabobalis nabobalis Apr 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so the idea is to bypass using pcolormesh when it makes sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, precisely, because it's glacial in an interactive plot.

@@ -523,7 +527,7 @@ def peek(self, colorbar=True, draw_limb=True, draw_grid=False, **matplot_args):
raise TypeError("draw_grid should be bool, int, long or float")

return figure

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Copy link
Member

@ayshih ayshih left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I marked this PR as "draft" since it is not finished, here's stuff that needs to be fixed in it:

  • You access axes.wcs before you check if axes is a WCSAxes instance.
  • Calling gca_wcs() doesn't make sense because (1) it will return the current pyplot axes if one exists, and thus may not correspond to m.wcs at all, and (2) if a user hasn't been using pyplot, it will create a new figure and axes through pyplot.
  • You (attempt to) import test_plotting.py, but I don't know why.
  • Your unit test appears to be adapted from test_plot_autoalign() from test_plotting.py, but I suspect you did not run your unit test at all because your code tries to access attributes and methods that aren't available for CompositeMap. Plus, you copied over the routine, but it would work as intended only if it is also marked as a figure test.
  • Even if your unit test did actually run, it doesn't test the functionality that this PR is trying to add because you are trying to plot the composite map onto a non-matching WCS. That does and should continue to use autoalign=True. A proper test would likely not be a figure test – because the figure output would be very similar and possibly even equal – but instead would probably have to check whether a matplotlib.collections.QuadMesh was attached to the plot when a single composite-map layer is plotted onto a matching WCS.

@nabobalis nabobalis marked this pull request as draft April 18, 2022 01:55
@nabobalis nabobalis changed the title Issue - Improve the performance of CompositeMap plotting #5894 Improve the performance of CompositeMap plotting Apr 22, 2022
@nabobalis
Copy link
Contributor

nabobalis commented Apr 22, 2022

Hi @ooprathamm, thanks for the PR.

Hopefully you will have time in the future to update this PR using the comments I and ayshih left!

I wanted to quickly explain what I use draft status for, its for any PR that is not passing the majority of checks and probably means it isn't ready for a "formal" review. This does not mean that no one will look at it, but normally a non-draft PR is in a position to be merged into the repository 90% of the time.

@nabobalis
Copy link
Contributor

Thank you for the PR @ooprathamm, if you have a chance to work on this in figure, please do reopen this PR or a new one!

@nabobalis nabobalis closed this May 13, 2022
@mwhv2 mwhv2 mentioned this pull request Sep 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
map Affects the map submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve the performance of CompositeMap plotting
3 participants