Add a large scale illumination effect #898
Add a large scale illumination effect #898ShannonS00 wants to merge 2 commits intoAstarVienna:mainfrom
Conversation
…D elliptical Gaussian. , 2. Asymmetric polynomial vignetting with direct falloff control.
Codecov Report❌ Patch coverage is
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. 🚀 New features to boost your workflow:
|
| __all__ = ["Illumination", "gaussian2d", "poly_vignetting"] | ||
|
|
||
|
|
||
| def gaussian2d(xx, yy, amp=1.0, mu=(0.0, 0.0), sigma=(2000.0, 2000.0)): |
There was a problem hiding this comment.
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))) |
There was a problem hiding this comment.
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] |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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. |
2 Build in callable models:
Own model input possible
Example:
can be included via
!DET.include_illuminationIncluded Tests in scopesim/tests/tests_effects/test_illumination.py