JAX-GalSim
JAX-GalSim copied to clipboard
Moffat maxK computation : Galsim 2.4-> 2.5
This issue is to keep in mind that the maxK computation of Untruncated Moffat is the 2.4.x versions of Glasim will be changed in the 2.5.x versions. The JAX-Galsim Moffat code will have to be adapted accordingly. Some formula are discussed in the PR #49.
One way to make the maxK search for untruncated Moffat, is to use the approx 2D functions of (beta
, gsparam.maxk_threshold
) parameters
def nlm3(x,y):
return -0.871303 \
+ 2125.34*jnp.exp(548.446*x*y) \
+ (-1.0 + x)**0.551405 * (2.3663 - 0.496395 * y) \
- 1.78113*y
def nlm4(x,y):
return -54.7189 \
+ (-1.0 + x)**0.0151804 * (60.3922 + 0.118008 * y) \
+ jnp.exp(0.118008*x*y)* (-4.87159 + 0.690609 * y) - 2.10138*y
def sigmoide(x):
return 1.0/(1.0 + jnp.exp(-x*5.0))
@jax.jit
def approx(beta, thr):
y = jnp.log10(thr)
w = sigmoide(beta-2.0)
return w * nlm3(beta,y) + (1.0-w) * nlm4(beta,y)
it has been fitted for beta in [1.001,100] and threshold in [10^-6, 10^-2], but this function can be used to get a bracket intervalle of the true maxK value, to use jaxopt Bisection algorithm if one wants a better approx.
I believe that the Galsim code >=2.5.0 was released and our tests are still passing, does that mean that this issue can be closed? Do you happen to know @beckermr ? (I must admit I can't remember exactly what the problem here was, perhaps @jecampagne can remind us)
i'll have to look at the code and see what is there right now.
we should be using more of these simple fitting functions to do parameter conversions (eg effective radius to fwhm) when creating objects in jax-galsim instead of directly solving.
This was fixed here: https://github.com/GalSim-developers/JAX-GalSim/commit/62d146e36e422bef9824925b5cc04bc378d5a8a9
We use a full bisection to solve for the maxk value like galsim. We can close this one.