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

Fixes the bug associated with axes_coordinates #189

Merged
merged 13 commits into from
Aug 8, 2019

Conversation

yashrsharma44
Copy link
Member

@yashrsharma44 yashrsharma44 commented Jul 28, 2019

This PR addresses the bug associated with axes_coordinates.
This PR addresses the following problems -

  1. Make sure the axes_coordinates for >2D plot contains no external values if axes_coordinate=None along plot_axis_indices. This makes sure that axes_coordinates is a list of None.
  2. Edited _derive_axes_coordinates to calculate the values for independent and dependent axes. If dependent axes, then the values are downscaled to the data_shape along the axis by taking mean along non-plotting axes.
  3. Added the support for getting edges in _derive_axes_coordinates .

Partially fixes #187
Ping @DanRyanIrish

Note that this PR should be merged after #176 is merged.

@ghost
Copy link

ghost commented Jul 28, 2019

Thanks for the pull request @yashrsharma44!

I am a bot that checks pull requests for milestones and changelog entries. If you have any questions about what I am saying, please ask!
I have the following to report on this pull request:

  • This pull request does not have a milestone assigned to it. Only maintainers can change this, so you don't need to worry about it. 😄
  • I didn't detect a changelog file in this pull request. Please add a changelog file to the changelog/ directory following the instructions in the changelog README.

If there are any issues with this message, please report them here.

@pep8speaks
Copy link

pep8speaks commented Jul 28, 2019

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

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2019-08-07 20:03:30 UTC

1. Make sure the axes_coordinates for >2D plot contains no external values if axes_coordinate=0 along plot_axis_indices. This makes sure that axes_coordinates is a list of None.
2. Edited `_derive_axes_coordinates` to calculate the values for independent and dependent axes. If dependent axes, then the values are downscaled to the data_shape along the axis.
3. Added the support for getting `edges` in `_derive_axes_coordinates` .
ndcube/mixins/plotting.py Outdated Show resolved Hide resolved
ndcube/mixins/plotting.py Outdated Show resolved Hide resolved
ndcube/mixins/plotting.py Outdated Show resolved Hide resolved
ndcube/mixins/plotting.py Outdated Show resolved Hide resolved
axis_label_text = self.world_axis_physical_types[i]

index = utils.wcs.get_dependent_data_axes(self.wcs, i, self.missing_axes)
reduce_axis = np.where(index == np.array(i))[0]
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it's necessary to wrap i into a numpy array...?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, it was more of a defensive approach, would change it!

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, now I remember, since index is a numpy array, so for comparing the same objects, I have to convert i into a numpy array.

@yashrsharma44
Copy link
Member Author

yashrsharma44 commented Aug 2, 2019

Work to be done -

  • Documentation to use the new plotting paradigm. To be covered in another PR.
  • Fix labelling of >2D NDCubes, i.e. fix the label issue of ImageAnimator/ImageAnimatorWCS.
  • Nitpickings?
  • Add docstrings entries.

Also Ping @DanRyanIrish for the changes.

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.

In addition to the inline comments, the axis labelling commented out starting line here and here need to be fixed. Either by uncommenting, or rewriting depending on whether they are still breaking tests and add the labels to the axes.

ndcube/mixins/plotting.py Outdated Show resolved Hide resolved
ndcube/mixins/plotting.py Outdated Show resolved Hide resolved
@yashrsharma44
Copy link
Member Author

Regarding the docstrings, I was thinking of adding a line explaining the type of axes_coordinates we want along with all the places where axes_coordinates are found.
#The physical coordinates expected by axes_coordinates should be an array of pixel_edges instead of pixel_centers.
@DanRyanIrish do you have any suggestions?

@DanRyanIrish
Copy link
Member

No need to say instead of pixel centers. But don't forget that at the highest levels a str denoted extra coords should also be supported.

@yashrsharma44
Copy link
Member Author

But don't forget that at the highest levels a str denoted extra coords should also be supported.

Currently, we don't support getting edges for extra_coords.

@DanRyanIrish
Copy link
Member

Don't we? Isn't that the role of _get_extra_coord_edges?

@yashrsharma44
Copy link
Member Author

Okay, I guess I didn't understand that. Yeah, for plotting we support extra_coords such that extra_coords can store pixel_centers and the plotting code internally converts it into pixel_edges. But currently, extra_coords has no parameter to get pixel_edges as of now.

@DanRyanIrish
Copy link
Member

That's fine. Since the API is only for the user to enter the name of the extra_coord they want to use for the axis, the conversion to pixel edges can be hidden from the user.

@DanRyanIrish
Copy link
Member

So add the fact that users can supply a string in axes_coordinates so long as it's a valid extra_coord name and that coord corresponds to the axis to which is it being assigned in the plot.

@yashrsharma44
Copy link
Member Author

I was thinking of adding this as a docstring for extra_coords -

# The physical coordinates expected by axes_coordinates can be string as well, which corresponds to a valid `extra_coords` and that coord corresponds to the axis to which is it being assigned in the plot.

@yashrsharma44
Copy link
Member Author

yashrsharma44 commented Aug 7, 2019

I guess the astropydev is failing due to the fact that it depends on SunPy stable release?

@DanRyanIrish
Copy link
Member

I was thinking of adding this as a docstring for extra_coords -

# The physical coordinates expected by axes_coordinates can be string as well, which corresponds to a valid `extra_coords` and that coord corresponds to the axis to which is it being assigned in the plot.

How about:

A str entry in axes_coordinates signifies that an extra_coord will be used for the axis's coordinates.  The str must be a valid name of an extra_coord that corresponds to the same axis to which it is applied in the plot.

Does that make sense?

@DanRyanIrish
Copy link
Member

I guess the astropydev is failing due to the fact that it depends on SunPy stable release?

Yes, only the sunpy_dev test has to pass.

@DanRyanIrish
Copy link
Member

And yes, once the str info has been added to the docstrings we can merge :)

@yashrsharma44
Copy link
Member Author

And yes, once the str info has been added to the docstrings we can merge :)

Thanks @DanRyanIrish

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.

I noticed that this PR does not seem to handle extra_coord str entries to axes_coordinates correctly. Instead of holding up this PR, can you create an issue saying extra_coord axes_coordinates support must be extended to NDCubeSequence?

@@ -691,6 +697,8 @@ class ImageAnimatorNDCubeSequence(ImageAnimatorWCS):
for that axis.
The physical coordinates expected by axis_ranges should be an array of
pixel_edges.
A str entry in axis_ranges signifies that an extra_coord will be used for the axis's coordinates.
The str must be a valid name of an extra_coord that corresponds to the same axis to which it is applied in the plot.
Copy link
Member

Choose a reason for hiding this comment

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

The str API is not valid for animator objects. Only for the NDCube and NDCubeSequence objects.

@@ -788,6 +796,8 @@ class ImageAnimatorCubeLikeNDCubeSequence(ImageAnimatorWCS):
for that axis.
The physical coordinates expected by axis_ranges should be an array of
pixel_edges.
A str entry in axis_ranges signifies that an extra_coord will be used for the axis's coordinates.
The str must be a valid name of an extra_coord that corresponds to the same axis to which it is applied in the plot.
Copy link
Member

Choose a reason for hiding this comment

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

Same as above. The str API is not valid for animator objects. The extra coord edges must be derived before entering them into the animator objects.

@@ -907,6 +917,8 @@ class LineAnimatorNDCubeSequence(LineAnimator):
for that axis.
The physical coordinates expected by axis_ranges should be an array of
pixel_edges.
A str entry in axis_ranges signifies that an extra_coord will be used for the axis's coordinates.
The str must be a valid name of an extra_coord that corresponds to the same axis to which it is applied in the plot.
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

@@ -1143,6 +1155,8 @@ class LineAnimatorCubeLikeNDCubeSequence(LineAnimator):
for that axis.
The physical coordinates expected by axis_ranges should be an array of
pixel_edges.
A str entry in axis_ranges signifies that an extra_coord will be used for the axis's coordinates.
The str must be a valid name of an extra_coord that corresponds to the same axis to which it is applied in the plot.
Copy link
Member

Choose a reason for hiding this comment

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

Same as above

@yashrsharma44
Copy link
Member Author

I guess I am not clear with the comment above. Are you saying that extra_coords are not supported yet in sequence_plotting? It would be good if you could elaborate on this more.

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.

I think my comment may have just muddied the waters. I will withdraw it and if we as users discover any future issues with sequence plotting, they can be handled in a new PR. I think it shouldn't hold up this PR.

@DanRyanIrish DanRyanIrish merged commit a6ff775 into sunpy:master Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Plotting of NDCube and NDCubeSequence is failing
3 participants