Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CentroidGaussian2D crashing after AutoSourceDetection #147

Open
mathvdd opened this issue Oct 16, 2023 · 2 comments
Open

CentroidGaussian2D crashing after AutoSourceDetection #147

mathvdd opened this issue Oct 16, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@mathvdd
Copy link

mathvdd commented Oct 16, 2023

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 (b5bca08).

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?

@lgrcia
Copy link
Owner

lgrcia commented Oct 17, 2023

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?

@lgrcia
Copy link
Owner

lgrcia commented Oct 17, 2023

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

@lgrcia lgrcia added the bug Something isn't working label Oct 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants