Skip to content

Add where_sensor, the pixels of its sensor which an instrument models - #56

Merged
roytsmart merged 2 commits into
mainfrom
feature/where-sensor
Dec 3, 2026
Merged

roytsmart merged 2 commits into
mainfrom
feature/where-sensor

Conversation

@roytsmart

@roytsmart roytsmart commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

ESIS leaves some pixels of each sensor out of its Level-4 fit, and ctis had no way to leave a pixel out of an inversion. This adds one: where_sensor, the pixels of its sensor which an instrument models.

Why

The mask over the storage region of each ESIS sensor shades a strip of active columns, which the optical model does not include. Left in the fit, those columns draw lines through the scene, as the first look at frame 15 found (#55). Tempest removed their weights, and those of a border of 4 pixels, before inverting. This is the ctis half of that; esis measures the pixels and passes the mask in M8.

What changes

  • where_sensor, an abstract property on AbstractInstrument and a field on IdealInstrument and OptikaInstrument, None by default for every pixel. It is a named array of booleans with the two axes of the sensor and, if it differs between channels, those of the channels. A mask is refused if it has any other axis or another length, if it is not a named array of booleans, or if it leaves out every pixel of a channel, where an inversion would have nothing to fit and MART could never converge.
  • In a pixel the instrument does not model:
    • image() gives zero, with an uncertainty of zero, with or without noise, integrated along wavelength or not;
    • backproject() takes nothing, whatever the images hold there, not a number included;
    • snr() counts nothing.
  • Around the matrices, not in them. The plan in Add the pixels which ESIS leaves out of the fit to the MART roadmap #53 was to zero the entries of those pixels in every block of weights. The mask is applied around the matrices instead: the images and their variance are zeroed there after the forward product, and the images before the backprojection.
    • The results are the same, bit for bit, since adding zeros does not change a sum.
    • The weights and the build are untouched, and not a number in the data is harmless.
    • Assigning another mask keeps the matrices and the factors around them, and the operators keep a copy of the mask of their own.
  • MartInverter:
    • the mean chi squared needed no change, since both of its paths already leave out a pixel whose noise has no variance;
    • the correlation of the residual now leaves those pixels out too: through a new optional argument, where, of ctis.inverters.merit.correlation_residual, which AbstractIterativeInverter.correlation_residual passes the mask to, and through the compiled merit of the iteration on the matrices.

Checked

  • The whole suite passes locally (716 tests), black and ruff are clean, and every changed line of the package is covered.
  • New tests, for both instruments where they apply:
    • the images and their uncertainty are zero where the instrument does not model the sensor, and elsewhere the same as without a mask;
    • not a number there backprojects as zero does;
    • snr() leaves those pixels out;
    • a mask of every pixel gives the results of no mask, bit for bit;
    • an invalid mask is refused by image(), backproject() and snr(), and one which leaves out every pixel of a channel by MartInverter too;
    • assigning a mask keeps the matrices and the factors around them, and the operators keep a copy of it, which does not change if the mask is changed in place;
    • the compiled kernels skip those pixels.
  • MartInverter with a mask takes the same path to the same solution on the matrices as on the methods of the instrument, for an IdealInstrument and an OptikaInstrument, and the same, bit for bit, whether the images hold zero, not a number or 1e30 where the instrument does not model the sensor.

Notes:

  • The roadmap's text on leaving pixels out is in Add the pixels which ESIS leaves out of the fit to the MART roadmap #53, which still describes zeroing the entries in each block and says that M6 must hand each block of weights to its caller. Neither is needed now. This PR does not touch the roadmap.
  • The width of the shadow on each sensor, and so the mask itself, is for esis to measure (M8).
  • The second commit follows a review of the first. It refuses a mask which leaves out a whole channel, which kept MART from converging, and makes the operators keep a copy of the mask, which they shared memory with.

🤖 Generated with Claude Code

https://claude.ai/code/session_01StcJvVHMXbjJmyFFwf4Pcn

An instrument can now leave pixels of its sensor out of its model, such
as the shadow of the storage mask on each sensor of ESIS. Its images are
zero there, with no noise, its backprojection takes nothing from them,
whatever they hold, and MART leaves them out of the mean chi squared and
of the correlation of the residual, which takes a `where` argument for
it. The mask is applied around the matrices of the instrument, so
assigning another does not assemble them again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StcJvVHMXbjJmyFFwf4Pcn
@codecov

codecov Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (dd10b61) to head (7e41b71).

Additional details and impacted files
@@            Coverage Diff             @@
##              main       #56    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           29        29            
  Lines         4655      4997   +342     
==========================================
+ Hits          4655      4997   +342     
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.

A mask which left out every pixel of a channel gave that channel no
merit, so MART could never converge. Such a mask is now refused, by
every method which takes it. The operators keep a copy of the mask, so
that changing it in place no longer changes them halfway, and so that
the compiled code is compiled once for every mask. Assigning only a new
mask keeps the factors around the matrices, as well as the matrices. A
plain array, whose axes have no names, is refused with an error which
says so, and the masks of the tests are built with named arrays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StcJvVHMXbjJmyFFwf4Pcn
@roytsmart
roytsmart merged commit 9c79903 into main Dec 3, 2026
12 checks passed
@roytsmart
roytsmart deleted the feature/where-sensor branch December 3, 2026 21:25
roytsmart added a commit that referenced this pull request Dec 3, 2026
#56 merged, so the roadmap now says how pixels are left out of the
fit: an instrument names the pixels of its sensor which it models, and
the mask is applied around the matrices instead of by zeroing the
weights of each block. A design bullet takes over the account of the
shadow of the storage mask from #53, corrected to the mechanism as
built, and the table of where things stand gains a row for #56. M8
brings the shadow and the border of 4 pixels, which esis measures, and
a new risk says that the widths of the shadow need measuring again.
The section on frame 15 no longer says that ctis cannot leave pixels
out.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StcJvVHMXbjJmyFFwf4Pcn
roytsmart added a commit that referenced this pull request Dec 3, 2026
Frame 15 of the ESIS flight has been inverted on the host at
production size, with the seven spectral lines of the model of tempest
untied, and the roadmap now says what that showed, in a new section,
"Frame 15 on the host".

Of the model: the four channels differ in throughput by up to half, as
tempest found; the scene holds a fifth to two fifths of the radiance of
the FITS files of tempest; the support of tempest reaches past the
field stop of today's model; the images hold light beyond the edges of
the field which the model lacks, so both inversions come out red along
the edges; a smooth mismatch across each image changes no Doppler
shift; the shadow of the storage mask, left in the fit, leaves lines in
the scene; and the mean chi squared of a channel counts its blank
pixels.

Of the Doppler shifts, also on synthetic frames whose O V moves as the
quiet Sun seen by SUMER: the first update of MART leaves a ghost, red
below every bright feature and blue above it, whose strength the width
of the first guess sets; stopping at the mean chi squared of tempest
stops inside it; and MART recovers a third to a half of a Doppler shift
over 3 arcsec, a fifth to a third over 12, and nothing of its mean over
the field. The centroid reads a Doppler shift best.

M8 now also brings over the thermal widths of the first guess of
tempest, a normalization of each channel of each frame and its stopping
rule, and cuts the support to the field stop of its model. The time of
the 30 frames on the host uses the 558 iterations tempest recorded, the
comparison of the loops no longer says that they differ in exponent,
which is out of date since #42, and four new risks cover the recovery
of Doppler shifts, the light which the model lacks, the radiance of the
distributed product and the throughput of each channel.

The roadmap also records `where_sensor` (#56): a row in the table of
where things stand, and a design bullet which takes over the account of
the shadow of the storage mask from #53, with the mask applied around
the matrices, as built. M8 brings the shadow and a border of 4 pixels,
which esis measures, and a new risk says that the widths of the shadow
need measuring again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01StcJvVHMXbjJmyFFwf4Pcn
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