SourceXtractorPlusPlus icon indicating copy to clipboard operation
SourceXtractorPlusPlus copied to clipboard

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

Open mkuemmel opened this issue 1 year ago • 6 comments

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!

mkuemmel avatar May 26 '23 13:05 mkuemmel

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?

marcschefer avatar May 26 '23 13:05 marcschefer

It is strange that:

  • the positional offset goes to the same direction;
  • there is this line at ~-1000.

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 avatar May 26 '23 14:05 mkuemmel

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 avatar May 26 '23 16:05 mkuemmel

It's a bit confusing:

  • the factor 1000 in the bad measurements comes from the detection images, meaning it does not start fitting at all and just reports the starting flux value;
  • the stop reason is "exceeded max number of iterations", which fits with the stop reason;
  • however the # of iterations is only 1;
  • also the flag should be set to 1, which I don't see in the result table;

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

mkuemmel avatar May 28 '23 19:05 mkuemmel

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 avatar Jun 15 '23 12:06 mkuemmel

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.

mkuemmel avatar Jun 15 '23 12:06 mkuemmel