Commit 808a4b20 authored by Vacaliuc, Bogdan's avatar Vacaliuc, Bogdan
Browse files

slides: add slide 3 — five silent MRR default disagreements



Row-per-tension table: ErrorWeightedBackground, CropFirstAndLastPoints,
RoundUpPixel, AcceptNullReflectivity, UseSANGLE. Five columns:
parameter, GUI value, autoreduce value, physics meaning, observable.

Each row calls out the specific resolution ("resolve to: False" etc.)
that the hack-a-thon needs to agree on, with a bottom-insight box
pointing at build_mrr_kwargs() as the structural fix.

Directly supports the "do I trust my numbers?" conversation that
scientists have been raising.

Co-Authored-By: default avatarClaude Opus 4.7 (1M context) <noreply@anthropic.com>
parent 7f308eb0
Loading
Loading
Loading
Loading
+304 KiB
Loading image diff...
+216 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1920 1080" width="1920" height="1080" font-family="Helvetica, Arial, sans-serif">
  <defs>
    <linearGradient id="headerGrad" x1="0" x2="0" y1="0" y2="1">
      <stop offset="0%" stop-color="#002E5D"/>
      <stop offset="100%" stop-color="#004B8D"/>
    </linearGradient>
    <filter id="softShadow" x="-10%" y="-10%" width="120%" height="120%">
      <feGaussianBlur in="SourceAlpha" stdDeviation="2"/>
      <feOffset dx="1" dy="2" result="offset"/>
      <feComponentTransfer><feFuncA type="linear" slope="0.18"/></feComponentTransfer>
      <feMerge><feMergeNode/><feMergeNode in="SourceGraphic"/></feMerge>
    </filter>
  </defs>

  <rect width="1920" height="1080" fill="#FAFAFA"/>

  <!-- Header -->
  <rect x="0" y="0" width="1920" height="100" fill="url(#headerGrad)"/>
  <text x="960" y="55" font-size="36" font-weight="700" fill="white" text-anchor="middle">Five Silent Default Disagreements in the MRR Call</text>
  <text x="960" y="85" font-size="18" fill="#B8D4E8" text-anchor="middle">Same algorithm, same input — two consumers pass different defaults for five parameters</text>

  <!-- Sub-heading -->
  <text x="40" y="140" font-size="17" fill="#2A2A2A">MagnetismReflectometryReduction has 53 properties.  For these five, quicknxsv2 (GUI) and mr_reduction (autoreduce)</text>
  <text x="40" y="163" font-size="17" fill="#2A2A2A">inherit <tspan font-weight="700">different effective defaults</tspan>, each of which has an observable effect on the final reflectivity or its failure mode.</text>

  <!-- Column headers -->
  <g>
    <rect x="40" y="195" width="285" height="55" rx="6" fill="#F5C13A" stroke="#A17B00" stroke-width="1.5"/>
    <text x="182" y="230" font-size="18" font-weight="700" fill="#3A2C00" text-anchor="middle">Parameter</text>

    <rect x="335" y="195" width="260" height="55" rx="6" fill="#4A90C2" stroke="#002E5D" stroke-width="1.5"/>
    <text x="465" y="222" font-size="16" font-weight="700" fill="white" text-anchor="middle">quicknxsv2 (GUI)</text>
    <text x="465" y="240" font-size="12" fill="#DCEEF8" text-anchor="middle">effective value</text>

    <rect x="605" y="195" width="260" height="55" rx="6" fill="#6DA64F" stroke="#1F5B1F" stroke-width="1.5"/>
    <text x="735" y="222" font-size="16" font-weight="700" fill="white" text-anchor="middle">mr_reduction (auto)</text>
    <text x="735" y="240" font-size="12" fill="#E2F1D9" text-anchor="middle">effective value</text>

    <rect x="875" y="195" width="480" height="55" rx="6" fill="#FEEADF" stroke="#8C3A00" stroke-width="1.5"/>
    <text x="1115" y="230" font-size="18" font-weight="700" fill="#8C3A00" text-anchor="middle">Physics / what the switch means</text>

    <rect x="1365" y="195" width="515" height="55" rx="6" fill="#E6F1E1" stroke="#1F5B1F" stroke-width="1.5"/>
    <text x="1622" y="230" font-size="18" font-weight="700" fill="#1F5B1F" text-anchor="middle">Observable — what a scientist sees</text>
  </g>

  <!-- Row 1: ErrorWeightedBackground -->
  <g>
    <rect x="40" y="260" width="285" height="120" rx="6" fill="#FFF8E7" stroke="#D2A000" stroke-width="1" filter="url(#softShadow)"/>
    <text x="60" y="295" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">ErrorWeighted</text>
    <text x="60" y="315" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">Background</text>
    <text x="60" y="347" font-size="13" fill="#3A2C00">Background averaging mode</text>
    <text x="60" y="365" font-size="13" fill="#3A2C00">inside RefRoi.</text>

    <rect x="335" y="260" width="260" height="120" rx="6" fill="#EEF7FB" stroke="#4A90C2" stroke-width="1"/>
    <text x="465" y="305" font-size="34" font-weight="700" fill="#002E5D" text-anchor="middle" font-family="monospace">False</text>
    <text x="465" y="345" font-size="12" fill="#1F3A5F" text-anchor="middle" font-style="italic">explicitly hardcoded</text>
    <text x="465" y="362" font-size="12" fill="#1F3A5F" text-anchor="middle">(uniform mean)</text>

    <rect x="605" y="260" width="260" height="120" rx="6" fill="#F0F7EE" stroke="#6DA64F" stroke-width="1"/>
    <text x="735" y="305" font-size="34" font-weight="700" fill="#1F5B1F" text-anchor="middle" font-family="monospace">True</text>
    <text x="735" y="345" font-size="12" fill="#1F3A1F" text-anchor="middle" font-style="italic">inherits MRR default</text>
    <text x="735" y="362" font-size="12" fill="#1F3A1F" text-anchor="middle">(1/σ² weighted)</text>

    <rect x="875" y="260" width="480" height="120" rx="6" fill="#FEF4EE" stroke="#E87722" stroke-width="1"/>
    <text x="895" y="287" font-size="13" fill="#3E2C00">Uniform mean: Y = Σy/N (Poisson-optimal for rate).</text>
    <text x="895" y="307" font-size="13" fill="#3E2C00">Inverse-variance mean: weighted by 1/σ² (≈1/Y for Poisson),</text>
    <text x="895" y="327" font-size="13" fill="#3E2C00">which biases toward <tspan font-weight="700">low-count bins</tspan> — exactly the wrong</text>
    <text x="895" y="347" font-size="13" fill="#3E2C00">direction for background estimation.</text>
    <text x="895" y="372" font-size="12" fill="#8C3A00" font-style="italic">See 10-mantid-algorithms-deep-dive.md §9a</text>

    <rect x="1365" y="260" width="515" height="120" rx="6" fill="#F3F9F0" stroke="#53A548" stroke-width="1"/>
    <text x="1385" y="287" font-size="13" fill="#1F3A1F">Background estimates differ by a few percent at low S/N.</text>
    <text x="1385" y="307" font-size="13" fill="#1F3A1F">R(Q) shifts at <tspan font-weight="700">high Q</tspan> — exactly where science calls are made.</text>
    <text x="1385" y="335" font-size="13" fill="#1F3A1F" font-weight="700">Who sees it: every autoreduce ↔ GUI comparison.</text>
    <text x="1385" y="365" font-size="12" fill="#53A548" font-style="italic">Resolve to: False (pick the Poisson-correct estimator).</text>
  </g>

  <!-- Row 2: CropFirstAndLastPoints -->
  <g>
    <rect x="40" y="395" width="285" height="120" rx="6" fill="#FFF8E7" stroke="#D2A000" stroke-width="1" filter="url(#softShadow)"/>
    <text x="60" y="430" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">CropFirstAnd</text>
    <text x="60" y="450" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">LastPoints</text>
    <text x="60" y="482" font-size="13" fill="#3A2C00">Edge-bin trimming on</text>
    <text x="60" y="500" font-size="13" fill="#3A2C00">the Q axis.</text>

    <rect x="335" y="395" width="260" height="120" rx="6" fill="#EEF7FB" stroke="#4A90C2" stroke-width="1"/>
    <text x="465" y="440" font-size="34" font-weight="700" fill="#002E5D" text-anchor="middle" font-family="monospace">False</text>
    <text x="465" y="480" font-size="12" fill="#1F3A5F" text-anchor="middle" font-style="italic">NexusData path, explicit</text>
    <text x="465" y="497" font-size="12" fill="#1F3A5F" text-anchor="middle">(CSD path inherits True)</text>

    <rect x="605" y="395" width="260" height="120" rx="6" fill="#F0F7EE" stroke="#6DA64F" stroke-width="1"/>
    <text x="735" y="440" font-size="34" font-weight="700" fill="#1F5B1F" text-anchor="middle" font-family="monospace">True</text>
    <text x="735" y="480" font-size="12" fill="#1F3A1F" text-anchor="middle" font-style="italic">inherits MRR default</text>

    <rect x="875" y="395" width="480" height="120" rx="6" fill="#FEF4EE" stroke="#E87722" stroke-width="1"/>
    <text x="895" y="422" font-size="13" fill="#3E2C00">First and last Q bins can have partial-bin statistics.</text>
    <text x="895" y="442" font-size="13" fill="#3E2C00">Cropping them is a safety margin; keeping them uses all data.</text>
    <text x="895" y="462" font-size="13" fill="#3E2C00"><tspan font-family="monospace" font-weight="700">CleanupBadData</tspan> already removes zero bins — cropping is a</text>
    <text x="895" y="482" font-size="13" fill="#3E2C00">second line of defense that may throw away real points.</text>

    <rect x="1365" y="395" width="515" height="120" rx="6" fill="#F3F9F0" stroke="#53A548" stroke-width="1"/>
    <text x="1385" y="422" font-size="13" fill="#1F3A1F">Q ranges differ by <tspan font-weight="700">2 bins at each end</tspan> between paths.</text>
    <text x="1385" y="442" font-size="13" fill="#1F3A1F">Auto-stitching overlap regions change → per-run scale factors</text>
    <text x="1385" y="462" font-size="13" fill="#1F3A1F">drift.</text>
    <text x="1385" y="485" font-size="13" fill="#1F3A1F" font-weight="700">Who sees it: anyone who stitches multi-run curves.</text>
    <text x="1385" y="505" font-size="12" fill="#53A548" font-style="italic">Resolve to: False (trust CleanupBadData + explicit range).</text>
  </g>

  <!-- Row 3: RoundUpPixel -->
  <g>
    <rect x="40" y="530" width="285" height="120" rx="6" fill="#FFF8E7" stroke="#D2A000" stroke-width="1" filter="url(#softShadow)"/>
    <text x="60" y="565" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">RoundUpPixel</text>
    <text x="60" y="600" font-size="13" fill="#3A2C00">Rounding of the fractional</text>
    <text x="60" y="618" font-size="13" fill="#3A2C00">specular pixel index in</text>
    <text x="60" y="636" font-size="13" fill="#3A2C00">constant-Q binning.</text>

    <rect x="335" y="530" width="260" height="120" rx="6" fill="#EEF7FB" stroke="#4A90C2" stroke-width="1"/>
    <text x="465" y="575" font-size="34" font-weight="700" fill="#002E5D" text-anchor="middle" font-family="monospace">False</text>
    <text x="465" y="615" font-size="12" fill="#1F3A5F" text-anchor="middle" font-style="italic">NexusData path, explicit</text>
    <text x="465" y="632" font-size="12" fill="#1F3A5F" text-anchor="middle">(fractional + 0.5 offset)</text>

    <rect x="605" y="530" width="260" height="120" rx="6" fill="#F0F7EE" stroke="#6DA64F" stroke-width="1"/>
    <text x="735" y="575" font-size="34" font-weight="700" fill="#1F5B1F" text-anchor="middle" font-family="monospace">True</text>
    <text x="735" y="615" font-size="12" fill="#1F3A1F" text-anchor="middle" font-style="italic">inherits MRR default</text>
    <text x="735" y="632" font-size="12" fill="#1F3A1F" text-anchor="middle">(round to integer)</text>

    <rect x="875" y="530" width="480" height="120" rx="6" fill="#FEF4EE" stroke="#E87722" stroke-width="1"/>
    <text x="895" y="558" font-size="13" fill="#3E2C00"><tspan font-family="monospace" font-weight="700">SpecularPixel</tspan> is typically fractional (e.g. 126.9).</text>
    <text x="895" y="578" font-size="13" fill="#3E2C00">Rounding shifts every θ_f by up to half a pixel, then through</text>
    <text x="895" y="598" font-size="13" fill="#3E2C00">the Q-binning formula to every Q value in the constant-Q path.</text>
    <text x="895" y="623" font-size="12" fill="#8C3A00" font-style="italic">Only matters when ConstantQBinning=True.</text>

    <rect x="1365" y="530" width="515" height="120" rx="6" fill="#F3F9F0" stroke="#53A548" stroke-width="1"/>
    <text x="1385" y="558" font-size="13" fill="#1F3A1F">θ shifts by ~0.3 pixel → ~0.003° for REF_M.</text>
    <text x="1385" y="578" font-size="13" fill="#1F3A1F">Measurable at high-Q for users running constant-Q reductions.</text>
    <text x="1385" y="603" font-size="13" fill="#1F3A1F" font-weight="700">Who sees it: constant-Q users (a minority today).</text>
    <text x="1385" y="630" font-size="12" fill="#53A548" font-style="italic">Resolve to: False (fractional-with-offset is physically right).</text>
  </g>

  <!-- Row 4: AcceptNullReflectivity -->
  <g>
    <rect x="40" y="665" width="285" height="120" rx="6" fill="#FFF8E7" stroke="#D2A000" stroke-width="1" filter="url(#softShadow)"/>
    <text x="60" y="700" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">AcceptNull</text>
    <text x="60" y="720" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">Reflectivity</text>
    <text x="60" y="753" font-size="13" fill="#3A2C00">What MRR does when a</text>
    <text x="60" y="771" font-size="13" fill="#3A2C00">cross-section sums to zero.</text>

    <rect x="335" y="665" width="260" height="120" rx="6" fill="#EEF7FB" stroke="#4A90C2" stroke-width="1"/>
    <text x="465" y="710" font-size="34" font-weight="700" fill="#002E5D" text-anchor="middle" font-family="monospace">True</text>
    <text x="465" y="745" font-size="12" fill="#1F3A5F" text-anchor="middle" font-style="italic">explicitly hardcoded</text>
    <text x="465" y="762" font-size="12" fill="#1F3A5F" text-anchor="middle">(accept zero R(Q))</text>

    <rect x="605" y="665" width="260" height="120" rx="6" fill="#F0F7EE" stroke="#6DA64F" stroke-width="1"/>
    <text x="735" y="710" font-size="34" font-weight="700" fill="#1F5B1F" text-anchor="middle" font-family="monospace">False</text>
    <text x="735" y="745" font-size="12" fill="#1F3A1F" text-anchor="middle" font-style="italic">inherits MRR default</text>
    <text x="735" y="762" font-size="12" fill="#1F3A1F" text-anchor="middle">(raise RuntimeError)</text>

    <rect x="875" y="665" width="480" height="120" rx="6" fill="#FEF4EE" stroke="#E87722" stroke-width="1"/>
    <text x="895" y="693" font-size="13" fill="#3E2C00">A symmetric polarized sample may have zero intensity on the</text>
    <text x="895" y="713" font-size="13" fill="#3E2C00">On-On cross-section — a <tspan font-weight="700">legitimate physical</tspan> result.</text>
    <text x="895" y="733" font-size="13" fill="#3E2C00">MRR's default treats it as an error and stops reduction.</text>
    <text x="895" y="758" font-size="12" fill="#8C3A00" font-style="italic">This is a failure-mode difference, not a numerical one.</text>

    <rect x="1365" y="665" width="515" height="120" rx="6" fill="#F3F9F0" stroke="#53A548" stroke-width="1"/>
    <text x="1385" y="693" font-size="13" fill="#1F3A1F">GUI: plots the zero curve, user moves on.</text>
    <text x="1385" y="713" font-size="13" fill="#1F3A1F">Autoreduce: raises, whole <tspan font-family="monospace">ReductionProcess</tspan> fails.</text>
    <text x="1385" y="740" font-size="13" fill="#1F3A1F" font-weight="700">Who sees it: scientists running polarized experiments.</text>
    <text x="1385" y="768" font-size="12" fill="#53A548" font-style="italic">Resolve to: True (accept; empty is a valid physical answer).</text>
  </g>

  <!-- Row 5: UseSANGLE -->
  <g>
    <rect x="40" y="800" width="285" height="125" rx="6" fill="#FFF8E7" stroke="#D2A000" stroke-width="1" filter="url(#softShadow)"/>
    <text x="60" y="835" font-size="16" font-weight="700" fill="#002E5D" font-family="monospace">UseSANGLE</text>
    <text x="60" y="870" font-size="13" fill="#3A2C00">Which encoder to trust for</text>
    <text x="60" y="888" font-size="13" fill="#3A2C00">scattering angle θ.</text>
    <text x="60" y="906" font-size="13" fill="#3A2C00">(SANGLE=stage, DANGLE=arm)</text>

    <rect x="335" y="800" width="260" height="125" rx="6" fill="#EEF7FB" stroke="#4A90C2" stroke-width="1"/>
    <text x="465" y="847" font-size="30" font-weight="700" fill="#002E5D" text-anchor="middle" font-family="monospace">True</text>
    <text x="465" y="880" font-size="12" fill="#1F3A5F" text-anchor="middle" font-style="italic">via UI's use_dangle=False</text>
    <text x="465" y="897" font-size="12" fill="#1F3A5F" text-anchor="middle">→ UseSANGLE = not use_dangle</text>
    <text x="465" y="913" font-size="11" fill="#C8102E" text-anchor="middle" font-weight="700">name inversion — debt!</text>

    <rect x="605" y="800" width="260" height="125" rx="6" fill="#F0F7EE" stroke="#6DA64F" stroke-width="1"/>
    <text x="735" y="847" font-size="30" font-weight="700" fill="#1F5B1F" text-anchor="middle" font-family="monospace">True</text>
    <text x="735" y="880" font-size="12" fill="#1F3A1F" text-anchor="middle" font-style="italic">use_sangle=True default</text>
    <text x="735" y="897" font-size="12" fill="#1F3A1F" text-anchor="middle">in ReductionProcess</text>
    <text x="735" y="913" font-size="11" fill="#6DA64F" text-anchor="middle" font-weight="700">currently agrees — by accident</text>

    <rect x="875" y="800" width="480" height="125" rx="6" fill="#FEF4EE" stroke="#E87722" stroke-width="1"/>
    <text x="895" y="828" font-size="13" fill="#3E2C00">Encoders disagree by fractions of a degree in practice.</text>
    <text x="895" y="848" font-size="13" fill="#3E2C00">quicknxsv2 stores "use_dangle", MRR expects "UseSANGLE".</text>
    <text x="895" y="868" font-size="13" fill="#3E2C00">The sign flip happens at the MRR call site, invisibly.</text>
    <text x="895" y="893" font-size="12" fill="#8C3A00" font-style="italic">Currently same result — but a name refactor could flip it.</text>
    <text x="895" y="913" font-size="12" fill="#8C3A00" font-style="italic">This is debt, not a current bug.</text>

    <rect x="1365" y="800" width="515" height="125" rx="6" fill="#F3F9F0" stroke="#53A548" stroke-width="1"/>
    <text x="1385" y="828" font-size="13" fill="#1F3A1F">Today: both paths agree (UseSANGLE=True).</text>
    <text x="1385" y="848" font-size="13" fill="#1F3A1F">Risk: a future rename of <tspan font-family="monospace" font-weight="700">use_dangle</tspan> could silently</text>
    <text x="1385" y="868" font-size="13" fill="#1F3A1F">flip every scattering angle.</text>
    <text x="1385" y="893" font-size="13" fill="#1F3A1F" font-weight="700">Who sees it: whoever refactors first.</text>
    <text x="1385" y="913" font-size="12" fill="#53A548" font-style="italic">Resolve: rename to use_sangle; make MRR's convention primary.</text>
  </g>

  <!-- Footer insight -->
  <rect x="40" y="945" width="1840" height="70" rx="8" fill="#002E5D" stroke="#001A35" stroke-width="2"/>
  <text x="60" y="975" font-size="17" font-weight="700" fill="#F5C13A">The fix is structural, not local.</text>
  <text x="60" y="998" font-size="14" fill="#E0ECF5">All five tensions disappear if one function — <tspan font-family="monospace" font-weight="700" fill="white">build_mrr_kwargs(configuration, direct_beam_config, …)</tspan> — is the only place that constructs MRR parameters, shared by GUI and autoreduce.</text>

  <!-- Footer -->
  <rect x="0" y="1020" width="1920" height="60" fill="#001A35"/>
  <text x="40" y="1058" font-size="13" fill="#6A90B0">Sources: 10-mantid-algorithms-deep-dive.md §11 · quicknxsv2 src/quicknxs/interfaces/data_handling/data_set.py:571,835 · mr_reduction src/mr_reduction/mr_reduction.py:337</text>
  <text x="1880" y="1058" font-size="13" fill="#6A90B0" text-anchor="end">Reflectometry Hack-a-thon 2026 · slide 3 of 8</text>
</svg>