-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Remove kapteyn_celestial and use astropy when possible #54
Conversation
@sargas - thanks for all your work on this! Let's try and push ahead with the fix to the astropy coordinates. I think we can then release a version of pyregion after astropy 1.0 is out that requires astropy 1.0. |
I just want to mention a few things for your consideration. Some may be true but some may be a result of my own mis-understanding, so use with caution.
|
@mcara - Thank you, honestly, I think you understand this stuff a lot better then myself. I didn't want to push this until I had the fix in for your files.
|
@sargas - Unfortunately, I do not think I know that much about WCS - many things are just conventions used by different telescopes so much depends on experience working with images from different telescopes (which I do not have). Let me address/clarify issues/statements point-by-point:
|
@mcara - just a quick note on 2) (the |
So I think I have ds9's implementation (really, saotk) understood and how it differs from what is in the latest commit:
Some things to note:
I've been figuring out how ds9/saotk/wcssubs does this to compare the algorithm with our own, so I don't think tweaks of this PR to match the algorithm will be a derived work of the GPL code (I haven't written any code yet for that reason). My next steps is getting some exotic headers in the tests, and seeing what I can make pass. |
@sargas - thank you for all your work on this! We should make sure that all your findings above about the assumptions of the code are clearly indicated in comments in the code. Once you've added the exotic headers, let me know and I can do a review of the changes here. |
Also, for now it might be worthwhile adding backported versions of the astropy WCS utilities that you use in order to get this to pass. |
I wanted to give a little update, since I think I've hit a roadblock that'll take some more work to get over and it's been ~ 2 weeks. The angle transformations in the latest PR I pushed have a flaw: they should be calculated from the origin for consistency with DS9. This probably justifies this being a helper function here instead of built-in to astropy (regardless of what I intended with astropy/astropy#3093 ). I'm not sure of a clean way to do this correctly with the current approach of iterating over coordinates/distances/angles. I'm going to try an approach where |
@sargas - thanks for the update and for working on this! Very much appreciated :) |
I know this is very difficult, but @sargas, is there a way you can bring this PR to a state where it can be merged? |
@cdeil I've taken a step back from trying to basically rewrite pyregion for now, and focused on doing the transformation correctly. I updated astropy_helpers in order to make sure I didn't break docs/ (although there's no listing of the API AFAIK). Updates to .travis.yml were required to make this build again (including dropping numpy 1.5). I'm unsure the cause of the latest build. |
The build failed because of a conda Cython install issue:
https://travis-ci.org/astropy/pyregion/jobs/96339140#L496 I haven't seen this before, maybe @astrofrog can just restart the build now or tomorrow to try again ... sounds like a temp server problem. |
Just a heads up, this PR should be ready for review (although I know efforts have shifted to astropy/regions) |
@sargas - Thanks! @astrofrog - How do you want to handle this? I guess having an improved |
@cdeil - I agree! |
I had a quick look at the diff, but I don't have the WCS background and time to look in detail at the changes in @astrofrog - Do you have time in the near future or should we try to find someone else? |
@cdeil - I don't have time to review this in the next couple of weeks (but could do so after) |
This needs a rebase and a review (cc @cdeil, @astrofrog @keflavich). |
Removed ability to use a WCS object for obtaining image coordinates Use methods in astropy 1.0+ for calculating cdelt
Rebased. Biggest API change is the lack of rot_wrt_axis parameter (I just use DS9's convention). All tests pass locally on python3.5 and python2.7. |
@sargas - Thanks! Does anyone have time to review this in the near future? Clearly, getting rid of Kapteyn and using Astropy more is a huge win, it means that this package is easier to maintain and can much more easily be packaged e.g. for Debian. Obviously, splitting this into several smaller pull requests would make review much easier. But maybe we just do it and merge this soon, and then iron out any potential issues in master in the coming weeks? |
I think this PR has a few things scattered in it:
Should I redo this PR to try to separate these better? As is, it addresses #89, #35, #76, #44, #43, so it is a bit ambitious |
@sargas - Since no-one else is volunteering, I'll review this PR in the coming days, even though I'm not a DS9 or pyregion expert by any means. If it's not too much work, could you please split out the backwards-incompatible |
@@ -152,119 +153,54 @@ def convert_attr(self, l): | |||
yield l1, c1 | |||
|
|||
@staticmethod | |||
def sky_to_image(l, header, rot_wrt_axis=1): | |||
""" | |||
def sky_to_image(shapelist, header): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Personally I almost always call Python functions / methods by keyword argument, as I find the resulting code more readable and less brittle for libraries where I might change the order of arguments.
So changing the argument from sky_to_image(l)
to sky_to_image(shapelist)
could break my or other user's scripts. Please point out such (slightly) backward-incompatible changes in the changelog, or, if it's not too much work, split them out into a separate PR that is dedicated to those argument name cleanup changes and has a dedicated changelog entry in the 2.0 section.
I would prefer shape_list
everywhere over shapelist
, but I don't feel strongly about this, no need to argue if you prefer shapelist
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add to the Changelog. I made this change because the 1-3 letter variables make it harder to understand what the code is doing. The l
parameter, the class for this function, and the module itself isn't documented, so I don't think there was any intention to make this a public API. Nice to see that regions
uses __all__
pretty judiciously to make this stuff clear.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry, I didn't realise this was on an internal method.
Then I agree, no need to point it out in the changelog (unless you've done it already, in this case OK to keep also).
I just remembered that when adding the API docs I also was tempted to clean up argument names for consistency. E.g. here
http://pyregion.readthedocs.io/en/latest/api/pyregion.get_mask.html it's called region
instead of shape_list
.
But we can defer this cleanup to separate issues / PRs, this one is mainly about Kapteyn -> Astropy and already very large.
@sargas - I've left some inline comments. This mostly looks good to me, I think it should go in soon. With such a big change, there's bound to be some accidental changes or breaks of user scripts. Increasing test coverage in this PR or one before merging this would probably help, if you have time: |
@sargas - The https://github.com/astropy/pyregion/blob/master/docs/figures/region_drawing.py script currently emits this warning:
Inspired by machete-mode debugging, I added
to find out that the culprit is this
I think you're not removing or fixing that yet in this PR? |
That was fixed almost 2 years ago in https://github.com/astropy/pyregion/pull/47/files#diff-46f90f66256f758de5bbd1dd5d7a6636L270 ? |
@sargas Thanks, you're right! |
This PR has been superseded by #100 . @sargas If there's other changes here that should still go in, please make new PRs. Everyone: please try out |
This is a branch not ready for merging due to a dependence on a patched, git version of astropy, but any comments would be appreciated.
Good
cloc pyregion/*.py
test_region
inpyregion/tests/test_region.py
is a little more usable: reference and test files are parameterized, making it easy to tell what combination failed the testestimate_cdelt
in favor ofastropy.wcs.utils.celestial_pixel_scale
rot_wrt_axis=2
option from PR Allow selection of the axis for angle measurement to the North #34 the way to go. This only changes things for WCS with non-orthogonal axes.Bad
celestial_pixel_scale
,SkyCoord.to_pixel
, etc). I think I'll end up with some _backported_astropy.py submodule for theseastropy
needs Fix FK5 -> Galactic conversion astropy#3107Ugly
estimate_angle
is correct or clear, but I don't have any fits files with non-orthogonal axes to test with. This is exactly @mcara's approachpyregion.physical_coordinate
looks ripe for gutting and replacing with some standard WCS functions, but I don't see anything inastropy.wcs.WCS
that deals with physical coordinates. Perhaps these are called something different in the WCS code?pyregion/tests/examples
that were unused by the tests. I load them as a basic will-this-crash test, but I need to look into these further to see if there is anything special that can be done with them in the tests