astrorama / SourceXtractorPlusPlus

SourceXtractor++, the next generation SExtractor
https://astrorama.github.io/SourceXtractorPlusPlus/
GNU Lesser General Public License v3.0
73 stars 9 forks source link

Should we recomment using gsl instead of levmar in #554??? #555

Open mkuemmel opened 1 year ago

mkuemmel commented 1 year ago

In the dataset discussed in #554, one way to avoid getting stuck would be using gsl instead of levmar. I checked that. While indeed the program runs through, a comparison of the fit results in x and y shows: x_offset y_offset

~2% of the sources are off in both, x and y. The sources are rather evenly distributed in x/y.

In flux there is even a branch which is far off: flux_comp

I did not go into detail, but it is strange that gsl gives 1000 times brighter flux than levmar. The sources that are at around 1 fit very good, however!

marcschefer commented 1 year ago

It's weird, we test gsl as part of our automated tests so I think it's working in normal cases. Could it be possible those failure cases are related to what's causing the infinite loop in levmar?

mkuemmel commented 1 year ago

It is strange that:

Maybe more effort is necessary in the parameterization, I only exchanged levmar --> gsl in the config files. On the other hand it's a rather simple PSF fitting, meaning only one parameter. If consistent the residuals of the brighter objects at -1000 must look ridiculous...

mkuemmel commented 1 year ago

Yepp, the objects at -1000. are black holes in the residuals.

But the failures are signaled in the stop reason. They all have stop-reason=11 (but there are also good stop-reson=11 sources.

I tried to figure out what that 11 means for gsl, but it is confusing. 11 means too many iterations, but for most of the baid fails the # of iteration is 0, also 11 should be translated into a flag, but the gsl flag is always 0.

mkuemmel commented 1 year ago

It's a bit confusing:

Somehow for those 4% sources the fits does not really start. No idea why.

mkuemmel commented 1 year ago

I ran the same dataset with levmar and with gsl and crossmatched the results. When plotting the relative difference between the initial flux and the fitted flux it looks like this:

rel_diffs

The good news: the sources that were not fitted with gsl were also not fitted with levmar.

The bad news: I have no idea why neither minimizer does a good job.

I should have checked the flagging. I'll investigate further....

mkuemmel commented 1 year ago

They all have in levmar: "7 - stopped by invalid (i.e. NaN or Inf) "func" values; a user error "

There are NAN's in the image file and 0 in the weight, but no weight threshold.