Repository navigation
Added a new function to convert SkyCoord to pixel coordinates - #2885
Conversation
|
There is the question of whether we can in some cases interpret the third coordinate of SkyCoord (if present but I can't think of a WCS where this would be appropriate). cc @eteq and @taldcroft, since they've also thought a lot about coordinates :) |
|
Of course, I could easily add |
There was a problem hiding this comment.
perhaps the origin keyword should be available in the convinience function? That is, change the signature of this function to (coords, wcs, wcsorigin=0), and then to the world2pix call as wcs.wcs_world2pix(lon, lat, origin)
|
👍 to this, but I would say it should also include |
|
@eteq - yes, I'll wait to make sure there are no objections, the inverse function is trivial to add. |
|
EDIT: I see with #2210 where this is ultimately going, so this is fine as-is. |
There was a problem hiding this comment.
Is there no better way of doing this? The reason I ask is SunPy uses a custom spherical representation to deal with 180 wrapping, which this will undo.
There was a problem hiding this comment.
Yes, I can use coords.data.lon instead but I should fall back on coords.spherical.lon if the representation doesn't have lon/lat.
There was a problem hiding this comment.
That will probably work, still feels a little hacky (in general) though.
There was a problem hiding this comment.
Using data.lon shouldn't be hacky in the sense that this is the true underlying representation. In your view, should creating a new spherical representation preserve the Longitude/Latitude classes/settings? If so, it might make sense to open a new issue for this to discuss it.
There was a problem hiding this comment.
Having it do that would be easier, but it might not always be the desired behaviour. I am just concerned that in general there is no real provision for extracting data in predictable fashion which preserved things like custom representations.
(as an aside, I think there should be a way to convert a representation to a Quantity object for piping into different code)
|
@mdboom - I've added a pixel to skycoord conversion function to. So at the moment my open questions are:
I'm not sure what the preferred solution is in each case - @mdboom, do you have any suggestions? |
|
@mdboom - do you have any thoughts on the questions I had above? The issue of 2d vs higher dimensional is probably less urgent, but I'm not sure what the best approach is for allowing the user to select between the different functions. Maybe it would be better after all to simply integrate this at the |
|
@mdboom - just a reminder, if you get a chance, could you let me know what you think about the possible solutions described above? |
|
@astrofrog wrote:
I think using @astrofrog wrote:
This won't work if there are SIP or distortion information, but if you call So maybe do this: If there is sip or distortion, and naxis != 2, throw an exception. If there is neither sip or distorion, call |
|
@mdboom - thanks, that all sounds reasonable. Since I've never really had to deal with distortions before, is it correct that I can check |
|
Yes -- you can juts check |
|
@mdboom - ok, thanks! I've now implemented your comments, so I think this is ready for final review (after a rebase it seems) |
805791e to
6f8d00c
Compare
There was a problem hiding this comment.
Maybe make this a method on astropy.wcs.WCS?
There was a problem hiding this comment.
I've done this and have made it a propery
|
@mdboom - I've addressed your comments, so if Travis passes this is good to go! |
…g distortions) and pure WCS. Extend tests.
1546b10 to
4a8e748
Compare
|
@mdboom - I have now rebased this, can this be merged if Travis passes? |
There was a problem hiding this comment.
I think this needs a @property decorator to get the tests to pass.
There was a problem hiding this comment.
Oops, I think this was lost during a rebase.
|
@mdboom - I addressed your comment and travis passes, so I'll go ahead and merge tomorrow if there are no remaining comments (though feel free to merge first if you come across this) |
Added a new function to convert SkyCoord to pixel coordinates
@mdboom @nden - would something like this be acceptable in astropy.wcs? I need it in various project and it will also make the implementation of #2210 easy.
If you think it would be ok, then I can go ahead and add some tests and a changelog entry.