@wafertools/wafermap 0.37.0 → 0.37.1

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.
@@ -72,7 +72,7 @@ export const USER_GUIDE_HTML=`<div class="wmap-guide">
72
72
  .wmap-guide-toc{display:none!important}
73
73
  }
74
74
  </style>
75
- <h1 id="wmap-wafer-map-user-guide">Wafer Map \u2014 User Guide<span class="wmap-guide-version" title="Built 2026-10-20T13:40:50.345Z">v0.37.0</span></h1>
75
+ <h1 id="wmap-wafer-map-user-guide">Wafer Map \u2014 User Guide<span class="wmap-guide-version" title="Built 2026-10-22T16:46:38.908Z">v0.37.1</span></h1>
76
76
  <p class="wmap-guide-online-link">This is a quick reference. <a href="https://wafertools.github.io/wafermap/user-guide/" target="_blank" rel="noopener">View the full illustrated guide online \u2197</a></p>
77
77
  <p>This guide describes the display and analysis features of the wafer map viewer.
78
78
  It is written for users who may be semiconductor test engineers, device engineers, and yield engineers
@@ -207,6 +207,11 @@ application has loaded.</p>
207
207
  <td>Parametric heatmap \u2014 leakage, Idsat, Vth, etc.</td>
208
208
  </tr>
209
209
  <tr>
210
+ <td><strong>PAT verdict</strong></td>
211
+ <td>Part average testing verdict of the die (within, outlier, fails)</td>
212
+ <td>Where the PAT outliers are, wafer by wafer</td>
213
+ </tr>
214
+ <tr>
210
215
  <td><strong>Stacked Hard Bins</strong></td>
211
216
  <td>Hard bin occurrence counts aggregated across multiple wafers</td>
212
217
  <td>Lot-level yield patterns</td>
@@ -1038,6 +1043,8 @@ toolbar. Choose <strong>Maps</strong> to return to the map; the switch stays whe
1038
1043
  sidebar (see <a href="#wmap-summary-panel" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-summary-panel\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Summary panel</a>) \u2014 the two toggle independently, and opening one never
1039
1044
  hides the other&#39;s toolbar button, since Findings has nothing to highlight
1040
1045
  against once the map is replaced.</p>
1046
+ <p>The <a href="https://wafertools.github.io/wafermap/charts/">Chart reference</a> describes every chart, plot and table: what it
1047
+ shows, how to read it, when to reach for it and where to find it. This section covers how the tab works.</p>
1041
1048
  <p>Any chart mark that stands for one wafer \u2014 a bar in <em>Yield by wafer</em>, a box in
1042
1049
  <em>Test value distribution</em>, a point in <em>Wafer-to-wafer trend</em> \u2014 can be
1043
1050
  right-clicked to chart that wafer on its own (see
@@ -1046,33 +1053,14 @@ right-clicked to chart that wafer on its own (see
1046
1053
  same numbers as tables (see <em>Data tables</em> below), and a <strong>My plots</strong> sub-tab for your
1047
1054
  own charts and sweeps (see <em>Plots</em> and <em>Sweep cards</em> below):</p>
1048
1055
  <ul>
1049
- <li><p><strong>Overview</strong> \u2014 a <strong>test pass rate</strong> chart showing which test fails most (and,
1050
- with &quot;Group by&quot; active, whether it fails more in one split than another). It
1051
- offers up to three ways of judging, whichever the data supports: <strong>Spec
1052
- limits</strong> (the value against its limits), <strong>Tester flag</strong> (the pass/fail the
1053
- tester itself recorded, which a parametric test carries whether or not limits
1054
- were exported), and <strong>Functional</strong> for pass/fail-only tests. The two
1055
- parametric views can disagree \u2014 guard bands and dynamic limits routinely cause
1056
- it \u2014 so the card reports how many dies the two judged differently rather than
1057
- picking one for you. The tests run down the left, worst first, each with its pass rate at the end; click a test&#39;s
1058
- bar for the dies that fail it. The card is the size of the others whatever the number of tests: more than fit
1059
- scroll, with the scrollbar at its right edge or the mouse wheel over the chart, under a pass-rate axis that stays put. With nothing to judge (no limits, no recorded verdicts) the card is left out. Alongside it, headline tiles stating the population (wafers, dies analysed,
1060
- and for a lot the mean wafer yield \u2014 an <em>unweighted</em> mean of each wafer&#39;s own
1061
- yield, not the die-weighted figure), a yield bar labelled with the pass bins
1062
- actually in use, each bar&#39;s yield at its end and the median of the bars as a line (with Group by on, one bar per
1063
- group, pooled as passing dies over judged dies; click a group&#39;s bar to see its wafers, <strong>Back</strong> to return), a
1064
- hard/soft bin pareto with its cumulative share (with Group by on, a bar per group in each bin, as each group&#39;s share
1065
- of its own dies, so groups of different sizes compare, or as counts), and
1066
- ring/quadrant regional yield, and with a reticle set a <strong>Reticle cell yield</strong> grid: the stepper field drawn as its cells (row 0 at
1067
- the bottom), each filled by the yield of that position pooled over every field on every wafer and labelled with it. Hover a cell
1068
- for its dies, click it to chart or tabulate them. A cell that is low in all of them points at the mask rather than the wafer.</p>
1069
- <p>With four or more wafers and wafer fields to compare (lot, split, date, probe card\u2026), <strong>What divides yield</strong> ranks
1070
- every field by how clearly its groups differ in yield and in the rate of each of the five most common fail bins. Each
1071
- wafer is one value, as in the split comparison, so n is wafers; rows are ranked by q (Welch&#39;s p adjusted for every
1072
- comparison in the table). A row names the worst and best groups with their mean over their wafers and the spread in
1073
- percentage points; <strong>Group by</strong> groups the whole tab by that field. A low q says the groups differ by more than
1074
- wafer-to-wafer noise, not why. The card also names fields it could not compare (every wafer its own value) and fields
1075
- that group the wafers identically, which no ranking can tell apart (a lot and its test date).</p>
1056
+ <li><p><strong>Overview</strong> \u2014 how the lot yielded: headline tiles stating the population, <a href="https://wafertools.github.io/wafermap/charts/#yield-by-wafer">Yield by wafer</a>, <a href="https://wafertools.github.io/wafermap/charts/#bin-pareto">Bin pareto</a>,
1057
+ <a href="https://wafertools.github.io/wafermap/charts/#pass-rate-by-test">Pass rate by test</a>, <a href="https://wafertools.github.io/wafermap/charts/#ring-yield">Ring yield</a> and <a href="https://wafertools.github.io/wafermap/charts/#quadrant-yield">Quadrant yield</a>, and with a reticle set
1058
+ <a href="https://wafertools.github.io/wafermap/charts/#reticle-cell-yield">Reticle cell yield</a>. With four or more wafers and wafer fields to compare, <a href="https://wafertools.github.io/wafermap/charts/#what-divides-yield">What divides yield</a>
1059
+ ranks the fields by how clearly their groups differ; <strong>Group by</strong> on its row groups the whole tab by that field. With
1060
+ Group by on, the yield bar and the pareto draw a bar per group (click a group&#39;s bar to see its wafers, <strong>Back</strong> to return). The
1061
+ pass-rate card offers up to three ways of judging, whichever the data supports: <strong>Spec limits</strong>, <strong>Tester flag</strong> and
1062
+ <strong>Functional</strong>; when the first two disagree it says how many dies they judged differently. The card is the size of the
1063
+ others whatever the number of tests: more than fit scroll. With nothing to judge it is left out.</p>
1076
1064
  </li>
1077
1065
  <li><p><strong>Worth a look</strong>, on the Overview below the yield, bin and region cards \u2014 the same items as
1078
1066
  <strong>What stands out</strong> beside the map, in the same order and words, each drawn as the chart that shows
@@ -1085,37 +1073,20 @@ names), and <strong>Show on map</strong> goes back to the map showing it as its
1085
1073
  open on that row. The rest follow on one &quot;Also&quot; line. It describes the whole lot, so while the Insights
1086
1074
  filter or <strong>Show</strong> narrows the population it says so instead of drawing cards.</p>
1087
1075
  </li>
1088
- <li><p><strong>Distributions</strong> \u2014 process capability (Cp/Cpk/Pp/Ppk for tests with both a
1089
- lower and upper limit \u2014 spec limits where given, otherwise test limits; tests
1090
- without both still appear, normalized
1091
- onto their own range and sorted by variability), a test-value box plot (one box per wafer down the left, or with
1092
- Group by on one per group: click a group&#39;s box to see its wafers, <strong>Back</strong> to return), a value histogram (all wafers,
1093
- one wafer, or one series per group), and a <strong>wafer-to-wafer trend</strong> \u2014 one point per wafer at its mean with a \xB11
1094
- standard deviation band, the mean of all wafers as a line (labelled the &quot;lot mean&quot; when they all come from one lot),
1095
- and the test&#39;s limits; drag across it to pick a run of wafers. The trend is always in slot order, deliberately: drift
1096
- across a cassette only reads in the physical sequence, so there is no sort control to destroy it, and it needs at
1097
- least two wafers. The box plot, histogram and trend are plots: each has the test picker and the axis settings
1098
- (<em>Axis includes limits</em>, <em>Clip outliers</em>, and which limits to draw), and a change in one reaches the others.
1099
- Clicking a capability box drives them onto that same test.</p>
1100
- <p>With <strong>Group by</strong> on, a <strong>Difference map</strong> at the foot of Distributions draws one group minus another at every die
1101
- position, as a wafer map: pick the two groups and a test (it follows the test the other panels show until you pick
1102
- one) or <em>Yield</em>. Each group&#39;s value at a position is its mean over the group&#39;s wafers there (for yield, the share
1103
- of them passing), as its stacked map would show it, and a position either group lacks is grey. The colours run
1104
- symmetrically from the largest negative difference to the largest positive, with zero in the middle. It is drawn on
1105
- the first wafer of the first group&#39;s geometry and orientation, so a die is where it is on every other map; the map
1106
- carries no wafer&#39;s identity, since it is none.</p>
1076
+ <li><p><strong>Distributions</strong> \u2014 how values spread: <a href="https://wafertools.github.io/wafermap/charts/#process-capability">Process capability</a>, the <a href="https://wafertools.github.io/wafermap/charts/#test-value-distribution">test-value box plot</a>
1077
+ (one box per wafer, or with Group by on one per group: click a group&#39;s box to see its wafers, <strong>Back</strong> to return), the
1078
+ <a href="https://wafertools.github.io/wafermap/charts/#value-histogram">value histogram</a> (all wafers, one wafer, or one series per group) and the
1079
+ <a href="https://wafertools.github.io/wafermap/charts/#wafer-to-wafer-trend">wafer-to-wafer trend</a>. The trend is always in slot order, deliberately: drift across a cassette only reads
1080
+ in the physical sequence, so there is no sort control to destroy it, and it needs at least two wafers; drag across it to pick a
1081
+ run of wafers. The box plot, histogram and trend are plots: each has the test picker and the axis settings (<em>Axis includes
1082
+ limits</em>, <em>Clip outliers</em>, and which limits to draw), and a change in one reaches the others. Clicking a capability box drives
1083
+ them onto that same test.</p>
1107
1084
  <p>With <strong>Group by</strong> on (a split, a lot), the cards that compare the groups come first, under <strong>Comparing \u2026</strong>: the
1108
- <strong>Comparison by</strong> table and the difference map, then the cards for each test under <strong>Test by test</strong>. The table compares
1109
- every measured test across the groups, ranked so the tests that moved are at the top. Each wafer counts once, as the mean of its dies, because dies
1110
- on one wafer share its processing: counted die by die, a difference no bigger than one wafer&#39;s offset would look
1111
- certain. So n is the number of wafers, and with two or three a group, many differences honestly come out
1112
- inconclusive. For each test the table gives each group&#39;s mean, <strong>Welch p</strong> (Welch&#39;s ANOVA, or Welch&#39;s t for two
1113
- groups: do the means differ, without assuming equal spreads), <strong>Rank p</strong> (Kruskal\u2013Wallis, the same question on ranks,
1114
- which one odd wafer cannot drive; approximate with fewer than five wafers a group), <strong>q</strong> (Welch p adjusted for how
1115
- many tests were compared, Benjamini\u2013Hochberg; the table is sorted by it), and the <strong>largest shift</strong> in wafer-to-wafer
1116
- standard deviations and as a share of the limit window. Choose a <strong>Control</strong> (the process of record) and each other
1117
- group&#39;s cell adds its difference from the control with a Holm-adjusted p. Click a test to show it in the panels below.
1118
- <strong>Comparison CSV</strong> saves the table. <a href="#wmap-comparing-groups-of-wafers" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-comparing-groups-of-wafers\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Comparing groups of wafers</a> explains each figure. Narrowing <strong>Show</strong> to one group leaves nothing to compare, so the table is not shown.</p>
1085
+ <a href="https://wafertools.github.io/wafermap/charts/#comparison-by-group">Comparison by</a> table and the <a href="https://wafertools.github.io/wafermap/charts/#difference-map">difference map</a> (pick the two groups and a test or <em>Yield</em>; it follows
1086
+ the test the other panels show until you pick one), then the cards for each test under <strong>Test by test</strong>. In the table,
1087
+ choose a <strong>Control</strong> and each other group&#39;s cell adds its difference from it; click a test to show it in the panels below;
1088
+ <strong>Comparison CSV</strong> saves the table. Narrowing <strong>Show</strong> to one group leaves nothing to compare, so the table is not shown.
1089
+ <a href="#wmap-comparing-groups-of-wafers" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-comparing-groups-of-wafers\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Comparing groups of wafers</a> explains each figure.</p>
1119
1090
  <p>The box plot, histogram, trend and the Correlation tab&#39;s scatter draw the
1120
1091
  test&#39;s limits as dashed lines. A test can have two kinds: <strong>test limits</strong>
1121
1092
  (labelled <em>Lo limit</em> / <em>Hi limit</em>, short dashes) \u2014 what each die was judged
@@ -1143,19 +1114,13 @@ the visible range when some do. The box plot additionally has its own
1143
1114
  every plotted value is positive) \u2014 the histogram and trend charts do not
1144
1115
  offer one.</p>
1145
1116
  </li>
1146
- <li><p><strong>Correlation</strong> \u2014 a test-to-test correlation matrix and a die-level scatter
1147
- plot, both stating the sample size the coefficients are computed over.
1148
- <strong>Max tests</strong> (5 to 100, 20 by default) sets how many tests the matrix shows, and
1149
- <strong>Correlation CSV</strong> saves the matrix as a table.
1150
- Clicking a matrix cell drives the scatter plot onto that pair, where <code>r</code> and
1151
- <code>n</code> over every point drawn are printed (with Group by on, the colour is the group; filter the legend to look at one).
1152
- When the points pool several splits or lots, the scatter says so: a trend across them may be the groups&#39; offset
1153
- rather than the relationship. Hover a
1154
- point to see which wafer and die it is; <strong>click</strong> it to open that wafer on the
1155
- X test. <strong>Drag</strong> a rectangle over the plot to select the dies inside it \u2014 across
1156
- as many wafers as they fall on \u2014 and a menu opens with charts and tables of
1157
- just those dies (see <a href="#wmap-charting-dies-and-wafers" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-charting-dies-and-wafers\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Charting dies and wafers</a>). The
1158
- selection stays ringed until you change the X or Y test or click empty space.</p>
1117
+ <li><p><strong>Correlation</strong> \u2014 the <a href="https://wafertools.github.io/wafermap/charts/#test-correlation-matrix">test correlation matrix</a> and a die-level <a href="https://wafertools.github.io/wafermap/charts/#test-scatter">scatter</a>, both
1118
+ stating the sample size the coefficients are computed over. <strong>Max tests</strong> (5 to 100, 20 by default) sets how many tests the
1119
+ matrix shows, and <strong>Correlation CSV</strong> saves it as a table. Clicking a matrix cell drives the scatter onto that pair. Hover a
1120
+ point to see which wafer and die it is; <strong>click</strong> it to open that wafer on the X test. <strong>Drag</strong> a rectangle over the plot to
1121
+ select the dies inside it \u2014 across as many wafers as they fall on \u2014 and a menu opens with charts and tables of just those dies
1122
+ (see <a href="#wmap-charting-dies-and-wafers" onclick="(function(e){e.preventDefault();var g=e.target.closest('.wmap-guide');var el=g&&g.querySelector('[id=\\'wmap-charting-dies-and-wafers\\']');if(el)el.scrollIntoView({behavior:'smooth'});})(event)">Charting dies and wafers</a>). The selection stays ringed until you change the X or Y test or
1123
+ click empty space.</p>
1159
1124
  </li>
1160
1125
  </ul>
1161
1126
  <p>In a gallery with more than one wafer, a <strong>Group by</strong> control appears whenever
@@ -1470,10 +1435,12 @@ and draws none. The limits are always the whole wafer&#39;s, even in a panel of
1470
1435
  The Overview shows the same verdicts as a <strong>Part average testing (PAT)</strong> card: for each wafer, the dies within the PAT
1471
1436
  limits, the outliers and the rate, the dies that fail anyway, and which tests the outliers are outside on. The Dies
1472
1437
  table (Data tab) has a <strong>PAT</strong> column, and <strong>PAT tests</strong> where there are outliers, in the CSV too; a selection that
1473
- is only part of a wafer has neither, since the limits belong to the whole wafer. <strong>Map the verdicts</strong> on the card opens a
1474
- gallery with a map of each wafer, its dies coloured by their PAT verdict (within the limits, outlier, fails anyway), so
1475
- the gallery&#39;s legend and value toggles show where the outliers are on each wafer. The maps state no yield: a verdict is
1476
- not a bin.</li>
1438
+ is only part of a wafer has neither, since the limits belong to the whole wafer. <strong>Map the verdicts</strong> on the card goes back to the
1439
+ maps coloured by PAT verdict, which is also the <strong>PAT verdict</strong> entry of the <strong>Plot mode</strong> menu on a map and on a
1440
+ gallery (offered when a test has both limits and a wafer has enough dies to set PAT limits from): within the limits
1441
+ in blue, outlier in amber, fails anyway in red, so the legend and value toggles show where the outliers are on each
1442
+ wafer. The dies keep their bins and measurements, so the tooltip shows them beside the verdict. With a filter on, the
1443
+ verdicts are judged over the dies the filter keeps, as on the card.</li>
1477
1444
  <li><strong>Panels</strong>: one small plot per value of a category field, laid out like the gallery&#39;s cards, on shared axes and
1478
1445
  colours with one legend and one statement above them. A wafer field (split, lot) gives each panel its whole wafers; a
1479
1446
  die field (ring, site, bin) the dies with that value from every wafer; <strong>Test</strong>, with several tests as the values,
@@ -1,3 +1,3 @@
1
- export declare const WMAP_VERSION = "0.37.0";
2
- export declare const WMAP_BUILD_TIME = "2026-10-20T13:45:09.045Z";
1
+ export declare const WMAP_VERSION = "0.37.1";
2
+ export declare const WMAP_BUILD_TIME = "2026-10-22T16:49:42.159Z";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- export const WMAP_VERSION="0.37.0",WMAP_BUILD_TIME="2026-10-20T13:45:09.045Z";
1
+ export const WMAP_VERSION="0.37.1",WMAP_BUILD_TIME="2026-10-22T16:49:42.159Z";
@@ -1 +1 @@
1
- import{createWafer as Q}from"../core/wafer.js";import{isYieldEligibleDie as ve,getDieKey as X,hasPosition as W,positionKey as Se}from"../core/dies.js";import{applyOrientation as se,transformDies as Ce,clipDiesToWafer as ke}from"../core/transforms.js";import{generateDies as Oe}from"../core/dies.js";import{dieHasAnyTestData as Ae,dieLink as U,finaliseDie as z,linkDie as $e,recordedVerdict as Ne,recordedVerdictsReader as Re,tableFromRows as Fe,testValue as Z,testsPresent as Ee,VERDICT_FAIL as Te,VERDICT_NONE as We,VERDICT_PASS as Ie}from"../core/dieTable.js";import{isDieColumns as _e,linkColumns as Pe,linkRows as re,relink as oe}from"./columnarInput.js";import{affineRotation as Ve,affineMirror as Be,affineCompose as Le,affinePoint as Ye}from"../core/transforms.js";import{inferWaferFromXY as Xe}from"../core/inference/wafer.js";import{resolveGridPitch as Ke}from"../core/inference/pitch.js";import{assignGridIndices as je}from"../core/inference/grid.js";import{generateReticleGrid as He}from"../core/reticle.js";import{applyDerivedTests as Ue}from"./derivedTests/apply.js";import{isStdfBin as ze,isStdfCoord as ae,isStdfTestNumber as de,isStdfSite as Ge,STDF_BIN_MAX as qe,STDF_COORD_MAX as fe,STDF_TEST_NUM_MAX as Je,STDF_SITE_MAX as Qe}from"../core/stdf.js";import{hasAnyKey as Ze,maxOf as ee,minOf as le,modeOf as et}from"../core/utils.js";import{aggregateValues as ue,aggregateBinCounts as tt,stackHoldsMeasurements as nt,stackBinsAreData as it}from"../core/aggregates.js";import{normalizePassBins as ce}from"../core/passBins.js";import{defaultRingCount as te}from"../core/ringCount.js";import{applyValueFilter as st,mergeValueFilterTests as rt,valueFilterWarning as ot}from"./valueFilter.js";export function isParametricTest(n){return n?.testType!=="F"}export function isBuiltMap(n){return"wafer"in n&&"dies"in n&&"dataAxisFlip"in n}function at(n){const e=(i,a)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(n)} ${a} (using ${i}).`}});if(n===void 0)return{ringCount:te(),ringCountWarning:void 0};if(typeof n!="number"||!Number.isFinite(n))return e(te(),"is not a finite number");const t=Math.max(1,Math.round(n));return t===n?{ringCount:n,ringCountWarning:void 0}:e(t,"is not a whole number of at least 1")}function dt(n,e){const t=Array.isArray(n)?{}:n,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let a;const d=(u,C)=>{i[u]++,a??=`${u} ${JSON.stringify(C)}`},o={bins:0,positions:0,values:0,sites:0,orientation:0},r=new Set;let p=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(a??=e.example),o.values+=e.nonFinite;for(const u of e.badTestNumbers)r.add(u)}const h=u=>u==null?!0:typeof u!="number"?!1:Number.isNaN(u)?(p++,!1):ze(u)?!0:(o.bins++,!1);function l(u){const C=new Set,D=new Set;for(let S=0;S<u.length;S+=S<50?1:100){const N=u[S];if(!(N===null||typeof N!="object")){if(N.testValues&&typeof N.testValues=="object")for(const M of Object.keys(N.testValues))C.add(M);if(N.testPass&&typeof N.testPass=="object")for(const M of Object.keys(N.testPass))D.add(M)}}const g=[...C],b=[...D],k=S=>de(Number(S));for(const S of new Set([...g,...b]))k(S)||r.add(S);const R=g.map(k),v=b.map(k),T=g.map(Number),L=b.map(Number);let K;for(let S=0;S<u.length;S++){const N=u[S];if(N===null||typeof N!="object")continue;const M=N;let F;const $=()=>F??={...M};M.hbin!=null&&typeof M.hbin!="number"&&d("hbin",M.hbin),M.sbin!=null&&typeof M.sbin!="number"&&d("sbin",M.sbin),h(M.hbin)||($().hbin=void 0),h(M.sbin)||($().sbin=void 0);const Y=typeof M.x=="number"&&!ae(M.x),j=typeof M.y=="number"&&!ae(M.y);if(Y||j){o.positions+=(Y?1:0)+(j?1:0);const s=$();s.x=void 0,s.y=void 0}M.siteNum!=null&&typeof M.siteNum!="number"?(d("siteNum",M.siteNum),$().siteNum=void 0):typeof M.siteNum=="number"&&!Ge(M.siteNum)&&(o.sites++,$().siteNum=void 0);const P=M.testValues;if(P&&typeof P=="object"){let s;for(let x=0;x<g.length;x++){const A=g[x],O=P[T[x]];if(O!=null){if(!R[x]){s??={...P},delete s[A];continue}typeof O!="number"?(d("testValues",O),s??={...P},delete s[A]):Number.isFinite(O)||(o.values++,s??={...P},delete s[A])}}s&&($().testValues=s)}const I=M.testPass;if(I&&typeof I=="object"){let s;for(let x=0;x<b.length;x++){const A=b[x],O=I[L[x]];if(O!=null){if(!v[x]){s??={...I},delete s[A];continue}typeof O!="boolean"&&(d("testPass",O),s??={...I},delete s[A])}}s&&($().testPass=s)}F&&((K??=u.slice())[S]=F)}return K}const f={warnings:[]};if(Array.isArray(n))f.results=l(n);else{Array.isArray(t.results)&&(f.results=l(t.results)),Array.isArray(t.dies)&&(f.dies=l(t.dies));const u=t.lotStack?.results;if(Array.isArray(u)){const C=u.map(D=>Array.isArray(D)?l(D):void 0);C.some(Boolean)&&(f.stackResults=C.map((D,g)=>D??u[g]))}}if(Array.isArray(t.testDefs)){const u=t.testDefs,C=u.filter(D=>D==null||typeof D.testNumber!="number"||de(D.testNumber));for(const D of u)C.includes(D)||r.add(String(D.testNumber));C.length!==u.length&&(f.testDefs=C)}const y=t.waferConfig?.orientation;if(typeof y=="number"){const u=Number.isFinite(y)?(y%360+360)%360:NaN;u===0||u===90||u===180||u===270?f.orientation=u:(o.orientation++,f.orientation=0)}const m=(u,C,D=`${C}s`)=>`${u} ${u===1?C:D}`,c=[];if(i.hbin&&c.push(m(i.hbin,"hard bin")),i.sbin&&c.push(m(i.sbin,"soft bin")),i.siteNum&&c.push(m(i.siteNum,"site number")),i.testValues&&c.push(m(i.testValues,"test value")),i.testPass&&c.push(m(i.testPass,"pass/fail verdict")),c.length){const u=`buildWaferMap received ${c.join(", ")} of the wrong type (for example ${a}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${u}`),f.warnings.push({code:"input-values-not-numbers",message:u,severity:"error"})}const w=[];if(o.bins&&w.push(`${m(o.bins,"bin")} (legal: whole numbers 0\u2013${qe}) \u2014 those dies have no bin`),o.positions&&w.push(`${m(o.positions,"coordinate")} (legal: whole numbers \u2212${fe} to ${fe}) \u2014 those dies have no position`),r.size&&w.push(`${m(r.size,"test number")} (legal: whole numbers 0\u2013${Je}) \u2014 those tests are left out`),o.values&&w.push(`${m(o.values,"test value")} that ${o.values===1?"is":"are"} not finite \u2014 left out`),o.sites&&w.push(`${m(o.sites,"site number")} (legal: 0\u2013${Qe}) \u2014 those dies have no site`),o.orientation&&w.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),w.length||p){const u=[];w.length&&u.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${w.join("; ")}.`),p&&u.push(`${m(p,"bin was","bins were")} NaN and ${p===1?"is":"are"} treated as no bin.`);const C=u.join(" ");console.warn(`[wafermap] ${C}`),f.warnings.push({code:"input-values-outside-stdf",message:C,severity:"warning"})}return f}function pe(n){const e=(h,l)=>h!==null&&typeof h=="object"&&h[l]!==void 0,t=Array.isArray(n)?{}:n,i=[],a=(h,l,f)=>{h&&i.push(`\`${l}\` (now \`${f}\`)`)};a(e(t,"data"),"data","results"),a(e(t,"die"),"die","dieConfig"),a(e(t,"stack"),"stack","lotStack"),a(e(t.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),a(e(t.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),a(e(t.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),a(e(t.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),a(Array.isArray(t.testDefs)&&t.testDefs.some(h=>e(h,"index")&&!e(h,"testNumber")),"TestDef.index","TestDef.testNumber");const d=e(t.lotStack,"results")?t.lotStack.results:[],o=(Array.isArray(n)?[n]:[t.results,...Array.isArray(d)?d:[]]).filter(h=>Array.isArray(h));if(a(o.some(h=>h.slice(0,100).some(l=>e(l,"values"))),"values","testValues"),!i.length)return;const r=i.length>1,p=`buildWaferMap ignored ${i.join(", ")}: ${r?"these names were":"that name was"} removed in an earlier release, so what ${r?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${p}`),{code:"input-field-removed",message:p,severity:"error"}}function ft(n){if(n.results!==void 0||n.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=n.waferConfig?.diameter,t=n.dieConfig?.width,i=n.dieConfig?.height;if(!(e>0&&t>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const a=Q({diameter:e,notch:n.waferConfig?.notch,orientation:0}),d=ke(Oe(a,{width:t,height:i}),a,{width:t,height:i}).filter(l=>!l.partial),{flipX:o,flipY:r}=me(n.dieConfig,{type:"center"}),{layout:p,...h}=n;return{...h,results:d.map(l=>({x:o?-l.x:l.x,y:r?-l.y:l.y})),waferConfig:{...n.waferConfig,center:{x:0,y:0}},dieConfig:{...n.dieConfig,coordinateOrigin:{type:"center"}}}}function lt(n){if(!Array.isArray(n)&&"results"in n&&n.results!==void 0&&"lotStack"in n&&n.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},t=!Array.isArray(n)&&_e(n.results)?{...n,results:Pe(n.results,e).records}:n,i=dt(t,e);return Array.isArray(t)?{results:ne(i.results??t),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:ce(void 0),ringCount:te(),valueFilter:"validity",ringCountWarning:void 0,removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:ne(i.results??t.results??[]),waferOpts:i.orientation===void 0||t.waferConfig===void 0?t.waferConfig:{...t.waferConfig,orientation:i.orientation},dieOpts:t.dieConfig,explicitDies:i.dies??t.dies,reticleOpts:t.reticleConfig,lotStackOpts:t.lotStack?{...t.lotStack,results:(i.stackResults??t.lotStack.results).map(ne)}:void 0,passBins:ce(t.passBins),valueFilter:t.valueFilter??"validity",...at(t.ringCount),removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:t.standardDiameters,testDefs:(i.testDefs??t.testDefs)?.length?i.testDefs??t.testDefs:void 0,hbinDefs:t.hbinDefs,sbinDefs:t.sbinDefs,metadataFields:t.metadataFields,derivedTests:t.derivedTests?.length?t.derivedTests:void 0,retestPolicy:t.retestPolicy??"last",edgeDieYieldMode:t.edgeDieYieldMode??"exclude"}}function ne(n){return n.length>0&&U(n[0])!==void 0?n:re(n).records}function ut(n,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function ct(n,e,t){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,a=-1/0,d=1/0,o=-1/0;for(const r of n)r.x<i&&(i=r.x),r.x>a&&(a=r.x),r.y<d&&(d=r.y),r.y>o&&(o=r.y);return{offsetX:Math.round((a+i)/2),offsetY:Math.round((o+d)/2)}}return{offsetX:t.offsetX,offsetY:t.offsetY}}function pt(n,e){if(n.length<xe)return!1;const t=he(n),i=(a,d,o)=>{const r=o-d+1;return a<d-r||a>o+r};return i(Math.round(e.x),t.xMin,t.xMax)||i(Math.round(e.y),t.yMin,t.yMax)}function he(n){let e=1/0,t=-1/0,i=1/0,a=-1/0;for(const d of n){const o=Math.round(d.x),r=Math.round(d.y);o<e&&(e=o),o>t&&(t=o),r<i&&(i=r),r>a&&(a=r)}return{xMin:e,xMax:t,yMin:i,yMax:a}}const ht="The supplied wafer centre";function mt(n,e){const t=he(n);return`${ht} (${e.x}, ${e.y}) is far outside the probed dies (X ${t.xMin}\u2026${t.xMax}, Y ${t.yMin}\u2026${t.yMax}), so it was ignored and the centre was inferred from the dies. Used as given, it would draw a wafer many times the die extent with the dies in one corner. If it is the real centre, supply waferConfig.diameter as well.`}function gt(n,e,t,i,a,d){if(d)return{colMidX:(Math.round(d.x)-e)*i,colMidY:(Math.round(d.y)-t)*a,anchored:!0};if(n.length===0)return{colMidX:0,colMidY:0,anchored:!1};let o=1/0,r=-1/0,p=1/0,h=-1/0;for(const l of n){const f=Math.round(l.x)-e,y=Math.round(l.y)-t;f<o&&(o=f),f>r&&(r=f),y<p&&(p=y),y>h&&(h=y)}return{colMidX:(o+r)/2*i,colMidY:(p+h)/2*a,anchored:!1}}function yt(n,e,t){let i=1/0,a=-1/0,d=1/0,o=-1/0,r=0,p=0;for(const f of n){const y=Math.round(f.x)-e,m=Math.round(f.y)-t;r+=y,p+=m,y<i&&(i=y),y>a&&(a=y),m<d&&(d=m),m>o&&(o=m)}const h=n.length,l=(f,y,m)=>{const c=(m-y)/2;return c<=0?0:Math.abs(f/h-(y+m)/2)/c};return l(r,i,a)>.11||l(p,d,o)>.11}function me(n,e){let t=n?.xAxisDirection==="left",i=n?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(t=!0),{flipX:t,flipY:i}}function bt(n){const e={...n};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function wt(n,e){const{method:t,targetBin:i}=n,a=n.results.map(d=>d.filter(W));if(t==="mean"||t==="median"||t==="stddev"||t==="min"||t==="max"||t==="count"){const d=new Set((e??[]).filter(l=>!isParametricTest(l)).map(l=>l.testNumber)),o=new Set;for(const l of a)for(const f of Ee(l,"values"))d.has(f)||o.add(f);if(o.size===0)return ue(a,t);const r=[...o],p=r.map(l=>ue(a,t,l)),h=new Map;for(let l=0;l<r.length;l++){const f=r[l];for(const y of p[l]){const m=X(y);h.has(m)||h.set(m,{template:y,testValues:{}});const c=h.get(m),w=y.testValues?.[0];w!==void 0&&(c.testValues[f]=w)}}return[...h.values()].map(({template:l,testValues:f})=>({...l,testValues:Ze(f)?f:void 0}))}if(t==="countBin"||t==="percent"){if(i===void 0)return[];const d=tt(a,i,"hard");if(t==="countBin")return d;const o=a.length;return d.map(r=>({...r,testValues:{0:o>0?(r.testValues?.[0]??0)/o*100:0}}))}if(t==="mode"){const d=new Map;for(const r of a)for(const p of r){const h=X(p);d.has(h)||d.set(h,[]),d.get(h).push(p)}const o=[];for(const[r,p]of d){const h=r.split(","),l=Number(h[0]),f=Number(h[1]),y=p.map(c=>c.hbin).filter(c=>c!==void 0),m=et(y);m!==null&&o.push({x:l,y:f,hbin:m})}return o}return[]}export function computeCoverage(n){const e=n.filter(W),t=e.length,i=e.filter(d=>d.edgeExcluded).length,a=e.filter(d=>d.hbin!==void 0||d.sbin!==void 0||dieHasTestData(d)).length;return{filledDies:a,totalDies:t,edgeExcludedDies:i,unpositionedDies:n.length-e.length,ratio:t>0?a/t:0}}export function computeYield(n,e,t="exclude",i=!0){const a=new Set(e),o=n.filter(c=>!c.partial).filter(c=>c.edgeExcluded).length,r=n.filter(c=>c.partial).length;if(!i)return{passDies:0,failDies:0,edgeExcludedDies:o,partialDies:r,totalDies:0,yieldPercent:null,yieldPercentGross:null};let p=0,h=0,l=!1;for(const c of n){if(!ve(c))continue;const w=c.hbin??c.sbin;w!==void 0&&(l=!0,a.has(w)?p++:h++)}const f=p+h,y=l&&f>0?p/f*100:null;let m=null;if(t==="denominator-only"){const c=f+o;m=l&&c>0?p/c*100:null}return{passDies:p,failDies:h,edgeExcludedDies:o,partialDies:r,totalDies:f,yieldPercent:y,yieldPercentGross:m}}function ge(n,e,t,i,a,d=0,o=0,r=0,p=0,h=0,l=!1,f=!1){if(!n)return[];const y=n.anchorDie??{x:0,y:0},m=He(e,{width:n.width,height:n.height,diePitchX:i,diePitchY:a,anchorDie:{x:y.x-d,y:y.y-o},gridOrigin:{x:-r,y:-p}}),c=Le(Be(l,f,e.center.x,e.center.y),Ve(h,e.center.x,e.center.y));return m.filter(w=>{const u=w.width/2,C=w.height/2,D=[[w.x-u,w.y-C],[w.x+u,w.y-C],[w.x+u,w.y+C],[w.x-u,w.y+C]].map(([v,T])=>Ye(c,v,T)),g=le(D.map(v=>v.x)),b=ee(D.map(v=>v.x)),k=le(D.map(v=>v.y)),R=ee(D.map(v=>v.y));return t.some(v=>v.physX>=g&&v.physX<b&&v.physY>=k&&v.physY<R)})}function xt(n,e,t){const a=Math.max(0,e.radius-t)**2;return n.map(d=>{const o=d.physX-e.center.x,r=d.physY-e.center.y;return o*o+r*r>a?{...d,edgeExcluded:!0}:d})}const Dt=.2;function Mt(n){const e=new Set;for(const t of n){if(t.supersedes!==void 0||!W(t))return!1;const i=Se(t);if(e.has(i))return!1;e.add(i)}return!0}function vt(n,e,t){if(Mt(n))return{results:n.slice(),warning:void 0};const i=new Set(t);function a(g,b){if(e==="last")return!0;if(e==="first")return!1;const k=G(g.hbin),R=G(b.hbin);if(k===void 0||R===void 0)return!1;const v=i.has(k),T=i.has(R);return e==="best"?T!==v?T:R<k:T!==v?v:R>k}const d=(g,b)=>b.supersedes!==void 0||a(g,b),o=g=>{const b=g.partId===void 0?"":String(g.partId).trim();return b===""?void 0:b},r=n.filter(g=>!W(g)),p=new Map;for(const g of r){const b=o(g);b!==void 0&&p.set(b,(p.get(b)??0)+1)}const l=(r.length===0?0:Math.max(0,...p.values())/r.length)<=Dt,f=new Map,y=[],m=new Map;let c=0,w=0;for(const g of n){const b=o(g);let k;if(W(g)?k=`p:${X(g)}`:l&&b!==void 0?k=`i:${b}`:k=`u:${w++}`,g.supersedes==="partId"&&b!==void 0){const v=m.get(b);v!==void 0&&v!==k&&f.has(v)&&f.delete(v)}const R=f.get(k);R===void 0?(f.set(k,{winner:g,count:1}),y.push(k)):(R.count++,k.startsWith("i:")&&c++,d(R.winner,g)&&(R.winner=g)),b!==void 0&&m.set(b,k)}const u=[],C=[...y.filter(g=>g.startsWith("p:")),...y.filter(g=>!g.startsWith("p:"))];for(const g of C){const b=f.get(g);b!==void 0&&u.push(b.count>1?{...b.winner,retestCount:b.count}:b.winner)}const D=c>0?{code:"retests-by-part-id",severity:"info",message:`${c} record${c===1?"":"s"} with no position shared a part ID with an earlier record and ${c===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:u,warning:D}}export function getDieTestValue(n,e){return Z(n,e)}export function getTestPassStatus(n,e,t){const i=Ne(n,e);return i!==void 0?i:t!==void 0&&!isParametricTest(t)?ye(Z(n,e)):void 0}function ye(n){return n===0||n===1?n===1:void 0}export function testPassStatusReader(n){const e=n.map(a=>a.testNumber),t=Re(e),i=n.map(a=>!isParametricTest(a));return function(d,o){t(d,o);for(let r=0;r<o.length;r++){if(o[r]!==We||!i[r])continue;const p=ye(Z(d,e[r]));p!==void 0&&(o[r]=p?Ie:Te)}return o}}export function dieHasTestData(n){return Ae(n)}function G(n){return n===void 0||Number.isNaN(n)?void 0:n}function q(n,e){const t={},i=G(e.hbin),a=G(e.sbin);i!==void 0&&(t.hbin=i),a!==void 0&&(t.sbin=a),e.retestCount!==void 0&&(t.retestCount=e.retestCount),e.siteNum!==void 0&&(t.siteNum=e.siteNum),e.partId!==void 0&&(t.partId=e.partId),e.metadata!==void 0&&(t.metadata=e.metadata);const d=U(e);return $e({...n,...t},d.table,d.row)}function be(n){return n.some(dieHasTestData)?"value":defaultBinMode([n])}export function defaultBinMode(n){const e=t=>n.some(i=>i.some(a=>t(a)!=null));return e(t=>t.hbin)?"hardBin":e(t=>t.sbin)?"softBin":"hardBin"}function we(n,e){return n.map(({code:t,message:i})=>({code:t,message:i,severity:t==="non-standard-diameter"||t==="diameter-exceeds-die-extent"||t==="implausible-center"?"warning":"error",confidence:e.wafer.confidence}))}const St="do not fit inside the supplied",Ct="Inferred wafer diameter",kt="The probed dies reach only",Ot=.75,xe=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const At=.02;function De(n,e){return e.reduce((t,i)=>Math.abs(i-n)<Math.abs(t-n)?i:t)}function $t(n,e){if(!e.length)return!0;const t=De(n,e);return Math.abs(t-n)/t<=At}function Nt(n){return n===void 0?STANDARD_WAFER_DIAMETERS_MM:n.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(n){const e=lt(!Array.isArray(n)&&n.layout?ft(n):n),t=[];let i;if(e.valueFilter!=="none"&&e.testDefs){const s=e.valueFilter,x=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(O=>{const _=O.length>0?U(O[0]):void 0;if(!_)return[];const E=st(_.table,e.testDefs,s);return E.tests.length>0&&oe(O,E.table),E.tests}),A=rt(x);if(A.length>0){i={mode:s,tests:A};const O=ot(s,A,e.testDefs);O&&t.push(O)}}if(e.derivedTests){const s=new Set(e.passBins),x=_=>{const E=_.length>0?U(_[0]):void 0,H=Ue(_,E?.table??Fe([]),e.testDefs,e.derivedTests,s);return E&&oe(_,H.table),H},O=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(x);e.testDefs=O[0]?.testDefs??e.testDefs,t.push(...O[0]?.warnings??[])}e.lotStackOpts&&!nt(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(bt));const a=e.lotStackOpts?re(wt(e.lotStackOpts,e.testDefs)).records:e.results;for(let s=0;s<Math.min(5,a.length);s++){const x=a[s];if(typeof x.x=="string"||typeof x.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const s of a)if(s.x==null!=(s.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(s.x)}, y=${String(s.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:d,warning:o}=vt(a,e.retestPolicy,e.passBins),r={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},p=[];if(e.explicitDies){let s=e.explicitDies.filter(W);const x=e.explicitDies.filter(B=>!W(B)),A=d.filter(W),O=d.filter(B=>!W(B));if(A.length>0){const B=new Map(A.map(V=>[X(V),V]));s=s.map(V=>{const ie=B.get(X(V));return ie?q(V,ie):V})}const _=e.waferOpts?.diameter??300,E=Q({diameter:_,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});E.orientation!==0&&(s=se(s,E)),s=s.map(z);const H=ge(e.reticleOpts,E,s,1,1,0,0,0,0,E.orientation),Me=O.map((B,V)=>z(q({id:`unpositioned_${V}`,width:s[0]?.width??1,height:s[0]?.height??1},B))),J=[...s,...x,...Me];return{wafer:E,dies:J,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:E.metadata??null,isLotStack:!1,dataCoverage:computeCoverage(J),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(J,e.passBins,e.edgeDieYieldMode),reticles:H,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const h=d.filter(W),l=d.filter(s=>!W(s)),f=h.map(s=>({x:s.x,y:s.y})),y=Ke(f,e.dieOpts,e.waferOpts?.diameter);r.diePitch={confidence:y.confidence,units:y.units};const{pitchX:m,pitchY:c}=y,w=y.units,u=ut(h,e.dieOpts),C=je(f);r.grid={confidence:C.confidence};const{offsetX:D,offsetY:g}=ct(f,u,C),{flipX:b,flipY:k}=me(e.dieOpts,u),R=e.waferOpts?.diameter===void 0&&e.waferOpts?.center!==void 0&&pt(f,e.waferOpts.center),v=R?void 0:e.waferOpts?.center;R&&p.push({code:"implausible-center",message:mt(f,e.waferOpts.center)});const{colMidX:T,colMidY:L,anchored:K}=gt(f,D,g,m,c,v);let S=e.waferOpts?.diameter;const N=f.map(s=>({x:(Math.round(s.x)-D)*m-T,y:(Math.round(s.y)-g)*c-L})),M=ee(N.map(({x:s,y:x})=>Math.hypot(Math.abs(s)+m/2,Math.abs(x)+c/2)));if(S===void 0)if(f.length>0)if(w==="mm"){const s=Xe(N,{minRadius:M});S=s.diameter,r.wafer={confidence:s.confidence,method:s.method};const x=Nt(e.standardDiameters);if(!$t(S,x)){const A=De(S,x);p.push({code:"non-standard-diameter",message:`${Ct} ${S.toFixed(1)} mm is not a standard wafer size (nearest is ${A} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else S=M*2,r.wafer={confidence:y.confidence*.8,method:"extent"};else S=w==="mm"?300:30,r.wafer={confidence:0,method:"default"};if(!K&&f.length>0&&yt(f,D,g)&&(r.wafer.method="inferred-partial",p.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&v===void 0&&M>0&&f.length>=xe){const s=M/(S/2);s<Ot&&p.push({code:"diameter-exceeds-die-extent",message:`${kt} ${(s*100).toFixed(0)}% of the ${S} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const s=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(s&&M>S/2+1e-9){const x=N.filter(({x:A,y:O})=>Math.hypot(Math.abs(A)+m/2,Math.abs(O)+c/2)>S/2+1e-9).length;p.push({code:"geometry-conflict",message:`${x} of ${N.length} probed die positions ${St} ${S} mm wafer at the supplied die pitch of ${m} \xD7 ${c} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${(M*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const F=Q({diameter:S,units:w,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});let $=h.map(s=>{const x=Math.round(s.x)-D,A=Math.round(s.y)-g,O={id:`${x}_${A}`,x,y:A,physX:x*m-T,physY:A*c-L,width:m,height:c,insideWafer:!0,partial:!1};return q(O,s)});(D!==0||g!==0)&&($=$.map(s=>({...s,x:s.x+D,y:s.y+g,id:`${s.x+D}_${s.y+g}`}))),$=se($,F),(b||k)&&($=Ce($,{flipX:b,flipY:k},F.center));const Y=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&($=xt($,F,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>F.radius&&Y.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${F.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),$=$.map(z);const j=ge(e.reticleOpts,F,$,m,c,D,g,T,L,F.orientation,b,k),P=l.map((s,x)=>z(q({id:`unpositioned_${x}`,width:m,height:c},s))),I=[...$,...P];return{wafer:F,dies:I,dataAxisFlip:{x:b,y:k},reticleConfig:e.reticleOpts,units:w,inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...Y,...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:F.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:computeCoverage(I),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(I,e.passBins,e.edgeDieYieldMode,it(e.lotStackOpts!==void 0,e.lotStackOpts?.method)),reticles:j,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
1
+ import{createWafer as Q}from"../core/wafer.js";import{isYieldEligibleDie as ve,getDieKey as X,hasPosition as W,positionKey as Se}from"../core/dies.js";import{applyOrientation as se,transformDies as Ce,clipDiesToWafer as ke}from"../core/transforms.js";import{generateDies as Oe}from"../core/dies.js";import{dieHasAnyTestData as Ae,dieLink as U,finaliseDie as z,linkDie as $e,recordedVerdict as Ne,recordedVerdictsReader as Re,tableFromRows as Fe,testValue as Z,testsPresent as Ee,VERDICT_FAIL as Te,VERDICT_NONE as We,VERDICT_PASS as Ie}from"../core/dieTable.js";import{isDieColumns as _e,linkColumns as Pe,linkRows as re,relink as oe}from"./columnarInput.js";import{affineRotation as Ve,affineMirror as Be,affineCompose as Le,affinePoint as Ye}from"../core/transforms.js";import{inferWaferFromXY as Xe}from"../core/inference/wafer.js";import{resolveGridPitch as Ke}from"../core/inference/pitch.js";import{assignGridIndices as je}from"../core/inference/grid.js";import{generateReticleGrid as He}from"../core/reticle.js";import{applyDerivedTests as Ue}from"./derivedTests/apply.js";import{isStdfBin as ze,isStdfCoord as ae,isStdfTestNumber as de,isStdfSite as Ge,STDF_BIN_MAX as qe,STDF_COORD_MAX as fe,STDF_TEST_NUM_MAX as Je,STDF_SITE_MAX as Qe}from"../core/stdf.js";import{hasAnyKey as Ze,maxOf as ee,minOf as le,modeOf as et}from"../core/utils.js";import{aggregateValues as ue,aggregateBinCounts as tt,stackHoldsMeasurements as nt,stackBinsAreData as it}from"../core/aggregates.js";import{normalizePassBins as ce}from"../core/passBins.js";import{defaultRingCount as te}from"../core/ringCount.js";import{applyValueFilter as st,mergeValueFilterTests as rt,valueFilterWarning as ot}from"./valueFilter.js";export function isParametricTest(n){return n?.testType!=="F"}export function isBuiltMap(n){return"wafer"in n&&"dies"in n&&"dataAxisFlip"in n}function at(n){const e=(i,a)=>({ringCount:i,ringCountWarning:{code:"analysis-option-corrected",severity:"warning",message:`ringCount=${String(n)} ${a} (using ${i}).`}});if(n===void 0)return{ringCount:te(),ringCountWarning:void 0};if(typeof n!="number"||!Number.isFinite(n))return e(te(),"is not a finite number");const t=Math.max(1,Math.round(n));return t===n?{ringCount:n,ringCountWarning:void 0}:e(t,"is not a whole number of at least 1")}function dt(n,e){const t=Array.isArray(n)?{}:n,i={hbin:0,sbin:0,siteNum:0,testValues:0,testPass:0};let a;const d=(u,C)=>{i[u]++,a??=`${u} ${JSON.stringify(C)}`},o={bins:0,positions:0,values:0,sites:0,orientation:0},r=new Set;let p=0;if(e){i.testValues+=e.wrongValues,i.testPass+=e.wrongVerdicts,e.example!==void 0&&(a??=e.example),o.values+=e.nonFinite;for(const u of e.badTestNumbers)r.add(u)}const h=u=>u==null?!0:typeof u!="number"?!1:Number.isNaN(u)?(p++,!1):ze(u)?!0:(o.bins++,!1);function l(u){const C=new Set,D=new Set;for(let S=0;S<u.length;S+=S<50?1:100){const N=u[S];if(!(N===null||typeof N!="object")){if(N.testValues&&typeof N.testValues=="object")for(const M of Object.keys(N.testValues))C.add(M);if(N.testPass&&typeof N.testPass=="object")for(const M of Object.keys(N.testPass))D.add(M)}}const g=[...C],b=[...D],k=S=>de(Number(S));for(const S of new Set([...g,...b]))k(S)||r.add(S);const R=g.map(k),v=b.map(k),T=g.map(Number),L=b.map(Number);let K;for(let S=0;S<u.length;S++){const N=u[S];if(N===null||typeof N!="object")continue;const M=N;let F;const $=()=>F??={...M};M.hbin!=null&&typeof M.hbin!="number"&&d("hbin",M.hbin),M.sbin!=null&&typeof M.sbin!="number"&&d("sbin",M.sbin),h(M.hbin)||($().hbin=void 0),h(M.sbin)||($().sbin=void 0);const Y=typeof M.x=="number"&&!ae(M.x),j=typeof M.y=="number"&&!ae(M.y);if(Y||j){o.positions+=(Y?1:0)+(j?1:0);const s=$();s.x=void 0,s.y=void 0}M.siteNum!=null&&typeof M.siteNum!="number"?(d("siteNum",M.siteNum),$().siteNum=void 0):typeof M.siteNum=="number"&&!Ge(M.siteNum)&&(o.sites++,$().siteNum=void 0);const P=M.testValues;if(P&&typeof P=="object"){let s;for(let x=0;x<g.length;x++){const A=g[x],O=P[T[x]];if(O!=null){if(!R[x]){s??={...P},delete s[A];continue}typeof O!="number"?(d("testValues",O),s??={...P},delete s[A]):Number.isFinite(O)||(o.values++,s??={...P},delete s[A])}}s&&($().testValues=s)}const I=M.testPass;if(I&&typeof I=="object"){let s;for(let x=0;x<b.length;x++){const A=b[x],O=I[L[x]];if(O!=null){if(!v[x]){s??={...I},delete s[A];continue}typeof O!="boolean"&&(d("testPass",O),s??={...I},delete s[A])}}s&&($().testPass=s)}F&&((K??=u.slice())[S]=F)}return K}const f={warnings:[]};if(Array.isArray(n))f.results=l(n);else{Array.isArray(t.results)&&(f.results=l(t.results)),Array.isArray(t.dies)&&(f.dies=l(t.dies));const u=t.lotStack?.results;if(Array.isArray(u)){const C=u.map(D=>Array.isArray(D)?l(D):void 0);C.some(Boolean)&&(f.stackResults=C.map((D,g)=>D??u[g]))}}if(Array.isArray(t.testDefs)){const u=t.testDefs,C=u.filter(D=>D==null||typeof D.testNumber!="number"||de(D.testNumber));for(const D of u)C.includes(D)||r.add(String(D.testNumber));C.length!==u.length&&(f.testDefs=C)}const y=t.waferConfig?.orientation;if(typeof y=="number"){const u=Number.isFinite(y)?(y%360+360)%360:NaN;u===0||u===90||u===180||u===270?f.orientation=u:(o.orientation++,f.orientation=0)}const m=(u,C,D=`${C}s`)=>`${u} ${u===1?C:D}`,c=[];if(i.hbin&&c.push(m(i.hbin,"hard bin")),i.sbin&&c.push(m(i.sbin,"soft bin")),i.siteNum&&c.push(m(i.siteNum,"site number")),i.testValues&&c.push(m(i.testValues,"test value")),i.testPass&&c.push(m(i.testPass,"pass/fail verdict")),c.length){const u=`buildWaferMap received ${c.join(", ")} of the wrong type (for example ${a}), treated as missing. Bins, sites and test values must be numbers and verdicts true/false \u2014 a bin of "1" is not pass bin 1 \u2014 so those dies have no bin, no site, no value or no verdict, and yield and every chart leave them out. Convert them with Number() (and verdicts to booleans) and rebuild.`;console.warn(`[wafermap] ${u}`),f.warnings.push({code:"input-values-not-numbers",message:u,severity:"error"})}const w=[];if(o.bins&&w.push(`${m(o.bins,"bin")} (legal: whole numbers 0\u2013${qe}) \u2014 those dies have no bin`),o.positions&&w.push(`${m(o.positions,"coordinate")} (legal: whole numbers \u2212${fe} to ${fe}) \u2014 those dies have no position`),r.size&&w.push(`${m(r.size,"test number")} (legal: whole numbers 0\u2013${Je}) \u2014 those tests are left out`),o.values&&w.push(`${m(o.values,"test value")} that ${o.values===1?"is":"are"} not finite \u2014 left out`),o.sites&&w.push(`${m(o.sites,"site number")} (legal: 0\u2013${Qe}) \u2014 those dies have no site`),o.orientation&&w.push("a waferConfig.orientation other than 0, 90, 180 or 270 \u2014 the map is built at 0"),w.length||p){const u=[];w.length&&u.push(`buildWaferMap received values outside the STDF V4 ranges, treated as missing: ${w.join("; ")}.`),p&&u.push(`${m(p,"bin was","bins were")} NaN and ${p===1?"is":"are"} treated as no bin.`);const C=u.join(" ");console.warn(`[wafermap] ${C}`),f.warnings.push({code:"input-values-outside-stdf",message:C,severity:"warning"})}return f}function pe(n){const e=(h,l)=>h!==null&&typeof h=="object"&&h[l]!==void 0,t=Array.isArray(n)?{}:n,i=[],a=(h,l,f)=>{h&&i.push(`\`${l}\` (now \`${f}\`)`)};a(e(t,"data"),"data","results"),a(e(t,"die"),"die","dieConfig"),a(e(t,"stack"),"stack","lotStack"),a(e(t.dieConfig,"origin"),"dieConfig.origin","dieConfig.coordinateOrigin"),a(e(t.waferConfig,"flat"),"waferConfig.flat","waferConfig.notch"),a(e(t.reticleConfig,"anchor"),"reticleConfig.anchor","reticleConfig.anchorDie"),a(e(t.lotStack,"aggr"),"lotStack.aggr","lotStack.method"),a(Array.isArray(t.testDefs)&&t.testDefs.some(h=>e(h,"index")&&!e(h,"testNumber")),"TestDef.index","TestDef.testNumber");const d=e(t.lotStack,"results")?t.lotStack.results:[],o=(Array.isArray(n)?[n]:[t.results,...Array.isArray(d)?d:[]]).filter(h=>Array.isArray(h));if(a(o.some(h=>h.slice(0,100).some(l=>e(l,"values"))),"values","testValues"),!i.length)return;const r=i.length>1,p=`buildWaferMap ignored ${i.join(", ")}: ${r?"these names were":"that name was"} removed in an earlier release, so what ${r?"they":"it"} described is not on this map. Rename and rebuild.`;return console.warn(`[wafermap] ${p}`),{code:"input-field-removed",message:p,severity:"error"}}function ft(n){if(n.results!==void 0||n.lotStack!==void 0)throw new Error("buildWaferMap: pass `layout`, `results` or `lotStack` \u2014 only one.");const e=n.waferConfig?.diameter,t=n.dieConfig?.width,i=n.dieConfig?.height;if(!(e>0&&t>0&&i>0))throw new Error("buildWaferMap: `layout` needs waferConfig.diameter and dieConfig.width and height, all positive.");const a=Q({diameter:e,notch:n.waferConfig?.notch,orientation:0}),d=ke(Oe(a,{width:t,height:i}),a,{width:t,height:i}).filter(l=>!l.partial),{flipX:o,flipY:r}=me(n.dieConfig,{type:"center"}),{layout:p,...h}=n;return{...h,results:d.map(l=>({x:o?-l.x:l.x,y:r?-l.y:l.y})),waferConfig:{...n.waferConfig,center:{x:0,y:0}},dieConfig:{...n.dieConfig,coordinateOrigin:{type:"center"}}}}function lt(n){if(!Array.isArray(n)&&"results"in n&&n.results!==void 0&&"lotStack"in n&&n.lotStack!==void 0)throw new Error("buildWaferMap: pass either `results` or `lotStack`, not both.");const e={wrongVerdicts:0,wrongValues:0,nonFinite:0,badTestNumbers:[]},t=!Array.isArray(n)&&_e(n.results)?{...n,results:Pe(n.results,e).records}:n,i=dt(t,e);return Array.isArray(t)?{results:ne(i.results??t),waferOpts:void 0,dieOpts:void 0,explicitDies:void 0,reticleOpts:void 0,lotStackOpts:void 0,passBins:ce(void 0),ringCount:te(),valueFilter:"validity",ringCountWarning:void 0,removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:void 0,testDefs:void 0,hbinDefs:void 0,sbinDefs:void 0,metadataFields:void 0,derivedTests:void 0,retestPolicy:"last",edgeDieYieldMode:"exclude"}:{results:ne(i.results??t.results??[]),waferOpts:i.orientation===void 0||t.waferConfig===void 0?t.waferConfig:{...t.waferConfig,orientation:i.orientation},dieOpts:t.dieConfig,explicitDies:i.dies??t.dies,reticleOpts:t.reticleConfig,lotStackOpts:t.lotStack?{...t.lotStack,results:(i.stackResults??t.lotStack.results).map(ne)}:void 0,passBins:ce(t.passBins),valueFilter:t.valueFilter??"validity",...at(t.ringCount),removedFieldWarning:pe(t),inputValueWarnings:i.warnings,standardDiameters:t.standardDiameters,testDefs:(i.testDefs??t.testDefs)?.length?i.testDefs??t.testDefs:void 0,hbinDefs:t.hbinDefs,sbinDefs:t.sbinDefs,metadataFields:t.metadataFields,derivedTests:t.derivedTests?.length?t.derivedTests:void 0,retestPolicy:t.retestPolicy??"last",edgeDieYieldMode:t.edgeDieYieldMode??"exclude"}}function ne(n){return n.length>0&&U(n[0])!==void 0?n:re(n).records}function ut(n,e){return e?.coordinateOrigin?e.coordinateOrigin:{type:"center"}}function ct(n,e,t){if(e.type==="custom"&&e.offset)return{offsetX:e.offset.x,offsetY:e.offset.y};if(e.type!=="center"){let i=1/0,a=-1/0,d=1/0,o=-1/0;for(const r of n)r.x<i&&(i=r.x),r.x>a&&(a=r.x),r.y<d&&(d=r.y),r.y>o&&(o=r.y);return{offsetX:Math.round((a+i)/2),offsetY:Math.round((o+d)/2)}}return{offsetX:t.offsetX,offsetY:t.offsetY}}function pt(n,e){if(n.length<xe)return!1;const t=he(n),i=(a,d,o)=>{const r=o-d+1;return a<d-r||a>o+r};return i(Math.round(e.x),t.xMin,t.xMax)||i(Math.round(e.y),t.yMin,t.yMax)}function he(n){let e=1/0,t=-1/0,i=1/0,a=-1/0;for(const d of n){const o=Math.round(d.x),r=Math.round(d.y);o<e&&(e=o),o>t&&(t=o),r<i&&(i=r),r>a&&(a=r)}return{xMin:e,xMax:t,yMin:i,yMax:a}}const ht="The supplied wafer centre";function mt(n,e){const t=he(n);return`${ht} (${e.x}, ${e.y}) is far outside the probed dies (X ${t.xMin}\u2026${t.xMax}, Y ${t.yMin}\u2026${t.yMax}), so it was ignored and the centre was inferred from the dies. Used as given, it would draw a wafer many times the die extent with the dies in one corner. If it is the real centre, supply waferConfig.diameter as well.`}function gt(n,e,t,i,a,d){if(d)return{colMidX:(Math.round(d.x)-e)*i,colMidY:(Math.round(d.y)-t)*a,anchored:!0};if(n.length===0)return{colMidX:0,colMidY:0,anchored:!1};let o=1/0,r=-1/0,p=1/0,h=-1/0;for(const l of n){const f=Math.round(l.x)-e,y=Math.round(l.y)-t;f<o&&(o=f),f>r&&(r=f),y<p&&(p=y),y>h&&(h=y)}return{colMidX:(o+r)/2*i,colMidY:(p+h)/2*a,anchored:!1}}function yt(n,e,t){let i=1/0,a=-1/0,d=1/0,o=-1/0,r=0,p=0;for(const f of n){const y=Math.round(f.x)-e,m=Math.round(f.y)-t;r+=y,p+=m,y<i&&(i=y),y>a&&(a=y),m<d&&(d=m),m>o&&(o=m)}const h=n.length,l=(f,y,m)=>{const c=(m-y)/2;return c<=0?0:Math.abs(f/h-(y+m)/2)/c};return l(r,i,a)>.11||l(p,d,o)>.11}function me(n,e){let t=n?.xAxisDirection==="left",i=n?.yAxisDirection==="down";return(e.type==="UL"||e.type==="UR")&&(i=!0),(e.type==="LR"||e.type==="UR")&&(t=!0),{flipX:t,flipY:i}}function bt(n){const e={...n};return delete e.limitLow,delete e.limitHigh,delete e.limitLowInclusive,delete e.limitHighInclusive,delete e.specLow,delete e.specHigh,e}function wt(n,e){const{method:t,targetBin:i}=n,a=n.results.map(d=>d.filter(W));if(t==="mean"||t==="median"||t==="stddev"||t==="min"||t==="max"||t==="count"){const d=new Set((e??[]).filter(l=>!isParametricTest(l)).map(l=>l.testNumber)),o=new Set;for(const l of a)for(const f of Ee(l,"values"))d.has(f)||o.add(f);if(o.size===0)return ue(a,t);const r=[...o],p=r.map(l=>ue(a,t,l)),h=new Map;for(let l=0;l<r.length;l++){const f=r[l];for(const y of p[l]){const m=X(y);h.has(m)||h.set(m,{template:y,testValues:{}});const c=h.get(m),w=y.testValues?.[0];w!==void 0&&(c.testValues[f]=w)}}return[...h.values()].map(({template:l,testValues:f})=>({...l,testValues:Ze(f)?f:void 0}))}if(t==="countBin"||t==="percent"){if(i===void 0)return[];const d=tt(a,i,"hard");if(t==="countBin")return d;const o=a.length;return d.map(r=>({...r,testValues:{0:o>0?(r.testValues?.[0]??0)/o*100:0}}))}if(t==="mode"){const d=new Map;for(const r of a)for(const p of r){const h=X(p);d.has(h)||d.set(h,[]),d.get(h).push(p)}const o=[];for(const[r,p]of d){const h=r.split(","),l=Number(h[0]),f=Number(h[1]),y=p.map(c=>c.hbin).filter(c=>c!==void 0),m=et(y);m!==null&&o.push({x:l,y:f,hbin:m})}return o}return[]}export function computeCoverage(n){const e=n.filter(W),t=e.length,i=e.filter(d=>d.edgeExcluded).length,a=e.filter(d=>d.hbin!==void 0||d.sbin!==void 0||dieHasTestData(d)).length;return{filledDies:a,totalDies:t,edgeExcludedDies:i,unpositionedDies:n.length-e.length,ratio:t>0?a/t:0}}export function computeYield(n,e,t="exclude",i=!0){const a=new Set(e),o=n.filter(c=>!c.partial).filter(c=>c.edgeExcluded&&!c.filteredOut).length,r=n.filter(c=>c.partial).length;if(!i)return{passDies:0,failDies:0,edgeExcludedDies:o,partialDies:r,totalDies:0,yieldPercent:null,yieldPercentGross:null};let p=0,h=0,l=!1;for(const c of n){if(!ve(c))continue;const w=c.hbin??c.sbin;w!==void 0&&(l=!0,a.has(w)?p++:h++)}const f=p+h,y=l&&f>0?p/f*100:null;let m=null;if(t==="denominator-only"){const c=f+o;m=l&&c>0?p/c*100:null}return{passDies:p,failDies:h,edgeExcludedDies:o,partialDies:r,totalDies:f,yieldPercent:y,yieldPercentGross:m}}function ge(n,e,t,i,a,d=0,o=0,r=0,p=0,h=0,l=!1,f=!1){if(!n)return[];const y=n.anchorDie??{x:0,y:0},m=He(e,{width:n.width,height:n.height,diePitchX:i,diePitchY:a,anchorDie:{x:y.x-d,y:y.y-o},gridOrigin:{x:-r,y:-p}}),c=Le(Be(l,f,e.center.x,e.center.y),Ve(h,e.center.x,e.center.y));return m.filter(w=>{const u=w.width/2,C=w.height/2,D=[[w.x-u,w.y-C],[w.x+u,w.y-C],[w.x+u,w.y+C],[w.x-u,w.y+C]].map(([v,T])=>Ye(c,v,T)),g=le(D.map(v=>v.x)),b=ee(D.map(v=>v.x)),k=le(D.map(v=>v.y)),R=ee(D.map(v=>v.y));return t.some(v=>v.physX>=g&&v.physX<b&&v.physY>=k&&v.physY<R)})}function xt(n,e,t){const a=Math.max(0,e.radius-t)**2;return n.map(d=>{const o=d.physX-e.center.x,r=d.physY-e.center.y;return o*o+r*r>a?{...d,edgeExcluded:!0}:d})}const Dt=.2;function Mt(n){const e=new Set;for(const t of n){if(t.supersedes!==void 0||!W(t))return!1;const i=Se(t);if(e.has(i))return!1;e.add(i)}return!0}function vt(n,e,t){if(Mt(n))return{results:n.slice(),warning:void 0};const i=new Set(t);function a(g,b){if(e==="last")return!0;if(e==="first")return!1;const k=G(g.hbin),R=G(b.hbin);if(k===void 0||R===void 0)return!1;const v=i.has(k),T=i.has(R);return e==="best"?T!==v?T:R<k:T!==v?v:R>k}const d=(g,b)=>b.supersedes!==void 0||a(g,b),o=g=>{const b=g.partId===void 0?"":String(g.partId).trim();return b===""?void 0:b},r=n.filter(g=>!W(g)),p=new Map;for(const g of r){const b=o(g);b!==void 0&&p.set(b,(p.get(b)??0)+1)}const l=(r.length===0?0:Math.max(0,...p.values())/r.length)<=Dt,f=new Map,y=[],m=new Map;let c=0,w=0;for(const g of n){const b=o(g);let k;if(W(g)?k=`p:${X(g)}`:l&&b!==void 0?k=`i:${b}`:k=`u:${w++}`,g.supersedes==="partId"&&b!==void 0){const v=m.get(b);v!==void 0&&v!==k&&f.has(v)&&f.delete(v)}const R=f.get(k);R===void 0?(f.set(k,{winner:g,count:1}),y.push(k)):(R.count++,k.startsWith("i:")&&c++,d(R.winner,g)&&(R.winner=g)),b!==void 0&&m.set(b,k)}const u=[],C=[...y.filter(g=>g.startsWith("p:")),...y.filter(g=>!g.startsWith("p:"))];for(const g of C){const b=f.get(g);b!==void 0&&u.push(b.count>1?{...b.winner,retestCount:b.count}:b.winner)}const D=c>0?{code:"retests-by-part-id",severity:"info",message:`${c} record${c===1?"":"s"} with no position shared a part ID with an earlier record and ${c===1?"was":"were"} treated as a retest of it.`}:void 0;return{results:u,warning:D}}export function getDieTestValue(n,e){return Z(n,e)}export function getTestPassStatus(n,e,t){const i=Ne(n,e);return i!==void 0?i:t!==void 0&&!isParametricTest(t)?ye(Z(n,e)):void 0}function ye(n){return n===0||n===1?n===1:void 0}export function testPassStatusReader(n){const e=n.map(a=>a.testNumber),t=Re(e),i=n.map(a=>!isParametricTest(a));return function(d,o){t(d,o);for(let r=0;r<o.length;r++){if(o[r]!==We||!i[r])continue;const p=ye(Z(d,e[r]));p!==void 0&&(o[r]=p?Ie:Te)}return o}}export function dieHasTestData(n){return Ae(n)}function G(n){return n===void 0||Number.isNaN(n)?void 0:n}function q(n,e){const t={},i=G(e.hbin),a=G(e.sbin);i!==void 0&&(t.hbin=i),a!==void 0&&(t.sbin=a),e.retestCount!==void 0&&(t.retestCount=e.retestCount),e.siteNum!==void 0&&(t.siteNum=e.siteNum),e.partId!==void 0&&(t.partId=e.partId),e.metadata!==void 0&&(t.metadata=e.metadata);const d=U(e);return $e({...n,...t},d.table,d.row)}function be(n){return n.some(dieHasTestData)?"value":defaultBinMode([n])}export function defaultBinMode(n){const e=t=>n.some(i=>i.some(a=>t(a)!=null));return e(t=>t.hbin)?"hardBin":e(t=>t.sbin)?"softBin":"hardBin"}function we(n,e){return n.map(({code:t,message:i})=>({code:t,message:i,severity:t==="non-standard-diameter"||t==="diameter-exceeds-die-extent"||t==="implausible-center"?"warning":"error",confidence:e.wafer.confidence}))}const St="do not fit inside the supplied",Ct="Inferred wafer diameter",kt="The probed dies reach only",Ot=.75,xe=20;export const STANDARD_WAFER_DIAMETERS_MM=[100,125,150,200,300];const At=.02;function De(n,e){return e.reduce((t,i)=>Math.abs(i-n)<Math.abs(t-n)?i:t)}function $t(n,e){if(!e.length)return!0;const t=De(n,e);return Math.abs(t-n)/t<=At}function Nt(n){return n===void 0?STANDARD_WAFER_DIAMETERS_MM:n.filter(e=>Number.isFinite(e)&&e>0)}export function buildWaferMap(n){const e=lt(!Array.isArray(n)&&n.layout?ft(n):n),t=[];let i;if(e.valueFilter!=="none"&&e.testDefs){const s=e.valueFilter,x=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(O=>{const _=O.length>0?U(O[0]):void 0;if(!_)return[];const E=st(_.table,e.testDefs,s);return E.tests.length>0&&oe(O,E.table),E.tests}),A=rt(x);if(A.length>0){i={mode:s,tests:A};const O=ot(s,A,e.testDefs);O&&t.push(O)}}if(e.derivedTests){const s=new Set(e.passBins),x=_=>{const E=_.length>0?U(_[0]):void 0,H=Ue(_,E?.table??Fe([]),e.testDefs,e.derivedTests,s);return E&&oe(_,H.table),H},O=(e.lotStackOpts?e.lotStackOpts.results:[e.results]).map(x);e.testDefs=O[0]?.testDefs??e.testDefs,t.push(...O[0]?.warnings??[])}e.lotStackOpts&&!nt(e.lotStackOpts.method)&&(e.testDefs=e.testDefs?.map(bt));const a=e.lotStackOpts?re(wt(e.lotStackOpts,e.testDefs)).records:e.results;for(let s=0;s<Math.min(5,a.length);s++){const x=a[s];if(typeof x.x=="string"||typeof x.y=="string")throw new TypeError("buildWaferMap: x and y must be numbers, received strings. Did you forget to cast CSV values? e.g. { x: +row.x, y: +row.y }")}for(const s of a)if(s.x==null!=(s.y==null))throw new TypeError(`buildWaferMap: die has only one of x/y set (x=${String(s.x)}, y=${String(s.y)}). A die must be either fully positioned (both x and y) or fully unpositioned (neither) \u2014 omit both to mark a die as having no reported position.`);const{results:d,warning:o}=vt(a,e.retestPolicy,e.passBins),r={wafer:{confidence:1,method:"provided"},diePitch:{confidence:1,units:"mm"},grid:{confidence:1}},p=[];if(e.explicitDies){let s=e.explicitDies.filter(W);const x=e.explicitDies.filter(B=>!W(B)),A=d.filter(W),O=d.filter(B=>!W(B));if(A.length>0){const B=new Map(A.map(V=>[X(V),V]));s=s.map(V=>{const ie=B.get(X(V));return ie?q(V,ie):V})}const _=e.waferOpts?.diameter??300,E=Q({diameter:_,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});E.orientation!==0&&(s=se(s,E)),s=s.map(z);const H=ge(e.reticleOpts,E,s,1,1,0,0,0,0,E.orientation),Me=O.map((B,V)=>z(q({id:`unpositioned_${V}`,width:s[0]?.width??1,height:s[0]?.height??1},B))),J=[...s,...x,...Me];return{wafer:E,dies:J,dataAxisFlip:{x:!1,y:!1},reticleConfig:e.reticleOpts,units:"mm",inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:E.metadata??null,isLotStack:!1,dataCoverage:computeCoverage(J),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(J,e.passBins,e.edgeDieYieldMode),reticles:H,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields}}const h=d.filter(W),l=d.filter(s=>!W(s)),f=h.map(s=>({x:s.x,y:s.y})),y=Ke(f,e.dieOpts,e.waferOpts?.diameter);r.diePitch={confidence:y.confidence,units:y.units};const{pitchX:m,pitchY:c}=y,w=y.units,u=ut(h,e.dieOpts),C=je(f);r.grid={confidence:C.confidence};const{offsetX:D,offsetY:g}=ct(f,u,C),{flipX:b,flipY:k}=me(e.dieOpts,u),R=e.waferOpts?.diameter===void 0&&e.waferOpts?.center!==void 0&&pt(f,e.waferOpts.center),v=R?void 0:e.waferOpts?.center;R&&p.push({code:"implausible-center",message:mt(f,e.waferOpts.center)});const{colMidX:T,colMidY:L,anchored:K}=gt(f,D,g,m,c,v);let S=e.waferOpts?.diameter;const N=f.map(s=>({x:(Math.round(s.x)-D)*m-T,y:(Math.round(s.y)-g)*c-L})),M=ee(N.map(({x:s,y:x})=>Math.hypot(Math.abs(s)+m/2,Math.abs(x)+c/2)));if(S===void 0)if(f.length>0)if(w==="mm"){const s=Xe(N,{minRadius:M});S=s.diameter,r.wafer={confidence:s.confidence,method:s.method};const x=Nt(e.standardDiameters);if(!$t(S,x)){const A=De(S,x);p.push({code:"non-standard-diameter",message:`${Ct} ${S.toFixed(1)} mm is not a standard wafer size (nearest is ${A} mm). The diameter was derived from the die extent, which assumes the probed grid reaches the wafer edge \u2014 a non-standard result usually means it does not, because the outer dies were never probed. Every die is then placed against a wafer that is too small, which moves dies between rings and changes ring and edge findings. Supply waferConfig.diameter.`})}}else S=M*2,r.wafer={confidence:y.confidence*.8,method:"extent"};else S=w==="mm"?300:30,r.wafer={confidence:0,method:"default"};if(!K&&f.length>0&&yt(f,D,g)&&(r.wafer.method="inferred-partial",p.push({code:"partial-coverage",message:"Wafer geometry was inferred from die positions alone. The data does not span a full symmetric wafer, so the inferred diameter and centre may be wrong and dies may be mis-positioned relative to the true wafer boundary. Supply waferConfig.diameter and waferConfig.center (the prober coordinate of the wafer centre) to position partial data correctly."})),e.waferOpts?.diameter!==void 0&&v===void 0&&M>0&&f.length>=xe){const s=M/(S/2);s<Ot&&p.push({code:"diameter-exceeds-die-extent",message:`${kt} ${(s*100).toFixed(0)}% of the ${S} mm wafer's radius. Either the diameter is larger than the real one, or this is a partial map covering only part of the wafer. Ring bands are equal-radius, so the outer rings are mostly or entirely empty and ring, quadrant and edge findings describe the assumed wafer rather than the probed area. Check waferConfig.diameter, or drop it and let the diameter be inferred from the die extent.`})}if(e.waferOpts?.diameter!==void 0){const s=e.dieOpts?.width!==void 0&&e.dieOpts?.height!==void 0;if(s&&M>S/2+1e-9){const x=N.filter(({x:A,y:O})=>Math.hypot(Math.abs(A)+m/2,Math.abs(O)+c/2)>S/2+1e-9).length;p.push({code:"geometry-conflict",message:`${x} of ${N.length} probed die positions ${St} ${S} mm wafer at the supplied die pitch of ${m} \xD7 ${c} mm. A die with test results is a real prober position and is always fully on the wafer, so one of the two supplied values must be wrong: containing these dies at this pitch would need a diameter of at least ${(M*2).toFixed(1)} mm. Check waferConfig.diameter and dieConfig.width/height against the real device.`})}}const F=Q({diameter:S,units:w,notch:e.waferOpts?.notch,orientation:e.waferOpts?.orientation??0,metadata:e.waferOpts?.metadata,reticle:e.reticleOpts});let $=h.map(s=>{const x=Math.round(s.x)-D,A=Math.round(s.y)-g,O={id:`${x}_${A}`,x,y:A,physX:x*m-T,physY:A*c-L,width:m,height:c,insideWafer:!0,partial:!1};return q(O,s)});(D!==0||g!==0)&&($=$.map(s=>({...s,x:s.x+D,y:s.y+g,id:`${s.x+D}_${s.y+g}`}))),$=se($,F),(b||k)&&($=Ce($,{flipX:b,flipY:k},F.center));const Y=[];e.waferOpts?.edgeExclusion&&e.waferOpts.edgeExclusion>0&&($=xt($,F,e.waferOpts.edgeExclusion),e.waferOpts.edgeExclusion>F.radius&&Y.push({code:"edge-exclusion-exceeds-radius",message:`edgeExclusion (${e.waferOpts.edgeExclusion}mm) exceeds the resolved wafer radius (${F.radius}mm) \u2014 the entire wafer is excluded.`,severity:"warning"})),$=$.map(z);const j=ge(e.reticleOpts,F,$,m,c,D,g,T,L,F.orientation,b,k),P=l.map((s,x)=>z(q({id:`unpositioned_${x}`,width:m,height:c},s))),I=[...$,...P];return{wafer:F,dies:I,dataAxisFlip:{x:b,y:k},reticleConfig:e.reticleOpts,units:w,inference:r,warnings:[...e.removedFieldWarning?[e.removedFieldWarning]:[],...e.inputValueWarnings,...o?[o]:[],...we(p,r),...Y,...t,...e.ringCountWarning?[e.ringCountWarning]:[]],plotMode:be(d),metadata:F.metadata??null,isLotStack:e.lotStackOpts!==void 0,dataCoverage:computeCoverage(I),passBins:e.passBins,...i?{valueFilter:i}:{},ringCount:e.ringCount,yield:computeYield(I,e.passBins,e.edgeDieYieldMode,it(e.lotStackOpts!==void 0,e.lotStackOpts?.method)),reticles:j,hbinDefs:e.hbinDefs,sbinDefs:e.sbinDefs,testDefs:e.testDefs,metadataFields:e.metadataFields,aggrMethod:e.lotStackOpts?.method,lotSize:e.lotStackOpts?.results.length}}
@@ -1 +1 @@
1
- import{GUIDE_SECTIONS as e}from"./guideSections.js";export const CHART_CATALOGUE=[{id:"bin-map",kind:"map",title:"Bin map",mode:["hardBin","softBin"],example:"display-control.html",about:"Each die coloured by its hard or soft bin, passing bins in greens and failing bins in other colours, to show where the failures are.",see:["test-value-map","bin-pareto"]},{id:"test-value-map",kind:"map",title:"Test value map",mode:["value"],example:"test-values.html",about:"Each die coloured by one test\u2019s value on a colour scale, with the test\u2019s limits on the colour bar, to show where on the wafer the value shifts.",see:["bin-map","limit-passfail-map","test-passfail-map","value-histogram"]},{id:"limit-passfail-map",kind:"map",title:"Limit pass/fail map",example:"test-values.html",about:"Each die coloured by whether its value for one test lies inside the test\u2019s limits, with the dies below the low limit and above the high limit marked apart, to show where a test fails its limits.",see:["test-value-map","test-passfail-map","pass-rate-by-test"]},{id:"test-passfail-map",kind:"map",title:"Test pass/fail map",example:"test-values.html",about:"Each die coloured by the pass or fail the tester recorded for one test, to show where a test failed, whether or not it has a measured value.",see:["limit-passfail-map","test-value-map","pass-rate-by-test"]},{id:"die-attribute-map",kind:"map",title:"Die attribute map",mode:["metadata"],example:"metadata-mode.html",about:"Each die coloured by an attribute the data carries (a test site, a probe step, a zone), to show whether a pattern follows it.",see:["bin-map"]},{id:"stacked-map",kind:"map",title:"Stacked map",mode:["stackedBins","stackedSoftBins","stackedValues"],example:"lot-stack-analysis.html",about:"The wafers of a lot laid over one another die by die: how often a bin occurs, or a value\u2019s mean, median or spread at each position, to show what repeats from wafer to wafer.",see:["difference-map","reticle-cell-yield"]},{id:"pat-verdict-map",kind:"map",title:"PAT verdict map",tab:"overview",about:"Each die coloured by its part average testing verdict (within the limits, an outlier or failing), one map per wafer, to show where the PAT outliers sit.",see:["part-average-testing-pat","bin-map","test-value-map"]},{id:"difference-map",kind:"map",title:"Difference map",card:"difference-map",tab:"distributions",about:"One group\u2019s wafer map less another\u2019s, die position by die position, to show where on the wafer they differ.",guide:[e.heatmap],see:["stacked-map","comparison-by-group"]},{id:"yield-by-wafer",kind:"chart",title:"Yield by wafer",cards:["card-yield"],tab:"overview",about:"Yield of each wafer or group: passing dies as a share of judged dies, with partial and edge-excluded dies left out. The line is the median bar.",see:["bin-pareto","what-divides-yield"]},{id:"bin-pareto",kind:"chart",title:"Bin pareto",cards:["card-bin-pareto"],tab:"overview",about:"Dies in each bin, largest first, so the bins that cost the most yield lead. Shown alone, the line is the running share of all dies.",see:["bin-map","pareto"]},{id:"pass-rate-by-test",kind:"chart",title:"Pass rate by test",cards:["card-pass-rate"],tab:"overview",about:"The share of judged dies that pass each test, lowest first, so the tests that fail the most dies lead.",see:["process-capability","bin-pareto"]},{id:"ring-yield",kind:"chart",title:"Ring yield",card:"ring-yield",tab:"overview",about:"Yield of each ring, from the wafer centre to its edge, to show a radial pattern.",see:["quadrant-yield","bin-map"]},{id:"quadrant-yield",kind:"chart",title:"Quadrant yield",card:"quadrant-yield",tab:"overview",about:"Yield of each quarter of the wafer, to show a one-sided pattern.",see:["ring-yield","bin-map"]},{id:"reticle-cell-yield",kind:"chart",title:"Reticle cell yield",card:"reticle-yield",tab:"overview",about:"Yield of each position in the reticle, pooled over every shot on every wafer. A cell low everywhere points at the mask rather than the wafer.",see:["stacked-map","ring-yield"]},{id:"test-value-distribution",kind:"chart",title:"Test value distribution",cards:["card-box"],tab:"distributions",about:"How one test\u2019s values spread on each wafer or group: the box holds the middle half of the dies, the line inside it is the median, and the whiskers reach the lowest and highest values.",see:["box-plot","value-histogram"]},{id:"value-histogram",kind:"chart",title:"Value histogram",cards:["card-histogram"],tab:"distributions",about:"How one test\u2019s values are distributed: the number of dies in each value range, with the test\u2019s limits marked.",see:["histogram","probability-plot","test-value-map"]},{id:"histogram-of-the-dies-picked",kind:"chart",title:"Histogram of the dies picked",cards:["drill-histogram"],tab:"drilldown",about:"How one test\u2019s values are distributed over the dies picked: the number of dies in each value range, with the test\u2019s limits marked.",see:["value-histogram"]},{id:"wafer-to-wafer-trend",kind:"chart",title:"Wafer-to-wafer trend",cards:["card-trend"],tab:"distributions",about:"Each wafer\u2019s mean of one test in wafer order, with a band of one standard deviation either side, to show drift through the lot.",guide:[e.bands],see:["control-chart","line-chart"]},{id:"test-scatter",kind:"chart",title:"Test scatter",cards:["card-scatter"],tab:"correlation",about:"One test against another, a point per die, to show whether the two move together. r is the correlation coefficient and n the number of dies.",guide:[e.fit],see:["test-correlation-matrix","scatter-plot"]},{id:"test-correlation-matrix",kind:"chart",title:"Test correlation matrix",card:"correlation",tab:"correlation",about:"The correlation of every pair of tests. A strong colour means two tests move together; click a cell to show the pair in the scatter.",see:["test-scatter","heatmap"]},{id:"process-capability",kind:"chart",title:"Process capability",card:"capability",tab:"distributions",about:"Every test with limits on one scale, the low limit at 0 and the high limit at 1, sorted lowest Ppk first, so the tests closest to their limits lead.",guide:[e.goal],see:["capability-goal-plot","pass-rate-by-test"]},{id:"comparison-by-group",kind:"table",title:"Comparison by group",card:"comparison",tab:"distributions",about:"Yield and each test compared between groups, counting each wafer once, with how likely a difference this large is by chance.",guide:[e.groups],see:["what-divides-yield","difference-map","box-plot"]},{id:"what-divides-yield",kind:"table",title:"What divides yield",card:"commonality",tab:"overview",about:"The wafer and lot fields ranked by how strongly they divide yield, as places to look for a cause.",guide:[e.dividesYield],see:["comparison-by-group","yield-by-wafer"]},{id:"part-average-testing-pat",kind:"table",title:"Part average testing (PAT)",card:"pat",tab:"overview",about:"Dies outside part average testing limits, set from each wafer\u2019s own spread of each test (the AEC-Q001 method), by wafer and by test.",guide:[e.pat],see:["pat-verdict-map","process-capability","scatter-plot"]},{id:"scatter-plot",kind:"chart",title:"Scatter plot",chart:"scatter",tab:"plots",about:"One field against another, a point per die or per wafer, to show whether they move together.",guide:[e.fit],see:["test-scatter","heatmap"]},{id:"histogram",kind:"chart",title:"Histogram",chart:"histogram",tab:"plots",about:"How a value is distributed: the number of dies or wafers in each value range.",see:["value-histogram","probability-plot","box-plot"]},{id:"box-plot",kind:"chart",title:"Box plot",chart:"box",tab:"plots",about:"How a value spreads in each category: the box holds the middle half, the line inside it is the median, and the whiskers reach the lowest and highest values.",guide:[e.groups],see:["test-value-distribution","nested-categories","probability-plot"]},{id:"bar-chart",kind:"chart",title:"Bar chart",chart:"bar",tab:"plots",about:"A count, a share or a summary value for each category, side by side.",see:["pareto","stacked-bars-and-shares","yield-by-wafer"]},{id:"line-chart",kind:"chart",title:"Line chart",chart:"line",tab:"plots",about:"A summary value in order along the X axis (wafer order, a test, a condition), to show a trend.",guide:[e.bands],see:["control-chart","sweep","wafer-to-wafer-trend"]},{id:"sweep",kind:"chart",title:"Sweep",chart:"sweep",tab:"plots",about:"A measured value against a swept condition, a curve per series, to show how the part responds across the range.",see:["line-chart"]},{id:"probability-plot",kind:"chart",title:"Probability plot",chart:"probability",tab:"plots",about:"The share of values at or below each value, a curve per colour, so whole distributions compare, tails included.",guide:[e.probability],see:["histogram","box-plot"]},{id:"control-chart",kind:"chart",title:"Control chart",chart:"control",tab:"plots",about:"One value per wafer in order against its centre line and control limits, with the points that break a Western Electric rule marked.",guide:[e.control],see:["wafer-to-wafer-trend","line-chart","capability-goal-plot"]},{id:"capability-goal-plot",kind:"chart",title:"Capability goal plot",chart:"goal",tab:"plots",about:"Each test with both limits placed by how far its mean is off centre and how wide its spread is, as shares of its limit window. A test outside the solid triangle is short of Ppk 1.33.",guide:[e.goal],see:["process-capability","control-chart"]},{id:"heatmap",kind:"chart",title:"Heatmap",chart:"heatmap",tab:"plots",about:"A value for every pair of two categories, as a colour, to show where the two interact.",guide:[e.heatmap],see:["test-correlation-matrix","difference-map","bar-chart"]},{id:"pareto",kind:"chart",title:"Pareto",tab:"plots",about:"Categories largest first with a line for their running share, to show which few account for most of the total.",see:["bin-pareto","bar-chart"]},{id:"stacked-bars-and-shares",kind:"chart",title:"Stacked bars and shares",tab:"plots",about:"Each bar split into its colours, as counts or as each colour\u2019s share of its own total, to show what a category is made of.",see:["bar-chart"]},{id:"nested-categories",kind:"chart",title:"Nested categories",tab:"plots",about:"A box or bar with categories inside categories, such as lots with their wafers, to show whether variation sits between or within the groups.",guide:[e.ranges],see:["box-plot","bar-chart"]},{id:"panels-small-multiples",kind:"chart",title:"Panels (small multiples)",tab:"plots",about:"One small chart per value of a field, on shared axes, to compare the same view across groups side by side.",guide:[e.ranges],see:["box-plot","scatter-plot","histogram"]},{id:"statistics-table",kind:"table",title:"Statistics table",tab:"data",about:"One row per test and group: the count, mean, spread, extremes, limits and capability, to read the numbers behind the charts.",see:["dies-table","process-capability"]},{id:"dies-table",kind:"table",title:"Dies table",tab:"data",about:"One row per die with its position, bin and values, to see exactly which dies a chart counts; it exports to CSV.",see:["wafers-table","statistics-table"]},{id:"wafers-table",kind:"table",title:"Wafers table",tab:"data",about:"One row per wafer with its attributes and its yield, to check what each wafer is and to compare them.",see:["dies-table","yield-by-wafer"]}];export function catalogueEntry(t){return CHART_CATALOGUE.find(a=>a.id===t)}
1
+ import{GUIDE_SECTIONS as e}from"./guideSections.js";export const CHART_CATALOGUE=[{id:"bin-map",kind:"map",title:"Bin map",mode:["hardBin","softBin"],example:"display-control.html",about:"Each die coloured by its hard or soft bin, passing bins in greens and failing bins in other colours, to show where the failures are.",see:["test-value-map","bin-pareto"]},{id:"test-value-map",kind:"map",title:"Test value map",mode:["value"],example:"test-values.html",about:"Each die coloured by one test\u2019s value on a colour scale, with the test\u2019s limits on the colour bar, to show where on the wafer the value shifts.",see:["bin-map","limit-passfail-map","test-passfail-map","value-histogram"]},{id:"limit-passfail-map",kind:"map",title:"Limit pass/fail map",example:"test-values.html",about:"Each die coloured by whether its value for one test lies inside the test\u2019s limits, with the dies below the low limit and above the high limit marked apart, to show where a test fails its limits.",see:["test-value-map","test-passfail-map","pass-rate-by-test"]},{id:"test-passfail-map",kind:"map",title:"Test pass/fail map",example:"test-values.html",about:"Each die coloured by the pass or fail the tester recorded for one test, to show where a test failed, whether or not it has a measured value.",see:["limit-passfail-map","test-value-map","pass-rate-by-test"]},{id:"die-attribute-map",kind:"map",title:"Die attribute map",mode:["metadata"],example:"metadata-mode.html",about:"Each die coloured by an attribute the data carries (a test site, a probe step, a zone), to show whether a pattern follows it.",see:["bin-map"]},{id:"stacked-map",kind:"map",title:"Stacked map",mode:["stackedBins","stackedSoftBins","stackedValues"],example:"lot-stack-analysis.html",about:"The wafers of a lot laid over one another die by die: how often a bin occurs, or a value\u2019s mean, median or spread at each position, to show what repeats from wafer to wafer.",see:["difference-map","reticle-cell-yield"]},{id:"pat-verdict-map",kind:"map",title:"PAT verdict map",tab:"overview",about:"Each die coloured by its part average testing verdict (within the limits, an outlier or failing), on the map or on every wafer of a gallery, to show where the PAT outliers sit.",see:["part-average-testing-pat","bin-map","test-value-map"]},{id:"difference-map",kind:"map",title:"Difference map",card:"difference-map",tab:"distributions",about:"One group\u2019s wafer map less another\u2019s, die position by die position, to show where on the wafer they differ.",guide:[e.heatmap],see:["stacked-map","comparison-by-group"]},{id:"yield-by-wafer",kind:"chart",title:"Yield by wafer",cards:["card-yield"],tab:"overview",about:"Yield of each wafer or group: passing dies as a share of judged dies, with partial and edge-excluded dies left out. The line is the median bar.",see:["bin-pareto","what-divides-yield"]},{id:"bin-pareto",kind:"chart",title:"Bin pareto",cards:["card-bin-pareto"],tab:"overview",about:"Dies in each bin, largest first, so the bins that cost the most yield lead. Shown alone, the line is the running share of all dies.",see:["bin-map","pareto"]},{id:"pass-rate-by-test",kind:"chart",title:"Pass rate by test",cards:["card-pass-rate"],tab:"overview",about:"The share of judged dies that pass each test, lowest first, so the tests that fail the most dies lead.",see:["process-capability","bin-pareto"]},{id:"ring-yield",kind:"chart",title:"Ring yield",card:"ring-yield",tab:"overview",about:"Yield of each ring, from the wafer centre to its edge, to show a radial pattern.",see:["quadrant-yield","bin-map"]},{id:"quadrant-yield",kind:"chart",title:"Quadrant yield",card:"quadrant-yield",tab:"overview",about:"Yield of each quarter of the wafer, to show a one-sided pattern.",see:["ring-yield","bin-map"]},{id:"reticle-cell-yield",kind:"chart",title:"Reticle cell yield",card:"reticle-yield",tab:"overview",about:"Yield of each position in the reticle, pooled over every shot on every wafer. A cell low everywhere points at the mask rather than the wafer.",see:["stacked-map","ring-yield"]},{id:"test-value-distribution",kind:"chart",title:"Test value distribution",cards:["card-box"],tab:"distributions",about:"How one test\u2019s values spread on each wafer or group: the box holds the middle half of the dies, the line inside it is the median, and the whiskers reach the lowest and highest values.",see:["box-plot","value-histogram"]},{id:"value-histogram",kind:"chart",title:"Value histogram",cards:["card-histogram"],tab:"distributions",about:"How one test\u2019s values are distributed: the number of dies in each value range, with the test\u2019s limits marked.",see:["histogram","probability-plot","test-value-map"]},{id:"histogram-of-the-dies-picked",kind:"chart",title:"Histogram of the dies picked",cards:["drill-histogram"],tab:"drilldown",about:"How one test\u2019s values are distributed over the dies picked: the number of dies in each value range, with the test\u2019s limits marked.",see:["value-histogram"]},{id:"wafer-to-wafer-trend",kind:"chart",title:"Wafer-to-wafer trend",cards:["card-trend"],tab:"distributions",about:"Each wafer\u2019s mean of one test in wafer order, with a band of one standard deviation either side, to show drift through the lot.",guide:[e.bands],see:["control-chart","line-chart"]},{id:"test-scatter",kind:"chart",title:"Test scatter",cards:["card-scatter"],tab:"correlation",about:"One test against another, a point per die, to show whether the two move together. r is the correlation coefficient and n the number of dies.",guide:[e.fit],see:["test-correlation-matrix","scatter-plot"]},{id:"test-correlation-matrix",kind:"chart",title:"Test correlation matrix",card:"correlation",tab:"correlation",about:"The correlation of every pair of tests. A strong colour means two tests move together; click a cell to show the pair in the scatter.",see:["test-scatter","heatmap"]},{id:"process-capability",kind:"chart",title:"Process capability",card:"capability",tab:"distributions",about:"Every test with limits on one scale, the low limit at 0 and the high limit at 1, sorted lowest Ppk first, so the tests closest to their limits lead.",guide:[e.goal],see:["capability-goal-plot","pass-rate-by-test"]},{id:"comparison-by-group",kind:"table",title:"Comparison by group",card:"comparison",tab:"distributions",about:"Yield and each test compared between groups, counting each wafer once, with how likely a difference this large is by chance.",guide:[e.groups],see:["what-divides-yield","difference-map","box-plot"]},{id:"what-divides-yield",kind:"table",title:"What divides yield",card:"commonality",tab:"overview",about:"The wafer and lot fields ranked by how strongly they divide yield, as places to look for a cause.",guide:[e.dividesYield],see:["comparison-by-group","yield-by-wafer"]},{id:"part-average-testing-pat",kind:"table",title:"Part average testing (PAT)",card:"pat",tab:"overview",about:"Dies outside part average testing limits, set from each wafer\u2019s own spread of each test (the AEC-Q001 method), by wafer and by test.",guide:[e.pat],see:["pat-verdict-map","process-capability","scatter-plot"]},{id:"scatter-plot",kind:"chart",title:"Scatter plot",chart:"scatter",tab:"plots",about:"One field against another, a point per die or per wafer, to show whether they move together.",guide:[e.fit],see:["test-scatter","heatmap"]},{id:"histogram",kind:"chart",title:"Histogram",chart:"histogram",tab:"plots",about:"How a value is distributed: the number of dies or wafers in each value range.",see:["value-histogram","probability-plot","box-plot"]},{id:"box-plot",kind:"chart",title:"Box plot",chart:"box",tab:"plots",about:"How a value spreads in each category: the box holds the middle half, the line inside it is the median, and the whiskers reach the lowest and highest values.",guide:[e.groups],see:["test-value-distribution","nested-categories","probability-plot"]},{id:"bar-chart",kind:"chart",title:"Bar chart",chart:"bar",tab:"plots",about:"A count, a share or a summary value for each category, side by side.",see:["pareto","stacked-bars-and-shares","yield-by-wafer"]},{id:"line-chart",kind:"chart",title:"Line chart",chart:"line",tab:"plots",about:"A summary value in order along the X axis (wafer order, a test, a condition), to show a trend.",guide:[e.bands],see:["control-chart","sweep","wafer-to-wafer-trend"]},{id:"sweep",kind:"chart",title:"Sweep",chart:"sweep",tab:"plots",about:"A measured value against a swept condition, a curve per series, to show how the part responds across the range.",see:["line-chart"]},{id:"probability-plot",kind:"chart",title:"Probability plot",chart:"probability",tab:"plots",about:"The share of values at or below each value, a curve per colour, so whole distributions compare, tails included.",guide:[e.probability],see:["histogram","box-plot"]},{id:"control-chart",kind:"chart",title:"Control chart",chart:"control",tab:"plots",about:"One value per wafer in order against its centre line and control limits, with the points that break a Western Electric rule marked.",guide:[e.control],see:["wafer-to-wafer-trend","line-chart","capability-goal-plot"]},{id:"capability-goal-plot",kind:"chart",title:"Capability goal plot",chart:"goal",tab:"plots",about:"Each test with both limits placed by how far its mean is off centre and how wide its spread is, as shares of its limit window. A test outside the solid triangle is short of Ppk 1.33.",guide:[e.goal],see:["process-capability","control-chart"]},{id:"heatmap",kind:"chart",title:"Heatmap",chart:"heatmap",tab:"plots",about:"A value for every pair of two categories, as a colour, to show where the two interact.",guide:[e.heatmap],see:["test-correlation-matrix","difference-map","bar-chart"]},{id:"pareto",kind:"chart",title:"Pareto",tab:"plots",about:"Categories largest first with a line for their running share, to show which few account for most of the total.",see:["bin-pareto","bar-chart"]},{id:"stacked-bars-and-shares",kind:"chart",title:"Stacked bars and shares",tab:"plots",about:"Each bar split into its colours, as counts or as each colour\u2019s share of its own total, to show what a category is made of.",see:["bar-chart"]},{id:"nested-categories",kind:"chart",title:"Nested categories",tab:"plots",about:"A box or bar with categories inside categories, such as lots with their wafers, to show whether variation sits between or within the groups.",guide:[e.ranges],see:["box-plot","bar-chart"]},{id:"panels-small-multiples",kind:"chart",title:"Panels (small multiples)",tab:"plots",about:"One small chart per value of a field, on shared axes, to compare the same view across groups side by side.",guide:[e.ranges],see:["box-plot","scatter-plot","histogram"]},{id:"statistics-table",kind:"table",title:"Statistics table",tab:"data",about:"One row per test and group: the count, mean, spread, extremes, limits and capability, to read the numbers behind the charts.",see:["dies-table","process-capability"]},{id:"dies-table",kind:"table",title:"Dies table",tab:"data",about:"One row per die with its position, bin and values, to see exactly which dies a chart counts; it exports to CSV.",see:["wafers-table","statistics-table"]},{id:"wafers-table",kind:"table",title:"Wafers table",tab:"data",about:"One row per wafer with its attributes and its yield, to check what each wafer is and to compare them.",see:["dies-table","yield-by-wafer"]}];export function catalogueEntry(t){return CHART_CATALOGUE.find(a=>a.id===t)}
@@ -1,4 +1,4 @@
1
- import type { Die } from '../core/dies.js';
1
+ import { type Die } from '../core/dies.js';
2
2
  import { type TestDef } from '../renderer/buildWaferMap.js';
3
3
  /** One group's wafer values, summarised. */
4
4
  export interface GroupSummary {
@@ -1 +1 @@
1
- import{testValuesReader as j}from"../core/dieTable.js";import{isParametricTest as q}from"../renderer/buildWaferMap.js";import{benjaminiHochberg as T,chiSquareUpperTail as L,fUpperTail as O,holm as P,sampleVariance as U,tTwoSided as x}from"./math.js";import{capabilityLimits as K}from"./capability.js";import{compareNatural as V,maxOf as W,median as G,minOf as R}from"../core/utils.js";const B=5,E=(n,s)=>{const i=s.length,f=i?s.reduce((u,k)=>u+k,0)/i:NaN;return{key:n,n:i,mean:f,sd:i>=2?Math.sqrt(U(s,f)):NaN,median:i?G([...s]):NaN}};function H(n){const s=n.length;if(n.some(e=>!(e.sd>0)))return;if(s===2){const[e,r]=n,d=e.sd**2/e.n,o=r.sd**2/r.n,y=(e.mean-r.mean)/Math.sqrt(d+o),w=(d+o)**2/(d**2/(e.n-1)+o**2/(r.n-1));return{method:"welch-t",statistic:y,df1:1,df2:w,p:x(y,w)}}const i=n.map(e=>e.n/e.sd**2),f=i.reduce((e,r)=>e+r,0),u=n.reduce((e,r,d)=>e+i[d]*r.mean,0)/f,k=n.reduce((e,r,d)=>e+i[d]*(r.mean-u)**2,0)/(s-1),c=n.reduce((e,r,d)=>e+(1-i[d]/f)**2/(r.n-1),0),m=k/(1+2*(s-2)*c/(s*s-1)),t=(s*s-1)/(3*c);return{method:"welch-anova",statistic:m,df1:s-1,df2:t,p:O(m,s-1,t)}}function I(n){const s=n.flatMap((t,e)=>t.map(r=>({v:r,g:e}))),i=s.length;if(n.length<2||i<3)return;s.sort((t,e)=>t.v-e.v);const f=new Array(n.length).fill(0);let u=0;for(let t=0;t<i;){let e=t;for(;e+1<i&&s[e+1].v===s[t].v;)e++;const r=(t+e)/2+1;for(let o=t;o<=e;o++)f[s[o].g]+=r;const d=e-t+1;u+=d**3-d,t=e+1}const k=1-u/(i**3-i);if(!(k>0))return;const c=(12/(i*(i+1))*n.reduce((t,e,r)=>t+f[r]**2/e.length,0)-3*(i+1))/k,m=n.length-1;return{h:c,df:m,p:L(c,m),approximate:n.some(t=>t.length<B)}}export function compareGroups(n,s){const i=n.map(e=>({key:e.key,values:e.values.filter(Number.isFinite)})),f=i.map(e=>E(e.key,e.values)),u=i.filter(e=>e.values.length>=2),k=i.filter(e=>e.values.length<2).map(e=>e.key),c={groups:f,tooSmall:k};if(u.length<2)return c.issue="Needs at least two groups with two or more wafers each",c;const m=f.filter(e=>u.some(r=>r.key===e.key));c.welch=H(m),c.kruskal=I(u.map(e=>e.values)),!c.welch&&!c.kruskal?c.issue="The wafer values do not vary, so there is nothing to compare":c.welch||(c.issue="A group\u2019s wafers all have the same value, so Welch\u2019s test cannot be computed; the rank test stands");const t=s!==void 0?m.find(e=>e.key===s):void 0;if(t){const e=m.filter(o=>o.key!==t.key).map(o=>{const y=o.sd**2/o.n,w=t.sd**2/t.n,a=Math.sqrt(y+w),p=o.mean-t.mean,l=a>0?p/a:NaN,h=a>0?(y+w)**2/(y**2/(o.n-1)+w**2/(t.n-1)):NaN,b=Math.sqrt(((o.n-1)*o.sd**2+(t.n-1)*t.sd**2)/(o.n+t.n-2));return{key:o.key,delta:p,deltaSd:b>0?p/b:NaN,t:l,df:h,p:Number.isFinite(l)?x(l,h):NaN}}),r=e.filter(o=>Number.isFinite(o.p)),d=P(r.map(o=>o.p));c.control=t.key,c.contrasts=e.map(o=>({...o,pAdjusted:Number.isFinite(o.p)?d[r.indexOf(o)]:NaN}))}return c}export const comparisonP=n=>n.welch?.p??n.kruskal?.p??NaN;export function groupKeys(n){return[...new Set(n.map(s=>s.group).filter(s=>s!==void 0))].sort(V)}export function compareTestsByGroup(n,s,i){const f=s.filter(q);if(f.length===0)return[];const u=f.map(a=>a.testNumber),k=j(u),c=new Float64Array(u.length),m=groupKeys(n),t=f.map(()=>m.map(()=>[])),e=new Float64Array(u.length),r=new Uint32Array(u.length);for(const a of n){if(a.group===void 0)continue;const p=m.indexOf(a.group);e.fill(0),r.fill(0);for(const l of a.dies){k(l,c);for(let h=0;h<c.length;h++){const b=c[h];Number.isFinite(b)&&(e[h]+=b,r[h]++)}}for(let l=0;l<u.length;l++)r[l]>0&&t[l][p].push(e[l]/r[l])}const d=f.map((a,p)=>{if(t[p].every(N=>N.length===0))return;const l=compareGroups(m.map((N,g)=>({key:N,values:t[p][g]})),i),h=K(a),b=h?h.usl-h.lsl:void 0,A=l.groups.filter(N=>!l.tooSmall.includes(N.key));let M=NaN,S=NaN;if(l.contrasts?.length){const N=l.contrasts.reduce((g,v)=>Math.abs(v.deltaSd)>Math.abs(g.deltaSd)?v:g);M=N.deltaSd,S=N.delta}else if(A.length>=2){const N=A.map(v=>v.mean);S=W(N)-R(N);const g=A.reduce((v,F)=>v+(F.n-1)*F.sd**2,0)/A.reduce((v,F)=>v+F.n-1,0);M=g>0?S/Math.sqrt(g):NaN}return{test:a,comparison:l,pAdjusted:NaN,effect:M,...b&&Number.isFinite(S)?{windowShare:S/b}:{}}}).filter(a=>a!==void 0),o=d.filter(a=>Number.isFinite(comparisonP(a.comparison))),y=T(o.map(a=>comparisonP(a.comparison)));o.forEach((a,p)=>{a.pAdjusted=y[p]});const w=a=>Number.isFinite(a.pAdjusted)?a.pAdjusted:1/0;return d.sort((a,p)=>w(a)-w(p)||(Math.abs(p.effect)||0)-(Math.abs(a.effect)||0))}export function formatP(n){return Number.isFinite(n)?n<.001?"< 0.001":n.toFixed(3):"\u2014"}
1
+ import{isYieldEligibleDie as j}from"../core/dies.js";import{testValuesReader as q}from"../core/dieTable.js";import{isParametricTest as T}from"../renderer/buildWaferMap.js";import{benjaminiHochberg as L,chiSquareUpperTail as O,fUpperTail as P,holm as U,sampleVariance as K,tTwoSided as x}from"./math.js";import{capabilityLimits as V}from"./capability.js";import{compareNatural as W,maxOf as E,median as G,minOf as R}from"../core/utils.js";const B=5,D=(n,s)=>{const i=s.length,f=i?s.reduce((m,k)=>m+k,0)/i:NaN;return{key:n,n:i,mean:f,sd:i>=2?Math.sqrt(K(s,f)):NaN,median:i?G([...s]):NaN}};function H(n){const s=n.length;if(n.some(e=>!(e.sd>0)))return;if(s===2){const[e,r]=n,d=e.sd**2/e.n,o=r.sd**2/r.n,y=(e.mean-r.mean)/Math.sqrt(d+o),w=(d+o)**2/(d**2/(e.n-1)+o**2/(r.n-1));return{method:"welch-t",statistic:y,df1:1,df2:w,p:x(y,w)}}const i=n.map(e=>e.n/e.sd**2),f=i.reduce((e,r)=>e+r,0),m=n.reduce((e,r,d)=>e+i[d]*r.mean,0)/f,k=n.reduce((e,r,d)=>e+i[d]*(r.mean-m)**2,0)/(s-1),c=n.reduce((e,r,d)=>e+(1-i[d]/f)**2/(r.n-1),0),u=k/(1+2*(s-2)*c/(s*s-1)),t=(s*s-1)/(3*c);return{method:"welch-anova",statistic:u,df1:s-1,df2:t,p:P(u,s-1,t)}}function I(n){const s=n.flatMap((t,e)=>t.map(r=>({v:r,g:e}))),i=s.length;if(n.length<2||i<3)return;s.sort((t,e)=>t.v-e.v);const f=new Array(n.length).fill(0);let m=0;for(let t=0;t<i;){let e=t;for(;e+1<i&&s[e+1].v===s[t].v;)e++;const r=(t+e)/2+1;for(let o=t;o<=e;o++)f[s[o].g]+=r;const d=e-t+1;m+=d**3-d,t=e+1}const k=1-m/(i**3-i);if(!(k>0))return;const c=(12/(i*(i+1))*n.reduce((t,e,r)=>t+f[r]**2/e.length,0)-3*(i+1))/k,u=n.length-1;return{h:c,df:u,p:O(c,u),approximate:n.some(t=>t.length<B)}}export function compareGroups(n,s){const i=n.map(e=>({key:e.key,values:e.values.filter(Number.isFinite)})),f=i.map(e=>D(e.key,e.values)),m=i.filter(e=>e.values.length>=2),k=i.filter(e=>e.values.length<2).map(e=>e.key),c={groups:f,tooSmall:k};if(m.length<2)return c.issue="Needs at least two groups with two or more wafers each",c;const u=f.filter(e=>m.some(r=>r.key===e.key));c.welch=H(u),c.kruskal=I(m.map(e=>e.values)),!c.welch&&!c.kruskal?c.issue="The wafer values do not vary, so there is nothing to compare":c.welch||(c.issue="A group\u2019s wafers all have the same value, so Welch\u2019s test cannot be computed; the rank test stands");const t=s!==void 0?u.find(e=>e.key===s):void 0;if(t){const e=u.filter(o=>o.key!==t.key).map(o=>{const y=o.sd**2/o.n,w=t.sd**2/t.n,a=Math.sqrt(y+w),p=o.mean-t.mean,l=a>0?p/a:NaN,h=a>0?(y+w)**2/(y**2/(o.n-1)+w**2/(t.n-1)):NaN,b=Math.sqrt(((o.n-1)*o.sd**2+(t.n-1)*t.sd**2)/(o.n+t.n-2));return{key:o.key,delta:p,deltaSd:b>0?p/b:NaN,t:l,df:h,p:Number.isFinite(l)?x(l,h):NaN}}),r=e.filter(o=>Number.isFinite(o.p)),d=U(r.map(o=>o.p));c.control=t.key,c.contrasts=e.map(o=>({...o,pAdjusted:Number.isFinite(o.p)?d[r.indexOf(o)]:NaN}))}return c}export const comparisonP=n=>n.welch?.p??n.kruskal?.p??NaN;export function groupKeys(n){return[...new Set(n.map(s=>s.group).filter(s=>s!==void 0))].sort(W)}export function compareTestsByGroup(n,s,i){const f=s.filter(T);if(f.length===0)return[];const m=f.map(a=>a.testNumber),k=q(m),c=new Float64Array(m.length),u=groupKeys(n),t=f.map(()=>u.map(()=>[])),e=new Float64Array(m.length),r=new Uint32Array(m.length);for(const a of n){if(a.group===void 0)continue;const p=u.indexOf(a.group);e.fill(0),r.fill(0);for(const l of a.dies)if(j(l)){k(l,c);for(let h=0;h<c.length;h++){const b=c[h];Number.isFinite(b)&&(e[h]+=b,r[h]++)}}for(let l=0;l<m.length;l++)r[l]>0&&t[l][p].push(e[l]/r[l])}const d=f.map((a,p)=>{if(t[p].every(N=>N.length===0))return;const l=compareGroups(u.map((N,g)=>({key:N,values:t[p][g]})),i),h=V(a),b=h?h.usl-h.lsl:void 0,A=l.groups.filter(N=>!l.tooSmall.includes(N.key));let M=NaN,S=NaN;if(l.contrasts?.length){const N=l.contrasts.reduce((g,v)=>Math.abs(v.deltaSd)>Math.abs(g.deltaSd)?v:g);M=N.deltaSd,S=N.delta}else if(A.length>=2){const N=A.map(v=>v.mean);S=E(N)-R(N);const g=A.reduce((v,F)=>v+(F.n-1)*F.sd**2,0)/A.reduce((v,F)=>v+F.n-1,0);M=g>0?S/Math.sqrt(g):NaN}return{test:a,comparison:l,pAdjusted:NaN,effect:M,...b&&Number.isFinite(S)?{windowShare:S/b}:{}}}).filter(a=>a!==void 0),o=d.filter(a=>Number.isFinite(comparisonP(a.comparison))),y=L(o.map(a=>comparisonP(a.comparison)));o.forEach((a,p)=>{a.pAdjusted=y[p]});const w=a=>Number.isFinite(a.pAdjusted)?a.pAdjusted:1/0;return d.sort((a,p)=>w(a)-w(p)||(Math.abs(p.effect)||0)-(Math.abs(a.effect)||0))}export function formatP(n){return Number.isFinite(n)?n<.001?"< 0.001":n.toFixed(3):"\u2014"}
@@ -1 +1 @@
1
- import{diePassStatus as v}from"../core/dies.js";import{testValuesReader as y}from"../core/dieTable.js";import{isParametricTest as F}from"../renderer/buildWaferMap.js";import{fiveNumberSummary as I}from"./math.js";import{capabilityLimits as x}from"./capability.js";export const PAT_K=6,PAT_IQR_SIGMA=1.35,PAT_MIN_DIES=30,PAT_SKEW_WARN=.2,PAT_VERDICT_LABEL={within:"Within PAT limits",outlier:"PAT outlier",fails:"Fails (bin or limits)"},PAT_VERDICT_ORDER=[PAT_VERDICT_LABEL.within,PAT_VERDICT_LABEL.outlier,PAT_VERDICT_LABEL.fails];export function patTests(r){return r.filter(i=>F(i)&&x(i)!==void 0)}const E=new WeakMap;function q(r,i,m){const A=[...m].sort((t,e)=>t-e).join(","),b=E.get(r);if(b&&b.defs===i&&b.passKey===A)return b;const a=patTests(i),p=a.map(t=>x(t)),P=y(a.map(t=>t.testNumber)),T=new Set(m),d=new Float64Array(a.length),_=a.map(()=>[]);for(const t of r)if(v(t,T)===!0){P(t,d);for(let e=0;e<a.length;e++){const n=d[e];Number.isFinite(n)&&n>=p[e].lsl&&n<=p[e].usl&&_[e].push(n)}}const N=new Map,w=[];a.forEach((t,e)=>{const{lsl:n,usl:f,basis:h}=p[e],c=_[e];if(c.length<PAT_MIN_DIES){w.push({testNumber:t.testNumber,reason:"few-values"});return}const s=I(Float64Array.from(c)),o=(s.q3-s.q1)/PAT_IQR_SIGMA;if(!(o>0)){w.push({testNumber:t.testNumber,reason:"no-spread"});return}const l=s.median-PAT_K*o,u=s.median+PAT_K*o;N.set(t.testNumber,{testNumber:t.testNumber,lo:Math.max(l,n),hi:Math.min(u,f),median:s.median,robustSigma:o,n:c.length,basis:h,clippedLo:l<n,clippedHi:u>f,skew:(s.q3+s.q1-2*s.median)/(s.q3-s.q1)})});const R=a.map(t=>N.get(t.testNumber)),S=r.map(t=>{const e=v(t,T)===!1,n=P(t,d);let f=!1;const h=[],c=[];return a.forEach((s,o)=>{const l=R[o],u=n[o];!l||!Number.isFinite(u)||(f=!0,u<p[o].lsl||u>p[o].usl?h.push(s.testNumber):(u<l.lo||u>l.hi)&&c.push(s.testNumber))}),f?h.length||e?{verdict:"fails",tests:h}:c.length?{verdict:"outlier",tests:c}:{verdict:"within",tests:[]}:{tests:[]}}),g={defs:i,passKey:A,pat:{limits:N,skipped:w},verdicts:S};return E.set(r,g),g}export function waferPatLimits(r,i,m){return q(r,i,m).pat}export function waferPatVerdicts(r,i,m){return q(r,i,m).verdicts}
1
+ import{diePassStatus as g}from"../core/dies.js";import{testValuesReader as y}from"../core/dieTable.js";import{isParametricTest as F}from"../renderer/buildWaferMap.js";import{fiveNumberSummary as I}from"./math.js";import{capabilityLimits as x}from"./capability.js";export const PAT_K=6,PAT_IQR_SIGMA=1.35,PAT_MIN_DIES=30,PAT_SKEW_WARN=.2,PAT_VERDICT_LABEL={within:"Within PAT limits",outlier:"PAT outlier",fails:"Fails (bin or limits)"},PAT_VERDICT_ORDER=[PAT_VERDICT_LABEL.within,PAT_VERDICT_LABEL.outlier,PAT_VERDICT_LABEL.fails];export function patTests(r){return r.filter(i=>F(i)&&x(i)!==void 0)}const E=new WeakMap;function q(r,i,m){const A=[...m].sort((t,e)=>t-e).join(","),d=E.get(r);if(d&&d.defs===i&&d.passKey===A)return d;const a=patTests(i),p=a.map(t=>x(t)),P=y(a.map(t=>t.testNumber)),T=new Set(m),b=new Float64Array(a.length),v=a.map(()=>[]);for(const t of r)if(g(t,T)===!0){P(t,b);for(let e=0;e<a.length;e++){const n=b[e];Number.isFinite(n)&&n>=p[e].lsl&&n<=p[e].usl&&v[e].push(n)}}const N=new Map,w=[];a.forEach((t,e)=>{const{lsl:n,usl:f,basis:h}=p[e],c=v[e];if(c.length<PAT_MIN_DIES){w.push({testNumber:t.testNumber,reason:"few-values"});return}const s=I(Float64Array.from(c)),o=(s.q3-s.q1)/PAT_IQR_SIGMA;if(!(o>0)){w.push({testNumber:t.testNumber,reason:"no-spread"});return}const l=s.median-PAT_K*o,u=s.median+PAT_K*o;N.set(t.testNumber,{testNumber:t.testNumber,lo:Math.max(l,n),hi:Math.min(u,f),median:s.median,robustSigma:o,n:c.length,basis:h,clippedLo:l<n,clippedHi:u>f,skew:(s.q3+s.q1-2*s.median)/(s.q3-s.q1)})});const R=a.map(t=>N.get(t.testNumber)),S=r.map(t=>{const e=g(t,T)===!1,n=P(t,b);let f=!1;const h=[],c=[];return a.forEach((s,o)=>{const l=R[o],u=n[o];!l||!Number.isFinite(u)||(f=!0,u<p[o].lsl||u>p[o].usl?h.push(s.testNumber):(u<l.lo||u>l.hi)&&c.push(s.testNumber))}),f?h.length||e?{verdict:"fails",tests:h}:c.length?{verdict:"outlier",tests:c}:{verdict:"within",tests:[]}:e?{verdict:"fails",tests:[]}:{tests:[]}}),_={defs:i,passKey:A,pat:{limits:N,skipped:w},verdicts:S};return E.set(r,_),_}export function waferPatLimits(r,i,m){return q(r,i,m).pat}export function waferPatVerdicts(r,i,m){return q(r,i,m).verdicts}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wafertools/wafermap",
3
- "version": "0.37.0",
3
+ "version": "0.37.1",
4
4
  "description": "Interactive wafer map visualization and yield analysis for semiconductor test data. Hard bins, soft bins, test values, retests, edge exclusion, reticle overlays, spatial statistics, failure clustering, and lot-level trend analysis — pure ES modules, no runtime dependencies, no server required.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -120,7 +120,14 @@
120
120
  "lot-analysis",
121
121
  "canvas",
122
122
  "visualization",
123
- "typescript"
123
+ "data-visualization",
124
+ "wafermap",
125
+ "esm",
126
+ "javascript",
127
+ "typescript",
128
+ "react",
129
+ "svelte",
130
+ "vue"
124
131
  ],
125
132
  "devDependencies": {
126
133
  "esbuild": "^0.28.1",
@@ -1,26 +0,0 @@
1
- import type { Die } from '../core/dies.js';
2
- import type { TestDef } from '../renderer/buildWaferMap.js';
3
- import type { RenderableWaferMap } from './renderWaferMap.js';
4
- import { type WaferMapDisplayItem } from './renderWaferGallery.js';
5
- export interface PatMapItem {
6
- label: string;
7
- dies: readonly Die[];
8
- allDies?: readonly Die[];
9
- passBins: readonly number[];
10
- ringCount: number;
11
- source?: RenderableWaferMap;
12
- }
13
- /**
14
- * One map per wafer that has its own result to draw on (geometry and orientation come from it), each die carrying its
15
- * verdict as a value of the field "PAT verdict" and the map coloured by it, so the legend, toolbar and tooltips name the
16
- * verdict and not a bin. A die with no verdict (no test judged it) carries no value and draws as no data. The maps state no
17
- * yield: a verdict is not a bin.
18
- */
19
- export declare function patVerdictMaps(items: readonly PatMapItem[], testDefs: readonly TestDef[]): WaferMapDisplayItem[];
20
- /** Opens the maps in a window over `anchor`: a gallery of them coloured by verdict, destroyed with the window. */
21
- export declare function openPatMaps(o: {
22
- anchor: HTMLElement;
23
- items: readonly PatMapItem[];
24
- testDefs: readonly TestDef[];
25
- }): void;
26
- //# sourceMappingURL=patMaps.d.ts.map
@@ -1 +0,0 @@
1
- import{copyDie as u}from"../core/dieTable.js";import{PAT_VERDICT_LABEL as i,waferPatVerdicts as p}from"../stats/pat.js";import{openModal as h}from"./toolbar.js";import{renderWaferGallery as m}from"./renderWaferGallery.js";const a="pat",v={key:a,label:"PAT verdict",values:[{value:i.within,color:"#0072b2"},{value:i.outlier,color:"#e69f00"},{value:i.fails,color:"#c0392b"}]};export function patVerdictMaps(t,s){const n=[];for(const e of t){if(!e.source)continue;const o=e.allDies??e.dies,r=p(o,s,e.passBins),l=o.map((d,f)=>{const c=r[f].verdict;return u(d,{hbin:void 0,sbin:void 0,testValues:void 0,testPass:void 0,metadata:c?{[a]:i[c]}:void 0})});n.push({...e.source,label:e.label,dies:l,ringCount:e.ringCount,passBins:[],hbinDefs:[],sbinDefs:[],testDefs:[],metadataFields:[v]})}return n}export function openPatMaps(t){const s=patVerdictMaps(t.items,t.testDefs);if(s.length===0)return;const n=t.anchor.ownerDocument,e=n.createElement("div");Object.assign(e.style,{height:"100%",minHeight:"0",overflow:"auto"});let o;h({title:"PAT verdicts by wafer",anchor:t.anchor,ownerDocument:n,onClose:()=>o?.destroy(),boxSize:{width:"min(96vw, 1200px)",height:"min(92vh, 780px)"}}).contentWrap.appendChild(e),o=m(e,s,{viewOptions:{plotMode:"metadata",activeMetadataKey:a},insights:{enabled:!1}})}