Commit 1fa33a7
committed
Add pentafoil/hexafoil distortion (p11-p14), fix spline sign bug, restore
cardinal-angle resampling, and add calibration diagnostics.
Five major changes in this commit:
1. PENTAFOIL/HEXAFOIL DISTORTION (p11-p14)
Fourier analysis of calibrant residuals showed k=5 (pentafoil) as the
dominant unmodeled harmonic at 5.6 µε. Added cos(5η)·R^5 (p11,p12)
and cos(6η)·R^6 (p13,p14) to the distortion model. nBase increases
from 16 to 20 in the optimizer; all 19 downstream files updated.
New --fit-p-models keywords: pentafoil5, hexafoil6.
Fix: CalibrantIntegratorOMP eg0 initializer was missing .p7-.p10
(evaluate-only mode used zeroed dipole/trefoil params).
2. SPLINE RESIDUAL CORRECTION SIGN FIX
The spline stored deltaR = RadFit - IdealR and applied Rt += deltaR,
amplifying errors instead of correcting them (correlation +0.53 with
residuals). Fixed by negating: delta_r_px = -delta_r / px.
Result: Stage 2 analytical = 6.0 µε → Stage 4 with spline = 4.5 µε
(25% improvement, previously regressed to 8.4 µε).
3. CARDINAL-ANGLE RADIAL RESAMPLING FOR CALIBRANT
IntegrationCore.c used nearest-neighbor pixel lookup, ignoring the
bilinear interpolation + radial gradient correction implemented in
IntegratorZarrOMP. Replaced with matching bilinear + optional
GradientCorrection=1 radial resampling. Reduces cardinal-angle
aliasing at sub-pixel R-bin widths (0.25 px).
New CLI flag: --gradient-correction (default 1).
4. INTEGRATOR VALIDATION FIXES
- Panel parameters (NPanelsY/Z, PanelShiftsFile) were not passed to
DetectorMapper in run_integrator_validation, losing all per-panel
corrections. Fixed.
- Added DeltaR (µm) and DeltaA (Å) columns to both calibrant and
integrator corr.csv output.
5. CALIBRATION DIAGNOSTICS
- Stage 1/2/3/4 corr.csv files saved with stage suffixes.
- Full-detector distortion map PNGs (200×200 vectorized numpy grid)
generated at each stage, showing analytical + panel + spline ΔR.
- Spline-only map PNG showing residual correction.
- Panel corrections (dY, dZ, dTheta, dLsd, dP2) included in maps.
- Mask-aware: gap pixels rendered as white.
- Stage 4: evaluate-only (nIterations=0) with/without spline for
diagnostic A/B comparison.
- plot_calibrant_results.py viewer updated: DeltaR/DeltaA columns,
dynamic column detection for backward compatibility.
Files changed: 21 (781 insertions, 139 deletions)
C core: DetectorGeometry, CalibrationCore, CalibrantIntegratorOMP,
CalibrantEstep, MIDAS_ParamParser, MapperCore, DetectorMapper,
IntegrationCore (previous commit)
C fitting: FitSetupParamsAllZarr, FitMultipleGrains, FitWedgeParallel,
PeaksFittingOMPZarrRefactor, ForwardSimulationCompressed
Python: AutoCalibrateZarr, ffGenerateZipRefactor
GUI: plot_calibrant_results.py
Tests: test_calibration_integration.py
Tested on CeO2 Varex 2880×2880 (63keV, 900mm) and CeO2 Pilatus 1475×1679
(72keV, 650mm). Varex: 6.0 µε analytical → 4.5 µε with spline.
Pilatus: 38 µε → panel corrections reduce integrator to 20 µε range.1 parent 2613e69 commit 1fa33a7
21 files changed
Lines changed: 781 additions & 139 deletions
File tree
- FF_HEDM
- Example/Calibration
- src
- gui/viewers
- tests
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
380 | 381 | | |
381 | 382 | | |
382 | | - | |
| 383 | + | |
383 | 384 | | |
384 | 385 | | |
385 | 386 | | |
| |||
443 | 444 | | |
444 | 445 | | |
445 | 446 | | |
446 | | - | |
| 447 | + | |
447 | 448 | | |
448 | 449 | | |
449 | 450 | | |
| |||
500 | 501 | | |
501 | 502 | | |
502 | 503 | | |
503 | | - | |
| 504 | + | |
| 505 | + | |
504 | 506 | | |
505 | 507 | | |
506 | | - | |
| 508 | + | |
507 | 509 | | |
508 | 510 | | |
509 | 511 | | |
| |||
533 | 535 | | |
534 | 536 | | |
535 | 537 | | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
536 | 542 | | |
537 | 543 | | |
538 | 544 | | |
| |||
544 | 550 | | |
545 | 551 | | |
546 | 552 | | |
547 | | - | |
| 553 | + | |
548 | 554 | | |
549 | 555 | | |
550 | 556 | | |
| |||
600 | 606 | | |
601 | 607 | | |
602 | 608 | | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
603 | 613 | | |
604 | 614 | | |
605 | 615 | | |
| |||
617 | 627 | | |
618 | 628 | | |
619 | 629 | | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
620 | 634 | | |
621 | 635 | | |
622 | | - | |
623 | | - | |
624 | | - | |
625 | | - | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
626 | 640 | | |
627 | 641 | | |
628 | 642 | | |
| |||
752 | 766 | | |
753 | 767 | | |
754 | 768 | | |
755 | | - | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
756 | 774 | | |
757 | 775 | | |
758 | 776 | | |
| |||
826 | 844 | | |
827 | 845 | | |
828 | 846 | | |
| 847 | + | |
| 848 | + | |
829 | 849 | | |
830 | 850 | | |
831 | 851 | | |
| |||
889 | 909 | | |
890 | 910 | | |
891 | 911 | | |
| 912 | + | |
892 | 913 | | |
893 | 914 | | |
894 | 915 | | |
| |||
934 | 955 | | |
935 | 956 | | |
936 | 957 | | |
937 | | - | |
| 958 | + | |
938 | 959 | | |
939 | 960 | | |
940 | 961 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
149 | 153 | | |
150 | 154 | | |
151 | 155 | | |
| |||
166 | 170 | | |
167 | 171 | | |
168 | 172 | | |
| 173 | + | |
169 | 174 | | |
170 | 175 | | |
171 | 176 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | 86 | | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| 90 | + | |
89 | 91 | | |
90 | 92 | | |
91 | 93 | | |
| |||
94 | 96 | | |
95 | 97 | | |
96 | 98 | | |
| 99 | + | |
97 | 100 | | |
98 | 101 | | |
99 | 102 | | |
| |||
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
| 131 | + | |
| 132 | + | |
128 | 133 | | |
129 | 134 | | |
130 | 135 | | |
| |||
157 | 162 | | |
158 | 163 | | |
159 | 164 | | |
| 165 | + | |
160 | 166 | | |
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| 170 | + | |
164 | 171 | | |
165 | 172 | | |
166 | 173 | | |
| |||
170 | 177 | | |
171 | 178 | | |
172 | 179 | | |
| 180 | + | |
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
| |||
187 | 195 | | |
188 | 196 | | |
189 | 197 | | |
190 | | - | |
| 198 | + | |
191 | 199 | | |
192 | 200 | | |
193 | 201 | | |
| |||
202 | 210 | | |
203 | 211 | | |
204 | 212 | | |
205 | | - | |
| 213 | + | |
206 | 214 | | |
207 | 215 | | |
208 | | - | |
| 216 | + | |
209 | 217 | | |
210 | 218 | | |
211 | 219 | | |
| |||
249 | 257 | | |
250 | 258 | | |
251 | 259 | | |
| 260 | + | |
252 | 261 | | |
253 | 262 | | |
254 | 263 | | |
255 | 264 | | |
256 | 265 | | |
| 266 | + | |
257 | 267 | | |
258 | 268 | | |
259 | 269 | | |
| |||
263 | 273 | | |
264 | 274 | | |
265 | 275 | | |
| 276 | + | |
266 | 277 | | |
267 | 278 | | |
268 | 279 | | |
| |||
271 | 282 | | |
272 | 283 | | |
273 | 284 | | |
| 285 | + | |
274 | 286 | | |
275 | 287 | | |
276 | 288 | | |
| |||
291 | 303 | | |
292 | 304 | | |
293 | 305 | | |
294 | | - | |
| 306 | + | |
295 | 307 | | |
296 | 308 | | |
297 | 309 | | |
| |||
305 | 317 | | |
306 | 318 | | |
307 | 319 | | |
308 | | - | |
| 320 | + | |
309 | 321 | | |
310 | 322 | | |
311 | | - | |
| 323 | + | |
312 | 324 | | |
313 | 325 | | |
314 | 326 | | |
| |||
0 commit comments