GalSim-developers / GalSim

The modular galaxy image simulation toolkit. Documentation:
http://galsim-developers.github.io/GalSim/
Other
223 stars 105 forks source link

maxk approximation used in Exponential profile #1268

Closed jecampagne closed 7 months ago

jecampagne commented 7 months ago

Hi, I’ve noticed something in the exponential profile. Galsim uses an approximation to get maxk (here it is maxk before dividing by scale_radius)

_maxk = self.gsparams.maxk_threshold**-Exponential._one_third

The exact formula is the following (you can code it differently)

_maxk = np.sqrt(np.power(self.gsparams.maxk_threshold,-2./3.)-1.)

I do not know the exact reason to use the approximated formula. With the default maxk_threshold=10^(-3) one gets 10. (approx) instead of 9.9498, which is 5 per mille diff. Of course the approx goes in the direction to increase a little bi t the maxk which is at least a good point.

But Spergel profile is exactly the exponential one in the case nu=1/2, and it is noticeable then that the maxk formula for Spergel is exact leading to a difference between Exponential & Spergel maxk which I think may be cured easily if needed.

rmjarvis commented 7 months ago

I think "if needed" is the key phrase. Is there a use case you have in mind where this makes a difference? It seems unlikely to me, and since the current formula is both faster to calculate and slightly conservative, I'm inclined to leave it as is.

jecampagne commented 7 months ago

As you wish no problem.