Skip to content

ADU unit (with camera gain) docstring for GAT - #156

Merged
ShantanuKodgirwar merged 2 commits into
mainfrom
gain-unit-GAT
Nov 23, 2026
Merged

ShantanuKodgirwar merged 2 commits into
mainfrom
gain-unit-GAT

Conversation

@ShantanuKodgirwar

Copy link
Copy Markdown
Contributor

What and why

The Anscombe amplitude loss only took data in photons, while poisson_loss and mixed_poisson_gaussian_loss take detector units plus a gain. Switching between them meant changing the data units. Now all three noise losses use the same units.

  • PtyLab/Engines/GradientEngine/losses.py: amplitude_loss gets a gain argument. With anscombe_offset_switch=True the offset is now $c = 3g/8 + \sigma^2/g$ (generalized Anscombe transform, Mäkitalo and Foi 2013). Without the shift, gain must stay 1. Shorter module and docstrings for losses.
  • PtyLab/Engines/GradientEngine/engine.py: readoutSigma is in detector units for every loss.
  • docs/differentiable/overview.md: lists gain for amplitude_loss and drops the photon-only note.

How it was tested

New test_generalized_anscombe_stabilizes_the_variance (variance $g/4$ at 20 and 500 photons, three gain/σ pairs), plus gain cases in the existing Anscombe tests. uv run pytest tests/Engines: 230 passed, 1 skipped.

Notes

With gain=1 (the default) results are unchanged.

@ShantanuKodgirwar
ShantanuKodgirwar merged commit 20aa79e into main Nov 23, 2026
6 checks passed
@ShantanuKodgirwar
ShantanuKodgirwar deleted the gain-unit-GAT branch November 23, 2026 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant