upxo.repqual.mcgs2d_representativeness_assesser module
Statistical representativeness assessment for 2D MCGS vs a target structure.
Class mc2repr runs distribution tests (e.g. KS, Mann–Whitney, Kruskal–Wallis,
Pearson) on morphological properties of target vs sample grain structures.
Targets may be EBSD-derived or UPXO MC/Voronoi GS. Results are stored for
inspection; there is no single automatic accept/reject score in this module.
Import:
from upxo.repqual.mcgs2d_representativeness_assesser import mc2repr
- class upxo.repqual.mcgs2d_representativeness_assesser.mc2repr(target_type=None, target=None, samples=None, par_bounds=None, metrics=None, kde_options=None, stest={'ks_p_threshold': 0.9, 'kw_p_threshold': 0.9, 'mw_p_threshold': 0.9, 'tests': ['correlation', 'kldiv', 'ks', 'jsdiv', 'mannwhitneyu', 'kruskalwallis']}, test_metrics=['mode0_location', 'mode0_count', 'mode1_location', 'mode1_count', 'mean'], parameters=['area'])[source]
Bases:
objectStatistical representativeness of 2D sample GS vs a target.
Runs distribution tests (KS, Mann–Whitney, Kruskal–Wallis, correlation, KL/JS divergence, etc.) on morphological properties of a target structure against one or more samples. Targets may be EBSD-derived or UPXO MC/Voronoi GS. Results are stored for inspection — there is no single automatic accept/reject score in this class.
- target_type
Target source code:
ebsd0— unprocessed 2D EBSD (DefDAP)ebsd1— processed DefDAP (e.g. remapped avg. orientation)umc2/umc3— UPXO Monte-Carlo 2D / 3Duvt2— UPXO Voronoi tessellation 2Dstats— morphology samples as dict or DataFrame columns
- Type:
- target
Target data:
MCGS.gs[tslice], VTGS, DefDAP EBSD, or stats table.
- samples
Sample name → grain-structure object, or
'make'to generate from an Excel dashboard (simulate → temporal slices → characterise).- Type:
- par_bounds
Per-property bounds, e.g. area/perimeter/aspect ratio →
[[peak_loc_%], [peak_density_%], [JS_bounds]].- Type:
- stest, test_metrics, performance
Configured statistical tests and computed outcomes.
- target_type
- target
- samples
- par_bounds
- metrics
- kde_options
- stest
- test_metrics
- parameters
- performance
- test()[source]
TEST 1: correlation: For two datasets, it is a measure of the linear relationship between them. If correlation is close to 1 then, the distributions are very similar.
TEST 2: kldiv:
TEST 3: ks: Kolmogorov-Smirnov test: Determines of the two distribution samples differ significantly. It uses cumulative distributions of the two datasets. Retyurns D-statistic and P-value.
D-statistic: maximum absolute difference of the cumulative
distributions (absolute max distance (supremum) b/w the CDFs of the two samples). A smaller D-static value is indicative of similar distributions. * P-value: probability that thwe tywo distributions are similar. If p-value is low (<= 0.05), distributions are different. If p-value is high (> 0.05), we cannot reject the null-hypothesis that the two distributions are the same. * Note: if P <= 0.05: the null hypothesis that the two samples are drawn from tyhe sample sample can be rejected, indicating that the samples are not representative of the target
TEST 4: jsdiv: P value will allways be between 0 and 1. @ 0: Distributions are identical. @ 1: Distributions are completely different
TEST 5: mannwhitneyu: Mann-Whitney test: Used to determine if two ‘ distribution samples are drawn from a population having the same population. If P-value is less than or equal to 0.05, then different distributiopns. If P-value is > 0.05, then the two disrtirbutions are similar.
TEST 6: kruskalwallis: Kruskal-wallis test. Used to determine if there are statistically significant differences between two distributions.
- stat_tests
- test_threshold
- distr_type