Skip to content

Add PixelResponseNonUniformity effect for fixed per-pixel gain variation (PRNU)#886

Draft
ShannonS00 wants to merge 5 commits intoAstarVienna:mainfrom
ShannonS00:shs/prnu
Draft

Add PixelResponseNonUniformity effect for fixed per-pixel gain variation (PRNU)#886
ShannonS00 wants to merge 5 commits intoAstarVienna:mainfrom
ShannonS00:shs/prnu

Conversation

@ShannonS00
Copy link

Summary

  • Adds a new PixelResponseNonUniformity effect in effects/electronics/noise.py that models per-pixel gain
    variation (PRNU) by multiplying each pixel by a (per pixel) gain factor drawn from N(1, prnu_std)
  • The gain map is generated once per detector and cached, reflecting that PRNU
    is a fixed physical property of the detector chip
  • prnu_std accepts a scalar float or a dict keyed by detector ID, for later implementation of different values per detector type (e.g. H2RG & GeoSnap) in the instrument packages
  • Defaults set to prnu_std=0.01 (1%)

…tronics/noise.py that models PRNU by multiplying each detector pixel by a per pixel gain factor drawn from N(1, prnu_std). The gain map is generated once per detector (keyed by detector ID) and reused across exposures for consistency. `prnu_std` can be a scalar float or a dict keyed by detector ID, allowing different RMS values per detector type (e.g.

H2RG vs GeoSnap).
@ShannonS00 ShannonS00 requested a review from oczoske March 10, 2026 17:02
@ShannonS00 ShannonS00 self-assigned this Mar 10, 2026
@ShannonS00 ShannonS00 added the effects Related to a ScopeSim effect label Mar 10, 2026
@codecov
Copy link

codecov bot commented Mar 10, 2026

Codecov Report

❌ Patch coverage is 79.41176% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.86%. Comparing base (02976b3) to head (be4928b).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
scopesim/effects/electronic/noise.py 79.41% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #886      +/-   ##
==========================================
+ Coverage   74.82%   74.86%   +0.03%     
==========================================
  Files          69       69              
  Lines        8869     8903      +34     
==========================================
+ Hits         6636     6665      +29     
- Misses       2233     2238       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@teutoburg teutoburg moved this to 🏗 In progress in ScopeSim-development Mar 10, 2026
@teutoburg
Copy link
Contributor

Please add:

  • A more meaningful title (PR titles are part of the documentation as they become changelog entries)
  • Some unit tests to to verify that this is doing what it should (or indeed runs at all)

I'm drafting this in the meantime...

@teutoburg teutoburg marked this pull request as draft March 10, 2026 18:13
@teutoburg teutoburg added the enhancement PR adding or improving a feature (use "Feature" type for issues (requests), not this label) label Mar 10, 2026
@teutoburg
Copy link
Contributor

Would this fully close your #885?

@teutoburg teutoburg added the Pipeline dev. Technical target audience label Mar 11, 2026
@ShannonS00 ShannonS00 changed the title Shs/prnu ( #885) Add PixelResponseNonUniformity effect for fixed per-pixel gain variation (PRNU) ( #885) Mar 11, 2026
Simplify PixelResponseNonUniformity based on PR review

- Replace SeedSequence-based per-detector seeding with direct random_seed
- Rename seed parameter from random_seed to prnu_seed
- Remove default prnu_std (now must be defined in instrument package)
- Add 5 unit tests covering multiplicative behaviour, fixed pattern, dict mode
- Update all METIS detector YAMLs to use prnu_seed (in IRDB)
@teutoburg teutoburg linked an issue Mar 11, 2026 that may be closed by this pull request
@teutoburg teutoburg changed the title Add PixelResponseNonUniformity effect for fixed per-pixel gain variation (PRNU) ( #885) Add PixelResponseNonUniformity effect for fixed per-pixel gain variation (PRNU) Mar 11, 2026
@oczoske
Copy link
Collaborator

oczoske commented Mar 12, 2026

Ideas for further tests (to improve patch coverage):

  •    with pytest.raises(TypeError):
              PixelResponseNonUniformity(prnu_std="not a number nor a dict")
    
  • before an apply_to:
    with pytest.raises(RuntimeError):
             prnu.plot()
  • after an apply_to:
      assert isinstance(prnu.plot(), plt.Figure)

elif isinstance(prnu_std_meta, (int, float)):
prnu_std = float(prnu_std_meta)
else:
raise ValueError(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change to TypeError.

…ut and enhance test coverage for error handling and plotting
…onally assert plot creation based on PLOTS flag. (like in test_PSF.py)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effects Related to a ScopeSim effect enhancement PR adding or improving a feature (use "Feature" type for issues (requests), not this label) Pipeline dev. Technical target audience

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

Add PixelResponseNonUniformity (PRNU) detector effect

3 participants