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

API question: to_patch or Artist or...? #12

Closed
keflavich opened this issue Mar 25, 2016 · 12 comments
Closed

API question: to_patch or Artist or...? #12

keflavich opened this issue Mar 25, 2016 · 12 comments
Labels
Milestone

Comments

@keflavich
Copy link
Contributor

What API should we adopt for plotting region objects?

Options we have considered:

  • region.to_patch()/region.to_patch_collection()
  • region.Artist
  • region.Patch/PatchCollection

Which do you prefer? cc @joleroi, @astrofrog @cdeil

@cdeil
Copy link
Member

cdeil commented Mar 26, 2016

The photutils apertures have a .plot(ax=None) method which creates the patch and calls ax.add_patch(patch):
https://github.com/astropy/photutils/blob/master/photutils/aperture_core.py#L500

I can see how splitting the two steps in separate methods is more modular / a good thing.

But to form an opinion on which of the options you propose are better, I'd have to see usage examples ... whichever is nicer to use will be my preference.

@bsipocz and @larrybradley -- You implemented the aperture plot methods in photutils. What do you think?
(FYI: I think the plan discussed / proposed at PyAstro16 is to move all the aperture code over to here, call it regions, add features and in a few months put it in the core as astropy.region.)

@keflavich
Copy link
Contributor Author

I like having a plot(ax=None) method, possibly in addition to a get_patch method. Is that too much?

@bsipocz
Copy link
Member

bsipocz commented Mar 26, 2016

There are a few issues with the photutils .plot method I never managed to iron out, but maybe this would be time for that, I just need to find my notes on it.

Also, do you mean to move over only the geometry part of the apertures, or everything including the do_photometry method? I totally support the first option, but would the latter be useful as well?

@larrybradley
Copy link
Member

If the patches are useful by themselves (are they?), then I agree with @keflavich: a get_patch() method to return the patch and a plot() method that internally calls get_patch() and then plots it. In other words, I think plotting an aperture should remain one plot() call and not require calling get_patch() followed by plot(), or plot(get_patch()), etc.

@larrybradley
Copy link
Member

@cdeil Are there notes from the conference about these region plans?

@larrybradley
Copy link
Member

Instead of get_patch() perhaps it should be called make_patch()?

@cdeil
Copy link
Member

cdeil commented Mar 26, 2016

+1 to make_patch.
We can still discuss if we want to hide it as _make_patch later, in case someone feels there's no use-case for it for end-users to call this.

@cdeil
Copy link
Member

cdeil commented Mar 26, 2016

@larrybradley - Here's the notes from the regions session at PyAstro16:
https://docs.google.com/document/d/17owovjcpNFirz-f8qCWWxvcHHPGGpO5JJic5WbtD9JY/edit

@joleroi will make a PR soon updating the README and docs/index in this repo to reflect the plan.

My understanding is that this is the plan:

  • The existing pyregion is deprecated. The functionality there is re-built here.
  • The functionality from photutils.aperture is integrated into the region classes here.
  • We let people use this regions package for a few weeks or months as a separate package
  • Then we merge it into the core as astropy.regions
  • Once things have stabilised, we can replace the aperture photometry code in photutils to use astropy.regions.

@larrybradley Concerns? Sounds good?

@larrybradley
Copy link
Member

Thanks, @cdeil. Sounds good to me.

@astrofrog
Copy link
Member

Sorry for commenting late on this, but we could use as_patch instead of make_patch, since that would read better in code (region.as_patch). If we think there might be other plotting packages in future, we should maybe call it region.as_mpl_patch although I could see that also being a keyword option in future.

@cdeil
Copy link
Member

cdeil commented Jun 26, 2016

I see at http://astropy-regions.readthedocs.io/en/latest/api.html that we now have as_patch on the SkyRegion and PixelRegion base classes, and as an example it's implemented for circles.

@keflavich and all - Can we close this issue?
Or alternatively --- what's the remaining action item?
Should the abstract method be moved to the base Region class, or should it remain on SkyRegion and PixelRegion only?

@cdeil cdeil added this to the 0.1 milestone Jun 26, 2016
@cdeil
Copy link
Member

cdeil commented Jul 7, 2016

I think this is done, closing this now.

If someone still have a thought on the question from my last comment, please reply here or make a PR if you think something should be changes.

Should the abstract method be moved to the base Region class, or should it remain on SkyRegion and PixelRegion only?

@cdeil cdeil closed this as completed Jul 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants