{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/astropy/issues/4761","repository_url":"https://api.github.com/repos/astropy/astropy","labels_url":"https://api.github.com/repos/astropy/astropy/issues/4761/labels{/name}","comments_url":"https://api.github.com/repos/astropy/astropy/issues/4761/comments","events_url":"https://api.github.com/repos/astropy/astropy/issues/4761/events","html_url":"https://github.com/astropy/astropy/issues/4761","id":146362043,"number":4761,"title":"Incorrect WCS conversion with SIP distortions (error ~1 arcmin!)","user":{"login":"astrofrog","id":314716,"avatar_url":"https://avatars.githubusercontent.com/u/314716?v=3","gravatar_id":"","url":"https://api.github.com/users/astrofrog","html_url":"https://github.com/astrofrog","followers_url":"https://api.github.com/users/astrofrog/followers","following_url":"https://api.github.com/users/astrofrog/following{/other_user}","gists_url":"https://api.github.com/users/astrofrog/gists{/gist_id}","starred_url":"https://api.github.com/users/astrofrog/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/astrofrog/subscriptions","organizations_url":"https://api.github.com/users/astrofrog/orgs","repos_url":"https://api.github.com/users/astrofrog/repos","events_url":"https://api.github.com/users/astrofrog/events{/privacy}","received_events_url":"https://api.github.com/users/astrofrog/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/astropy/astropy/labels/wcs","name":"wcs","color":"c7def8"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":38,"created_at":"2016-04-06T16:12:43Z","updated_at":"2016-04-22T16:11:38Z","closed_at":"2016-04-07T03:02:00Z","body":"I am trying to convert world to pixel coordinates using the following header:\r\n\r\nhttps://gist.githubusercontent.com/astrofrog/57bcb965eab79f99d953d2c1b162af02/raw/29ecd814239f11237ebe3bb5668582977976e9d1/header.hdr\r\n\r\nHere's an example of converting (19500,6500) in pixel coordinates to (ra,dec):\r\n\r\n```\r\nIn [1]: from astropy.io import fits\r\n\r\nIn [2]: from astropy.wcs import WCS\r\n\r\nIn [3]: header = fits.Header.fromtextfile('header.hdr')\r\n\r\nIn [4]: wcs = WCS(header)\r\n\r\nIn [5]: wcs.all_pix2world(19500, 6500, 1)\r\nOut[5]: [array(215.17565987230577), array(52.917709465941066)]\r\n```\r\n\r\nI'm using origin=1 to be able to compare to ds9 results. If I now open ds9, and convert this same position, I get:\r\n\r\nra=215.0174\r\ndec=52.948131\r\n\r\nwhich is almost an arcminute.\r\n\r\nIf I then try and convert the world coordinates back to pixel coordinates, I get an error, even though the world coordinates are inside the image:\r\n\r\n```\r\nIn [8]: wcs.all_world2pix(215.17565987230577, 52.917709465941066, 1)\r\n---------------------------------------------------------------------------\r\nNoConvergence                             Traceback (most recent call last)\r\n<ipython-input-8-e392834de60b> in <module>()\r\n----> 1 wcs.all_world2pix(215.17565987230577, 52.917709465941066, 1)\r\n\r\n/Users/tom/miniconda3/envs/dev35/lib/python3.5/site-packages/astropy/wcs/wcs.py in all_world2pix(self, *args, **kwargs)\r\n   1806                 adaptive=adaptive, detect_divergence=detect_div,\r\n   1807                 quiet=quiet),\r\n-> 1808             'input', *args, **kwargs\r\n   1809         )\r\n   1810 \r\n\r\n/Users/tom/miniconda3/envs/dev35/lib/python3.5/site-packages/astropy/wcs/wcs.py in _array_converter(self, func, sky, *args, **kwargs)\r\n   1242                     \"a 1-D array for each axis, followed by an origin.\")\r\n   1243 \r\n-> 1244             return _return_list_of_arrays(axes, origin)\r\n   1245 \r\n   1246         raise TypeError(\r\n\r\n/Users/tom/miniconda3/envs/dev35/lib/python3.5/site-packages/astropy/wcs/wcs.py in _return_list_of_arrays(axes, origin)\r\n   1198             if ra_dec_order and sky == 'input':\r\n   1199                 xy = self._denormalize_sky(xy)\r\n-> 1200             output = func(xy, origin)\r\n   1201             if ra_dec_order and sky == 'output':\r\n   1202                 output = self._normalize_sky(output)\r\n\r\n/Users/tom/miniconda3/envs/dev35/lib/python3.5/site-packages/astropy/wcs/wcs.py in <lambda>(*args, **kwargs)\r\n   1805                 *args, tolerance=tolerance, maxiter=maxiter,\r\n   1806                 adaptive=adaptive, detect_divergence=detect_div,\r\n-> 1807                 quiet=quiet),\r\n   1808             'input', *args, **kwargs\r\n   1809         )\r\n\r\n/Users/tom/miniconda3/envs/dev35/lib/python3.5/site-packages/astropy/wcs/wcs.py in _all_world2pix(self, world, origin, tolerance, maxiter, adaptive, detect_divergence, quiet)\r\n   1786                     .format(k), best_solution=pix,\r\n   1787                     accuracy=np.abs(dpix), niter=k,\r\n-> 1788                     slow_conv=ind, divergent=inddiv)\r\n   1789 \r\n   1790         return pix\r\n\r\nNoConvergence: 'WCS.all_world2pix' failed to converge to the requested accuracy.\r\nAfter 2 iterations, the solution is diverging at least for one input point.\r\n```\r\n\r\n@mcara @nden - do you have any idea what could be going on here?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/astropy/astropy/issues/comments/213494737","html_url":"https://github.com/astropy/astropy/issues/4761#issuecomment-213494737","issue_url":"https://api.github.com/repos/astropy/astropy/issues/4761","id":213494737,"user":{"login":"mcara","id":5985250,"avatar_url":"https://avatars.githubusercontent.com/u/5985250?v=3","gravatar_id":"","url":"https://api.github.com/users/mcara","html_url":"https://github.com/mcara","followers_url":"https://api.github.com/users/mcara/followers","following_url":"https://api.github.com/users/mcara/following{/other_user}","gists_url":"https://api.github.com/users/mcara/gists{/gist_id}","starred_url":"https://api.github.com/users/mcara/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcara/subscriptions","organizations_url":"https://api.github.com/users/mcara/orgs","repos_url":"https://api.github.com/users/mcara/repos","events_url":"https://api.github.com/users/mcara/events{/privacy}","received_events_url":"https://api.github.com/users/mcara/received_events","type":"User","site_admin":false},"created_at":"2016-04-22T16:11:38Z","updated_at":"2016-04-22T16:11:38Z","body":"In https://github.com/astropy/astropy/issues/4387#issuecomment-163678412 @nden suggested to open a new issue to discuss this subject. Therefore @astrofrog , maybe this issue should be re-opened or maybe a new issue should be created to discuss specifically the use of ``-SIP`` as a \"trigger\" for applying SIP distortions in a WCS."}}