DifferentiableUniverseInitiative / GalFlow

A TensorFlow reimplementation of GalSim
MIT License
10 stars 4 forks source link

Implement forward Fourier transform #8

Open b-remy opened 3 years ago

b-remy commented 3 years ago

The aim of this issue is to document the implementation of the galsim Fourier transform in TF used in the beginning of the demo notebook.

We want to take as input a pixel image a return the Fourier image, as the drawKImage(bounds, scale, recenter) galsim function does.

EiffL commented 3 years ago

actually ^^' I need this for something..... so gonna go ahead and implement this

b-remy commented 2 years ago

Ok, I think I definitely need to implement this now ^^

I would appreciate any pointer you may have about galsim drawKImage!

So far I found these:

EiffL commented 2 years ago

yeahhhhh, so probably we should take some time to talk about that.

EiffL commented 2 years ago

So I made a tiny notebook to try out the Fourier convolution against GalSim, here: https://colab.research.google.com/drive/1I-Nt62ss6HsCLAvXiP62IR-YHuJLXe8n?usp=sharing

EiffL commented 2 years ago

Looks like I was wrong, it works for even size stamp :-/

b-remy commented 2 years ago

I'm trying to understand how galsim is performing forward Fourier transform. Something weird I noticed is that is seems we don't have the same scale when computing the k-image in galsim or in tensorflow: image The galsim k-image seems to be slightly larger scale... It was computed with:

kim0 = obj0.drawKImage(bounds=bounds, 
                       scale=2*_pi/(_stamp_size*padding_factor*_scale), 
                       recenter=False).array

where _scale is the gal profile scale, _stamp_size is the size of the original image, padding_factor=1. More info in colab.

Maybe when I compute the Fourier transform with TF or numpy, the Fourier scale is not 2*_pi/(_stamp_size*_scale)... I'll continue to investigate.

EiffL commented 2 years ago

Note that it's the "bounds" that define the image range, not necessarily the scale, in galsim