midas-defect 0.2.0__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. {midas_defect-0.2.0 → midas_defect-0.3.0}/PKG-INFO +2 -2
  2. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/__init__.py +1 -1
  3. midas_defect-0.3.0/midas_defect/peak_tracker.py +260 -0
  4. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/raster.py +243 -5
  5. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/seed_index.py +51 -7
  6. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect.egg-info/PKG-INFO +2 -2
  7. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect.egg-info/SOURCES.txt +2 -0
  8. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect.egg-info/requires.txt +1 -1
  9. {midas_defect-0.2.0 → midas_defect-0.3.0}/pyproject.toml +3 -3
  10. midas_defect-0.3.0/tests/test_peak_tracker.py +246 -0
  11. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_raster.py +125 -0
  12. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_seed_index.py +32 -0
  13. {midas_defect-0.2.0 → midas_defect-0.3.0}/LICENSE +0 -0
  14. {midas_defect-0.2.0 → midas_defect-0.3.0}/README.md +0 -0
  15. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/asterism/__init__.py +0 -0
  16. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/asterism/direction.py +0 -0
  17. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/asterism/eigenvalue_spectrum.py +0 -0
  18. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/asterism/family_asterism.py +0 -0
  19. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/asterism/local_decomposition.py +0 -0
  20. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/asterism/second_moment.py +0 -0
  21. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/asterism_fit.py +0 -0
  22. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/attribution.py +0 -0
  23. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/bootstrap/__init__.py +0 -0
  24. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/bootstrap/aggregators.py +0 -0
  25. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/bootstrap/decorators.py +0 -0
  26. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/bootstrap/parallel.py +0 -0
  27. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/bootstrap/samplers.py +0 -0
  28. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/bragg_diffuse.py +0 -0
  29. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/burgers_population.py +0 -0
  30. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cli/__init__.py +0 -0
  31. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cli/asterism.py +0 -0
  32. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cli/polytype.py +0 -0
  33. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cli/rods.py +0 -0
  34. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/completeness.py +0 -0
  35. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/contrast_factor.py +0 -0
  36. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/contrast_factor_hex.py +0 -0
  37. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cpfem/__init__.py +0 -0
  38. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cpfem/damask_io.py +0 -0
  39. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cpfem/elastic_sc.py +0 -0
  40. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cpfem/fepx_io.py +0 -0
  41. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/cpfem/prisms_io.py +0 -0
  42. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/data_io.py +0 -0
  43. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/debye_waller/__init__.py +0 -0
  44. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/debye_waller/per_grain_wilson.py +0 -0
  45. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/defect_tests.py +0 -0
  46. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/delta_pdf.py +0 -0
  47. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/detector_qc.py +0 -0
  48. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/distributions/__init__.py +0 -0
  49. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/distributions/divergence.py +0 -0
  50. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/distributions/friedel.py +0 -0
  51. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/distributions/mackenzie.py +0 -0
  52. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/domains.py +0 -0
  53. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/energy/__init__.py +0 -0
  54. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/energy/balance_closure.py +0 -0
  55. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/energy/per_grain.py +0 -0
  56. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/energy/volume_weighted.py +0 -0
  57. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/examples/__init__.py +0 -0
  58. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/examples/_figures.py +0 -0
  59. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/examples/copland_fullres_validate.py +0 -0
  60. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/examples/demk_fcc_end_to_end.py +0 -0
  61. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/examples/raster_batch_cli.py +0 -0
  62. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/examples/tutorial_size_strain_mosaic.py +0 -0
  63. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/forward_sim.py +0 -0
  64. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/geometry.py +0 -0
  65. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/gnd/__init__.py +0 -0
  66. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/gnd/nye_tensor.py +0 -0
  67. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/gnd/scalar_gnd.py +0 -0
  68. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/gnd/ssd_decomposition.py +0 -0
  69. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/honesty.py +0 -0
  70. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/huang.py +0 -0
  71. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/indexing.py +0 -0
  72. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/ingest.py +0 -0
  73. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/intensity_budget.py +0 -0
  74. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/lattice.py +0 -0
  75. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/line_profile/__init__.py +0 -0
  76. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/line_profile/modified_wh.py +0 -0
  77. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/line_profile/per_grain_reflections.py +0 -0
  78. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/line_profile/warren_alpha.py +0 -0
  79. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/line_profile/warren_beta.py +0 -0
  80. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/peakshape.py +0 -0
  81. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/phases/__init__.py +0 -0
  82. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/phases/_systems.py +0 -0
  83. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/phases/bcc.py +0 -0
  84. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/phases/fcc.py +0 -0
  85. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/phases/hcp.py +0 -0
  86. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/__init__.py +0 -0
  87. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/_width.py +0 -0
  88. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/activated_axis.py +0 -0
  89. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/aggregate_thickness.py +0 -0
  90. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/cell_index.py +0 -0
  91. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/doublet_survey.py +0 -0
  92. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/fault_balance.py +0 -0
  93. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/finite_stack.py +0 -0
  94. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/ladder.py +0 -0
  95. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/lamella_thickness.py +0 -0
  96. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/modulation_tilt.py +0 -0
  97. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/modulation_type.py +0 -0
  98. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/satellite_doublet.py +0 -0
  99. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/satellite_excess.py +0 -0
  100. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/polytype/satellite_intensity.py +0 -0
  101. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/provenance.py +0 -0
  102. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/reports/__init__.py +0 -0
  103. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/reports/figures.py +0 -0
  104. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/reports/inventory.py +0 -0
  105. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/residual_decomposition.py +0 -0
  106. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/rod_detect.py +0 -0
  107. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/rod_profile.py +0 -0
  108. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/rows.py +0 -0
  109. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/schmid/__init__.py +0 -0
  110. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/schmid/per_grain.py +0 -0
  111. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/schmid/per_system.py +0 -0
  112. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/schmid/stratification.py +0 -0
  113. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/segmentation_bias.py +0 -0
  114. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/selfcal.py +0 -0
  115. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/spatial/__init__.py +0 -0
  116. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/spatial/autocorrelation.py +0 -0
  117. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/spatial/hall_petch.py +0 -0
  118. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/spatial/stress_gradient.py +0 -0
  119. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/strain/__init__.py +0 -0
  120. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/strain/eigenvalue_spectrum.py +0 -0
  121. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/strain/projection.py +0 -0
  122. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/strain/von_mises.py +0 -0
  123. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/stress/__init__.py +0 -0
  124. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/stress/cubic_anisotropic.py +0 -0
  125. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/stress/invariants.py +0 -0
  126. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/stress/resolved_shear.py +0 -0
  127. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/stress/voigt.py +0 -0
  128. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/subgrain.py +0 -0
  129. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/synthetic.py +0 -0
  130. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/thermodynamics/__init__.py +0 -0
  131. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/thermodynamics/mecking_kocks.py +0 -0
  132. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/thermodynamics/taylor_inversion.py +0 -0
  133. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/types.py +0 -0
  134. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/variants/__init__.py +0 -0
  135. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/variants/common_reference.py +0 -0
  136. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/variants/kmeans_fz.py +0 -0
  137. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/variants/matched_pairs.py +0 -0
  138. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/viz.py +0 -0
  139. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect/williamson_hall.py +0 -0
  140. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect.egg-info/dependency_links.txt +0 -0
  141. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect.egg-info/entry_points.txt +0 -0
  142. {midas_defect-0.2.0 → midas_defect-0.3.0}/midas_defect.egg-info/top_level.txt +0 -0
  143. {midas_defect-0.2.0 → midas_defect-0.3.0}/setup.cfg +0 -0
  144. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_ab_from_dscatter_is_refuted.py +0 -0
  145. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_asterism.py +0 -0
  146. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_asterism_fit.py +0 -0
  147. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_bootstrap.py +0 -0
  148. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_bragg_diffuse.py +0 -0
  149. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_burgers_population.py +0 -0
  150. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_cell_index.py +0 -0
  151. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_cli_polytype.py +0 -0
  152. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_completeness.py +0 -0
  153. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_contrast_factor.py +0 -0
  154. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_contrast_factor_hex.py +0 -0
  155. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_contrast_factor_ungar1999_table2.py +0 -0
  156. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_convention_scan.py +0 -0
  157. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_cpfem.py +0 -0
  158. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_debye_waller.py +0 -0
  159. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_defect_tests.py +0 -0
  160. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_delta_pdf.py +0 -0
  161. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_demk_experimental_modules.py +0 -0
  162. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_demk_g1592_9r_regression.py +0 -0
  163. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_demk_real_data_regression.py +0 -0
  164. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_detector_angle_maps.py +0 -0
  165. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_detector_qc.py +0 -0
  166. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_diffuse_to_bragg.py +0 -0
  167. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_distributions.py +0 -0
  168. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_elastic_sc.py +0 -0
  169. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_energy.py +0 -0
  170. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_family_asterism.py +0 -0
  171. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_fault_balance.py +0 -0
  172. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_find_domains.py +0 -0
  173. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_forward_sim.py +0 -0
  174. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_friedel_pairing.py +0 -0
  175. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_geometry.py +0 -0
  176. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_geometry_honest_2026.py +0 -0
  177. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_gnd.py +0 -0
  178. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_grains_reader_widths.py +0 -0
  179. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_honesty_decoy_raw.py +0 -0
  180. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_huang.py +0 -0
  181. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_index_from_cloud_cell.py +0 -0
  182. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_ingest.py +0 -0
  183. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_intensity_budget.py +0 -0
  184. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_lattice.py +0 -0
  185. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_line_profile.py +0 -0
  186. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_manual_calling_contract.py +0 -0
  187. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_modulation_tilt.py +0 -0
  188. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_orientation_convention.py +0 -0
  189. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_p1_honesty_2026.py +0 -0
  190. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_peakshape.py +0 -0
  191. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_phases.py +0 -0
  192. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_polytype.py +0 -0
  193. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_polytype_productized_2026.py +0 -0
  194. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_polytype_width.py +0 -0
  195. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_qlab_to_pixel.py +0 -0
  196. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_real_data_regression.py +0 -0
  197. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_reports.py +0 -0
  198. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_residual_decomposition.py +0 -0
  199. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_rod_detect.py +0 -0
  200. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_rod_path_conventions.py +0 -0
  201. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_rod_profile.py +0 -0
  202. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_rows.py +0 -0
  203. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_satellite_doublet.py +0 -0
  204. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_satellite_ladder.py +0 -0
  205. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_schmid.py +0 -0
  206. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_segmentation_bias.py +0 -0
  207. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_selfcal.py +0 -0
  208. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_space_group_forwarded.py +0 -0
  209. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_spatial.py +0 -0
  210. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_strain.py +0 -0
  211. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_stress.py +0 -0
  212. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_subgrain.py +0 -0
  213. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_synthetic_regression.py +0 -0
  214. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_targeted_recovery.py +0 -0
  215. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_thermodynamics.py +0 -0
  216. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_types.py +0 -0
  217. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_variants.py +0 -0
  218. {midas_defect-0.2.0 → midas_defect-0.3.0}/tests/test_williamson_hall.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: midas-defect
3
- Version: 0.2.0
3
+ Version: 0.3.0
4
4
  Summary: Differentiable, phase-agnostic diffuse-scattering defect metrology on top of standard FF-HEDM: intensity-budget closure, per-grain dislocation density, fault-rod and selection-rule tests.
5
5
  Author-email: Hemant Sharma <hsharma@anl.gov>
6
6
  License-Expression: BSD-3-Clause
@@ -21,7 +21,7 @@ Requires-Dist: tifffile>=2023.0
21
21
  Requires-Dist: scikit-image>=0.20
22
22
  Requires-Dist: zarr>=2.14
23
23
  Requires-Dist: midas-transforms>=0.1
24
- Requires-Dist: midas-hkls>=0.13.0
24
+ Requires-Dist: midas-hkls>=0.14.0
25
25
  Requires-Dist: midas-stress>=0.1
26
26
  Requires-Dist: midas-diffract>=0.1
27
27
  Requires-Dist: midas-index>=0.1
@@ -13,4 +13,4 @@ import os
13
13
  # time (before either runtime initializes) so callers don't hit a hard crash.
14
14
  os.environ.setdefault("KMP_DUPLICATE_LIB_OK", "TRUE")
15
15
 
16
- __version__ = "0.2.0"
16
+ __version__ = "0.3.0"
@@ -0,0 +1,260 @@
1
+ """Model-free peak tracking across a raster: no hkl, no indexing, no cell.
2
+
3
+ Why detector-space tracking, not hkl matching: each raster position's crystal domain has its
4
+ OWN orientation (U), so "hkl=(2,0,2)" at position A and the same label at position B are not
5
+ the same physical reflection unless the two domains happen to share orientation. But NEIGHBORING
6
+ raster positions very likely share the same physical grain with only a slowly drifting
7
+ orientation (mosaic), so a peak's DETECTOR position (row, col, frame) moves smoothly from one
8
+ raster point to its neighbor. Tracking that trajectory directly -- flood-fill from a seed pixel,
9
+ re-centering a small search window at each step from the previous position's own centroid -- is
10
+ a raw-data-first measurement that sidesteps the whole indexing/index-asymmetry discussion (an
11
+ a/b-splitting artifact already documented for one project) entirely: no cell, no lattice, no
12
+ domain. Where the peak's signal drops out (grain boundary, moved off a family's Bragg condition,
13
+ etc.) the walk simply stops there and is not propagated further -- that is real information (a
14
+ discontinuity), not a bug to paper over.
15
+ """
16
+ from __future__ import annotations
17
+
18
+ from typing import Callable, Dict, Optional
19
+
20
+ import numpy as np
21
+
22
+ __all__ = ["windowed_centroid", "track_peak_over_raster", "plot_peak_maps",
23
+ "snap_to_local_max", "STATUS_NO_SIGNAL", "STATUS_REJECTED", "STATUS_TRACKED"]
24
+
25
+ STATUS_NO_SIGNAL = 0 # windowed_centroid found nothing above the SNR floor
26
+ STATUS_REJECTED = 1 # a candidate was found, but the continuity guard rejected it
27
+ STATUS_TRACKED = 2 # accepted and propagated to neighbors
28
+
29
+ _FIELDS = ("centroid_row", "centroid_col", "centroid_frame", "intensity",
30
+ "sigma_row", "sigma_col", "sigma_frame", "peak_max", "background")
31
+
32
+
33
+ def windowed_centroid(frames: np.ndarray, row0: int, col0: int, frame0: int, *,
34
+ win_rc: int = 15, win_f: int = 4, min_snr: float = 5.0
35
+ ) -> Optional[Dict[str, float]]:
36
+ """Intensity-weighted 3-D centroid and width in a box around (row0, col0, frame0).
37
+
38
+ Background is the box's own median (robust to a few bright pixels); a peak is accepted
39
+ only if its max exceeds `min_snr` times the local background's MAD-based noise estimate --
40
+ otherwise this position has genuinely lost the peak, and the caller must not propagate a
41
+ centroid onward from it.
42
+
43
+ Returns a dict (centroid_row, centroid_col, centroid_frame, intensity, sigma_row, sigma_col,
44
+ sigma_frame, peak_max, background) or None if the peak is not found in this window.
45
+ """
46
+ n_f, n_r, n_c = frames.shape
47
+ r0, r1 = max(0, row0 - win_rc), min(n_r, row0 + win_rc + 1)
48
+ c0, c1 = max(0, col0 - win_rc), min(n_c, col0 + win_rc + 1)
49
+ f0, f1 = max(0, frame0 - win_f), min(n_f, frame0 + win_f + 1)
50
+ box = frames[f0:f1, r0:r1, c0:c1].astype(np.float64)
51
+ if box.size == 0:
52
+ return None
53
+
54
+ bg = float(np.median(box))
55
+ mad = float(np.median(np.abs(box - bg))) + 1e-9
56
+ noise = 1.4826 * mad
57
+ peak_max = float(box.max())
58
+ if noise <= 0 or (peak_max - bg) < min_snr * noise:
59
+ return None
60
+
61
+ w = np.clip(box - bg, 0, None)
62
+ total = w.sum()
63
+ if total <= 0:
64
+ return None
65
+
66
+ ff, rr, cc = np.meshgrid(np.arange(f0, f1), np.arange(r0, r1), np.arange(c0, c1),
67
+ indexing="ij")
68
+ cen_f = float((w * ff).sum() / total)
69
+ cen_r = float((w * rr).sum() / total)
70
+ cen_c = float((w * cc).sum() / total)
71
+ sig_f = float(np.sqrt((w * (ff - cen_f) ** 2).sum() / total))
72
+ sig_r = float(np.sqrt((w * (rr - cen_r) ** 2).sum() / total))
73
+ sig_c = float(np.sqrt((w * (cc - cen_c) ** 2).sum() / total))
74
+
75
+ return dict(centroid_row=cen_r, centroid_col=cen_c, centroid_frame=cen_f,
76
+ intensity=float(total), sigma_row=sig_r, sigma_col=sig_c, sigma_frame=sig_f,
77
+ peak_max=peak_max, background=bg)
78
+
79
+
80
+ def snap_to_local_max(proj: np.ndarray, row: int, col: int, radius: int = 12):
81
+ """Snap an approximate (row, col) to the true local maximum of `proj` within `radius`.
82
+
83
+ Used to turn an imprecise click (or any coarse guess) on a max-over-frames projection into
84
+ a usable seed pixel -- clicking exactly on a 1-pixel-wide spot is unrealistic.
85
+ """
86
+ n_r, n_c = proj.shape
87
+ r0, r1 = max(0, row - radius), min(n_r, row + radius + 1)
88
+ c0, c1 = max(0, col - radius), min(n_c, col + radius + 1)
89
+ box = proj[r0:r1, c0:c1]
90
+ rr, cc = np.unravel_index(np.argmax(box), box.shape)
91
+ return r0 + rr, c0 + cc
92
+
93
+
94
+ def track_peak_over_raster(loader: Callable[[int], np.ndarray], n_rows: int, n_cols: int,
95
+ seed_pos: int, seed_row: float, seed_col: float, seed_frame: float,
96
+ *, win_rc: int = 15, win_f: int = 4, min_snr: float = 5.0,
97
+ max_step_px: float = 8.0, max_step_frames: float = 2.0,
98
+ max_intensity_ratio: float = 4.0, log: Callable = print
99
+ ) -> Dict[str, np.ndarray]:
100
+ """Flood-fill a peak's detector trajectory over a row-major (n_rows x n_cols) raster.
101
+
102
+ `loader(p)` returns position p's (already dead-frame-cleaned) raw frame stack.
103
+ `seed_pos` is the 0-indexed position the user picked the peak from; `seed_row/col/frame`
104
+ is that peak's approximate location there (need not be exact -- the first window re-centers).
105
+
106
+ **Continuity guard, added after checking a real run for jumps between raster-grid
107
+ neighbors:** a first version with only an SNR cut let the tracker HIJACK a different,
108
+ unrelated bright peak whenever one drifted within the `win_rc` search box -- 391/1171
109
+ grid-adjacent pairs jumped >5 px, several 20-32 px with a simultaneous 3-20x intensity
110
+ change, concentrated where the search entered a busier (powder-rich) region. A 4 um raster
111
+ step should not move a real peak far on the detector, so a candidate is accepted only if
112
+ BOTH its centroid shift from the seed (`max_step_px`, `max_step_frames`) AND its intensity
113
+ ratio to the seed's own last intensity (`max_intensity_ratio`) stay bounded; otherwise this
114
+ branch stops here rather than silently propagating a wrong lock forward looking locally
115
+ smooth.
116
+
117
+ A rejected candidate is not simply discarded: it is recorded with ``status`` ==
118
+ ``STATUS_REJECTED`` and its field values are still stored, so a caller can show "a peak was
119
+ found here but it does not connect continuously" rather than an indistinguishable blank.
120
+ Neighbors are not enqueued from a rejected step, same as from a no-signal one -- only an
121
+ accepted step propagates the walk, since a rejected candidate's own position is exactly
122
+ what should not be trusted as a re-centering seed.
123
+
124
+ Returns a dict of (n_rows, n_cols) float arrays (NaN where `status` ==
125
+ :data:`STATUS_NO_SIGNAL`): the fields in :data:`_FIELDS`, plus an integer ``status`` array
126
+ (:data:`STATUS_NO_SIGNAL` / :data:`STATUS_REJECTED` / :data:`STATUS_TRACKED`) and a boolean
127
+ ``tracked`` array (``status == STATUS_TRACKED``, kept for callers that only care about the
128
+ accepted walk).
129
+ """
130
+ grids = {f: np.full((n_rows, n_cols), np.nan) for f in _FIELDS}
131
+ status = np.full((n_rows, n_cols), STATUS_NO_SIGNAL, dtype=np.int8)
132
+ visited = np.zeros((n_rows, n_cols), dtype=bool)
133
+
134
+ queue = [(seed_pos, seed_row, seed_col, seed_frame, None)]
135
+ n_done = 0
136
+ n_rejected = 0
137
+ while queue:
138
+ p, sr, sc, sf, seed_intensity = queue.pop(0)
139
+ r, c = p // n_cols, p % n_cols
140
+ if visited[r, c]:
141
+ continue
142
+ visited[r, c] = True
143
+
144
+ frames = loader(p)
145
+ result = windowed_centroid(frames, int(round(sr)), int(round(sc)), int(round(sf)),
146
+ win_rc=win_rc, win_f=win_f, min_snr=min_snr)
147
+ n_done += 1
148
+ if n_done % 25 == 0:
149
+ log(f" tracked {n_done} positions so far ({int((status == STATUS_TRACKED).sum())} "
150
+ f"with signal, {n_rejected} rejected as likely hijacks)...")
151
+
152
+ if result is None:
153
+ continue # lost here -- do not enqueue neighbors from a failed centroid
154
+
155
+ accepted = True
156
+ if seed_intensity is not None:
157
+ step_px = np.hypot(result["centroid_row"] - sr, result["centroid_col"] - sc)
158
+ step_f = abs(result["centroid_frame"] - sf)
159
+ ratio = max(result["intensity"], seed_intensity) / min(result["intensity"], seed_intensity)
160
+ if step_px > max_step_px or step_f > max_step_frames or ratio > max_intensity_ratio:
161
+ accepted = False
162
+
163
+ for f in _FIELDS:
164
+ grids[f][r, c] = result[f]
165
+
166
+ if not accepted:
167
+ n_rejected += 1
168
+ status[r, c] = STATUS_REJECTED
169
+ continue # likely hijacked a different, unrelated peak -- stop this branch here
170
+
171
+ status[r, c] = STATUS_TRACKED
172
+ for dr, dc in ((1, 0), (-1, 0), (0, 1), (0, -1)):
173
+ nr, nc = r + dr, c + dc
174
+ if 0 <= nr < n_rows and 0 <= nc < n_cols and not visited[nr, nc]:
175
+ queue.append((nr * n_cols + nc, result["centroid_row"], result["centroid_col"],
176
+ result["centroid_frame"], result["intensity"]))
177
+
178
+ grids["status"] = status
179
+ grids["tracked"] = status == STATUS_TRACKED
180
+ n_tracked = int(grids["tracked"].sum())
181
+ log(f"done: {n_tracked} / {n_rows * n_cols} tracked, {n_rejected} rejected as likely "
182
+ f"hijacks, {n_rows * n_cols - n_tracked - n_rejected} no signal")
183
+ return grids
184
+
185
+
186
+ def plot_peak_maps(data, *, fields=("centroid_row", "centroid_col", "centroid_frame",
187
+ "intensity", "sigma_row", "sigma_col"),
188
+ cmap: str = "viridis", title_prefix: str = "", show: bool = True):
189
+ """Render a grid of per-field raster maps from a :func:`track_peak_over_raster` result.
190
+
191
+ `data` is the dict returned by :func:`track_peak_over_raster` (or an ``np.load`` of an
192
+ ``.npz`` saved from it -- anything indexable by the field names plus ``status``).
193
+
194
+ Three-state per pixel, using ``status``: STATUS_NO_SIGNAL pixels are left blank (no color,
195
+ via ``cmap.set_bad``); STATUS_TRACKED pixels are colored normally by the field value;
196
+ STATUS_REJECTED pixels are colored by their (still-real) field value but additionally
197
+ outlined with a red square marker, so "a discontinuous candidate was found here" stays
198
+ visible rather than reading identically to "nothing here" or to a trusted walk step.
199
+
200
+ `fields` selects which panels to draw and in what order -- pass any subset/order of
201
+ ``centroid_row``, ``centroid_col``, ``centroid_frame``, ``intensity``, ``sigma_row``,
202
+ ``sigma_col``, ``sigma_frame``, ``peak_max``, ``background``. `cmap` is any matplotlib
203
+ colormap name, applied to every panel.
204
+
205
+ Returns the ``(fig, axes)`` matplotlib objects (matplotlib is imported lazily so the
206
+ package can be installed without it).
207
+
208
+ Accepts a result from a version of :func:`track_peak_over_raster` predating ``status``
209
+ (only ``tracked``, a plain bool grid) -- degrades to the old two-state rendering (no
210
+ STATUS_REJECTED outline) rather than raising, since existing saved ``.npz`` results should
211
+ not need re-tracking just to be plotted with the new function.
212
+ """
213
+ import matplotlib.pyplot as plt
214
+
215
+ tracked = np.asarray(data["tracked"])
216
+ if "status" in data:
217
+ status = np.asarray(data["status"])
218
+ else:
219
+ status = np.where(tracked, STATUS_TRACKED, STATUS_NO_SIGNAL)
220
+ n_total = status.size
221
+ n_tracked = int(tracked.sum())
222
+
223
+ labels = {"centroid_row": "centroid row (px)", "centroid_col": "centroid col (px)",
224
+ "centroid_frame": "centroid frame (omega step)",
225
+ "intensity": "integrated intensity", "sigma_row": "width, row (px)",
226
+ "sigma_col": "width, col (px)", "sigma_frame": "width, omega (frames)",
227
+ "peak_max": "peak max (counts)", "background": "local background (counts)"}
228
+
229
+ n = len(fields)
230
+ ncols = 3 if n > 2 else n
231
+ nrows = -(-n // ncols) # ceil
232
+ fig, axes = plt.subplots(nrows, ncols, figsize=(4.3 * ncols, 3.6 * nrows), squeeze=False)
233
+ axes_flat = axes.flat
234
+
235
+ rej_r, rej_c = np.where(status == STATUS_REJECTED)
236
+
237
+ for ax, key in zip(axes_flat, fields):
238
+ cmap_obj = plt.get_cmap(cmap).copy()
239
+ cmap_obj.set_bad("#dddddd")
240
+ arr = np.where(status >= STATUS_REJECTED, np.asarray(data[key]), np.nan)
241
+ im = ax.imshow(arr, origin="lower", cmap=cmap_obj)
242
+ if rej_r.size:
243
+ ax.scatter(rej_c, rej_r, s=16, facecolors="none", edgecolors="red",
244
+ linewidths=0.9, marker="s")
245
+ ax.set_title(labels.get(key, key), fontsize=10)
246
+ ax.set_xlabel("col (raster)")
247
+ ax.set_ylabel("row (raster)")
248
+ fig.colorbar(im, ax=ax, fraction=0.046)
249
+ for ax in list(axes_flat)[n:]:
250
+ ax.axis("off")
251
+
252
+ seed_p = data["seed_p"] if "seed_p" in data else None
253
+ seed_str = f"seed p={int(seed_p)} -- " if seed_p is not None else ""
254
+ fig.suptitle(f"{title_prefix}{seed_str}{n_tracked}/{n_total} tracked, "
255
+ f"{int((status == STATUS_REJECTED).sum())} rejected "
256
+ f"(red outline = rejected, found but discontinuous)")
257
+ fig.tight_layout()
258
+ if show:
259
+ plt.show()
260
+ return fig, axes
@@ -113,10 +113,12 @@ from .geometry import (Geometry, detector_angle_maps, ewald_crossing_omegas, pix
113
113
  from .honesty import decoy_test, feature_in_raw, inflated_cell
114
114
  from .ingest import build_mask, detect_powder_rings, find_blobs_3d, flag_powder, subtract_background
115
115
  from .rows import hkl_box_from_geometry
116
+ from .seed_index import bootstrap_orientation_uncertainty
116
117
 
117
118
  __all__ = ["PositionResult", "reduce_one_position", "reduce_raster_block",
118
119
  "assemble_raster_results", "omega_sign_check", "OmegaSignCheck",
119
- "predict_reflections", "raster_wide_asymmetry_sign_test"]
120
+ "predict_reflections", "raster_wide_asymmetry_sign_test",
121
+ "plot_domain_overlay", "plot_orientation_envelope", "plot_lattice_envelope"]
120
122
 
121
123
 
122
124
  # ---------------------------------------------------------------------------
@@ -202,6 +204,49 @@ class PositionResult:
202
204
  split_pct: Optional[Tuple[float, float, float]] # (delta, sigma, z) from split_with_error, or None
203
205
  notes: List[str] = field(default_factory=list)
204
206
  quotable: bool = False
207
+ #: SKETCH, 2026-09-13. **`/verify` REFUTED the claim that this envelope's width is "a real,
208
+ #: differentiating signal of orientation determinability"** (claim b82502d6b5ad: physics,
209
+ #: statistics, and artifact lenses all REFUTED; independent reproduction SURVIVED -- the
210
+ #: numbers themselves are computed correctly, the interpretation was not). Do not present
211
+ #: a sparse-domain envelope as evidence that domain's orientation is "real but uncertain"
212
+ #: without also checking `decoy` for that domain -- a domain the pipeline's own honesty
213
+ #: gate does not trust can show a wide envelope for reasons having nothing to do with
214
+ #: orientation physics (see `bootstrap_orientation_uncertainty`'s docstring for the full
215
+ #: mechanism: generic 1/sqrt(n) bootstrap scaling, non-independent resamples from a tiny
216
+ #: combinatorial pool below ``keep_n``, or -- the bug actually fixed by this claim -- a
217
+ #: silently-tetragonal orientation fit for a domain that is not tetragonal).
218
+ #:
219
+ #: One entry per domain (aligned with ``domains.domains``), from
220
+ #: ``seed_index.bootstrap_orientation_uncertainty``, or ``None`` where not computed
221
+ #: (default: not computed at all, see ``reduce_one_position``'s ``orientation_uncertainty``
222
+ #: flag -- this is NOT free, each entry re-runs the orientation fit
223
+ #: ``n_orientation_boot`` times). Keys: ``pair_angle_mean_deg`` / ``pair_angle_p95_deg`` /
224
+ #: ``pair_angle_max_deg`` (pairwise misorientation across the bootstrap U's), plus
225
+ #: ``U_mean``/``U_bootstraps``/``n_distinct_subsets``/``independent_resamples`` -- READ
226
+ #: ``independent_resamples`` before trusting a spread from a sparse domain.
227
+ #:
228
+ #: ``max`` several times ``mean`` is NOT by itself evidence of a bimodal/non-unimodal
229
+ #: spread -- checked directly on the cleanest synthetic domain available (321 reflections,
230
+ #: textbook single orientation): max/mean still came out ~3.7x, purely from comparing the
231
+ #: MAX of many bootstrap pairs against their MEAN (an order-statistics effect, not a
232
+ #: property of the underlying distribution's shape). To check for a genuinely multi-modal
233
+ #: spread, inspect ``U_bootstraps`` directly rather than reading a ratio off the summary
234
+ #: numbers.
235
+ orientation_envelope: List[Optional[dict]] = field(default_factory=list)
236
+ #: SKETCH, 2026-09-13, not yet independently /verify'd. (n_kept, 6) array of every
237
+ #: bootstrap resample's full expanded cell -- (a, b, c, alpha, beta, gamma) -- from
238
+ #: `midas_hkls.refine_cell_joint`'s own resampling loop, or None when no domain reached
239
+ #: `refine_cell_joint` (``refined_cell is None``) or too few resamples succeeded.
240
+ #: `split_pct`'s sigma is this array's std on columns 0/1; this is the same data before
241
+ #: being collapsed to that one number -- read individual a/b/c ranges from columns
242
+ #: 0/1/2, not just their difference.
243
+ cell_bootstrap_samples: Optional[np.ndarray] = None
244
+ #: (a, b, c, alpha, beta, gamma) bootstrap sigma, i.e. ``cell_bootstrap_samples.std(axis=0,
245
+ #: ddof=1)`` -- the compact, per-parameter summary of the same data, kept separately
246
+ #: because it (not the full array) is what belongs in a raster-wide map: cheap to carry
247
+ #: through JSON for hundreds of positions, where the full bootstrap array is not (see
248
+ #: ``to_dict()``, which drops ``cell_bootstrap_samples`` but keeps this).
249
+ cell_sigma_bootstrap: Optional[Tuple[float, ...]] = None
205
250
 
206
251
  def summary(self) -> str:
207
252
  lines = [f"position {self.point}: {self.n_spots} spots, {self.omega_sign}",
@@ -238,6 +283,20 @@ class PositionResult:
238
283
  d["omega_sign"] = dict(chosen_sign=self.omega_sign.chosen_sign,
239
284
  n_explained=self.omega_sign.n_explained,
240
285
  decisive=self.omega_sign.decisive)
286
+ # orientation_envelope/cell_bootstrap_samples carry raw bootstrap arrays (U_bootstraps:
287
+ # n_domains * n_orientation_boot * 3x3 floats; cell_bootstrap_samples: n_bootstrap * 6
288
+ # floats) meant for one position's own live plotting (05), not for a whole raster's
289
+ # worth of JSON files (06/reduce_raster_block) -- keep only the compact summaries a
290
+ # raster map actually needs; U_mean/cell_bootstrap_samples stay in-memory-only.
291
+ d["orientation_envelope"] = [
292
+ None if oe is None else
293
+ dict(U_mean=oe["U_mean"].tolist(), pair_angle_mean_deg=oe["pair_angle_mean_deg"],
294
+ pair_angle_p95_deg=oe["pair_angle_p95_deg"], pair_angle_max_deg=oe["pair_angle_max_deg"],
295
+ n_boot=oe["n_boot"], keep_n=oe["keep_n"], n_distinct_subsets=oe["n_distinct_subsets"],
296
+ independent_resamples=oe["independent_resamples"])
297
+ for oe in self.orientation_envelope
298
+ ]
299
+ d["cell_bootstrap_samples"] = None
241
300
  return d
242
301
 
243
302
  def save(self, path) -> None:
@@ -328,6 +387,124 @@ def predict_reflections(U: np.ndarray, B: np.ndarray, hkl: np.ndarray, geom: Geo
328
387
  hkl[kept_idx].astype(int), kept_idx)
329
388
 
330
389
 
390
+ # ---------------------------------------------------------------------------
391
+ # Reporting plots -- SKETCH, 2026-09-13. matplotlib is the package's optional `viz`
392
+ # extra, imported lazily inside each function so it stays optional at module import time.
393
+ # ---------------------------------------------------------------------------
394
+
395
+ def plot_domain_overlay(frames: np.ndarray, res: "PositionResult", geom: Geometry, *, ax=None):
396
+ """The max-intensity projection over ``frames``, with every domain's own claimed
397
+ reflections predicted back onto it (same discipline DFXM calls "look at the curves
398
+ before the summary"). One color per domain, labelled with its `decoy_test` verdict --
399
+ a domain whose own honesty gate failed should look suspect here too, not just in a table.
400
+ """
401
+ import matplotlib.pyplot as plt
402
+ fig = None
403
+ if ax is None:
404
+ fig, ax = plt.subplots(figsize=(7.5, 6.6))
405
+ colors = plt.cm.tab10(np.linspace(0, 1, max(len(res.domains.domains), 1)))
406
+ im = ax.imshow(np.log10(np.clip(frames.max(axis=0), 1, None)), cmap="magma")
407
+ if fig is not None:
408
+ fig.colorbar(im, ax=ax, fraction=0.046, label="log10(max over frames)")
409
+ for i, dom in enumerate(res.domains.domains):
410
+ pr, pc, _pw, _phkl, _kept = predict_reflections(dom.U, dom.lat.B, dom.hkl, geom,
411
+ res.omega_sign.chosen_sign)
412
+ ax.scatter(pc, pr, s=32, facecolors="none", edgecolors=[colors[i]], linewidths=1.3,
413
+ label=f"domain {i} ({len(pr)} claimed, decoy={res.decoy[i]['verdict']})")
414
+ ax.set_title(f"position {res.point}: {len(res.domains.domains)} domain(s) found")
415
+ ax.set_xlabel("column"); ax.set_ylabel("row")
416
+ if res.domains.domains:
417
+ ax.legend(fontsize=8, frameon=False, loc="lower right")
418
+ return fig
419
+
420
+
421
+ def plot_orientation_envelope(res: "PositionResult"):
422
+ """Per domain, a histogram of each bootstrap ``U``'s misorientation from the bootstrap
423
+ mean -- the visual form of ``PositionResult.orientation_envelope``.
424
+
425
+ **Read this plot, not just the summary numbers, before trusting a sparse domain's
426
+ envelope.** `/verify` REFUTED an early version of this envelope as a general
427
+ "orientation determinability signal" (claim ``b82502d6b5ad``) partly because a domain
428
+ resampled from too few reflections draws from a tiny combinatorial pool
429
+ (``n_distinct_subsets``) and can show a visibly LUMPY, non-smooth, even bimodal
430
+ histogram rather than a genuine continuous spread -- exactly the kind of thing a summary
431
+ mean/p95/max cannot show but a histogram does immediately. Domains with
432
+ ``orientation_envelope[i] is None`` (fewer than 4 claimed reflections) are skipped.
433
+ """
434
+ import matplotlib.pyplot as plt
435
+ n_dom = len(res.domains.domains)
436
+ fig, axes = plt.subplots(1, max(n_dom, 1), figsize=(5.5 * max(n_dom, 1), 4.2), squeeze=False)
437
+ axes = axes[0]
438
+ colors = plt.cm.tab10(np.linspace(0, 1, max(n_dom, 1)))
439
+ for i in range(n_dom):
440
+ ax = axes[i]
441
+ oe = res.orientation_envelope[i] if i < len(res.orientation_envelope) else None
442
+ dom = res.domains.domains[i]
443
+ if oe is None:
444
+ ax.text(0.5, 0.5, "not computed\n(<4 claimed reflections, or\n"
445
+ "orientation_uncertainty=False)", ha="center", va="center",
446
+ transform=ax.transAxes, fontsize=9)
447
+ ax.set_title(f"domain {i}"); ax.set_xticks([]); ax.set_yticks([])
448
+ continue
449
+ U_mean = oe["U_mean"]
450
+ angles = []
451
+ for Ub in oe["U_bootstraps"]:
452
+ delta = Ub @ np.asarray(U_mean).T
453
+ c = np.clip((np.trace(delta) - 1) / 2, -1, 1)
454
+ angles.append(np.degrees(np.arccos(c)))
455
+ ax.hist(angles, bins=min(12, max(len(angles) // 2, 3)), color=colors[i], edgecolor="k", alpha=0.85)
456
+ ax.axvline(oe["pair_angle_mean_deg"], color="k", ls="--", lw=1,
457
+ label=f"mean pairwise = {oe['pair_angle_mean_deg']:.3f} deg")
458
+ ax.set_xlabel("misorientation vs bootstrap mean U (deg)")
459
+ ax.set_ylabel(f"count (of {oe['n_boot']} resamples)")
460
+ indep = "independent" if oe["independent_resamples"] else "NOT independent (too few reflections)"
461
+ ax.set_title(f"domain {i}: {len(dom.hkl)} claimed refl., keep_n={oe['keep_n']}\n"
462
+ f"decoy={res.decoy[i]['verdict']}, resamples {indep}", fontsize=9)
463
+ ax.legend(fontsize=8, frameon=False)
464
+ fig.suptitle(f"Orientation envelope -- position {res.point} "
465
+ f"(/verify claim b82502d6b5ad: REFUTED as a general determinability signal; "
466
+ f"mechanism correctness-fixed, read decoy_test alongside this)", fontsize=9)
467
+ fig.tight_layout()
468
+ return fig
469
+
470
+
471
+ def plot_lattice_envelope(res: "PositionResult"):
472
+ """``a``, ``b``, ``c`` bootstrap distributions, individually -- NOT just their difference.
473
+
474
+ Needs ``res.cell_bootstrap_samples``, which is only populated in-memory by
475
+ :func:`reduce_one_position` (never persisted through :meth:`PositionResult.to_dict`,
476
+ since it is one position's full raw bootstrap array, not something a whole raster's
477
+ JSON files should carry). Call this on a live ``reduce_one_position`` result, not on
478
+ something read back via :func:`assemble_raster_results`.
479
+ """
480
+ import matplotlib.pyplot as plt
481
+ if res.cell_bootstrap_samples is None:
482
+ raise ValueError(
483
+ "res.cell_bootstrap_samples is None -- either no domain reached refine_cell_joint "
484
+ "(res.refined_cell is None), too few bootstrap resamples succeeded, or this "
485
+ "PositionResult came from assemble_raster_results (which does not carry it; "
486
+ "see this function's docstring)."
487
+ )
488
+ samples = res.cell_bootstrap_samples
489
+ a_fit, b_fit, c_fit = res.refined_cell[0], res.refined_cell[1], res.refined_cell[2]
490
+ fig, axes = plt.subplots(1, 3, figsize=(14, 4.2))
491
+ for j, (lab, fit_val) in enumerate(zip(["a", "b", "c"], [a_fit, b_fit, c_fit])):
492
+ ax = axes[j]
493
+ vals = samples[:, j]
494
+ ax.hist(vals, bins=15, color="steelblue", edgecolor="k", alpha=0.85)
495
+ ax.axvline(fit_val, color="crimson", lw=1.5, label=f"joint fit: {fit_val:.5f} A")
496
+ lo, hi = np.percentile(vals, [2.5, 97.5])
497
+ ax.axvspan(lo, hi, color="crimson", alpha=0.08, label=f"95% range: [{lo:.5f}, {hi:.5f}]")
498
+ ax.set_xlabel(f"{lab} (A)")
499
+ ax.set_ylabel(f"count (of {len(vals)} bootstrap resamples)")
500
+ ax.set_title(f"{lab}: {fit_val:.5f} +/- {vals.std(ddof=1):.5f} A", fontsize=10)
501
+ ax.legend(fontsize=7, frameon=False)
502
+ fig.suptitle(f"Lattice envelope -- position {res.point}, joint fit over "
503
+ f"{len(res.domains.domains)} domain(s) (quotable={res.quotable})", fontsize=10)
504
+ fig.tight_layout()
505
+ return fig
506
+
507
+
331
508
  def reduce_one_position(
332
509
  frames: np.ndarray, geom: Geometry, *,
333
510
  a: float, c: float, space_group_number: int,
@@ -343,6 +520,8 @@ def reduce_one_position(
343
520
  seed_from_nominal: bool = False,
344
521
  ingest_kwargs: Optional[dict] = None,
345
522
  find_domains_kwargs: Optional[dict] = None,
523
+ orientation_uncertainty: bool = False,
524
+ n_orientation_boot: int = 25,
346
525
  ) -> PositionResult:
347
526
  """One raster position, start to finish: frames -> a gated a/b splitting, if one is possible.
348
527
 
@@ -364,6 +543,18 @@ def reduce_one_position(
364
543
  Nothing here decides FOR you whether a splitting is real. ``PositionResult.quotable`` is
365
544
  only set once every gate in ``phase-3-refine.md``'s order has been checked; read
366
545
  ``PositionResult.notes`` for which one, if any, said no.
546
+
547
+ ``orientation_uncertainty`` (SKETCH, 2026-09-13, off by default): also bootstrap each
548
+ domain's OWN orientation fit (``seed_index.bootstrap_orientation_uncertainty``,
549
+ ``n_orientation_boot`` resamples each) and report the result in
550
+ ``PositionResult.orientation_envelope`` -- the same "don't report a bare point estimate"
551
+ discipline ``split_with_error`` already applies to the cell, extended to ``U``. This is
552
+ NOT free: it re-runs an Adam refinement ``n_orientation_boot`` times per domain, on top of
553
+ everything else this function already does, so it defaults to off for raster-wide batch
554
+ runs where that cost multiplies by every position. Independent of the a/b gate chain --
555
+ computed for every domain FOUND, not only ones that reach ``refine_cell_joint``, since
556
+ orientation determinability is a property of a domain's own indexing fit, not of whether
557
+ its a/b split is separable.
367
558
  """
368
559
  ik = dict(ingest_kwargs or {})
369
560
  fk = dict(find_domains_kwargs or {})
@@ -444,6 +635,7 @@ def reduce_one_position(
444
635
  decoy_list: List[dict] = []
445
636
  feature_list: List[dict] = []
446
637
  gate_list: List[dict] = []
638
+ orientation_list: List[Optional[dict]] = []
447
639
  fit_domains = []
448
640
 
449
641
  hkl_box = _hkl_box(hmax, hmax, lmax, space_group_number)
@@ -453,6 +645,38 @@ def reduce_one_position(
453
645
  for dom in domains.domains:
454
646
  claim_idx = np.flatnonzero(dom.claim)
455
647
 
648
+ # SKETCH, 2026-09-13. /verify REFUTED an early version of this on real La3Ni2O7
649
+ # 2601_LT p364 data (claim b82502d6b5ad, physics+statistics+artifact lenses; numbers
650
+ # reproduced exactly, REPRODUCTION survived -- the interpretation did not):
651
+ # - physics: the FIRST version called bootstrap_orientation_uncertainty with only
652
+ # (a, c), silently assuming h and k share one axis (tetragonal) -- wrong for any
653
+ # domain this project's own a/b work has already found is NOT tetragonal. Fixed:
654
+ # dom.lat.b is now passed explicitly.
655
+ # - statistics/artifact: a sparse domain's "wider envelope" is not automatically a
656
+ # meaningful determinability signal -- it can be (a) the generic 1/sqrt(n) scaling
657
+ # any bootstrap M-estimator shows regardless of data quality, compounded by (b) too
658
+ # few centroids to draw independent resamples at all (see
659
+ # `independent_resamples`/`n_distinct_subsets` in the returned dict), and (c) the
660
+ # domain itself may be one the pipeline's OWN honesty gates (decoy_test) do not
661
+ # trust -- check `res.decoy[i]['verdict']` alongside this envelope, not instead of
662
+ # it, before reading a wide spread as "this domain's orientation is real but
663
+ # uncertain" rather than "this domain's fit may not be trustworthy at all."
664
+ # Off by default (orientation_uncertainty=False) -- see reduce_one_position's
665
+ # docstring for the cost tradeoff. Computed for every domain FOUND, independent of the
666
+ # a/b gate chain below (a domain's orientation determinability is not the same
667
+ # question as whether its a/b split is separable) -- but NOT independent of whether
668
+ # the domain's own fit passes `decoy_test`; read both together.
669
+ if orientation_uncertainty:
670
+ centroids = list(zip((tuple(int(x) for x in row) for row in dom.hkl), q[claim_idx]))
671
+ if len(centroids) >= 4:
672
+ orientation_list.append(bootstrap_orientation_uncertainty(
673
+ centroids, dom.U, a=float(dom.lat.a), b=float(dom.lat.b), c=float(dom.lat.c),
674
+ n_boot=n_orientation_boot))
675
+ else:
676
+ orientation_list.append(None) # bootstrap_orientation_uncertainty floors keep_n at 4
677
+ else:
678
+ orientation_list.append(None)
679
+
456
680
  # completeness: predict this domain's own cell/orientation over the WHOLE box, and
457
681
  # separately over its own claimed hkl (to derive the window from its own residuals --
458
682
  # never guessed, per `window_from_residuals`).
@@ -568,6 +792,8 @@ def reduce_one_position(
568
792
 
569
793
  refined_cell = None
570
794
  split_pct = None
795
+ cell_bootstrap_samples = None
796
+ cell_sigma_bootstrap = None
571
797
  if fit_domains:
572
798
  from midas_hkls import DomainData, refine_cell_joint, split_with_error
573
799
  dd = [DomainData(hkl=d.hkl, g=q[np.flatnonzero(d.claim)], label=f"domain{i}")
@@ -577,10 +803,12 @@ def reduce_one_position(
577
803
  n_bootstrap=n_bootstrap)
578
804
  refined_cell = fit.cell
579
805
  split_pct = split_with_error(fit)
806
+ cell_bootstrap_samples = fit.cell_bootstrap_samples # (n_kept, 6): a,b,c,alpha,beta,gamma
807
+ cell_sigma_bootstrap = fit.cell_sigma_bootstrap
580
808
  else:
581
809
  notes.append("no domain passed the a/b gate chain; no cell was jointly refined")
582
810
 
583
- fit_passed_decoy = all(decoy_list[i]["verdict"] != "uninformative"
811
+ fit_passed_decoy = all(decoy_list[i]["verdict"] == "informative"
584
812
  for i, g in enumerate(gate_list) if g.get("passed_to_refine"))
585
813
  quotable = (
586
814
  bool(fit_domains)
@@ -589,8 +817,16 @@ def reduce_one_position(
589
817
  and np.isfinite(split_pct[1])
590
818
  )
591
819
  if fit_domains and not fit_passed_decoy:
592
- notes.append("a domain that passed the a/b gate chain did not pass the decoy test "
593
- "(a deliberately wrong cell scored as well) -- not quotable")
820
+ failing_verdicts = sorted({decoy_list[i]["verdict"]
821
+ for i, g in enumerate(gate_list) if g.get("passed_to_refine")}
822
+ - {"informative"})
823
+ if "real_fails" in failing_verdicts:
824
+ notes.append("a domain that passed the a/b gate chain did not pass the decoy test "
825
+ "(the real fit itself did not clear the acceptance threshold) -- "
826
+ "not quotable")
827
+ if "uninformative" in failing_verdicts:
828
+ notes.append("a domain that passed the a/b gate chain did not pass the decoy test "
829
+ "(a deliberately wrong cell scored as well) -- not quotable")
594
830
  if split_pct is not None and not np.isfinite(split_pct[1]):
595
831
  notes.append("a and b are equal by the refined symmetry: no splitting is being measured")
596
832
 
@@ -599,7 +835,9 @@ def reduce_one_position(
599
835
  completeness=completeness_list, recovery=recovery_list,
600
836
  decoy=decoy_list, feature_in_raw=feature_list, ab_gates=gate_list,
601
837
  refined_cell=refined_cell, split_pct=split_pct, notes=notes,
602
- quotable=bool(quotable))
838
+ quotable=bool(quotable), orientation_envelope=orientation_list,
839
+ cell_bootstrap_samples=cell_bootstrap_samples,
840
+ cell_sigma_bootstrap=cell_sigma_bootstrap)
603
841
 
604
842
 
605
843
  # ---------------------------------------------------------------------------