astropy / astropy/pyregion

Spatial filter seems to match positions outside region

Open
#65 14 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
41
Forks
41
PR merge metrics
No merged PRs in 30d

Description

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.

``` python
from __future__ import print_function
from astropy.units import degree
from astropy.wcs import WCS
import matplotlib.pyplot as plt
import pyregion

region = pyregion.parse('''
fk5
circle(0:00:00.000,00:00:00.00,36000")
circle(3:00:00.000,75:00:00.00,36000")
''')

ras = []
decs = []

for ra in range(-179, 180):
for dec in range (-89, 90):
wcs = WCS(naxis=2)
wcs.wcs.radesys = 'ICRS'
wcs.wcs.ctype = ['RA---TAN', 'DEC--TAN']
wcs.wcs.cunit = [degree, degree]
wcs.wcs.crpix = [1, 1]
wcs.wcs.cdelt = [-0.0003, 0.0003]
wcs.wcs.crval = [ra, dec]

if region.get_filter(header=wcs.to_header()).inside1(1, 1):
#print(ra, dec)
ras.append(ra)
decs.append(dec)

plt.scatter(ras, decs)
plt.xlim(-180, 180)
plt.ylim(-90, 90)
plt.show()
```

![figure_1](https://cloud.githubusercontent.com/assets/1649796/11386855/8b918740-92c9-11e5-9300-73ecce29c0b4.png)

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by running the reported whole-sky script with the current pyregion and Astropy versions, focusing on get_filter(header=wcs.to_header()).inside1(1, 1). Trace how the FK5 circles are transformed and tested, then verify that only positions inside the two expected circles are returned and that the RA ±90° artifacts disappear.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.