Skip to content

Let the sampling of the field and the pupil be seeded - #220

Merged
roytsmart merged 1 commit into
mainfrom
feature/area-effective-seed
Sep 2, 2026
Merged

Let the sampling of the field and the pupil be seeded#220
roytsmart merged 1 commit into
mainfrom
feature/area-effective-seed

Conversation

@roytsmart

Copy link
Copy Markdown
Collaborator

area_effective samples the field and the pupil at a point drawn inside each cell rather than at its center, which is what #219 established: it keeps the quadrature from aliasing against an edge which falls between samples. Nothing could fix that sampling, so nothing computed through it could be reproduced.

Two calls on the ESIS model, nothing changed between them:

no seed          peaks 0.018716  0.018704   identical: False

About two percent apart, which is the same size as the effect #219 was measured against. An article which draws that curve draws a different one every time it is built, and a count rate computed from it moves with it.

With a seed

same seed        peaks 0.018696  0.018696   identical: True
different seed   peaks 0.018696  0.018642   identical: False

Two streams, not one

The field and the pupil are drawn from two seeds derived from the given one with SeedSequence, rather than both from the seed itself. Sharing it would offset a field cell and a pupil cell by the same fraction wherever the two grids agreed in shape — the same failure as giving every axis of one grid the same offset, which puts each sample on the diagonal of its cell instead of inside it. named-arrays guards the second case; this guards the first.

The default

None, so the sampling draws as it does today and nothing computed now moves.

The alternative is a fixed default, which would make every result reproducible without being asked. That is arguably what this should be — the randomness is a quadrature technique rather than anything physical, and a user who wants a different realization can say so. It would shift every existing result once, by about the two percent above, so I have not made that choice here. Worth deciding deliberately.

Requires

named-arrays~=2.9, which added the seed parameter to cell_centers (sun-data/named-arrays#230).

The field and the pupil are sampled at a point drawn inside each cell
rather than at its center, which is what keeps the quadrature from
aliasing against an edge that falls between samples. Nothing could fix
that sampling, so nothing computed through it could be reproduced. Two
calls to `area_effective` on the ESIS model, with nothing changed between
them, gave effective areas about two percent apart, and an article which
draws that curve drew a different one every time it was built.

`area_effective` takes a seed, as does the sampling behind `image`, whose
noise comes from the same draw.

The field and the pupil are drawn from two streams derived from that one
seed rather than from the seed itself. A seed shared between them would
offset a field cell and a pupil cell by the same fraction wherever the
two grids agreed in shape, which is not a sample of anything.

The default is to draw as before, so nothing computed today moves. A
caller who wants an answer twice now has a way of asking for it.
@codecov

codecov Bot commented Sep 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (60a7344) to head (b6c6696).

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #220   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          121       121           
  Lines         7491      7500    +9     
=========================================
+ Hits          7491      7500    +9     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 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.

@roytsmart
roytsmart merged commit f2acf0b into main Sep 2, 2026
12 checks passed
@roytsmart
roytsmart deleted the feature/area-effective-seed branch September 2, 2026 19:19
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