Skip to content

Add a large scale illumination effect #898

Draft
ShannonS00 wants to merge 2 commits intoAstarVienna:mainfrom
ShannonS00:shs/illumination
Draft

Add a large scale illumination effect #898
ShannonS00 wants to merge 2 commits intoAstarVienna:mainfrom
ShannonS00:shs/illumination

Conversation

@ShannonS00
Copy link
Copy Markdown
Contributor

  • New effect in effects/illumination.py that applies large-scale illumination variation (e.g. vignetting) to the image plane

2 Build in callable models:

  1. _gaussian2d (normalised 2D elliptical Gaussian)
  2. poly_vignetting (asymmetric polynomial with direct falloff control).
  • Own model input possible
    Example:

    def my_model(xx, yy, slope=-0.001):
           return np.clip(1 + slope * np.sqrt(xx**2 + yy**2), 0, None)
    
       eff = Illumination(model=my_model, modelargs={"slope": -0.0005})
    
  • can be included via !DET.include_illumination

Included Tests in scopesim/tests/tests_effects/test_illumination.py

…D elliptical Gaussian.

, 2. Asymmetric polynomial vignetting with direct falloff control.
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 2, 2026

Codecov Report

❌ Patch coverage is 86.79245% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.83%. Comparing base (be4928b) to head (910b31f).
⚠️ Report is 33 commits behind head on main.

Files with missing lines Patch % Lines
scopesim/effects/illumination.py 86.53% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #898      +/-   ##
==========================================
- Coverage   74.86%   74.83%   -0.03%     
==========================================
  Files          69       70       +1     
  Lines        8903     8989      +86     
==========================================
+ Hits         6665     6727      +62     
- Misses       2238     2262      +24     

☔ 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 Apr 2, 2026
@oczoske oczoske linked an issue Apr 3, 2026 that may be closed by this pull request
__all__ = ["Illumination", "gaussian2d", "poly_vignetting"]


def gaussian2d(xx, yy, amp=1.0, mu=(0.0, 0.0), sigma=(2000.0, 2000.0)):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't like xx and yy very much here - maybe just pass obj (or obj.hdu.data or even obj.hdu.data.shape) and build xx and yy inside if and as needed? But opinions may differ.

"""
dx = xx - mu[0]
dy = yy - mu[1]
return amp * np.exp(-(dx**2 / (2 * sigma[0]**2) + dy**2 / (2 * sigma[1]**2)))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could use astropy.modeling.functional_models.Gaussian2D here. That has the advantage that a possible rotation is already built in.

sigma : tuple of float
(sx, sy) Gaussian widths in pixels.
"""
dx = xx - mu[0]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Beware of assigning too many arrays - each of these has 2048 x 2048 pixels (and if we want to use if for MICADO 12k x 12k ...).

sy = np.where(dy >= 0, stretch[2], stretch[3])
r2 = (dx / sx)**2 + (dy / sy)**2
if r_ref is None:
r_ref = np.sqrt(r2.max())
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The sqrt seems superfluous as it's immediatly re-squared, but it's only a number, so just an aesthetical matter. The alternative might be

if r_ref is None:
    r2_ref = r2.max()
else:
    r2_ref = r_ref**2


def poly_vignetting(xx, yy, max_falloff=0.01, r_ref=None, mu=(0.0, 0.0),
stretch=(1.0, 1.0, 1.0, 1.0)):
"""Asymmetric polynomial vignetting with direct falloff control.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just quadratic, right?

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

Labels

None yet

Projects

Status: 🏗 In progress

Development

Successfully merging this pull request may close these issues.

Add large scale Illumination effect / Vignetting

3 participants