{"action":"created","issue":{"url":"https://api.github.com/repos/astropy/pyregion/issues/65","repository_url":"https://api.github.com/repos/astropy/pyregion","labels_url":"https://api.github.com/repos/astropy/pyregion/issues/65/labels{/name}","comments_url":"https://api.github.com/repos/astropy/pyregion/issues/65/comments","events_url":"https://api.github.com/repos/astropy/pyregion/issues/65/events","html_url":"https://github.com/astropy/pyregion/issues/65","id":118747807,"number":65,"title":"Spatial filter seems to match positions outside region","user":{"login":"grahambell","id":1649796,"avatar_url":"https://avatars.githubusercontent.com/u/1649796?v=3","gravatar_id":"","url":"https://api.github.com/users/grahambell","html_url":"https://github.com/grahambell","followers_url":"https://api.github.com/users/grahambell/followers","following_url":"https://api.github.com/users/grahambell/following{/other_user}","gists_url":"https://api.github.com/users/grahambell/gists{/gist_id}","starred_url":"https://api.github.com/users/grahambell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grahambell/subscriptions","organizations_url":"https://api.github.com/users/grahambell/orgs","repos_url":"https://api.github.com/users/grahambell/repos","events_url":"https://api.github.com/users/grahambell/events{/privacy}","received_events_url":"https://api.github.com/users/grahambell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/astropy/pyregion/labels/bug","name":"bug","color":"d93f0b"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/astropy/pyregion/milestones/2","html_url":"https://github.com/astropy/pyregion/milestones/v1.3","labels_url":"https://api.github.com/repos/astropy/pyregion/milestones/2/labels","id":1914807,"number":2,"title":"v1.3","description":"","creator":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"open_issues":2,"closed_issues":0,"state":"open","created_at":"2016-08-01T06:55:28Z","updated_at":"2016-08-02T10:33:22Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2015-11-25T02:39:39Z","updated_at":"2016-08-03T10:52:56Z","closed_at":null,"body":"The spatial filter seems to match positions which are not part of the specified region.  In the following (very slow) test script, I test points over the whole sky using a 1 degree grid.  The output has, as well as the two expected circles, lines at RA = +/- 90 degrees and a few other scattered points.  This was with Astropy 1.0.6 and the current master version of pyregion from this repository.\r\n\r\n```python\r\nfrom __future__ import print_function                                           \r\nfrom astropy.units import degree                                                \r\nfrom astropy.wcs import WCS                                                     \r\nimport matplotlib.pyplot as plt                                                 \r\nimport pyregion                                                                 \r\n                                                                                \r\nregion = pyregion.parse('''                                                     \r\n    fk5                                                                         \r\n    circle(0:00:00.000,00:00:00.00,36000\")                                      \r\n    circle(3:00:00.000,75:00:00.00,36000\")                                      \r\n''')                                                                            \r\n                                                                                \r\nras = []                                                                        \r\ndecs = []                                                                       \r\n                                                                                \r\nfor ra in range(-179, 180):                                                     \r\n    for dec in range (-89, 90):                                                 \r\n        wcs = WCS(naxis=2)                                                      \r\n        wcs.wcs.radesys = 'ICRS'                                                \r\n        wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']                                \r\n        wcs.wcs.cunit = [degree, degree]                                        \r\n        wcs.wcs.crpix = [1, 1]                                                  \r\n        wcs.wcs.cdelt = [-0.0003, 0.0003]                                       \r\n        wcs.wcs.crval = [ra, dec]                                               \r\n                                                                                \r\n        if region.get_filter(header=wcs.to_header()).inside1(1, 1):             \r\n            #print(ra, dec)                                                     \r\n            ras.append(ra)                                                      \r\n            decs.append(dec)                                                    \r\n                                                                                \r\nplt.scatter(ras, decs)                                                          \r\nplt.xlim(-180, 180)                                                             \r\nplt.ylim(-90, 90)                                                               \r\nplt.show() \r\n```\r\n\r\n![figure_1](https://cloud.githubusercontent.com/assets/1649796/11386855/8b918740-92c9-11e5-9300-73ecce29c0b4.png)"},"comment":{"url":"https://api.github.com/repos/astropy/pyregion/issues/comments/237205782","html_url":"https://github.com/astropy/pyregion/issues/65#issuecomment-237205782","issue_url":"https://api.github.com/repos/astropy/pyregion/issues/65","id":237205782,"user":{"login":"cdeil","id":852409,"avatar_url":"https://avatars.githubusercontent.com/u/852409?v=3","gravatar_id":"","url":"https://api.github.com/users/cdeil","html_url":"https://github.com/cdeil","followers_url":"https://api.github.com/users/cdeil/followers","following_url":"https://api.github.com/users/cdeil/following{/other_user}","gists_url":"https://api.github.com/users/cdeil/gists{/gist_id}","starred_url":"https://api.github.com/users/cdeil/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdeil/subscriptions","organizations_url":"https://api.github.com/users/cdeil/orgs","repos_url":"https://api.github.com/users/cdeil/repos","events_url":"https://api.github.com/users/cdeil/events{/privacy}","received_events_url":"https://api.github.com/users/cdeil/received_events","type":"User","site_admin":false},"created_at":"2016-08-03T10:52:56Z","updated_at":"2016-08-03T10:52:56Z","body":"I've started debugging this ... here's some notes.\r\n\r\nScript to print the RA / DEC values where the pyregion result is incorrect:\r\nhttps://gist.github.com/cdeil/ee69188cb8df95a4b8e2fca22dceea5c\r\n\r\nFirst incorrect result is for:\r\n```\r\nRA, DEC = -141 15\r\n```\r\n\r\nScript to show what's going on for that case:\r\nhttps://gist.github.com/cdeil/91ef8dedaa9e9fafc4e460ba1355c6af\r\n\r\nOutput:\r\nhttps://gist.github.com/cdeil/5236392a1375006e98af55a2a198211f\r\n\r\nLooks like the issue is `nan` values in the first circle in the `filter = region.get_filter(header=header)`:\r\n```\r\nOr[Circle(nan, nan, nan), Circle(3772783.136359, 139402848.023292, 147909026.067737)]\r\n```\r\n\r\nHowever, this seems to work: `region.as_imagecoord(header=header)`\r\n```\r\n[Shape : circle ( HMS(0:00:00.000),DMS(00:00:00.00),Ang(36000\") ), Shape : circle ( HMS(3:00:00.000),DMS(75:00:00.00),Ang(36000\") )]\r\n```\r\n\r\nI'll continue looking at this after lunch.\r\n\r\n@leejjoon or anyone -- any idea what the issue or fix is?"}}
{"actor":{"display_login":"cdeil"}}