Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Demonstrating model bias for realistic galaxies #11

Open
b-remy opened this issue Jun 2, 2022 · 15 comments · May be fixed by #7
Open

Demonstrating model bias for realistic galaxies #11

b-remy opened this issue Jun 2, 2022 · 15 comments · May be fixed by #7

Comments

@b-remy
Copy link
Owner

b-remy commented Jun 2, 2022

This issue is to report results of experiments aiming to demonstrate the model bias when trying to estimate shear with a forward model.

@b-remy
Copy link
Owner Author

b-remy commented Jun 2, 2022

We consider here real galaxies from the COSMOS 23.5 catalog. In order to demonstrate model bias we fit a Sersic model on two set of observations:

  • real galaxies
  • parametric galaxies (sersic fit)

We remove galaxies such that n < 0.4 or half_light_radius > .3 to get a correct SNR. Gaussian noise of standard deviation 0.01 is added on top of COSMOS stamp noise realization.

Real galaxies simulations

  • Shear parameter

image

image

  • Intrinsic e parameters:

image

  • Simulations
    image

  • Residuals
    image

Parametric galaxies simulations

  • Shear parameter

image

image

  • Intrinsic e parameters:

image

  • Simulations
    image

  • Residuals
    image

@EiffL
Copy link
Collaborator

EiffL commented Jun 2, 2022

Wow, that is awesome!!!

@b-remy
Copy link
Owner Author

b-remy commented Jun 7, 2022

Something we were wondering is whether there was a pattern in the residuals for the realistic dataset due to something else that the profile discrepancy.

A way to check this is to generate the same image with galsim only for both the real image and the sersic fit and look at the residuals (code to generate the residual image). We can observe the same residuals as for our model fitting measurement.

image

@EiffL
Copy link
Collaborator

EiffL commented Jun 7, 2022

hummm the code is a little bit confusing to me, a lot is going on, can you just draw the real galaxy and subtract the parametric one? No added noise so it should be like 5 lines of code

@b-remy
Copy link
Owner Author

b-remy commented Jun 7, 2022

Here is when I only draw the galaxies convolved with their psf (no added noise).

image

I can make the code even simpler but I wanted to look at the same galaxies as in my example above.

@EiffL
Copy link
Collaborator

EiffL commented Jun 7, 2022

Right right, I just wanted to see clearly the exact steps going into making both parametric and real galaxies. In like 5 lines, just drawing one galaxy is enough for instance. I think I saw a few things that may not be quite right but it was hard to tell as there were 3 different gal objects every time (and that I didn't sleep much ^^')

@b-remy
Copy link
Owner Author

b-remy commented Jun 7, 2022

Ok, here is the top left galaxy for instance

ind = 2
galp = cat.makeGalaxy(ind, gal_type='parametric')
galr = cat.makeGalaxy(ind, gal_type='real')
psf = galr.original_psf

convr = galsim.Convolve(galr, psf) # real gal
convp = galsim.Convolve(galp, psf) # parametric gal

imr = convr.drawImage(nx=64, ny=64, scale=0.03).array
imp = convp.drawImage(nx=64, ny=64, scale=0.03).array

figure(figsize=(12,4))
subplot(131)
title('real gal')
imshow(imr)
colorbar()
subplot(132)
title('sersic fit')
imshow(imp)
colorbar()
subplot(133)
title('residuals')
imshow(imr-imp)
colorbar()

image

@EiffL
Copy link
Collaborator

EiffL commented Jun 7, 2022

Ok, so the first thing I saw is that you want to use the method 'no_pixel' to draw the galaxies, b cause the pixel response is already included in the PSF most likely

@EiffL
Copy link
Collaborator

EiffL commented Jun 7, 2022

And I remembered something similar from some work a long time ago, see this notebook
https://github.com/McWilliamsCenter/deep_galaxy_models/blob/master/Figure_autoencode.ipynb

1 similar comment
@EiffL
Copy link
Collaborator

EiffL commented Jun 7, 2022

And I remembered something similar from some work a long time ago, see this notebook
https://github.com/McWilliamsCenter/deep_galaxy_models/blob/master/Figure_autoencode.ipynb

@EiffL
Copy link
Collaborator

EiffL commented Jun 7, 2022

Drawing galaxy from cosmos

gal = cosmos_cat.makeGalaxy(i, gal_type='real', noise_pad_size=0.8*PIXEL_SCALE*STAMP_SIZE)
psf = gal.original_psf
real = galsim.Convolve(psf, gal)
real.drawImage(im_real, method='no_pixel', use_true_center=False);


# Drawing galaxy from parametric model
param_gal = cosmos_cat.makeGalaxy(i, gal_type='parametric')
param = galsim.Convolve(psf, param_gal)
param.drawImage(im_param, method='no_pixel', use_true_center=False);

@b-remy
Copy link
Owner Author

b-remy commented Jun 8, 2022

It does not seem to change much the result...

ind = 2
galp = cat.makeGalaxy(ind, gal_type='parametric')
galr = cat.makeGalaxy(ind, gal_type='real', noise_pad_size=64*np.sqrt(2)*0.03)
psf = galr.original_psf

convr = galsim.Convolve(psf, galr) # real gal
convp = galsim.Convolve(psf, galp) # parametric gal

imr = convr.drawImage(nx=64, ny=64, scale=0.03, method='no_pixel', use_true_center=False).array
imp = convp.drawImage(nx=64, ny=64, scale=0.03, method='no_pixel', use_true_center=False).array

figure(figsize=(12,4))
subplot(131)
title('real gal')
imshow(imr)
colorbar()
subplot(132)
title('sersic fit')
imshow(imp)
colorbar()
subplot(133)
title('residuals')
imshow(imr-imp)
colorbar()

image

@b-remy
Copy link
Owner Author

b-remy commented Jun 8, 2022

So it looks like there is an offset in the galsim sersic fit centroid!

I added a centroid shift variable to my model (810ebda) and just ran a MAP for the field above. It fixed the dipole pattern in the residuals :-)

  • galsim sersic fit

image

  • After fitting the centroid with a simple gradient descent

image

=> So I guess, I will now try to sample the centroid offset in the same time as the other parameters to check the model bias.

@EiffL
Copy link
Collaborator

EiffL commented Jun 8, 2022

Aaaaah that looks much better!

@b-remy b-remy linked a pull request Jun 9, 2022 that will close this issue
@b-remy
Copy link
Owner Author

b-remy commented Jun 9, 2022

Here are the latest results (ab506ca), now fitting e, gamma and centroid shift on realistic sheared images (assuming n, hlr and flux galsim sersic fit parameters:

image

residuals
image

And some chains
image

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants