Closed mkuemmel closed 4 years ago
Hi,
So I have finally found the origin of this problem. I must admit I lost a lot of time because isnan() doesn't work when compiling in fast-math mode which I didn't realize until I looked everywhere and couldn't find any NaN.
So the problem comes from allowing low Sersic indices. I'm using an approximation to compute the flux and it's normally good for a Sersic index n > 0.36 ( but when n gets lower than that it quickly explodes to infinity and results in NaN in my models.
I suggest for now limiting Sersic index to minimum 0.36: sersic = FreeParameter(2.0, Range((.36, 7.0), RangeType.LINEAR))
I used to switch with another approximation for low numbers but I was worried that the discontinuity would mess with minimization and at some point we discussed it and concluded that very low Sersic indices were not needed.
So I'm not sure if the solution is to revert to that code.
I hope this work around helps for now.
Oh shoot, that's the reason why the NAN's appeared so 'suddenly'. I changed the python configuration ... The simulations have Nser > 0.3, so the gap to 0.36 is not too large.
In any case it would make sense to document this limitation or maybe even throw an error for lower limits<0.36.
Just for my curiosity: What about the fit results for the sources with NAN? Where they okay or garbage, such as the last reasonable fit result?
I'm not sure but yes, it's possible that the fit would just stop when the NaNs appear and so have somewhat reasonable values for the parameters.
Turns out that this is due to a bad choice of the initial conditions for the modelling of the Sersic function.
Close it now.
Found some NAN's in the model image and the residual image. No indication in the results that the fits went wrong.
Delivered a test data set to @marcschefer .