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

Add quantization noise + remove sky_image quantization #100

Merged
merged 9 commits into from
Dec 11, 2024

Conversation

aguinot
Copy link
Collaborator

@aguinot aguinot commented Dec 11, 2024

Add quantization noise to the image. This allow to improve background estimation, see #85.
Below are the results with the quantization noise on. It looks like the original signal is not impacted.

backgrounds

background_hist

@aguinot aguinot added the bug Something isn't working label Dec 11, 2024
@aguinot
Copy link
Collaborator Author

aguinot commented Dec 11, 2024

Question:
At the moment the quantization noise is always added as long as any is requested. All the other noise have a dedicated keyword in the config to turn on/off. Do we want that for this too? (very easy to add)

quantization_noise.fill(0)
quantization_noise.addNoise(galsim.DeviateNoise(galsim.UniformDeviate(rng)))
noise_img += quantization_noise
noise_img -= 0.5
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this subtraction by 0.5 come from?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With quantization we assume that if you have a value of 100.5 ADUs it has the same chance to round to 100 or 101 which lead to +/-0.5. The Uniform distribution from GalSim return value in the range [0, 1], the -0.5 is just to rescale the range to [-0.5, 0.5].

Copy link
Member

@rmandelb rmandelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed during the meeting:

  • put in documentation
  • include in end to end demo

euclidlike_imsim/noise.py Outdated Show resolved Hide resolved
@aguinot
Copy link
Collaborator Author

aguinot commented Dec 11, 2024

As discussed during the meeting:

  • put in documentation
  • include in end to end demo
  • I have added a basic documentation to the get_noise function which will be propagated to the documentation (it i the easiest as there is no dedicated page in addition to the API).
  • Added to the end-to-end demo

@aguinot
Copy link
Collaborator Author

aguinot commented Dec 11, 2024

@rmandelb Ready to for review

Copy link
Member

@rmandelb rmandelb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my comments/suggestions are trivial, so I'm approving to avoid the need for another review. I think you should be able to just accept the suggestions and merge.

euclidlike_imsim/noise.py Outdated Show resolved Hide resolved
euclidlike_imsim/noise.py Outdated Show resolved Hide resolved
euclidlike_imsim/noise.py Outdated Show resolved Hide resolved
if cfg_noise["quantization_noise"]:
quantization_noise = noise_img.copy()
quantization_noise.fill(0)
quantization_noise.addNoise(galsim.DeviateNoise(galsim.UniformDeviate(rng)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the github interface something funny is happening with indentation? Is this a tabs vs. spaces thing or just a fluke?

examples/end_to_end_demo.py Outdated Show resolved Hide resolved
# Note that the image type after this step is still a float. If we want to actually
# get integer values, we can do new_img = galsim.Image(full_image, dtype=int)

# Here we add quantization noise to the image. This prevent to have problems due
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Here we add quantization noise to the image. This prevent to have problems due
# Here we add quantization noise to the image. This prevents problems due

examples/end_to_end_demo.py Outdated Show resolved Hide resolved
examples/end_to_end_demo.py Outdated Show resolved Hide resolved
aguinot and others added 6 commits December 11, 2024 15:55
Co-authored-by: Rachel Mandelbaum <[email protected]>
Co-authored-by: Rachel Mandelbaum <[email protected]>
Co-authored-by: Rachel Mandelbaum <[email protected]>
Co-authored-by: Rachel Mandelbaum <[email protected]>
Co-authored-by: Rachel Mandelbaum <[email protected]>
Co-authored-by: Rachel Mandelbaum <[email protected]>
@aguinot aguinot merged commit 8cb572b into main Dec 11, 2024
2 checks passed
@aguinot aguinot deleted the quantization_noise branch December 11, 2024 23:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants