Repository navigation
Issue-223: Add the single-frame limit and the should-be-seen sort - #242
Open
ronisahajoo wants to merge 1 commit into
Open
ronisahajoo wants to merge 1 commit into
ronisahajoo wants to merge 1 commit into
Conversation
H4 audit stages A2 and A3 (A22.9.4): - limits.py: 5-sigma point-source limit at a spot from VARIANCE and the PSF (QR2 PSF cube or QR3/DR1 EPSF table), as an AB magnitude at the WCS-WAVE wavelength; a flagged spot or missing input gives a reason. - Sort each (rock, frame) pair into should_be_seen, marginal or too_faint, and list the rocks too faint in every frame. - Record the choices in Q-532 and the open [verify] items in A14.1. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ronisahajoo
requested review from
JoottunAtish,
KevinYerkiah and
MintHerbs
as code owners
December 1, 2026 12:02
3 tasks
JoottunAtish
approved these changes
Dec 1, 2026
JoottunAtish
left a comment
Contributor
There was a problem hiding this comment.
Nice work. The PR does what #223 asks and nothing more. The maths is right, it refuses instead of guessing wherever it should, and the docs, decisions and UML are updated together. CI is green, and test_area_limits.py passes locally (35 passed). Approving.
What I checked:
- Done when:
- The synthetic limit matches the analytic 5σ value within 0.01 mag for both
PSFandEPSFat four pixel phases, and a seeded noise test checks it against a real PSF fit. - The sort returns the three classes and the list of rocks too faint everywhere, and it is order-independent.
- The V1 row is updated.
- The synthetic limit matches the analytic 5σ value within 0.01 mag for both
- Data first: the limit comes from VARIANCE, the PSF and the WCS; 5σ and 3σ are recipe thresholds.
- Provenance:
FrameLimitisderived; the predictions and the sort aremodel_dependent. - Refusal: there are 11
NoLimitreasons, an unsortable pair keeps its reason, and a bad QR1/QR2 header is refused. - IDs: this PR takes Q-532, so nothing collides with #238 (Q-530) or #239 (Q-531).
Nits (non-blocking, fine as a follow-up)
- Thresholds and the gate hash (
backend/app/core/area/limits.py:96-98).LimitConfigstays out ofparams_hash, butsnr_limitandsnr_marginalchange the sort that the H4 gate reads. Under R-34, a threshold change must re-run the gate. Record in Q-532 that these thresholds go into the gate's input hash (or the run's method), so HN-5 wires it in. - Is the QR2
PSFcube optical? (limits.py:231-262, Q-532 point 3). The code integrates the cube over each pixel. If IRSA's cube is already pixel-integrated, the pixel is counted twice and the limit comes out too shallow. Cite where IRSA says it is optical, or add a [verify]. - Magnitude systems in A22.9.4. Say whether the inferred 18.8–19.2 figure is V, Vega or AB. At 1–5 µm the AB−Vega offset is 1 to 3 mag, which alone could explain the gap from the measured 18.2–18.4. The 8925 Boattini line ("V 17.4, about 1.5 mag above the single-frame limit") also mixes V with this limit.
- Unchecked WCS shortcut (
limits.py:271-276). The detector position assumesCRVAL1A/CRVAL2A= 0 andCDELT1A/CDELT2A= 1. That holds in every cached fixture, but a cheap check that refuses withpsf_zonewhen they differ would close the gap. - Zone-centre check (
limits.py:251). The x-fastest check needs zone centres that match exactly along a row, so a tiny float difference inYCTR_nwould refuse a good header. It fails safe; add a tolerance or a comment. no_limit:<reason>looks like a hunt code (limits.py:79,416). When HN-5 puts these intomissing, they must go through #239'scodes.pybuilders and the shared words file (Q-477), not be emitted raw. A separatelimit_reasonfield onSortedPairwould avoid the confusion.SortedPaircould also carryexpected_snrdirectly, to feed #238's row field.- Status word for Q-532. It is "Open (built)" in the index and the topic file, but "(Proposed, Q-532)" in the A22.9.4 A3 row. Use one.
- A3.1 is out of date (
docs/architecture/data-sources.md). AddEPSF/PSFto the "Extensions used" row. Also, keeping the 4 MBEPSFin the cache follows Q-20's code but goes against Q-20's size reason; flag it for Kevin before QR3 or DR1 runs fill the cache.
Merge note: this PR will conflict with #238 and #239 on the "Next free" line and the index rows in docs/decisions/README.md. Rebase whichever merges last. Q-532 still needs confirming, including the 3σ marginal bound.
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.
Closes #223
What this adds
H4 audit stages A2 and A3 (A22.9.4), in
backend/app/core/area/limits.py:VARIANCEand the PSF (QR2PSFcube, or QR3/DR1EPSFtable), as an AB magnitude at theWCS-WAVEwavelength. Taggedderived. A flagged spot or a missing input returns a reason, not a number.should_be_seen,marginalortoo_faintwith its margin, plus the rocks too faint in every frame. Taggedmodel_dependent.It is a library module: nothing calls it yet. A1, A4, the
join.pyfixes and the blind search are not touched.Testing
In
backend, offline:ruff check,ruff format --checkandmypypass.pytest: 1909 passed, 5 skipped (sky images not baked or mirrored locally), 0 failed.test_area_limits.py. Synthetic limits match the analytic value within 0.01 mag.Not run: a full docs link check and a Mermaid render of
docs/uml/04-package.md(the UML edit is text inside one label).Please check
marginalruns from 3σ to 5σ [verify] (the spec gives no bound).XCTR_n/YCTR_ncount from 1, and whether the archive's PSF header error shows in them.PSFis stripped, so the limit answerspsf_missinguntil HN-5 fetches cutouts with the PSF kept.🤖 Generated with Claude Code