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

Add more features and clarification to Animators #3504

Merged
merged 8 commits into from
Nov 21, 2019

Conversation

Cadair
Copy link
Member

@Cadair Cadair commented Nov 14, 2019

This is a direct follow on from #3407 it adds the following functionality / cleanups:

  • Use modest_image from Glue to improve rendering of images in ArrayAnimatorWCS by reading less of the array. (Especially useful with dask arrays or memmapped arrays).

  • Allow passing through extra slider functions in the ArrayAnimator constructor, this lets you provide extra sliders for controlling the colourbar limits for instance.

  • Make the specification of button labels optional, by default it will use the function names.

  • Wire in an existing keyword argument to BaseFuncAnimator which allows the specification of a function to setup the plot as keyword argument.

  • Modify the call signature of the button call back functions so that they get passed the animator object, so that they can easily do things that modify the plot.

  • Add optional slider labels to BaseFuncAnimator and set them by default in ArrayAnimatorWCS to the world axis names if present or the world axis physical types if not.

@ghost
Copy link

ghost commented Nov 14, 2019

Thanks for the pull request @Cadair! Everything looks great!

@pep8speaks
Copy link

pep8speaks commented Nov 14, 2019

Hello @Cadair! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 12:1: E402 module level import not at top of file
Line 13:1: E402 module level import not at top of file
Line 14:1: E402 module level import not at top of file
Line 15:1: E402 module level import not at top of file
Line 17:1: E402 module level import not at top of file

Line 463:101: E501 line too long (105 > 100 characters)

Line 143:5: E306 expected 1 blank line before a nested definition, found 0

Line 99:9: E303 too many blank lines (2)
Line 99:101: E501 line too long (118 > 100 characters)
Line 107:5: E303 too many blank lines (2)
Line 111:101: E501 line too long (107 > 100 characters)

Comment last updated at 2019-11-21 18:12:40 UTC

@Cadair Cadair added this to the 1.1 milestone Nov 14, 2019
@Cadair Cadair added the visualization Affects the visualization submodule label Nov 14, 2019
@Cadair Cadair requested a review from a team November 14, 2019 15:02
@DanRyanIrish
Copy link
Member

Sounds potentially powerful. Would have to see a demo to fully understand though.

@Cadair Cadair force-pushed the even_more_animator_features branch 3 times, most recently from b2f9e9a to 0b4cf63 Compare November 14, 2019 17:05
@nabobalis
Copy link
Contributor

Rebase conflicted for me (I suspect something is off with my repo) so I just merged in master.

@nabobalis
Copy link
Contributor

Not sure how the figs failed when they passed on my machine?!

@Cadair Cadair self-assigned this Nov 20, 2019
@Cadair Cadair force-pushed the even_more_animator_features branch 2 times, most recently from be67da1 to 3d524f2 Compare November 21, 2019 14:53
@Cadair
Copy link
Member Author

Cadair commented Nov 21, 2019

There appears to be a codecov issue with uploading coverage on the py38-online build, so that test is not representative.

Copy link
Member

@dstansby dstansby left a comment

Choose a reason for hiding this comment

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

Looks good to me, left some suggestions that you can take or leave as you please.

@@ -0,0 +1,19 @@
Glue - multidimensional data exploration
Copy link
Member

Choose a reason for hiding this comment

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

Maybe worth a note here referencing the file it is needed for?

@@ -0,0 +1,351 @@
"""
Modification of Chris Beaumont's mpl-modest-image package to allow the use of
Copy link
Member

Choose a reason for hiding this comment

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

Has this gone upstream/if not is it worth going upstream?

Copy link
Member Author

Choose a reason for hiding this comment

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

That you would have to ask @astrofrog

are skipped.

The interface of ModestImage is the same as AxesImage. However, it
does not currently support setting the 'extent' property. There
Copy link
Member

Choose a reason for hiding this comment

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

Change this bit of docstring, since this implementation does allow extent?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't really want to change this file as it's in extern, I just want to be able to copy it out of Glue if there are updates there?

Copy link
Member

Choose a reason for hiding this comment

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

And the reason we aren't just importing it from glue is...? I imagine it saves us a dependency but also means we have to update manually. Or I am not understanding externs?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah, it means we don't have to depend on glue, which is a large dependency with a lot of qt and other things, really not worth it.

sunpy/visualization/animator/base.py Outdated Show resolved Hide resolved
sunpy/visualization/animator/base.py Outdated Show resolved Hide resolved
sunpy/visualization/animator/base.py Outdated Show resolved Hide resolved
sunpy/visualization/animator/base.py Outdated Show resolved Hide resolved
@@ -1,5 +1,5 @@
[tox]
envlist = py{36,37,38}-{offline,online,astropydev,numpydev,astropy31},build_docs,figure,conda
envlist = py{36,37,38}-{offline,online,astropydev,numpydev,astropy31},build_docs,figure,figure_astropydev,conda
Copy link
Member

Choose a reason for hiding this comment

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

Why this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

We forgot to add the new env to tox.ini in #3407

Co-Authored-By: David Stansby <dstansby@gmail.com>
Copy link
Member

@DanRyanIrish DanRyanIrish left a comment

Choose a reason for hiding this comment

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

So long as the questions I have raise no concerns, this looks fine to me.

are skipped.

The interface of ModestImage is the same as AxesImage. However, it
does not currently support setting the 'extent' property. There
Copy link
Member

Choose a reason for hiding this comment

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

And the reason we aren't just importing it from glue is...? I imagine it saves us a dependency but also means we have to update manually. Or I am not understanding externs?

base_kwargs = {
'slider_functions': [self.update_plot] * self.num_sliders,
'slider_ranges': [[0, dim] for dim in np.array(data.shape)[self.slider_axes]]
'slider_functions': ([self.update_plot] * self.num_sliders) + slider_functions,
Copy link
Member

Choose a reason for hiding this comment

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

So does this mean the slider functions specified by the user in the slider_ranges kwargs are only extra slider functions, e.g. for a colourbar? Data axes' sliders are still derived internally?

Same for slider_ranges

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, indeed it does.

extra_slider_labels = []
if "slider_functions" in kwargs and "slider_labels" not in kwargs:
extra_slider_labels = [a.__name__ for a in kwargs['slider_functions']]

Copy link
Member

Choose a reason for hiding this comment

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

Too many empty lines.

@Cadair Cadair merged commit b877147 into sunpy:master Nov 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
visualization Affects the visualization submodule
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants