Closed andrevitorelli closed 2 years ago
I am not sure about your implementation. Here are a few things that are important:
I would encourage you to look at the implementation in ngmix which is actually even simpler than yours. Basically you leave your method generate_mcal_image
as it is (without the fixnoise addition). then you do the following:
def get_fixnoise_mcal(img, psf, rng):
"""
Get mcal image using fixnoise correction.
param:
img: galaxy stamp
psf: corresponding psf
rng: either seed or random generator
output:
mcal_images
"""
mcal_img = generate_mcal_image(img, psf)
# handle the noise
noise_img = get_noise(img, rng)
input_noise = rot90(noise_img)
mcal_noise = generate_mcal_image(input_noise, psf)
# rotate back the noise
final_noise = rot90(mcal_noise, k=-1)
# correction
final_result = mcal_img + final_noise
return final_result
You can have a look at their implementation here
Also, given the autodiff framework I am not sure if what I proposed above work as it is or if it require some changes. I guess generating randoms within the autodiff part is not ideal so you will probably need to that outside the function (generating the noise image). Which make sense since in a more realistic context the noise will be provided by the step before the metacal.
Apart for the comment I left, the rest looks good to me
Closed for reorganization of development.
Creates fixnoise code. I am not sure if this is the correct way, so I summon @EiffL and/or @aguinot to review. This is really just a short few lines of code. I get the mean and std of the images, create noise images based on them, shear just the same, and then I rotate them by 90 degrees before adding to the main image.