Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## feature/diffusion-kernel #256 +/- ##
===========================================================
Coverage 100.00% 100.00%
===========================================================
Files 133 133
Lines 11553 11773 +220
===========================================================
+ Hits 11553 11773 +220
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
roytsmart
force-pushed
the
feature/diffusion-kernel
branch
from
October 13, 2026 17:29
73d0dc8 to
40dc0c4
Compare
roytsmart
force-pushed
the
feature/diffusion-covariance
branch
from
October 13, 2026 17:29
9e3a338 to
1ac8e1f
Compare
Charge diffusion spreads the electrons of each photon over several pixels, which correlates the noise of neighboring pixels. Under uniform illumination the covariance depends only on the offset between them. - AbstractDiffusionModel.kernel_pair: the probability that two electrons of the same photon are collected a given offset apart, from the pairs of Gaussians of the mixture. Its center is probability_same_pixel and it sums to one. _num_kernel sizes it from the separations of the pairs. - optika.sensors.covariance_signal: the covariance per absorbed photon. It is written as the variance without diffusion in the center plus a term that only moves variance between pixels, so its center is vmr_signal times the gain and its sum is the variance without diffusion at every wavelength. - kernel_covariance on the sensor materials and on AbstractImagingSensor, next to kernel and kernel_variance. The Monte Carlo test compares the covariance with flat fields simulated on a periodic grid at four offsets, to six times the standard error from the scatter between 64 frames. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BAw6Lv7Cy2ULGmsMJ4b1dE
- The docstrings of the kernels of pairs say that a default kernel of more than 101 pixels raises an error, and that of `covariance_signal` that a pixel of zero width turns off diffusion. - The tests check that zero-width pixels give the covariance without a model, and that the covariance of a model holding uncertain values is that of its nominal values and of each sample. - Every test function this PR adds or changes is annotated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BAw6Lv7Cy2ULGmsMJ4b1dE
roytsmart
force-pushed
the
feature/diffusion-kernel
branch
from
October 13, 2026 18:01
40dc0c4 to
60a2c44
Compare
roytsmart
force-pushed
the
feature/diffusion-covariance
branch
from
October 13, 2026 18:01
1ac8e1f to
3b44daa
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #255 (→ #251 → #244). Requested in #255 (comment) to model the correlated noise of Hinode/XRT.
What it adds
Charge diffusion spreads the electrons of each photon over several pixels, which correlates the noise of neighboring pixels. Under uniform illumination the covariance depends only on the offset between the two pixels. This PR computes it.
AbstractDiffusionModel.kernel_pair(depth, thickness_substrate, width_pixel, axis_x, axis_y, num=None)mixtureadded to Add SlabDiffusionModel, a model of diffusion across the field-free region #251. Given the two Gaussians the electrons are drawn from, their separation is Gaussian with variance vᵢ + vⱼ. Along each axis, a separation δ puts them Δ pixels apart with probability (1 − |δ − Δ|)₊, which is the same rule as a single electron. So each pair of Gaussians has the existing_kernel_1dwith variance vᵢ + vⱼ.probability_same_pixel, and it sums to one._num_kernel(..., pair=True)sizes it from the tails of the separations. For the slab model it is about √2 times as wide askernel: 13 pixels against 11 for 13 µm pixels.optika.sensors.covariance_signal(wavelength, *, axis_x, axis_y, ...)It gives the covariance per absorbed photon in e²/ph, as a
FunctionArrayover offsets. It is a sibling ofvmr_signalandkernel_signal.It is written as the undiffused variance at the center plus a term that only moves variance between pixels:
C_Δ = σ₀² δ_Δ0 + n̄(n̄ + 𝓕 − 1) ⟨(P_Δ − δ_Δ0) η²⟩
Here σ₀² is
vmr_signal(diffusion=None)× iqy × cce.So its center equals
vmr_signal× iqy × cce exactly, and its sum equals the undiffused variance, at every wavelength from 1 to 7000 Å. Writing C_Δ directly as n̄⟨η⟩δ + n̄(n̄+𝓕−1)⟨P_Δ η²⟩ would mixvmr_signal's infinite substrate with the truncated depth average, and would only match between about 20 and 5000 Å.kernel_covarianceAbstractSensorMaterial(abstract),IdealSensorMaterial(a single pixel of 1 e²/ph),AbstractBackIlluminatedSiliconSensorMaterialandAbstractImagingSensor, next tokernelandkernel_variance.kernel_varianceequals the center ofkernel_covariance.kernel_variance's docstring now says the two differ.The docstring example plots the correlation coefficients for a CCD97 with 16 µm pixels at 304 Å: 0.239 side by side and 0.084 diagonally.
Checks
kernel_pair:probability_same_pixelto 2e-16.covariance_signal:vmr_signal× iqy × cce to 8e-16 from 1 to 7000 Å.cce_backsurface = 0.2.optika/sensorsandoptika/systems/_linear_test.pylocally. Patch coverage is 211/211, measured locally.Not in scope
exposeand its uncertainty are unchanged.Like the rest of the stack, this stays off main until the 4.0 release is decided.
🤖 Generated with Claude Code
https://claude.ai/code/session_01BAw6Lv7Cy2ULGmsMJ4b1dE