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

Rename Mask class and add origin arg to plot methods #203

Merged
merged 10 commits into from Aug 27, 2018

Conversation

sushobhana
Copy link
Member

@sushobhana sushobhana commented Aug 12, 2018

According to discussion in astropy/photutils#684

  1. Added origin arg to plot methods (which is present in photutils)
  2. Added to_region and plot methods to BoundingBox
  3. Rename Mask to RegionMask.

Now, RegionMask are ApertureMask are same both API and code wise.
Geometry functions and BoundingBox are also same in both packages.

Copy link
Contributor

@keflavich keflavich left a comment

Choose a reason for hiding this comment

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

The PR looks good to me. It would be great if you could include a document example with a figure showing how and when you'd use the offset origin option. Maybe on cropped data?

"""
Calls as_patch method forwarding all kwargs and adds patch
to given axis.

Parameters
----------
origin : array_like, optional
The ``(x, y)`` position of the origin of the displayed image.
Copy link
Contributor

Choose a reason for hiding this comment

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

could you clarify: these are x,y positions in pixel units, right? Just to make sure they're not confused with data units (e.g., WCS)

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, pixel units. Perhaps should we accept PixCoord instead of a tuple to avoid confusion?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's... a good idea from a programmer's perspective, as it makes the code more robust, but it's really inconvenient for something as simple as a pixel coordinate, since it requires an additional import and a much longer function call. I am weakly in favor of accepting a tuple and just documenting it.

Parameters:
-----------
origin : array_like, optional
The ``(x, y)`` position of the origin of the displayed image.
Copy link
Contributor

Choose a reason for hiding this comment

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

same clarification here

Parameters:
-----------
origin : array_like, optional
The ``(x, y)`` position of the origin of the displayed image.
Copy link
Contributor

Choose a reason for hiding this comment

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

and here, and in all similar instances

@cdeil
Copy link
Member

cdeil commented Aug 21, 2018

@sushobhana - Please rebase against upstream master to resolve the merge conflicts.

@sushobhana sushobhana mentioned this pull request Aug 23, 2018
@cdeil cdeil added this to the 0.3 milestone Aug 24, 2018
@sushobhana
Copy link
Member Author

@keflavich Added an example and rebased it. Ready to merge??

@cdeil cdeil assigned keflavich and unassigned sushobhana Aug 26, 2018
Copy link
Contributor

@keflavich keflavich left a comment

Choose a reason for hiding this comment

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

Needs some docstring cleanup, then I think it's good?

You can shift the origin of the region very conveniently while plotting by simply
supplying the ``origin`` pixel coordinates to :meth:`~regions.PixelRegion.plot`
and :meth:`~regions.PixelRegion.as_patch`. The ``**kwargs`` argument takes any
keyword argument that the `~matplotlib.patches.Patch` object accepts. For Ex:
Copy link
Contributor

Choose a reason for hiding this comment

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

either say "For example:" or "e.g.:"

`~regions.CompundPixelRegion` don't have because there are no equivalent classes
in `matplotlib.patches`.
the `~regions.TextPixelRegion` and `~regions.CompoundPixelRegion`
don't have because there are no equivalent classes in `matplotlib.patches`.
Copy link
Contributor

Choose a reason for hiding this comment

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

don't have what? don't have as_patch methods?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is mentioned in the above line

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, but this is grammatically incorrect.

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 rephrased it.

ax : `matplotlib.axes.Axes` instance, optional
If `None`, then the current `~matplotlib.axes.Axes` instance
is used.
kwargs
Copy link
Contributor

Choose a reason for hiding this comment

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

will this render correctly? I think you need kwargs: dict ?

origin : array_like, optional
The ``(x, y)`` position of the origin of the displayed
image.
ax : `matplotlib.axes.Axes` instance, optional
Copy link
Contributor

Choose a reason for hiding this comment

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

whitespace is inconsistent; no before :

Copy link
Member Author

Choose a reason for hiding this comment

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

actually, sphinx doesn't render properly if there is no before :

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh... my bad, you have to add spaces in other places, not remove them here

"""
Matplotlib patch object for annulus region (`matplotlib.patches.PathPatch`).

Parameters:
Copy link
Contributor

Choose a reason for hiding this comment

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

no trailing :

@sushobhana
Copy link
Member Author

Thanks @keflavich !

@@ -34,7 +34,7 @@ and calls ``plt.gca()`` if no axis is passed in.
You can shift the origin of the region very conveniently while plotting by simply
supplying the ``origin`` pixel coordinates to :meth:`~regions.PixelRegion.plot`
and :meth:`~regions.PixelRegion.as_patch`. The ``**kwargs`` argument takes any
keyword argument that the `~matplotlib.patches.Patch` object accepts. For Ex:
keyword argument that the `~matplotlib.patches.Patch` object accepts. For e.g.:
Copy link
Contributor

Choose a reason for hiding this comment

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

it's just e.g., not For e.g., but I'll handle that

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 did not know e.g. itself means for example, I thought it is short for example (had to google it!) ..hehe

@keflavich keflavich merged commit b5237c5 into astropy:master Aug 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants