astropy/photutils — pull request #198 by cdeil (2014-12-12 09:33:10+00:00)
Title: Bug in exact elliptical photometry

cc @astrofrog I've just found a really tough bug in the exact elliptical overlap calculation. 99% of the time, my tests pass, but for some (x,y) positions, the answer is far off the true value.

Here's a minimal example:

```python
import numpy as np
import photutils

data = np.ones((1000, 1000))
x = 259.469906 # values from here up to 259.5 give bad results, but 259.4699055 is fine.
y = 400.923861394
r = 3.

circ = photutils.CircularAperture((x, y), r)
ellip = photutils.EllipticalAperture((x, y), r, r, 0.)
res1 = photutils.aperture_photometry(data, circ, method='exact')
res2 = photutils.aperture_photometry(data, ellip, method='exact')

print res1['aperture_sum'] - res2['aperture_sum']
```

Result:

```
aperture_sum
--------------
-0.88177189712
```

Should be 0.0, and is 0.0 when x is adjusted *very* slightly, as noted in the code comment.

Pretty sure I've isolated this to the elliptical overlap code. It's an impressive and large piece of work, so I hope @astrofrog has some idea!