CosmoStat / autometacal

Metacalibration and shape measurement by automatic differentiation
MIT License
4 stars 1 forks source link

offset between metacal image and galsim generated image #15

Closed andrevitorelli closed 3 years ago

andrevitorelli commented 3 years ago

On the metacal_proof_of_concept-Fourier notebook, there is always a problem with the residuals between the input image and the reconvolved image. This is a problem due to some shift, created by the use_true_center keyword. The "input image" (image_shear) is created with it set to False, but the "observation image" ( obs_imag original profile+psf+noise) with it set to True. The "observation image" is used to do the metacal procedure, but when compared to the reconvolved image we have this shift in the residuals (it always appears, but if you have a smaller radius galaxy it becomes clearer than the original example). If I get the residuals frommetacal_image - image_shear, I have none, just noise. If I get it from metacal_image - obs_imag , I have the shift. No combination of setting the use_true_center between the images solves this, I either get shifts from both, or from obs_imag. Something happens after we go from the obs_imag to the kspace image with drawKimage that does not reproduce the effect of the use_true_center. To check that: run the notebook withgal_r0 = 1.0(second notebook cell), and change the use_true_center from image_shear or obs_imag at will.

EiffL commented 3 years ago

Thanks @andrevitorelli for looking into this! I'm looking at the notebook on the main branch but I'm not sur I can find all the images you are refering to, I don't see an metacal_image. Also, I think image_shear is not necessary in the second part of the notebook.

Could you make a trimmed down version of that notebook, which only shows the differences you are getting? So, no metacal, just drawing a galaxy and convolving it with GalSim and GalFlow

I'd be interested to look at it.

EiffL commented 3 years ago

@andrevitorelli I've simplified your notebook a bit further, and added a section that just tests whether you can draw the kimage and compute the inverse FFT, even without looking at PSF convolution https://github.com/CosmoStat/autometacal/blob/u/andrevitorelli%2Fmcal_imags/notebooks/reconvolve_shift_example.ipynb

So, it appears that it's a problem of convention, and center can shift by 1/2 pixels. To use the same convention with drawImage and drawKimage, you should use use_true_center=False in drawImage, apparently

EiffL commented 3 years ago

it's a bit annoying.... because the ifft is shifted compared to the input pixel image.... so, another way to fix the problem, is to apply a phase shift to the fourier image to unshift the image by 1/2 pixels.

Also, yeah, this should only be a problem for even images..... odd images should be ok... but it's better if our code works in both cases :-)

EiffL commented 3 years ago

@andrevitorelli so is this resolved now?

andrevitorelli commented 3 years ago

@EiffL Not yet, I was trying to test a few things first.

EiffL commented 3 years ago

@andrevitorelli so is this resolved now?

andrevitorelli commented 3 years ago

I don't know, since the whole metacal functions are not working on images from the dataset (at all). I have some hints why, but I haven't been able to solve it yet. Also, at times, when the profile is sharp, there are still visible effects on the residuals that seem not to come from the offset (since they are present with either odd or even number of pixels). So either:

But I guess the issue can be technically closed as "outdated".

EiffL commented 3 years ago

sooo I'm gonna flag this as solved for now