-
Notifications
You must be signed in to change notification settings - Fork 22
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
LinAlgError when setting spectra #282
Comments
Thanks for reporting. The code that fails here is a linear solver to get the best-fit amplitude across all bands, aka the SEDs, for all sources given their initial morphology. In absence of zero or nan weights, there's two ways of getting that:
In either case the best-fit solution is ill-defined and numerically unstable. Hence, the exception when trying to invert the covariance matrix of the best-fit. It's interesting to see the btk had to catch this failure, so this isn't completely rare in simulated cases, whereas we have not seen it to be overly problematic with actual detection catalogs, where it's essentially impossible to have two detections so close together. I would say that the solutions of a deblender in such cases will be pretty useless (and that's probably true for any deblender: if the data can't tell the difference, you get either the initial guess or the prior), but exceptions should be avoided or caught. So, I suggest that we fix this problem on our end. The fix will be to test for both of the cases listed above:
Something like sed1 = sed * np.arange(1, C+1)/C
sed2 = sed * (1 - np.arange(1, C+1)/C) should work. |
I took a closer look at the cases where the exception occurs and I confirm that the exception occurs in the fields that have two galaxies too close to one another (centers lie in the same pixel). |
Thanks for confirming. We should be able to patch that soon |
Hello,
I am trying to initialize sources with
scarlet.initialization.init_all_sources
but I get a numpy.linalg.LinAlgError from this line of the functionscarlet.initialization.set_spectra_to_match
.The code I used for this run is uploaded here
and I get the following output:
Here are a few things I tried to resolve this issue:
min_snr
.ExtendedSource
.set_spectra = False
As expected
set_spectra = False
manages to avoid this error but quite surprisingly the error also disappears when settingshifting=True
although this parameter should not have an impact since the sources are well within the boundary of the images.I am currently using the scarlet btk-v1 release and I noticed in the BTK example runs of scarlet, a try catch block was introduced to catch this exception.
Does this error come from extremely faint sources?
The text was updated successfully, but these errors were encountered: