Closed pllim closed 2 years ago
Fix #960 . I don't understand why the "old way" works but not the APE 14 interface. I wonder if @mcara can advise here.
On line 137 you call pix = self.wcs.wcs_world2pix(np.array([args], np.float_), origin)
- notice wcs_
world2pix
- which does NOT use iteration to revert coordinates since it ignores polynomial (SIP) distortions and inversion can be performed analytically. APE14 calls all_
world2pix
which will fail if you are away by 1 degree from the center of an ACS image.
This may be an unnecessary complication, but instead of this complicated pirouette with adding 1 degree and catching exceptions and mixing APE14 with non-APE14 calls, could you create a bounding box around image(s) (multiple images for multiple ACS chips) and then create a spherical polygon and test if a point is inside the polygon before trying to invert coordinates? Just a suggestion.
Ah, adding +1 degree is in a different module - see https://github.com/ejeschke/ginga/issues/960#issue-909792583
I think that code could create spherical polygon and test if a point is inside (but I am not familiar with the code or why it is done the way it is done and so I may be wrong). Here it is OK to catch exceptions but, if you do not need logging all these messages, you could simply call all_world2pix(..., quiet=True)
but you should test this to see if it works for you.
adding +1 degree is in a different module
I did try to make the "hack" smaller but it didn't fix the problem. Somewhere else in the code, it tries to do something that also triggers NoConvergence
. Between Compass
and the lower level wcs.py
in the code base, I got lost where this is really happening. Maybe @ejeschke knows.
create spherical polygon
I hope you are not asking me to add spherical-geometry
as a dependency here.
I hope you are not asking me to add spherical-geometry as a dependency here.
He-he. Yes, that's what I meant.
I did try to make the "hack" smaller but it didn't fix the problem.
What is the problem you are trying to solve by adding +1 degree?
Instead of spherical_geometry
, you could take corners of the image and compute maximum "distance" (in degrees) from CRVAL and consider that to be the "radius of convergence" for coordinate inversion. If a point is inside the circle - call APE14, if not - call wcs_world2pix
. Probably you can use something from astropy.coordinates
for this.
Fix #960 . I don't understand why the "old way" works but not the APE 14 interface. I wonder if @mcara can advise here. The image is jbt7a3k7q_flc.fits.
This PR is a pre-requisite for #959 .