CentroidGaussian2D crashing after AutoSourceDetection
I have a simple Sequence with AutoSourceDetection followed by CentroidGaussian2D on which I run a cutout of my image centered on the astrometric solution for my moving target. I had the following crash:
[...]
File "/home/Mathieu/prose/prose/core/sequence.py", line 111, in run
self._run(loader=loader)
File "/home/Mathieu/prose/prose/core/sequence.py", line 134, in _run
block._run(buffer)
File "/home/Mathieu/prose/prose/core/block.py", line 91, in _run
self.run(image)
File "/home/Mathieu/prose/prose/blocks/centroids.py", line 58, in run
centroid_sources(
File "/home/Mathieu/anaconda3/lib/python3.9/site-packages/photutils/centroids/core.py", line 391, in centroid_sources
if (np.any(np.min(xpos) < 0) or np.any(np.min(ypos) < 0)
File "/home/Mathieu/anaconda3/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 2953, in min
return _wrapreduction(a, np.minimum, 'min', axis, None, out,
File "/home/Mathieu/anaconda3/lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 88, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
ValueError: [CentroidGaussian2D] zero-size array to reduction operation minimum which has no identity
It looks like the crash was due to AutoSourceDetection giving a source with coordinates in x = 0. which _PhotutilsCentroid could not handle (it was returning x, y = [],[] in centroid.py line 53.
I solved it by simply modifying line 51 to accept sources with 0. coordinates (b5bca08b44ae3a9ede0a34d4e6a28a64dc5265ed).
I am not sure as I don't understand completely that part of the code but I don't think this modification affects anything else?
Seems like a good fix. We should run the tests but I don't see anywhere where that'll be a problem. What about opening a pull request with some of your recent changes?
I think some of them are specific to your work though, so we should chat about it. But the chat can also be done in the PR itsefl