Commit 2c6751b8 authored by Andrey Filippov's avatar Andrey Filippov
Browse files

CLAUDE: pose stage non-exclusive with the render product (pose = part of the RT cycle)



Andrey's ruling: the pose stage normally ALWAYS runs (it is part of the RT
cycle, not a mutually-exclusive test) - the last run had rend_test ON which
silently skipped the pose stage (old precedence) and left TILE-CALIB unbuilt.
Now: pose_test runs FIRST, rend_test render follows when also ON, cond_test
stays standalone (only when nothing else ran). Dialog/tooltips updated
('CUAS RT render (full product)').

Verified meanwhile (POSE-11 renders): frozen per-sequence DC cut the
RT-RENDER horizon wobble 234 -> 42.4 counts pk-pk (5.5x), exactly to the
oracle DBG floor - the residual at 1-rev period is the shared FPN ghost;
FPN.tiff still Jun-1 vintage because cuas_calc_fpn was OFF (the '(Re)calculate
FPN' checkbox) - the rot_period=164.9 recompute has not actually run yet.

Co-Authored-By: default avatarClaude Fable 5 <noreply@anthropic.com>
parent 689efd90
Loading
Loading
Loading
Loading
+34 −28
Original line number Diff line number Diff line
@@ -45,9 +45,11 @@ import ij.ImagePlus;
 * Top-level flow (keep {@link #run} READABLE - it is the map of the RT mode):
 *   1. INITIALIZATION - transform the borrowed data (center ingest, per-scene
 *      instances) and fix missing calibration (per-sensor photometric).
 *   2. DIAGNOSTICS  - optional exclusive test modes (rend_test / pose_test /
 *      cond_test). They REPLACE the production run and return; they must never
 *      leak into the production flow nor grow the top method.
 *   2. DIAGNOSTICS  - optional test/prototype stages (pose_test / rend_test /
 *      cond_test). The POSE stage is part of the RT cycle and normally always
 *      runs (Andrey 07/06/2026); the render product follows it when enabled;
 *      cond_test is standalone. They replace the production detection and
 *      return; they must never leak into the production flow nor grow the top.
 *   3. PRODUCTION   - the per-input(scene) processing loop and target detection.
 *      MVP target shape: for each input scene, a multi-threaded read of the 16
 *      sensor /jp4/*.tiff (or their hardware-stream equivalents later) ->
@@ -330,45 +332,49 @@ public class CuasRT {
	}

	/**
	 * Optional EXCLUSIVE diagnostic modes - each replaces the production run. Precedence
	 * (unchanged from the OpticalFlow inline era): rend_test > pose_test > cond_test.
	 * Keep new tests HERE - the production path and the top method must not grow.
	 * @return true if a diagnostic ran (caller returns without production processing).
	 * Optional diagnostic/prototype stages. NOT mutually exclusive anymore (Andrey
	 * 07/06/2026): the POSE stage is part of the RT cycle and normally ALWAYS runs
	 * (checkbox retained until the production loop consumes the poses directly); the
	 * render product runs AFTER it when also enabled. cond_test remains a standalone
	 * diagnostic (runs only when nothing else did). Keep new tests HERE - the
	 * production path and the top method must not grow.
	 * @return true if any stage ran (caller returns without production detection).
	 */
	private static boolean diagnostics(
			final CLTParameters clt_parameters,
			final QuadCLT       master_CLT,
			final QuadCLT []    quadCLTs,
			final int           debugLevel) {
		if (clt_parameters.curt.rend_test) {
			// MINIMAL RT ingest+render certification: per scene raw /jp4/ ->
			// conditionSceneToGpu -> virtual-grid render at BORROWED stored pose + ERS
			// rates -> -CUAS-RT-RENDER hyperstack, comparable slice-by-slice to the
			// -CUAS-INDIVIDUAL/MERGED-CUAS-DBG oracle products. Certify/debug THIS chain
			// first, only then the pose test (Andrey 07/05/2026). By Claude on 07/05/2026.
			System.out.println("===== CUAS RT render test (curt_rend_test): ingest+render sequence vs oracle DBG =====");
			CuasRender.testRenderSequence(
		boolean ran = false;
		if (clt_parameters.curt.pose_test) {
			// The POSE stage (part of the RT cycle): re-generate per-scene 3-angle poses
			// against the virtual-center reference, ascending, prediction-seeded, single
			// pass on the final combo DSI. Output: -POSE-RT-TEST.csv + fitted-vs-stored
			// summary (truth = scenes_poses restored from INTERFRAME corr-xml).
			// By Claude on 07/03/2026, from Andrey's design.
			System.out.println("===== CUAS RT pose stage (curt_pose_test): per-scene 3-angle fit vs virtual center =====");
			CuasPoseRT.testPoseSequence(
					clt_parameters, // CLTParameters clt_parameters,
					master_CLT,     // QuadCLT       center_CLT,
					quadCLTs,       // QuadCLT []    quadCLTs,
					debugLevel);    // int           debugLevel
			return true;
			ran = true;
		}
		if (clt_parameters.curt.pose_test) {
			// RT pose-adjustment prototype: re-generate per-scene 3-angle poses against the
			// virtual-center reference, ascending, prediction-seeded, single pass on the
			// final combo DSI. Output: -POSE-RT-TEST.csv + fitted-vs-stored summary (truth =
			// scenes_poses restored from INTERFRAME corr-xml). By Claude on 07/03/2026,
			// from Andrey's design.
			System.out.println("===== CUAS RT pose test (curt_pose_test): per-scene 3-angle fit vs virtual center =====");
			CuasPoseRT.testPoseSequence(
		if (clt_parameters.curt.rend_test) {
			// Full-render product (after the pose stage when both are ON): per scene raw
			// /jp4/ -> conditionSceneToGpu -> virtual-grid render at BORROWED stored pose +
			// ERS rates -> -CUAS-RT-RENDER hyperstack, comparable slice-by-slice to the
			// -CUAS-INDIVIDUAL/MERGED-CUAS-DBG oracle products. By Claude on 07/05/2026,
			// non-exclusive per Andrey 07/06/2026.
			System.out.println("===== CUAS RT render (curt_rend_test): ingest+render sequence vs oracle DBG =====");
			CuasRender.testRenderSequence(
					clt_parameters, // CLTParameters clt_parameters,
					master_CLT,     // QuadCLT       center_CLT,
					quadCLTs,       // QuadCLT []    quadCLTs,
					debugLevel);    // int           debugLevel
			return true;
			ran = true;
		}
		if (clt_parameters.curt.cond_test) {
		if (!ran && clt_parameters.curt.cond_test) {
			// Conditioning/calibration diagnostic: raw /jp4/ baseline (no photometric/FPN/
			// conditioning), saved as -CUAS-PERSENSOR-RAW for side-by-side compare with the
			// conditioned -CUAS-PERSENSOR (saved by the calibration step when curt.calib is
@@ -392,9 +398,9 @@ public class CuasRT {
					master_CLT.getGPUQuad(), // GpuQuad with the current 16-sensor TD
					master_CLT,              // debug-stack save target (-CUAS-TDAVG-CHECK)
					debugLevel);
			return true;
			ran = true;
		}
		return false;
		return ran;
	}

	/**
+3 −3
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ public class CuasRtParameters {
	public boolean  pose_corr_save =  false; // DEBUG: save the per-scene 2D correlations vs the virtual center in the pixel domain (-POSE-RT-CORR2D: z=scenes, tile grid of 16x16 cells, last LMA cycle) - lean engine only. // By Claude on 07/04/2026
	public boolean  pose_img_save =   false; // DEBUG: save the composite scenes actually correlated - imclt render of the consolidated 16-sensor TD average at the converged pose (-POSE-RT-COMPOSITE: z=scenes; NaN outside task tiles) + the virtual-center reference render (-POSE-RT-CENTER-REF). Lean engine only. // By Claude on 07/04/2026
	public boolean  pose_stored =     false; // DEBUG: decouple rendering/measurement from the LMA - use the STORED (oracle vintage) pose for every scene, no adjustment; one leanMeasure per scene feeds -POSE-RT-HYPER/-CORR2D/-COMPOSITE. The composite must then match the oracle CUAS-MERGED-CUAS-DBG renders tile-for-tile. Lean engine only. // By Claude on 07/04/2026
	public boolean  rend_test =       false; // MINIMAL RT ingest+render test (CuasRender.testRenderSequence, takes precedence over pose test): per scene raw /jp4/ -> conditionSceneToGpu -> virtual-grid render at BORROWED stored pose+ERS rates -> -CUAS-RT-RENDER hyperstack [s00..s15, merged][scenes], comparable to -CUAS-INDIVIDUAL/MERGED-CUAS-DBG. Certify THIS before the pose test. // By Claude on 07/05/2026
	public boolean  rend_test =       false; // RT full-render product (CuasRender.testRenderSequence): per scene raw /jp4/ -> conditionSceneToGpu -> virtual-grid render at BORROWED stored pose+ERS rates -> -CUAS-RT-RENDER hyperstack [s00..s15, merged][scenes], comparable to -CUAS-INDIVIDUAL/MERGED-CUAS-DBG. NON-exclusive: runs AFTER the pose stage when both are ON (the pose stage is part of the RT cycle - Andrey 07/06/2026). // By Claude on 07/05/2026
	public boolean  dbg_fpixels =     true;  // save the ORACLE debug renders during ingest (prepareFpixels): -CUAS-INDIVIDUAL-CUAS-DBG (an EXTRA per-sensor render pass, ~11GB) + -CUAS-MERGED-CUAS-DBG (save only - the merged render is the production input regardless). Was hardcoded. Turn OFF to save the render time and disk once the RT chain (-CUAS-RT-RENDER) is the trusted full render. // By Claude on 07/05/2026
	public double   fz_inter =        10000.0; // RT fat zero, INTER (pose/motion: scene x virtual-center correlation). DECOUPLED from the legacy gpu_fatz*/AUX switches (which stay untouched for non-RT/FOPEN). Value is for a single physical-pair amplitude; FZ ~ amplitude^2 in the GPU normalize - scale down x4..x16 for consolidated-average applications as needed. 10000 = the proven oracle INTER operating point (the lean code erroneously used the INTRA value before). // By Claude on 07/05/2026
	public double   fz_intra =        2000.0; // RT fat zero, INTRA (ranging/disparity: sensor-pair correlations within one scene). Reserved for the RT ranging path; same decoupling/scaling notes as fz_inter. // By Claude on 07/05/2026
@@ -114,8 +114,8 @@ public class CuasRtParameters {
				"DEBUG: save the rendered composite (TD-averaged, grid-transformed) scenes correlated against the virtual center (-POSE-RT-COMPOSITE, z=scenes) + the center reference render (-POSE-RT-CENTER-REF). Lean engine only.");
		gd.addCheckbox ("Pose test stored poses (no LMA)",           this.pose_stored, // By Claude on 07/04/2026
				"DEBUG: measure/render every scene at its STORED pose, skip the LMA entirely - decouples the task/render/correlation chain from the solver. Lean engine only.");
		gd.addCheckbox ("CUAS RT render test (ingest+render)",       this.rend_test, // By Claude on 07/05/2026
				"MINIMAL standalone test (precedence over pose test): raw jp4 -> conditioning -> virtual-grid render at borrowed stored poses/ERS; saves -CUAS-RT-RENDER [s00..s15+merged][scenes] to compare against the -CUAS-*-DBG oracle products.");
		gd.addCheckbox ("CUAS RT render (full product)",             this.rend_test, // By Claude on 07/05/2026
				"Full RT-chain render: raw jp4 -> conditioning -> virtual-grid render at borrowed stored poses/ERS; saves -CUAS-RT-RENDER [s00..s15+merged][scenes], comparable to the -CUAS-*-DBG oracle products. NON-exclusive: runs AFTER the pose stage when both are ON.");
		gd.addCheckbox ("Save oracle DBG renders (11GB)",            this.dbg_fpixels, // By Claude on 07/05/2026
				"Save -CUAS-INDIVIDUAL-CUAS-DBG (an EXTRA per-sensor render pass, ~11GB) and -CUAS-MERGED-CUAS-DBG during ingest. Turn OFF to save render time and disk once -CUAS-RT-RENDER (RT render test) is the trusted full render.");
		gd.addNumericField("RT fat zero INTER (pose/motion)",        this.fz_inter, 1,9,"", // By Claude on 07/05/2026