pmelchior / scarlet

hyperspectral galaxy modeling and deblending
MIT License
49 stars 22 forks source link

Blend.fit raises "ValueError: operands could not be broadcast together with shapes ..." #275

Closed grantmerz closed 1 year ago

grantmerz commented 1 year ago

Hello. After downloading the latest version of scarlet to fix issue #274 (thanks for the quick turnaround!), I came across this error when running my script on some more images.

  File "/home/g4merz/.conda/envs/astrodetnv/lib/python3.9/site-packages/schwimmbad/mpi.py", line 72, in __init__
    self.wait()
  File "/home/g4merz/.conda/envs/astrodetnv/lib/python3.9/site-packages/schwimmbad/mpi.py", line 126, in wait
    result = func(arg)
  File "/home/g4merz/deblend/scripts/training_data_test_mpi.py", line 267, in run_scarlet_training
    out = sc.run_scarlet(datas, filters, sigma_model=1, sigma_obs=sigma_obs, plot_scene=True,
  File "/home/g4merz/deblend/astrodet/astrodet/scarlet_update.py", line 570, in run_scarlet
    starlet_blend, logL = fit_scarlet_blend(starlet_sources, observation, max_iters=max_iters, plot_likelihood=plot_likelihood)
  File "/home/g4merz/deblend/astrodet/astrodet/scarlet_update.py", line 314, in fit_scarlet_blend
    it, logL = starlet_blend.fit(max_iters, e_rel=e_rel)
  File "/home/g4merz/.conda/envs/astrodetnv/lib/python3.9/site-packages/scarlet-1.0.1+g11d1363-py3.9-linux-ppc64le.egg/scarlet/blend.py", line 165, in fit
    proxmin.adaprox(
  File "/home/g4merz/.conda/envs/astrodetnv/lib/python3.9/site-packages/proxmin/algorithms.py", line 387, in adaprox
    z_ = prox[j](z - gamma / Alpha[j] * Psi * (z - X[j]), gamma)
  File "/home/g4merz/.conda/envs/astrodetnv/lib/python3.9/site-packages/scarlet-1.0.1+g11d1363-py3.9-linux-ppc64le.egg/scarlet/constraint.py", line 79, in __call__
    X = c(X, step)
  File "/home/g4merz/.conda/envs/astrodetnv/lib/python3.9/site-packages/scarlet-1.0.1+g11d1363-py3.9-linux-ppc64le.egg/scarlet/constraint.py", line 54, in __call__
    return self.f(X, step)
  File "/home/g4merz/.conda/envs/astrodetnv/lib/python3.9/site-packages/proxmin/operators.py", line 123, in prox_hard
    below = np.abs(X) < thresh_
ValueError: operands could not be broadcast together with shapes (7,81,81) (7,191,191)

I use the same code that models some sources as StarletSources and the rest as ExtendedSources. This error only appears on some images. Any help would be greatly appreciated! Thanks.

grantmerz commented 1 year ago

I believe this is actually an issue with some artifacts in my images leftover from bright stars. Throws off the catalog creation and also source modelling. I'll close this issue.

pmelchior commented 1 year ago

This is a bug, probably from some resizing update. Can you say under what conditions this error arises?