@wafertools/wafermap 0.35.0 → 0.36.0
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.
- package/AGENTS.md +18 -9
- package/CHANGELOG.md +246 -0
- package/README.md +7 -4
- package/dist/packages/canvas-adapter/chartPrefs.d.ts +16 -0
- package/dist/packages/canvas-adapter/chartPrefs.js +1 -0
- package/dist/packages/canvas-adapter/charts/boxplot.js +1 -1
- package/dist/packages/canvas-adapter/charts/capability.js +1 -1
- package/dist/packages/canvas-adapter/charts/correlation.js +1 -1
- package/dist/packages/canvas-adapter/charts/histogram.js +1 -1
- package/dist/packages/canvas-adapter/dataTab.js +1 -1
- package/dist/packages/canvas-adapter/drilldown.js +1 -1
- package/dist/packages/canvas-adapter/index.d.ts +1 -0
- package/dist/packages/canvas-adapter/index.js +1 -1
- package/dist/packages/canvas-adapter/insightsTab.d.ts +7 -0
- package/dist/packages/canvas-adapter/insightsTab.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferGallery.d.ts +20 -5
- package/dist/packages/canvas-adapter/renderWaferGallery.js +1 -1
- package/dist/packages/canvas-adapter/renderWaferMap.d.ts +85 -38
- package/dist/packages/canvas-adapter/renderWaferMap.js +1 -1
- package/dist/packages/canvas-adapter/summaryPanel.d.ts +38 -12
- package/dist/packages/canvas-adapter/summaryPanel.js +4 -2
- package/dist/packages/canvas-adapter/summaryToggle.d.ts +11 -0
- package/dist/packages/canvas-adapter/summaryToggle.js +1 -0
- package/dist/packages/canvas-adapter/testValueOffer.d.ts +14 -0
- package/dist/packages/canvas-adapter/testValueOffer.js +1 -0
- package/dist/packages/canvas-adapter/toCanvas.js +1 -1
- package/dist/packages/canvas-adapter/toolbar.d.ts +2 -0
- package/dist/packages/canvas-adapter/toolbar.js +2 -2
- package/dist/packages/canvas-adapter/userGuideHtml.d.ts +1 -1
- package/dist/packages/canvas-adapter/userGuideHtml.js +46 -23
- package/dist/packages/canvas-adapter/version.d.ts +2 -2
- package/dist/packages/canvas-adapter/version.js +1 -1
- package/dist/packages/canvas-adapter/warnings.js +1 -1
- package/dist/packages/core/aggregates.d.ts +10 -0
- package/dist/packages/core/aggregates.js +1 -1
- package/dist/packages/core/classify.d.ts +5 -0
- package/dist/packages/core/classify.js +1 -1
- package/dist/packages/core/dieTable.d.ts +31 -0
- package/dist/packages/core/dieTable.js +1 -1
- package/dist/packages/core/passBins.d.ts +6 -0
- package/dist/packages/core/passBins.js +1 -1
- package/dist/packages/core/wafer.d.ts +10 -1
- package/dist/packages/core/wafer.js +1 -1
- package/dist/packages/renderer/buildView.d.ts +5 -0
- package/dist/packages/renderer/buildView.js +1 -1
- package/dist/packages/renderer/buildWaferMap.d.ts +50 -4
- package/dist/packages/renderer/buildWaferMap.js +1 -1
- package/dist/packages/renderer/derivedTests/parser.js +1 -1
- package/dist/packages/renderer/fmt.d.ts +10 -0
- package/dist/packages/renderer/fmt.js +1 -1
- package/dist/packages/renderer/index.d.ts +1 -0
- package/dist/packages/renderer/index.js +1 -1
- package/dist/packages/renderer/spec.d.ts +4 -0
- package/dist/packages/renderer/spec.js +1 -1
- package/dist/packages/renderer/valueFilter.d.ts +55 -0
- package/dist/packages/renderer/valueFilter.js +1 -0
- package/dist/packages/stats/analyzeWaferLot.d.ts +16 -0
- package/dist/packages/stats/analyzeWaferLot.js +1 -1
- package/dist/packages/stats/analyzeWaferMap.d.ts +62 -4
- package/dist/packages/stats/analyzeWaferMap.js +1 -1
- package/dist/packages/stats/capability.d.ts +5 -0
- package/dist/packages/stats/capability.js +1 -1
- package/dist/packages/stats/clusterDetection.js +1 -1
- package/dist/packages/stats/connectedComponents.d.ts +19 -0
- package/dist/packages/stats/connectedComponents.js +1 -1
- package/dist/packages/stats/correlation.d.ts +36 -4
- package/dist/packages/stats/correlation.js +1 -1
- package/dist/packages/stats/filterFindings.d.ts +1 -1
- package/dist/packages/stats/filterFindings.js +1 -1
- package/dist/packages/stats/findingText.d.ts +8 -0
- package/dist/packages/stats/findingText.js +2 -2
- package/dist/packages/stats/index.d.ts +2 -1
- package/dist/packages/stats/index.js +1 -1
- package/dist/packages/stats/lotDrift.js +1 -1
- package/dist/packages/stats/lotPattern.js +1 -1
- package/dist/packages/stats/math.d.ts +25 -3
- package/dist/packages/stats/math.js +1 -1
- package/dist/packages/stats/mergeTestDefs.js +1 -1
- package/dist/packages/stats/patternClassification.d.ts +44 -18
- package/dist/packages/stats/patternClassification.js +1 -1
- package/dist/packages/stats/plotData.d.ts +11 -0
- package/dist/packages/stats/plotData.js +1 -1
- package/dist/packages/stats/regions.d.ts +6 -0
- package/dist/packages/stats/regions.js +1 -1
- package/dist/packages/stats/renderSummaryReport.js +33 -33
- package/dist/packages/stats/reportHtml.d.ts +12 -18
- package/dist/packages/stats/reportHtml.js +112 -48
- package/dist/packages/stats/synthesis.d.ts +48 -17
- package/dist/packages/stats/synthesis.js +1 -1
- package/dist/packages/stats/testPassRate.js +1 -1
- package/dist/packages/stats/testValueBudget.d.ts +15 -0
- package/dist/packages/stats/testValueBudget.js +1 -0
- package/dist/packages/stats/types.d.ts +89 -22
- package/llms.txt +2 -2
- package/package.json +1 -1
- package/dist/packages/canvas-adapter/summaryRail.d.ts +0 -7
- package/dist/packages/canvas-adapter/summaryRail.js +0 -1
|
@@ -1,16 +1,38 @@
|
|
|
1
|
+
/** The error function erf(x), from {@link complementaryErrorFunction}. */
|
|
2
|
+
export declare function errorFunction(value: number): number;
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
+
* The complementary error function erfc(x) = 1 − erf(x), accurate to about 1e-15 relative across the whole
|
|
5
|
+
* range, the far tail included: W. J. Cody's rational approximations (Math. Comp. 23, 1969; the CALERF
|
|
6
|
+
* routine). A small p-value is read from the tail, where 1 − erf(x) computed by subtraction is noise below
|
|
7
|
+
* about 1e-7 and becomes 0.
|
|
4
8
|
*/
|
|
5
|
-
export declare function
|
|
9
|
+
export declare function complementaryErrorFunction(value: number): number;
|
|
6
10
|
/** Standard normal cumulative distribution function Φ(value). */
|
|
7
11
|
export declare function normalCdf(value: number): number;
|
|
12
|
+
/** The standard normal upper tail 1 − Φ(value), accurate where it is small. */
|
|
13
|
+
export declare function normalUpperTail(value: number): number;
|
|
14
|
+
/** Two-sided p-value of a z statistic: the one rule every z-based test in the library reads its p from. */
|
|
15
|
+
export declare function zPValue(z: number): number;
|
|
8
16
|
/**
|
|
9
17
|
* Exact one-sided binomial tail P(X ≥ k) for X ~ Binomial(n, p). Exact rather
|
|
10
18
|
* than a normal approximation because it is asked about small n — how many of a
|
|
11
19
|
* lot's few wafers fail at one die position — where the approximation is poor.
|
|
12
20
|
*/
|
|
13
21
|
export declare function binomialUpperTail(k: number, n: number, p: number): number;
|
|
22
|
+
/** ln Γ(x) for x > 0, by the Lanczos approximation (g = 7, 9 terms): relative error near 1e-15. */
|
|
23
|
+
export declare function logGamma(x: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Two-sided Fisher exact p-value of the 2×2 table [[a, b], [c, d]]: the probability, with the margins fixed,
|
|
26
|
+
* of a table no more likely than the one observed. For rates whose expected counts are too small for a
|
|
27
|
+
* normal approximation, which there reports differences far more significant than they are. The table's
|
|
28
|
+
* probabilities are walked by their ratio, so the cost is the span of the first cell, not the dies.
|
|
29
|
+
*/
|
|
30
|
+
export declare function fisherExact(a: number, b: number, c: number, d: number): number;
|
|
31
|
+
/**
|
|
32
|
+
* A seeded uniform generator on [0, 1) (mulberry32). For resampling that must give the same answer on
|
|
33
|
+
* every run (a permutation test's p-value), never for anything that should look random to a user.
|
|
34
|
+
*/
|
|
35
|
+
export declare function seededRandom(seed: number): () => number;
|
|
14
36
|
/**
|
|
15
37
|
* Benjamini–Hochberg adjusted p-values, in the order given. The one
|
|
16
38
|
* false-discovery-rate rule in the library: findings (`adjustPValues`) and the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function errorFunction(t){
|
|
1
|
+
export function errorFunction(t){return t<0?-1+complementaryErrorFunction(-t):1-complementaryErrorFunction(t)}export function complementaryErrorFunction(t){const e=Math.abs(t);let n;if(e<=.46875){const o=e>111e-18?e*e:0;let r=q[4]*o,s=o;for(let u=0;u<3;u++)r=(r+q[u])*o,s=(s+b[u])*o;return 1-t*(r+q[3])/(s+b[3])}if(e<=4){let o=y[8]*e,r=e;for(let s=0;s<7;s++)o=(o+y[s])*e,r=(r+F[s])*e;n=(o+y[7])/(r+F[7])}else{if(e>=26.543)return t>0?0:2;const o=1/(e*e);let r=N[5]*o,s=o;for(let l=0;l<4;l++)r=(r+N[l])*o,s=(s+w[l])*o;n=(1/Math.sqrt(Math.PI)-o*(r+N[4])/(s+w[4]))/e}const c=Math.trunc(e*16)/16,i=(e-c)*(e+c);return n*=Math.exp(-c*c)*Math.exp(-i),t<0?2-n:n}const q=[3.1611237438705655,113.86415415105016,377.485237685302,3209.3775891384694,.18577770618460315],b=[23.601290952344122,244.02463793444417,1282.6165260773723,2844.236833439171],y=[.5641884969886701,8.883149794388377,66.11919063714163,298.6351381974001,881.952221241769,1712.0476126340707,2051.0783778260716,1230.3393547979972,21531153547440383e-24],F=[15.744926110709835,117.6939508913125,537.1811018620099,1621.3895745666903,3290.7992357334597,4362.619090143247,3439.3676741437216,1230.3393548037495],N=[.30532663496123236,.36034489994980445,.12578172611122926,.016083785148742275,.0006587491615298378,.016315387137302097],w=[2.568520192289822,1.8729528499234673,.5279051029514285,.06051834131244132,.0023352049762686918];export function normalCdf(t){return .5*complementaryErrorFunction(-t/Math.SQRT2)}export function normalUpperTail(t){return .5*complementaryErrorFunction(t/Math.SQRT2)}export function zPValue(t){return Math.min(1,2*normalUpperTail(Math.abs(t)))}export function binomialUpperTail(t,e,n){if(t<=0)return 1;if(t>e||n<=0)return 0;if(n>=1)return 1;let c=t*Math.log(n)+(e-t)*Math.log1p(-n);for(let s=0;s<t;s++)c+=Math.log(e-s)-Math.log(s+1);let i=Math.exp(c),o=0;const r=n/(1-n);for(let s=t;s<=e;s++)o+=i,i*=(e-s)/(s+1)*r;return Math.min(1,o)}export function logGamma(t){if(t<.5)return Math.log(Math.PI/Math.sin(Math.PI*t))-logGamma(1-t);const e=[.9999999999998099,676.5203681218851,-1259.1392167224028,771.3234287776531,-176.6150291621406,12.507343278686905,-.13857109526572012,9984369578019572e-21,15056327351493116e-23],n=t-1;let c=e[0];for(let o=1;o<9;o++)c+=e[o]/(n+o);const i=n+7.5;return .5*Math.log(2*Math.PI)+(n+.5)*Math.log(i)-i+Math.log(c)}export function fisherExact(t,e,n,c){const i=t+e,o=n+c,r=t+n,s=i+o,l=Math.max(0,r-o),u=Math.min(i,r);if(u<=l)return 1;const m=h=>logGamma(i+1)+logGamma(o+1)+logGamma(r+1)+logGamma(s-r+1)-logGamma(s+1)-logGamma(h+1)-logGamma(i-h+1)-logGamma(r-h+1)-logGamma(o-r+h+1),p=Math.exp(m(t));let M=Math.exp(m(l)),f=0;const a=p*(1+1e-7);for(let h=l;h<=u;h++)M<=a&&(f+=M),M*=(i-h)*(r-h)/((h+1)*(o-r+h+1));return Math.min(1,f)}export function seededRandom(t){let e=t>>>0;return()=>{e=e+1831565813>>>0;let n=e;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}}export function benjaminiHochberg(t){const e=t.length,n=t.map((o,r)=>r).sort((o,r)=>t[o]-t[r]),c=new Array(e);let i=1;for(let o=e-1;o>=0;o--){const r=n[o];i=Math.min(i,t[r]*e/(o+1),1),c[r]=i}return c}export function quantile(t,e){if(t.length===0)return NaN;const n=e*(t.length-1),c=Math.floor(n),i=Math.ceil(n);return t[c]+(t[i]-t[c])*(n-c)}export function robustFence(t,e=1.5,n=8){const c=Float64Array.from(Array.from(t).filter(s=>Number.isFinite(s)));if(c.length<n)return null;const{q1:i,q3:o}=fiveNumberSummary(c),r=o-i;return r===0?null:{lo:i-e*r,hi:o+e*r}}export function sampleVariance(t,e){const n=t.length;if(n<2)return 0;if(e===void 0){let i=0;for(let o=0;o<n;o++)i+=t[o];e=i/n}let c=0;for(let i=0;i<n;i++)c+=(t[i]-e)**2;return c/(n-1)}export function describeValues(t){const e=t.length;let n=0;for(let m=0;m<e;m++)n+=t[m];const c=n/e,i=Math.sqrt(sampleVariance(t,c)),{min:o,q1:r,median:s,q3:l,max:u}=fiveNumberSummary(t);return{min:o,max:u,mean:c,count:e,stddev:i,median:s,q1:r,q3:l}}export function fiveNumberSummary(t){let e=1/0,n=-1/0;for(let r=0;r<t.length;r++){const s=t[r];s<e&&(e=s),s>n&&(n=s)}t.length===0&&(e=NaN,n=NaN);const{q1:c,median:i,q3:o}=E(t);return{min:e,q1:c,median:i,q3:o,max:n}}function E(t){const e=t.length;if(e===0)return{q1:NaN,median:NaN,q3:NaN};const n=e-1,c=(p,M,f)=>{const a=p*n,h=Math.floor(a),x=R(t,h,M,f);if(a===h)return x;let g=1/0;for(let d=h+1;d<=f;d++)t[d]<g&&(g=t[d]);return x+(g-x)*(a-h)},i=Math.floor(.5*n),o=c(.5,0,n),r=Math.floor(.25*n),s=r===i?c(.25,i,n):m(.25,r,i),u=Math.floor(.75*n)===i?c(.75,i,n):c(.75,i+1,n);return{q1:s,median:o,q3:u};function m(p,M,f){const a=p*n,h=R(t,M,0,f-1);if(a===M)return h;let x=t[f];for(let g=M+1;g<f;g++)t[g]<x&&(x=t[g]);return h+(x-h)*(a-M)}}function R(t,e,n,c){for(;n<c;){const i=t[n],o=t[n+c>>>1],r=t[c],s=i<o?o<r?o:i<r?r:i:i<r?i:o<r?r:o;let l=n,u=c;for(;l<=u;){for(;t[l]<s;)l++;for(;t[u]>s;)u--;if(l<=u){const m=t[l];t[l]=t[u],t[u]=m,l++,u--}}if(e<=u)c=u;else if(e>=l)n=l;else break}return t[e]}export function mannKendall(t){const e=t.length;if(e<3)return null;let n=0;const c=[];for(let f=0;f<e-1;f++)for(let a=f+1;a<e;a++){const h=t[a]-t[f];n+=h>0?1:h<0?-1:0,c.push(h/(a-f))}const i=new Map;for(const f of t)i.set(f,(i.get(f)??0)+1);let o=e*(e-1)*(2*e+5)/18;for(const f of i.values())f>1&&(o-=f*(f-1)*(2*f+5)/18);if(o<=0)return null;const r=n===0?0:(n-Math.sign(n))/Math.sqrt(o),s=zPValue(r);c.sort((f,a)=>f-a);const l=c.length>>1,u=c.length%2?c[l]:(c[l-1]+c[l])/2,m=t.map((f,a)=>f-u*a).sort((f,a)=>f-a),p=m.length>>1,M=m.length%2?m[p]:(m[p-1]+m[p])/2;return{n:e,s:n,z:r,pValue:s,slope:u,intercept:M}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{fmtExact as h}from"../renderer/fmt.js";const T=1e-6;function k(n,t){if(n===t)return!0;if(!Number.isFinite(n)||!Number.isFinite(t))return!1;const i=Math.max(Math.abs(n),Math.abs(t));return Math.abs(n-t)<=T*i}function H(n){const t=n.name?.trim();return t||void 0}function I(n){const t=n.unit?.trim();return t||void 0}function N(n){return n.toLowerCase()}function p(n,t){const i=new Set,r=[];for(const l of n){const s=t(l);i.has(s)||(i.add(s),r.push(l))}return r}function b(n){const t=[];for(const i of n)t.some(r=>k(r,i))||t.push(i);return t}function M(n){return`${n.testNumber} (${n.values.join(" vs ")})`}function x(n,t=5){const i=n.slice(0,t).map(M).join(", "),r=n.length-Math.min(t,n.length);return r>0?`${i}, and ${r} more`:i}export function mergeTestDefs(n){const t=new Map,i=[];for(const s of n)for(const o of s?.testDefs??[]){const f=o.testNumber;let d=t.get(f);d||(d=[],t.set(f,d),i.push(f)),d.push(o)}const r=[],l=[];for(const s of i){const o=t.get(s),f=p(o.map(H).filter(e=>e!==void 0),N),d=p(o.map(I).filter(e=>e!==void 0),e=>e),g=p(o.map(e=>e.testType).filter(e=>e!==void 0),e=>e),$=f.length>1?{testNumber:s,kind:"name",excluded:!0,values:f}:d.length>1?{testNumber:s,kind:"unit",excluded:!0,values:d}:g.length>1?{testNumber:s,kind:"testType",excluded:!0,values:g}:void 0;if($){l.push($);continue}const u=b(o.map(e=>e.limitLow).filter(e=>e!==void 0)),a=b(o.map(e=>e.limitHigh).filter(e=>e!==void 0)),w=p(o.filter(e=>e.limitLow!==void 0).map(e=>e.limitLowInclusive!==!1),e=>String(e)),L=p(o.filter(e=>e.limitHigh!==void 0).map(e=>e.limitHighInclusive!==!1),e=>String(e)),c=u.length>1||a.length>1||w.length>1||L.length>1;c&&l.push({testNumber:s,kind:"limits",excluded:!1,values:u.length>1?u.map(h):a.length>1?a.map(h):w.length>1?w.map(e=>`${e?"\u2265":">"} ${h(u[0])}`):L.map(e=>`${e?"\u2264":"<"} ${h(a[0])}`)});const m=b(o.map(e=>e.specLow).filter(e=>e!==void 0)),v=b(o.map(e=>e.specHigh).filter(e=>e!==void 0)),y=m.length>1||v.length>1;y&&l.push({testNumber:s,kind:"specLimits",excluded:!1,values:(m.length>1?m:v).map(h)}),r.push({testNumber:s,name:f[0]??"",...d[0]!==void 0?{unit:d[0]}:{},...g[0]!==void 0?{testType:g[0]}:{},...o.find(e=>e.logScale!==void 0)?{logScale:o.find(e=>e.logScale!==void 0).logScale}:{},...!c&&u[0]!==void 0?{limitLow:u[0]}:{},...!c&&a[0]!==void 0?{limitHigh:a[0]}:{},...!c&&w[0]===!1?{limitLowInclusive:!1}:{},...!c&&L[0]===!1?{limitHighInclusive:!1}:{},...!y&&m[0]!==void 0?{specLow:m[0]}:{},...!y&&v[0]!==void 0?{specHigh:v[0]}:{},...o.some(e=>e.derived)?{derived:!0}:{},...o.find(e=>e.expression!==void 0)?{expression:o.find(e=>e.expression!==void 0).expression}:{}})}return{defs:r,conflicts:l,warnings:S(l)}}function S(n){const t=[],i=n.filter(s=>s.excluded),r=n.filter(s=>s.kind==="limits"),l=n.filter(s=>s.kind==="specLimits");return i.length>0&&t.push({code:"test-def-collision",severity:"error",message:`${i.length} test ${i.length===1?"number describes":"numbers describe"} a different measurement in different wafers, so the same number cannot identify one test across this population. Affected: `+x(i)+". These tests are withheld from every cross-wafer chart, report and map mode \u2014 pooling them would mix unrelated measurements into one distribution. Each wafer's own view is unaffected. Load one test program at a time to see them."}),r.length>0&&t.push({code:"test-limit-conflict",severity:"warning",message:`${r.length} ${r.length===1?"test is":"tests are"} held to different test limits in different wafers. Affected: `+x(r)+". The measured values are still comparable, so distributions include them, but the limit yield, the limit lines, and capability measured against the test limits are withheld for these tests \u2014 there is no single pair of limits to judge the merged population against."}),l.length>0&&t.push({code:"test-limit-conflict",severity:"warning",message:`${l.length} ${l.length===1?"test has":"tests have"} different spec limits in different wafers. Affected: `+x(l)+". Their spec limits are withheld for the merged population, so capability uses the test limits where they agree."}),t}
|
|
@@ -43,6 +43,23 @@ export interface PatternFeatures {
|
|
|
43
43
|
* low value = concentrated arc (edge-local).
|
|
44
44
|
*/
|
|
45
45
|
edgeAngularSpread: number;
|
|
46
|
+
/**
|
|
47
|
+
* Spread of the salient region across its principal axis (root mean square), in die pitches. A scratch is
|
|
48
|
+
* about one die wide at any angle (under 1); a blob is wider.
|
|
49
|
+
*/
|
|
50
|
+
lineWidth: number;
|
|
51
|
+
/** Extent of the salient region along its principal axis, in die pitches. */
|
|
52
|
+
lineLength: number;
|
|
53
|
+
/** Failing dies on that line: the salient region and the fragments that continue it along its axis. */
|
|
54
|
+
lineSize: number;
|
|
55
|
+
/** Nearest and farthest distance of that line's dies from the wafer centre, normalised by radius. */
|
|
56
|
+
lineMinDistNorm: number;
|
|
57
|
+
lineMaxDistNorm: number;
|
|
58
|
+
/**
|
|
59
|
+
* Fail rate in five rings of equal width, centre outwards (0–0.2 of the radius, 0.2–0.4, …). A donut is a
|
|
60
|
+
* raised band at mid-radius over a cleaner centre and rim; a centre cluster falls away from the first.
|
|
61
|
+
*/
|
|
62
|
+
radialFailRates: number[];
|
|
46
63
|
}
|
|
47
64
|
export interface PatternClassification {
|
|
48
65
|
pattern: PatternLabel;
|
|
@@ -61,38 +78,47 @@ export interface PatternThresholds {
|
|
|
61
78
|
edgeLocalEdgeRdd: number;
|
|
62
79
|
/** p25DistNorm separator: ≥ this → edge-ring; [0.55, this) → edge-local. */
|
|
63
80
|
edgeLocalCentroidDist: number;
|
|
64
|
-
/** p25DistNorm separator: < this → center; [this, 0.55) → donut. */
|
|
65
|
-
donutP25Dist: number;
|
|
66
81
|
centerCentroidDist: number;
|
|
67
82
|
centerCentroidDistHigh: number;
|
|
68
83
|
centerEdgeRdd: number;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
84
|
+
/** A scratch's salient region is at most this wide across its axis (lineWidth, die pitches). */
|
|
85
|
+
scratchMaxLineWidth: number;
|
|
86
|
+
/** …and at least this long along it (lineLength, die pitches): random fails at 15% make thin groups 6–7
|
|
87
|
+
* dies long by chance, whatever the wafer's size. */
|
|
88
|
+
scratchMinLineLength: number;
|
|
89
|
+
/** …and at least this long against the wafer's radius in pitches, so a scratch is long for its wafer. */
|
|
90
|
+
scratchMinLineLengthRadius: number;
|
|
91
|
+
/** A scratch's line must reach at least this far out (lineMaxDistNorm): a
|
|
74
92
|
* scratch is long, so an elongated blob wholly inside the central zone is a
|
|
75
93
|
* centre cluster, not a scratch. */
|
|
76
94
|
scratchMinReach: number;
|
|
95
|
+
/** …and come at least this far in (lineMinDistNorm below it): a thin line along the rim is edge-local. */
|
|
96
|
+
scratchMaxInnerDist: number;
|
|
97
|
+
/** A donut's mid-radius band (the higher of rings 2 and 3 of `radialFailRates`) fails at least this much more
|
|
98
|
+
* often than the centre band, at least `donutRim` more than the outermost, and at least `donutPeak` in all. */
|
|
99
|
+
donutHole: number;
|
|
100
|
+
donutRim: number;
|
|
101
|
+
donutPeak: number;
|
|
77
102
|
minimumFailingDies: number;
|
|
78
103
|
}
|
|
79
104
|
/**
|
|
80
105
|
* Default thresholds for the spatial pattern classifier.
|
|
81
106
|
*
|
|
82
107
|
* Calibrated against WM-811K — 25,519 labelled real-world wafers from TSMC
|
|
83
|
-
* 300mm fabrication (Wu et al. 2015). Benchmark results on that dataset
|
|
108
|
+
* 300mm fabrication (Wu et al. 2015). Benchmark results on that dataset
|
|
109
|
+
* (`scripts/run-benchmark-npz.mjs`, 2026-10-09):
|
|
84
110
|
*
|
|
85
|
-
* | Pattern | Recall |
|
|
86
|
-
*
|
|
87
|
-
* | Near-full | 100% |
|
|
88
|
-
* |
|
|
89
|
-
* |
|
|
90
|
-
* |
|
|
91
|
-
* |
|
|
92
|
-
* |
|
|
93
|
-
* |
|
|
111
|
+
* | Pattern | Recall | Precision |
|
|
112
|
+
* |------------|--------|-----------|
|
|
113
|
+
* | Near-full | 100% | 40% |
|
|
114
|
+
* | Center | 85% | 88% |
|
|
115
|
+
* | Donut | 78% | 69% |
|
|
116
|
+
* | Edge-ring | 75% | 92% |
|
|
117
|
+
* | Edge-local | 68% | 52% |
|
|
118
|
+
* | Random | 60% | 52% |
|
|
119
|
+
* | Scratch | 41% | 87% |
|
|
94
120
|
*
|
|
95
|
-
* Overall
|
|
121
|
+
* Overall: 71% exact match.
|
|
96
122
|
*/
|
|
97
123
|
export declare const DEFAULT_PATTERN_THRESHOLDS: PatternThresholds;
|
|
98
124
|
/** How each pattern is named to an engineer — the wafer's finding and the lot's. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{findConnectedComponents as
|
|
1
|
+
import{findConnectedComponents as fn}from"./connectedComponents.js";import{clamp01 as pn}from"../core/utils.js";import{ringOf as yn}from"../core/classify.js";export const DEFAULT_PATTERN_THRESHOLDS={nearFullGlobalRdd:.6,edgeRingEdgeRdd:.18,edgeRingEdgeRddHigh:.3,edgeRingRadialSpread:.45,edgeRingAngularSpread:.6,edgeLocalEdgeRdd:.1,edgeLocalCentroidDist:.76,centerCentroidDist:.22,centerCentroidDistHigh:.1,centerEdgeRdd:.35,scratchMaxLineWidth:.8,scratchMinLineLength:8,scratchMinLineLengthRadius:.3,scratchMinReach:.35,scratchMaxInnerDist:.7,donutHole:.15,donutRim:.15,donutPeak:.15,minimumFailingDies:5};function B(n,t,o){return yn(n.physX-t.center.x,n.physY-t.center.y,t.radius,o)===o}function mn(n,t,o){if(n.length<3)return 0;let s=0,d=0,c=0;for(const M of n){const u=M.physX-t,g=M.physY-o;s+=u*u,d+=g*g,c+=u*g}s/=n.length,d/=n.length,c/=n.length;const a=s+d,i=s*d-c*c,p=Math.max(0,(a/2)**2-i),f=a/2+Math.sqrt(p),m=a/2-Math.sqrt(p);if(f<=0)return 0;const R=pn(m/f);return Math.sqrt(1-R)}function Mn(n,t){if(t===0)return 0;const o=new Map,s=new Map,d=new Map,c=new Map;for(const i of n)o.set(i.y,(o.get(i.y)??0)+1),s.set(i.x,(s.get(i.x)??0)+1),d.set(i.x-i.y,(d.get(i.x-i.y)??0)+1),c.set(i.x+i.y,(c.get(i.x+i.y)??0)+1);let a=0;for(const i of o.values())i>a&&(a=i);for(const i of s.values())i>a&&(a=i);for(const i of d.values())i>a&&(a=i);for(const i of c.values())i>a&&(a=i);return a/t}function xn(n,t,o,s){if(n.length<2)return{width:0,length:0};let d=0,c=0,a=0;for(const u of n){const g=u.physX-t,x=u.physY-o;d+=g*g,c+=x*x,a+=g*x}const i=.5*Math.atan2(2*a,d-c),p=Math.cos(i),f=Math.sin(i);let m=1/0,R=-1/0,M=0;for(const u of n){const g=u.physX-t,x=u.physY-o,D=g*p+x*f,y=x*p-g*f;M+=y*y,D<m&&(m=D),D>R&&(R=D)}return{width:Math.sqrt(M/n.length)/s,length:(R-m)/s}}function K(n){let t=0,o=0;for(const s of n)t+=s.physX,o+=s.physY;return[t/n.length,o/n.length]}const Rn=1.5,Dn=3;function Sn(n,t,o){const s=[...n];if(n.length<2)return s;const d=t.filter(c=>c.length>0);for(;;){const[c,a]=K(s);let i=0,p=0,f=0;for(const l of s){const h=l.physX-c,S=l.physY-a;i+=h*h,p+=S*S,f+=h*S}const m=.5*Math.atan2(2*f,i-p),R=Math.cos(m),M=Math.sin(m),u=l=>(l.physX-c)*R+(l.physY-a)*M;let g=1/0,x=-1/0;for(const l of s){const h=u(l);h<g&&(g=h),h>x&&(x=h)}let D=-1,y=1/0;for(let l=0;l<d.length;l++){let h=1/0,S=-1/0,I=!1;for(const b of d[l]){if(Math.abs((b.physY-a)*R-(b.physX-c)*M)>Rn*o){I=!0;break}const N=u(b);N<h&&(h=N),N>S&&(S=N)}if(I)continue;const L=Math.max(h-x,g-S,0);L<=Dn*o&&L<y&&(D=l,y=L)}if(D<0)return s;s.push(...d[D]),d.splice(D,1)}}function Ln(n,t,o,s){const d=t.length,c=n.length,a=d>0?c/d:0,i=t.filter(e=>B(e,o,s)),p=n.filter(e=>B(e,o,s)),f=i.length>0?p.length/i.length:0,m=fn(n),R=e=>{let r=1/0,A=1/0,_=0,v=0;for(const E of e)_+=E.physX,v+=E.physY,(E.y<r||E.y===r&&E.x<A)&&(r=E.y,A=E.x);const un=Math.hypot(_/e.length-o.center.x,v/e.length-o.center.y);return[Math.round(un*1e6),r,A]},M=m.length>0?m.map(e=>({c:e,k:R(e)})).sort((e,r)=>r.c.length-e.c.length||e.k[0]-r.k[0]||e.k[1]-r.k[1]||e.k[2]-r.k[2]).map(({c:e})=>e):[n],u=M[0],g=M.slice(0,5).flat(),x=u.length,D=c>0?x/c:0,y=o.center.x,l=o.center.y,h=o.radius;let S=0,I=0,L=1/0,b=0;for(const e of u){S+=e.physX,I+=e.physY;const r=Math.sqrt((e.physX-y)**2+(e.physY-l)**2);r<L&&(L=r),r>b&&(b=r)}const N=S/u.length,U=I/u.length,V=Math.sqrt((N-y)**2+(U-l)**2)/h,j=L===1/0?0:L/h,J=Math.min(b/h,1),k=n.map(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h).sort((e,r)=>e-r),Q=k[Math.floor(k.length*.25)]??0,H=t.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h<.5).length,O=t.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h>=.5).length,Z=n.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h<.5).length,$=n.filter(e=>Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h>=.5).length,P=H>0?Z/H:0,w=O>0?$/O:0,nn=w>0?P/w:P>0?2:1,tn=g.reduce((e,r)=>e+r.physX,0)/g.length,en=g.reduce((e,r)=>e+r.physY,0)/g.length,on=mn(g,tn,en),sn=Mn(g,g.length),F=16,G=new Set;for(const e of p){const r=(Math.atan2(e.physY-l,e.physX-y)+2*Math.PI)%(2*Math.PI);G.add(Math.floor(r/(2*Math.PI)*F)%F)}const rn=p.length>0?G.size/F:0,T=Math.max(u[0]?.width??1,u[0]?.height??1),X=Sn(u,M.slice(1,12),T),{width:cn,length:an}=xn(X,...K(X),T);let Y=1/0,q=0;for(const e of X){const r=Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h;r<Y&&(Y=r),r>q&&(q=r)}const dn=Y===1/0?0:Y,ln=Math.min(q,1),C=5,W=new Array(C).fill(0),z=new Array(C).fill(0),hn=new Set(n);for(const e of t){const r=Math.min(C-1,Math.floor(Math.sqrt((e.physX-y)**2+(e.physY-l)**2)/h*C));W[r]++,hn.has(e)&&z[r]++}const gn=W.map((e,r)=>e>0?z[r]/e:0);return{globalRdd:a,edgeRdd:f,centroidDistNorm:V,minDistNorm:j,maxDistNorm:J,p25DistNorm:Q,eccentricity:on,linearScore:sn,salienceSize:x,salienceFraction:D,edgeAngularSpread:rn,innerOuterRatio:nn,lineWidth:cn,lineLength:an,lineSize:X.length,lineMinDistNorm:dn,lineMaxDistNorm:ln,radialFailRates:gn}}function bn(n,t,o){const s=Math.max(5,Math.round(o*.003)),d=n.salienceSize>=s;if(n.globalRdd<t.nearFullGlobalRdd&&n.p25DistNorm>=t.edgeLocalCentroidDist&&n.edgeAngularSpread>=t.edgeRingAngularSpread&&n.edgeRdd>=t.edgeLocalEdgeRdd)return{pattern:"edge-ring",confidence:n.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"};const[c,a,i,,p]=n.radialFailRates,f=Math.max(a,i);if(n.globalRdd<t.nearFullGlobalRdd&&f>=t.donutPeak&&f-c>=t.donutHole&&f-p>=t.donutRim)return{pattern:"donut",confidence:f-c>=2*t.donutHole?"high":"medium"};if(n.globalRdd<t.nearFullGlobalRdd&&n.lineSize>=s&&n.lineWidth<=t.scratchMaxLineWidth&&n.lineLength>=t.scratchMinLineLength&&n.lineLength>=t.scratchMinLineLengthRadius*Math.sqrt(o/Math.PI)&&n.lineMaxDistNorm>=t.scratchMinReach&&n.lineMinDistNorm<t.scratchMaxInnerDist)return{pattern:"scratch",confidence:n.lineWidth<=t.scratchMaxLineWidth/2?"high":"medium"};if(n.globalRdd<t.nearFullGlobalRdd&&n.salienceFraction<.1)return{pattern:"random",confidence:"low"};if(n.globalRdd>=t.nearFullGlobalRdd)return{pattern:"near-full",confidence:n.globalRdd>=.8?"high":"medium"};const m=d&&n.edgeRdd>=t.edgeLocalEdgeRdd&&n.maxDistNorm>=.7;return m&&n.p25DistNorm>=t.edgeLocalCentroidDist&&n.maxDistNorm-n.minDistNorm<=t.edgeRingRadialSpread?{pattern:"edge-ring",confidence:n.edgeRdd>=t.edgeRingEdgeRddHigh?"high":"medium"}:m&&n.p25DistNorm>=.55&&n.p25DistNorm<t.edgeLocalCentroidDist?{pattern:"edge-local",confidence:n.edgeRdd>=t.edgeRingEdgeRdd?"medium":"low"}:d&&n.centroidDistNorm<=t.centerCentroidDist&&n.edgeRdd<=t.centerEdgeRdd?{pattern:"center",confidence:n.centroidDistNorm<=t.centerCentroidDistHigh?"high":"medium"}:{pattern:"random",confidence:"low"}}export const PATTERN_LABELS={center:"Center cluster",donut:"Donut","edge-ring":"Edge-ring","edge-local":"Edge-local",scratch:"Scratch","near-full":"Near-full",random:"Random",none:"None"};export function patternFailVerdict(n,t){const o=n.hbin??n.sbin;return o===void 0?void 0:!t.has(o)}export function patternExplains(n,t,o,s){if(!{"edge-ring":["ring","edge-arc"],"edge-local":["edge-arc","sector","quadrant"],center:["ring","cluster"],donut:["ring"],scratch:["cluster","sector","quadrant"],"near-full":["ring"]}[n]?.includes(t))return!1;if(t!=="ring"||o.length===0)return!0;const c=o.includes(s),a=o.includes(1);return n==="edge-ring"||n==="edge-local"?c:n==="center"?a:n==="donut"?!c&&!a:!0}export function classifyPattern(n,t,o){const s=new Set(o.passBins),d=n.filter(c=>patternFailVerdict(c,s)===!0);return classifyFailingDies(d,n,t,o.ringCount)}export function classifyFailingDies(n,t,o,s){const d={...DEFAULT_PATTERN_THRESHOLDS},c=Math.max(d.minimumFailingDies,Math.round(t.length*.003));if(n.length<c)return null;const a=Ln(n,t,o,s),{pattern:i,confidence:p,note:f}=bn(a,d,t.length);return{pattern:i,confidence:p,features:a,...f?{note:f}:{}}}
|
|
@@ -139,6 +139,17 @@ export interface ResolvedPlot {
|
|
|
139
139
|
field: string;
|
|
140
140
|
count: number;
|
|
141
141
|
}>;
|
|
142
|
+
/**
|
|
143
|
+
* Values the value filter took out of the tests this plot reads: the limit set they were outside of, and how many
|
|
144
|
+
* dies lost a value per test. Absent when none did. These dies are in `omitted` too (they have no value).
|
|
145
|
+
*/
|
|
146
|
+
excluded?: {
|
|
147
|
+
limitSet: string;
|
|
148
|
+
fields: Array<{
|
|
149
|
+
field: string;
|
|
150
|
+
count: number;
|
|
151
|
+
}>;
|
|
152
|
+
};
|
|
142
153
|
}
|
|
143
154
|
/** The reader's name for a field, whether or not the population has it. */
|
|
144
155
|
export declare function fieldLabel(field: PlotField, testDefs?: readonly TestDef[]): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hasPosition as he}from"../core/dies.js";import{DIE_REGIONS as G,DIE_REGION_KEYS as Re}from"./dieRegions.js";import{testValue as Ge,testsPresent as be}from"../core/dieTable.js";import{compareNatural as Se,minOf as Le,maxOf as Te}from"../core/utils.js";import{isParametricTest as ne,getTestPassStatus as He}from"../renderer/buildWaferMap.js";import{facetValueOf as Ve,buildFacetTable as Xe,FACET_NONE_VALUE as Oe}from"./facets.js";import{yieldCounts as De}from"./yield.js";import{sameTestName as ze}from"./sweep.js";import{sameField as pe,plotIssue as qe,isField as ye}from"./plotSpec.js";function Ke(e){if(!e)return;const i={};for(const n of["limitLow","limitHigh","specLow","specHigh"])Number.isFinite(e[n])&&(i[n]=e[n]);return Object.keys(i).length?i:void 0}function Ze(e){let i=0;for(const l of e)i+=l.dies.length;const n=new Array(i),o=new Uint32Array(i);let s=0;return e.forEach((l,u)=>{for(const a of l.dies)n[s]=a,o[s++]=u}),{dies:n,item:o}}const J={wafer:"Wafer",x:"Die X",y:"Die Y",ring:G.ring.label,quadrant:G.quadrant.label,reticleCell:G.reticleCell.label,reticleShot:G.reticleShot.label,hbin:"Hard bin",sbin:"Soft bin",site:"Site",yield:"Yield",dieCount:"Dies",waferOrder:"Wafer order"};export function fieldLabel(e,i){if("test"in e){const n=i?.find(s=>s.testNumber===e.test),o=n?.name||e.name||`Test ${e.test}`;return n!==void 0&&!ne(n)?`${o} (pass/fail)`:o}return"builtin"in e?J[e.builtin]??String(e.builtin):ie(e.meta)}function ie(e){const i=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim();return i?i[0].toUpperCase()+i.slice(1):e}const Je=/^[+-]?(?:\d+\.?\d*|\.\d+)$/;function H(e,i){const{items:n,rows:o,ctx:s}=i,l=fieldLabel(e,s.testDefs),u={field:e,label:l},a=o.dies.length,$=n.length;if("test"in e){const c=s.testDefs?.find(h=>h.testNumber===e.test);if(c===void 0){if(i.present??=new Set(o.dies.length?be(o.dies,"values"):[]),!i.present.has(e.test))return{...u,level:"die",kind:"numeric",issue:`Needs test ${e.test}${e.name?` (${e.name})`:""}, which is not in these dies`}}else if(e.name&&c.name&&!ze(e.name,c.name))return{...u,level:"die",kind:"numeric",unit:c.unit,issue:`Test ${e.test} is "${e.name}" in this plot and "${c.name}" here`};if(c!==void 0&&!ne(c)){const h=o.dies.map(m=>{const t=He(m,e.test,c);return t===void 0?void 0:t?"Pass":"Fail"});return{...u,level:"die",kind:"categorical",cat:h}}const y=new Float64Array(a);for(let h=0;h<a;h++)y[h]=Ge(o.dies[h],e.test)??NaN;return{...u,level:"die",kind:"numeric",unit:c?.unit,num:y,limits:Ke(c)}}if("meta"in e){const c=n.map(m=>Ve(m.metadata,e.meta,s.curation));if(c.every(m=>m===void 0))return{...u,level:"wafer",kind:"categorical",cat:c,issue:`No wafer has a "${ie(e.meta)}" value`};const y=c.map(m=>m===void 0||!Je.test(m.trim())?NaN:Number(m)),h=c.every((m,t)=>m===void 0||Number.isFinite(y[t]));return{...u,level:"wafer",kind:h?"numeric":"categorical",cat:c,num:h?Float64Array.from(y):void 0}}switch(e.builtin){case"wafer":return{...u,level:"wafer",kind:"categorical",cat:n.map(c=>c.label)};case"waferOrder":return{...u,level:"wafer",kind:"numeric",num:Float64Array.from(n,(c,y)=>y+1)};case"dieCount":return{...u,level:"wafer",kind:"numeric",num:Float64Array.from(n,c=>c.dies.length)};case"yield":{const c=new Float64Array($),y=new Float64Array($);return n.forEach((h,m)=>{const{pass:t,total:b}=De(h.dies,h.passBins);c[m]=b>0?t/b*100:NaN,y[m]=b}),{...u,level:"wafer",kind:"numeric",unit:"%",num:c,weights:y}}case"x":case"y":{const c=new Float64Array(a);for(let y=0;y<a;y++){const h=o.dies[y];c[y]=he(h)?e.builtin==="x"?h.x:h.y:NaN}return{...u,level:"die",kind:"numeric",num:c}}case"hbin":case"sbin":{const c=o.dies.map(y=>{const h=e.builtin==="hbin"?y.hbin:y.sbin;return h===void 0?void 0:`Bin ${h}`});return{...u,level:"die",kind:"categorical",cat:c}}case"site":return{...u,level:"die",kind:"categorical",cat:o.dies.map(c=>c.siteNum===void 0?void 0:`Site ${c.siteNum}`)};case"ring":case"quadrant":case"reticleCell":case"reticleShot":{const c=G[e.builtin],y=o.dies.map((h,m)=>{const t=n[o.item[m]];return c.valueOf(h,{wafer:t.wafer,ringCount:t.ringCount})});return{...u,level:"die",kind:"categorical",cat:y}}default:return{...u,level:"die",kind:"categorical",issue:"Needs a newer version of this tool"}}}function Qe(e,i){const n=e.rows.dies.length,o=new Float64Array(n),s=new Float64Array(n);for(let l=0;l<n;l++){const u=e.items[e.rows.item[l]],{pass:a,total:$}=De([e.rows.dies[l]],u.passBins);o[l]=$>0?a*100:NaN,s[l]=$}return{...i,level:"die",num:o,weights:s,perDie:!0}}export function combine(e,i){const n=e.filter(Number.isFinite);if(i==="count")return n.length;if(n.length===0)return NaN;switch(i){case"sum":return n.reduce((o,s)=>o+s,0);case"min":return Le(n);case"max":return Te(n);case"median":{const o=[...n].sort((l,u)=>l-u),s=o.length>>1;return o.length%2?o[s]:(o[s-1]+o[s])/2}default:return n.reduce((o,s)=>o+s,0)/n.length}}const re={mean:"Mean",median:"Median",min:"Min",max:"Max",sum:"Sum",count:"Count",yield:"Pooled yield"};function W(e,i,n,o,s,l){const u=o.axes?.[e]??{};let a=u.scale??"linear";if(a==="log"){for(const $ of s)if(Number.isFinite($)&&$<=0){a="linear",l.push(`The ${e.toUpperCase()} axis stays linear: a log axis needs every value above zero`);break}}return{label:u.label??i,unit:n,scale:a,min:u.min,max:u.max,reverse:u.reverse}}function et(e,i){const{chart:n}=e,o=e.fields??{},s=o.x?fieldLabel(o.x,i.testDefs):n==="box"||n==="bar"?"Wafer":void 0,l=o.y?fieldLabel(o.y,i.testDefs):void 0;switch(n){case"scatter":return s&&l?`${l} vs ${s}`:"Scatter";case"histogram":return l??(o.x?fieldLabel(o.x,i.testDefs):void 0)??"Histogram";case"line":return s&&l?`${l} over ${s}`:"Line";case"box":return l&&s?`${l} by ${s}`:"Box";case"bar":return s?l?`${l} by ${s}`:`Dies by ${s}`:"Bar";default:return""}}function Ee(e,i,n,o={}){return{spec:e,issues:n,notes:[],level:"die",autoTitle:et(e,o),groups:[""],population:{wafers:i.length,dies:i.reduce((s,l)=>s+l.dies.length,0)},plotted:0,omitted:[]}}export function combinationIssue(e,i,n={}){const o=[i.x,n.continuousColor?void 0:i.color].filter($=>!!$&&$.level==="die"),s=!!i.y&&i.y.yield&&i.y.level==="wafer",l=(e==="bar"||e==="line")&&(n.aggregate===void 0||n.aggregate==="yield"||n.aggregate==="mean");if(s&&o.length&&!l)return{long:`${i.y.label} is one figure per wafer, and ${o[0].label} belongs to dies, so a ${e} of it cannot be split by ${o[0].label}. A bar chart of yield can (pooled yield per ${o[0].label.toLowerCase()}), or plot a measured value instead`,short:`${i.y.label} is per wafer: use a bar or line chart`};const u=[i.x,i.y].filter($=>!!$);let a=n.level??(u.some($=>$.level==="die")?"die":"wafer");if(e==="bar"&&!i.y&&o.length&&(a="die"),i.color?.level==="die"&&a==="wafer"&&!n.continuousColor&&!(s&&(e==="bar"||e==="line")))return{long:`${i.color.label} is per die, so it cannot colour a plot with one mark per wafer. Plot a measured value (one mark per die), or make a bar chart of yield, which can be split by ${i.color.label.toLowerCase()}`,short:`${i.color.label} is per die: this plot has one mark per wafer`}}export function resolvePlot(e,i,n={}){const o=qe(e);if(o)return Ee(e,i,[o],n);const s=(...r)=>Ee(e,i,r,n);if(e.chart==="sweep")return s("A sweep is drawn by the sweep panel");const l=Ze(i),u={items:i,rows:l,ctx:n},a=e.chart,$=e.fields??{},c=$.x??(a==="box"||a==="bar"?{builtin:"wafer"}:void 0),y=$.y,h=a==="histogram"?y??c:y;if(a==="scatter"||a==="line"){if(!c)return s("Choose a field for X");if(!y)return s("Choose a field for Y")}if(a==="box"&&!y)return s("Choose a field for Y");if(a==="histogram"&&!h)return s("Choose a field to count");const m=a==="histogram"?void 0:c?H(c,u):void 0;let t=h?H(h,u):void 0;const b=a==="scatter"||a==="line"?[["X",m],["Y",t]]:a==="histogram"?[["to count",t]]:a==="box"||a==="bar"?[["Y",t]]:[];for(const[r,f]of b)if(f&&!f.issue&&f.kind==="categorical"&&!f.num)return s(`${f.label} is a category, not a number, so it cannot be ${r==="to count"?"the field a histogram counts":`the ${r} of a ${a}`}. Use it as the X of a bar or box chart (one bar per ${f.label.toLowerCase()}), or as the colour`);const S=$.color;let w,xe=!1,oe;S===void 0||"follow"in S?n.groupBy?oe=n.groupBy:i.length>1&&(xe=!0):"none"in S||(w=H(S,u)),oe&&(w=H({meta:oe},u)),xe&&(w=H({builtin:"wafer"},u)),w?.issue&&(S===void 0||"follow"in S)&&(w=void 0);const se=[m?.issue,t?.issue,w?.issue].filter(r=>!!r),Q=!!w&&w.kind==="numeric"&&!("meta"in w.field);if(Q&&a!=="scatter"&&se.push(`${w.label} is continuous, so it can colour a scatter but not a ${a}: colour by a category such as wafer, split or bin`),se.length)return s(...se);const Be=[m,t].filter(r=>!!r);let F=e.level??(Be.some(r=>r.level==="die")?"die":"wafer");const ae=[m,Q?void 0:w].filter(r=>!!r&&r.level==="die"),le=r=>r&&{label:r.label,level:r.level,kind:r.kind,yield:!!r.weights},ve=combinationIssue(a,{x:le(m),y:le(t),color:le(w)},{aggregate:e.aggregate,level:e.level,continuousColor:Q});if(ve)return s(ve.long);a==="bar"&&!t&&ae.length&&(F="die"),t&&t.level==="wafer"&&t.weights&&ae.length&&(t=Qe(u,t),F="die"),F==="die"&&t?.weights&&!t.perDie&&!ae.length&&(F="wafer");const T=F==="die"?l.dies.length:i.length,ee=r=>F==="die"?l.item[r]:r,ue=r=>({item:ee(r),die:F==="die"?l.dies[r]:void 0}),Ne=e.aggregate&&e.aggregate!=="yield"?e.aggregate:"mean",D=r=>{if(!r.num)throw new Error("numeric field expected");if(r.level===F)return r.num;if(r.level==="wafer"){const g=new Float64Array(T);for(let d=0;d<T;d++)g[d]=r.num[ee(d)];return g}const f=i.map(()=>[]);for(let g=0;g<r.num.length;g++)f[l.item[g]].push(r.num[g]);return Float64Array.from(f,g=>combine(g,Ne))},Ce=r=>{if(!r.cat)throw new Error("category field expected");if(r.level===F)return r.cat;if(r.level==="wafer")return Array.from({length:T},(f,g)=>r.cat[ee(g)]);throw new Error("a per-die category cannot be used at wafer level")},Ue=r=>r.weights&&r.level===F?r.weights:void 0;let ce=[""],E=new Int32Array(T),V,I;if(w&&Q)V=w.label,I=D(w);else if(w){V=w.label;const r=Ce(w),f=new Map,g=[];for(let x=0;x<T;x++){const v=r[x]??Oe;f.has(v)||(f.set(v,0),g.push(v))}const k="builtin"in w.field&&w.field.builtin==="wafer"?g:w.num&&"meta"in w.field?[...g].sort((x,v)=>(Number(x)||0)-(Number(v)||0)):[...g].sort(Se);k.forEach((x,v)=>f.set(x,v)),ce=k;for(let x=0;x<T;x++)E[x]=f.get(r[x]??Oe)}const fe=new Map,M=r=>fe.set(r,(fe.get(r)??0)+1),_=[],Pe=F==="die"?"dies":"wafers";let X,O,B,Y,Ae,z=0;const U=ce.length,te=r=>r.level==="die"&&F==="wafer"?`${re[Ne].toLowerCase()} of ${r.label} per wafer`:void 0;if(a==="scatter"){const r=D(m),f=D(t),g=[];for(let d=0;d<T;d++){if(!Number.isFinite(r[d])){M(m.label);continue}if(!Number.isFinite(f[d])){M(t.label);continue}if(I&&!Number.isFinite(I[d])){M(w.label);continue}g.push({x:r[d],y:f[d],group:E[d],item:ee(d),die:F==="die"?l.dies[d]:void 0,...I?{value:I[d]}:{}})}if(z=g.length,I&&g.length){const d=g.map(k=>k.value);Ae={label:w.label,unit:w.unit,lo:Le(d),hi:Te(d)}}X={type:"scatter",points:g},O=W("x",m.label,m.unit,e,g.map(d=>d.x),_),B=W("y",t.label,t.unit,e,g.map(d=>d.y),_),Y=[te(m),te(t)].filter(Boolean).join("; ")||void 0}else if(a==="histogram"){const r=D(t),f=Array.from({length:U},()=>[]),g=Array.from({length:U},()=>[]);for(let d=0;d<T;d++){if(!Number.isFinite(r[d])){M(t.label);continue}f[E[d]].push(r[d]),g[E[d]].push(d),z++}X={type:"histogram",values:f,units:g,unit:ue},O=W("x",t.label,t.unit,e,f.flat(),_),B={label:"Count",scale:"linear",...e.axes?.y?.label?{label:e.axes.y.label}:{}},Y=te(t)}else if(a==="line"){const r=D(m),f=D(t),g=new Set,d=new Map,k=new Map;for(let N=0;N<T;N++){if(!Number.isFinite(r[N])){M(m.label);continue}if(!Number.isFinite(f[N])){M(t.label);continue}g.add(r[N]);const A=`${E[N]}|${r[N]}`;(d.get(A)??d.set(A,[]).get(A)).push(f[N]),z++,(k.get(A)??k.set(A,[]).get(A)).push(N)}const x=[...g].sort((N,A)=>N-A),v=e.aggregate??"mean",j=Array.from({length:U},(N,A)=>x.map(P=>{const K=d.get(`${A}|${P}`);return K?combine(K,v==="yield"?"mean":v):NaN})),L=Array.from({length:U},(N,A)=>x.map(P=>d.get(`${A}|${P}`)?.length??0)),R=Array.from({length:U},(N,A)=>x.map(P=>k.get(`${A}|${P}`)??[]));X={type:"line",xs:x,values:j,counts:L,cellUnits:R,unit:ue},O=W("x",m.label,m.unit,e,x,_);const q=v==="yield"?"mean":v;B=W("y",t.perDie?t.label:`${re[q]} ${t.label}`,t.unit,e,j.flat(),_),Y=t.perDie?`passing dies over judged dies, per ${m.label.toLowerCase()}`:`${re[q].toLowerCase()} of ${t.label} per ${m.label}`}else{const r=m,f="builtin"in r.field&&(r.field.builtin==="x"||r.field.builtin==="y");if(r.kind==="numeric"&&r.level==="die"&&!f)return s(`${r.label} is continuous, so a ${a} cannot have one ${a==="bar"?"bar":"box"} per value; use a scatter or line, or choose a categorical X such as wafer, ring or bin`);const g=r.cat?Ce(r):Array.from(D(r),p=>Number.isFinite(p)?String(p):void 0),d=new Map,k=[];for(let p=0;p<T;p++){const C=g[p];C!==void 0&&!d.has(C)&&(d.set(C,0),k.push(C))}const x="builtin"in r.field&&r.field.builtin==="wafer",v=x?k:r.kind==="numeric"?[...k].sort((p,C)=>Number(p)-Number(C)):[...k].sort(Se);v.forEach((p,C)=>d.set(p,C));const j=a==="bar"&&!t,L=e.aggregate??(j?"count":t?.weights?"yield":"mean");if(L==="yield"&&!t?.weights)return s("Pooled yield needs Yield as the Y field");if(a==="box"&&L==="count")return s("A box plot needs a measured field for Y");const R=t?D(t):void 0,q=t?Ue(t):void 0,N=Array.from({length:U},()=>v.map(()=>[])),A=Array.from({length:U},()=>v.map(()=>[])),P=Array.from({length:U},()=>v.map(()=>[]));for(let p=0;p<T;p++){const C=g[p]===void 0?void 0:d.get(g[p]);if(C===void 0){M(r.label);continue}if(R&&!Number.isFinite(R[p])){M(t.label);continue}N[E[p]][C].push(R?R[p]:1),A[E[p]][C].push(p),q&&P[E[p]][C].push(q[p]),z++}const K=N.map((p,C)=>p.map((Z,Ye)=>{if(Z.length===0)return NaN;if(L==="yield"){const Fe=P[C][Ye],ke=Fe.reduce((me,ge)=>me+ge,0);return ke>0?Z.reduce((me,ge,je)=>me+ge*Fe[je],0)/ke:NaN}return combine(Z,L)})),Ie=x?v.map(p=>g.findIndex((C,Z)=>C===p&&Z>=0)):void 0;if(X={type:a==="box"?"box":"bar",categories:v,cells:N,cellUnits:A,unit:ue,values:K,categoryItems:Ie?.map(p=>F==="die"?l.item[p]:p)},O={label:e.axes?.x?.label??r.label,scale:"linear"},a==="bar"){const p=L==="count"?"Count":re[L],C=j?`Count of ${Pe}`:L==="yield"?"Pooled yield":`${p} ${t.label}`;B=W("y",C,L==="yield"?"%":L==="count"?void 0:t?.unit,e,K.flat(),_),Y=j?void 0:L==="yield"?`passing dies over judged dies, pooled per ${r.label.toLowerCase()}`:`${p.toLowerCase()} of ${t.label}${t.level==="die"&&F==="wafer"?" per wafer":""} per ${r.label.toLowerCase()}`}else B=W("y",t.label,t.unit,e,N.flat(2),_),Y=te(t)}const de=(r,f)=>r&&!r.perDie&&(f===void 0||f==="mean"||f==="median"||f==="min"||f==="max")?r.limits:void 0,We=e.aggregate??"mean";return O&&(a==="scatter"||a==="line")&&(O.limits=de(m)),B&&a!=="histogram"&&(B.limits=de(t,a==="scatter"||a==="box"?void 0:We)),a==="histogram"&&O&&(O.limits=de(t)),{spec:e,issues:[],notes:_,marks:X,level:F,autoTitle:(()=>{const r=m?.label,f=t?.label,g=a==="scatter"?`${f} vs ${r}`:a==="histogram"?`${f}`:a==="line"?`${f} over ${r}`:a==="box"?`${f} by ${r}`:f?`${f} by ${r}`:`Dies by ${r}`;return V&&w&&!pe(w.field,c)?`${g} \xB7 by ${V}`:g})(),x:O,y:B,groups:ce,colorScale:Ae,colorLabel:V,aggregation:Y,population:{wafers:i.length,dies:l.dies.length},plotted:z,omitted:[...fe].map(([r,f])=>({field:r,count:f}))}}export function plotTitle(e){return e.spec.title?.trim()?e.spec.title:e.autoTitle}export function plotFootnote(e){const{wafers:i,dies:n}=e.population,o=[`${i.toLocaleString("en-GB")} wafer${i===1?"":"s"} \xB7 ${n.toLocaleString("en-GB")} dies`];e.aggregation&&o.push(e.aggregation);for(const s of e.omitted)o.push(`${s.count.toLocaleString("en-GB")} ${e.level==="die"?"dies":"wafers"} without ${s.field} not plotted`);return o.join(" \xB7 ")}export function fieldKey(e){return"test"in e?`test:${e.test}`:"builtin"in e?`builtin:${e.builtin}`:`meta:${e.meta}`}export function fieldCatalogue(e,i={}){const n=[],o=e.flatMap(t=>t.dies),s=new Set(o.length?be(o,"values"):[]),l=i.testDefs??[],u=new Map;for(const t of l)t.testType!=="F"&&(s.has(t.testNumber)||!o.length)&&u.set(t.testNumber,t.name);for(const t of s)!u.has(t)&&!l.some(b=>b.testNumber===t&&b.testType==="F")&&u.set(t,void 0);for(const[t,b]of[...u].sort((S,w)=>S[0]-w[0]))n.push({field:{test:t,...b?{name:b}:{}},label:b?`${b} \xB7 ${t}`:`Test ${t}`,name:b||`Test ${t}`,group:"Tests",kind:"numeric",level:"die",categorical:!1});const a=new Set(o.length?be(o,"all"):[]);for(const t of l){if(ne(t)||!(a.has(t.testNumber)||!o.length))continue;const b=t.name||`Test ${t.testNumber}`;n.push({field:{test:t.testNumber,...t.name?{name:t.name}:{}},label:`${b} \xB7 ${t.testNumber} (pass/fail)`,name:b,group:"Verdicts",kind:"categorical",level:"die",categorical:!0})}const $=t=>o.some(t),c=(t,b,S)=>n.push({field:{builtin:t},label:J[t],name:J[t],group:"Die",kind:b,level:"die",categorical:S});$(t=>he(t))&&(c("x","numeric",!1),c("y","numeric",!1));const y=$(t=>he(t));for(const t of Re)e.some(b=>G[t].available({wafer:b.wafer,ringCount:b.ringCount},y))&&c(t,"categorical",!0);$(t=>t.hbin!==void 0)&&c("hbin","categorical",!0),$(t=>t.sbin!==void 0)&&c("sbin","categorical",!0),$(t=>t.siteNum!==void 0)&&c("site","categorical",!0);const h=(t,b,S)=>n.push({field:{builtin:t},label:J[t],name:J[t],group:"Wafer",kind:b,level:"wafer",categorical:S});h("wafer","categorical",!0),e.length>1&&h("waferOrder","numeric",!1),h("yield","numeric",!1),h("dieCount","numeric",!1);const m={items:e,rows:{dies:[],item:new Uint32Array(0)},ctx:i};for(const t of Xe(e.map(b=>({metadata:b.metadata,dieCount:b.dies.length})),{facetableOnly:!0,curation:i.curation})){if(t.values.length===0)continue;const b=H({meta:t.key},m);n.push({field:{meta:t.key},label:t.label||ie(t.key),name:t.label||ie(t.key),group:"Wafer",kind:b.kind,level:"wafer",categorical:!0,distinct:t.values.length})}return n}export function fieldsForRole(e,i,n){const o=n==="y"||n==="x"&&(i==="scatter"||i==="line"||i==="histogram");return n==="color"?e.filter(s=>s.categorical||i==="scatter"&&s.kind==="numeric"):o?e.filter(s=>s.kind==="numeric"):e.filter(s=>s.categorical)}export function defaultPlot(e,i){const n=e.filter(o=>o.group==="Tests");return n.length>=2?{id:i,chart:"scatter",fields:{x:n[0].field,y:n[1].field}}:n.length===1?{id:i,chart:"histogram",fields:{y:n[0].field}}:{id:i,chart:"scatter",fields:{x:{builtin:"waferOrder"},y:{builtin:"yield"}}}}const we=new Set(["wafer","dies","die x","die y","wafer order"]),tt=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$e=(e,i)=>i.length>=3&&new RegExp(`(^|[^A-Za-z0-9_])${tt(i)}($|[^A-Za-z0-9_])`,"i").test(e);export function titleDrift(e,i){const n=e.title?.trim(),o={names:[],omits:[]};if(!n)return o;const s=e.fields?.color,l=[e.fields?.x,e.fields?.y,s].filter(t=>ye(t)),u=t=>l.some(b=>pe(b,t)),a=i.filter(t=>!we.has(t.name.toLowerCase())&&!("meta"in t.field)&&!u(t.field)&&$e(n,t.name)).map(t=>t.name),$=[e.fields?.x,e.fields?.y].filter(t=>ye(t)),c=t=>i.find(b=>pe(b.field,t))?.name??fieldLabel(t),y=$.filter(t=>!we.has(c(t).toLowerCase())&&$e(n,c(t))),h=$.filter(t=>!we.has(c(t).toLowerCase())&&!$e(n,c(t))),m=y.length>0||a.length>0?h.map(c):[];return{names:a,omits:m}}const Me=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;export function describeTitleDrift(e){const i=[];return e.names.length&&i.push(`The title names ${Me(e.names)}, which this plot does not show.`),e.omits.length&&i.push(`It does not name ${Me(e.omits)}, which this plot shows.`),i.length?i.join(" "):null}export function examplePlots(e,i,n){const o=e.filter(u=>u.group==="Tests").map(u=>u.field),s=[],l=i>1;if(o.length>=2&&s.push({id:n(),chart:"scatter",fields:{x:o[0],y:o[1]}}),o.length>=1&&s.push({id:n(),chart:"histogram",fields:{y:o[0],color:{none:!0}}}),o.length>=1&&l&&s.push({id:n(),chart:"box",fields:{x:{builtin:"wafer"},y:o[0],color:{none:!0}}}),l){const u=e.find(a=>"meta"in a.field&&a.distinct!==void 0&&a.distinct>=2&&a.distinct<=Math.max(2,Math.floor(i/2)));s.push({id:n(),chart:"bar",fields:{x:u?u.field:{builtin:"wafer"},y:{builtin:"yield"},color:{none:!0}}})}return o.length>=1&&l&&s.push({id:n(),chart:"line",fields:{x:{builtin:"waferOrder"},y:o[0],color:{none:!0}},aggregate:"mean"}),o.length>=2&&s.push({..._e(o.flatMap(u=>"test"in u?[u]:[]),n()),title:"Example sweep"}),s}export function plotTestNumber(e){const{x:i,y:n,color:o}=e.fields??{},s=e.chart==="scatter"?[i,n,o]:e.chart==="histogram"?[n,i]:[n];for(const l of s)if(ye(l)&&"test"in l)return l.test}export function defaultSweep(e,i){return _e(e.filter(ne).map(n=>({test:n.testNumber,name:n.name})),i)}function _e(e,i){const n=[...e].sort((s,l)=>s.test-l.test).slice(0,5),o=Object.fromEntries(n.flatMap(s=>s.name?[[String(s.test),s.name]]:[]));return{id:i,chart:"sweep",sweep:{series:[{label:"Series 1",tests:n.map(s=>s.test),...Object.keys(o).length?{testNames:o}:{}}]}}}
|
|
1
|
+
import{hasPosition as be}from"../core/dies.js";import{DIE_REGIONS as G,DIE_REGION_KEYS as He}from"./dieRegions.js";import{excludedBy as Xe,excludedValue as ze,testValue as qe,testsPresent as pe}from"../core/dieTable.js";import{limitSetName as Ke}from"../renderer/valueFilter.js";import{compareNatural as Te,minOf as Ee,maxOf as Oe}from"../core/utils.js";import{isParametricTest as ne,getTestPassStatus as Ze}from"../renderer/buildWaferMap.js";import{facetValueOf as Je,buildFacetTable as Qe,FACET_NONE_VALUE as De}from"./facets.js";import{yieldCounts as Me}from"./yield.js";import{sameTestName as et}from"./sweep.js";import{sameField as ye,plotIssue as tt,isField as we}from"./plotSpec.js";import{fmtExact as nt}from"../renderer/fmt.js";function it(e){if(!e)return;const r={};for(const i of["limitLow","limitHigh","specLow","specHigh"])Number.isFinite(e[i])&&(r[i]=e[i]);return Object.keys(r).length?r:void 0}function rt(e){let r=0;for(const a of e)r+=a.dies.length;const i=new Array(r),o=new Uint32Array(r);let s=0;return e.forEach((a,u)=>{for(const l of a.dies)i[s]=l,o[s++]=u}),{dies:i,item:o}}const J={wafer:"Wafer",x:"Die X",y:"Die Y",ring:G.ring.label,quadrant:G.quadrant.label,reticleCell:G.reticleCell.label,reticleShot:G.reticleShot.label,hbin:"Hard bin",sbin:"Soft bin",site:"Site",yield:"Yield",dieCount:"Dies",waferOrder:"Wafer order"};export function fieldLabel(e,r){if("test"in e){const i=r?.find(s=>s.testNumber===e.test),o=i?.name||e.name||`Test ${e.test}`;return i!==void 0&&!ne(i)?`${o} (pass/fail)`:o}return"builtin"in e?J[e.builtin]??String(e.builtin):ie(e.meta)}function ie(e){const r=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim();return r?r[0].toUpperCase()+r.slice(1):e}const ot=/^[+-]?(?:\d+\.?\d*|\.\d+)$/;function V(e,r){const{items:i,rows:o,ctx:s}=r,a=fieldLabel(e,s.testDefs),u={field:e,label:a},l=o.dies.length,$=i.length;if("test"in e){const c=s.testDefs?.find(h=>h.testNumber===e.test);if(c===void 0){if(r.present??=new Set(o.dies.length?pe(o.dies,"values"):[]),!r.present.has(e.test))return{...u,level:"die",kind:"numeric",issue:`Needs test ${e.test}${e.name?` (${e.name})`:""}, which is not in these dies`}}else if(e.name&&c.name&&!et(e.name,c.name))return{...u,level:"die",kind:"numeric",unit:c.unit,issue:`Test ${e.test} is "${e.name}" in this plot and "${c.name}" here`};if(c!==void 0&&!ne(c)){const h=o.dies.map(g=>{const t=Ze(g,e.test,c);return t===void 0?void 0:t?"Pass":"Fail"});return{...u,level:"die",kind:"categorical",cat:h}}const w=new Float64Array(l);for(let h=0;h<l;h++)w[h]=qe(o.dies[h],e.test)??NaN;return{...u,level:"die",kind:"numeric",unit:c?.unit,num:w,limits:it(c)}}if("meta"in e){const c=i.map(g=>Je(g.metadata,e.meta,s.curation));if(c.every(g=>g===void 0))return{...u,level:"wafer",kind:"categorical",cat:c,issue:`No wafer has a "${ie(e.meta)}" value`};const w=c.map(g=>g===void 0||!ot.test(g.trim())?NaN:Number(g)),h=c.every((g,t)=>g===void 0||Number.isFinite(w[t]));return{...u,level:"wafer",kind:h?"numeric":"categorical",cat:c,num:h?Float64Array.from(w):void 0}}switch(e.builtin){case"wafer":return{...u,level:"wafer",kind:"categorical",cat:i.map(c=>c.label)};case"waferOrder":return{...u,level:"wafer",kind:"numeric",num:Float64Array.from(i,(c,w)=>w+1)};case"dieCount":return{...u,level:"wafer",kind:"numeric",num:Float64Array.from(i,c=>c.dies.length)};case"yield":{const c=new Float64Array($),w=new Float64Array($);return i.forEach((h,g)=>{const{pass:t,total:b}=Me(h.dies,h.passBins);c[g]=b>0?t/b*100:NaN,w[g]=b}),{...u,level:"wafer",kind:"numeric",unit:"%",num:c,weights:w}}case"x":case"y":{const c=new Float64Array(l);for(let w=0;w<l;w++){const h=o.dies[w];c[w]=be(h)?e.builtin==="x"?h.x:h.y:NaN}return{...u,level:"die",kind:"numeric",num:c}}case"hbin":case"sbin":{const c=o.dies.map(w=>{const h=e.builtin==="hbin"?w.hbin:w.sbin;return h===void 0?void 0:`Bin ${h}`});return{...u,level:"die",kind:"categorical",cat:c}}case"site":return{...u,level:"die",kind:"categorical",cat:o.dies.map(c=>c.siteNum===void 0?void 0:`Site ${c.siteNum}`)};case"ring":case"quadrant":case"reticleCell":case"reticleShot":{const c=G[e.builtin],w=o.dies.map((h,g)=>{const t=i[o.item[g]];return c.valueOf(h,{wafer:t.wafer,ringCount:t.ringCount})});return{...u,level:"die",kind:"categorical",cat:w}}default:return{...u,level:"die",kind:"categorical",issue:"Needs a newer version of this tool"}}}function st(e,r){const i=e.rows.dies.length,o=new Float64Array(i),s=new Float64Array(i);for(let a=0;a<i;a++){const u=e.items[e.rows.item[a]],{pass:l,total:$}=Me([e.rows.dies[a]],u.passBins);o[a]=$>0?l*100:NaN,s[a]=$}return{...r,level:"die",num:o,weights:s,perDie:!0}}export function combine(e,r){const i=e.filter(Number.isFinite);if(r==="count")return i.length;if(i.length===0)return NaN;switch(r){case"sum":return i.reduce((o,s)=>o+s,0);case"min":return Ee(i);case"max":return Oe(i);case"median":{const o=[...i].sort((a,u)=>a-u),s=o.length>>1;return o.length%2?o[s]:(o[s-1]+o[s])/2}default:return i.reduce((o,s)=>o+s,0)/i.length}}const re={mean:"Mean",median:"Median",min:"Min",max:"Max",sum:"Sum",count:"Count",yield:"Pooled yield"};function W(e,r,i,o,s,a){const u=o.axes?.[e]??{};let l=u.scale??"linear";if(l==="log"){for(const $ of s)if(Number.isFinite($)&&$<=0){l="linear",a.push(`The ${e.toUpperCase()} axis stays linear: a log axis needs every value above zero`);break}}return{label:u.label??r,unit:i,scale:l,min:u.min,max:u.max,reverse:u.reverse}}function lt(e,r){const{chart:i}=e,o=e.fields??{},s=o.x?fieldLabel(o.x,r.testDefs):i==="box"||i==="bar"?"Wafer":void 0,a=o.y?fieldLabel(o.y,r.testDefs):void 0;switch(i){case"scatter":return s&&a?`${a} vs ${s}`:"Scatter";case"histogram":return a??(o.x?fieldLabel(o.x,r.testDefs):void 0)??"Histogram";case"line":return s&&a?`${a} over ${s}`:"Line";case"box":return a&&s?`${a} by ${s}`:"Box";case"bar":return s?a?`${a} by ${s}`:`Dies by ${s}`:"Bar";default:return""}}function Be(e,r,i,o={}){return{spec:e,issues:i,notes:[],level:"die",autoTitle:lt(e,o),groups:[""],population:{wafers:r.length,dies:r.reduce((s,a)=>s+a.dies.length,0)},plotted:0,omitted:[]}}export function combinationIssue(e,r,i={}){const o=[r.x,i.continuousColor?void 0:r.color].filter($=>!!$&&$.level==="die"),s=!!r.y&&r.y.yield&&r.y.level==="wafer",a=(e==="bar"||e==="line")&&(i.aggregate===void 0||i.aggregate==="yield"||i.aggregate==="mean");if(s&&o.length&&!a)return{long:`${r.y.label} is one figure per wafer, and ${o[0].label} belongs to dies, so a ${e} of it cannot be split by ${o[0].label}. A bar chart of yield can (pooled yield per ${o[0].label.toLowerCase()}), or plot a measured value instead`,short:`${r.y.label} is per wafer: use a bar or line chart`};const u=[r.x,r.y].filter($=>!!$);let l=i.level??(u.some($=>$.level==="die")?"die":"wafer");if(e==="bar"&&!r.y&&o.length&&(l="die"),r.color?.level==="die"&&l==="wafer"&&!i.continuousColor&&!(s&&(e==="bar"||e==="line")))return{long:`${r.color.label} is per die, so it cannot colour a plot with one mark per wafer. Plot a measured value (one mark per die), or make a bar chart of yield, which can be split by ${r.color.label.toLowerCase()}`,short:`${r.color.label} is per die: this plot has one mark per wafer`}}export function resolvePlot(e,r,i={}){const o=tt(e);if(o)return Be(e,r,[o],i);const s=(...n)=>Be(e,r,n,i);if(e.chart==="sweep")return s("A sweep is drawn by the sweep panel");const a=rt(r),u={items:r,rows:a,ctx:i},l=e.chart,$=e.fields??{},c=$.x??(l==="box"||l==="bar"?{builtin:"wafer"}:void 0),w=$.y,h=l==="histogram"?w??c:w;if(l==="scatter"||l==="line"){if(!c)return s("Choose a field for X");if(!w)return s("Choose a field for Y")}if(l==="box"&&!w)return s("Choose a field for Y");if(l==="histogram"&&!h)return s("Choose a field to count");const g=l==="histogram"?void 0:c?V(c,u):void 0;let t=h?V(h,u):void 0;const b=l==="scatter"||l==="line"?[["X",g],["Y",t]]:l==="histogram"?[["to count",t]]:l==="box"||l==="bar"?[["Y",t]]:[];for(const[n,d]of b)if(d&&!d.issue&&d.kind==="categorical"&&!d.num)return s(`${d.label} is a category, not a number, so it cannot be ${n==="to count"?"the field a histogram counts":`the ${n} of a ${l}`}. Use it as the X of a bar or box chart (one bar per ${d.label.toLowerCase()}), or as the colour`);const k=$.color;let y,ve=!1,oe;k===void 0||"follow"in k?i.groupBy?oe=i.groupBy:r.length>1&&(ve=!0):"none"in k||(y=V(k,u)),oe&&(y=V({meta:oe},u)),ve&&(y=V({builtin:"wafer"},u)),y?.issue&&(k===void 0||"follow"in k)&&(y=void 0);const se=[g?.issue,t?.issue,y?.issue].filter(n=>!!n),Q=!!y&&y.kind==="numeric"&&!("meta"in y.field);if(Q&&l!=="scatter"&&se.push(`${y.label} is continuous, so it can colour a scatter but not a ${l}: colour by a category such as wafer, split or bin`),se.length)return s(...se);const Pe=[g,t].filter(n=>!!n);let F=e.level??(Pe.some(n=>n.level==="die")?"die":"wafer");const le=[g,Q?void 0:y].filter(n=>!!n&&n.level==="die"),ae=n=>n&&{label:n.label,level:n.level,kind:n.kind,yield:!!n.weights},Ne=combinationIssue(l,{x:ae(g),y:ae(t),color:ae(y)},{aggregate:e.aggregate,level:e.level,continuousColor:Q});if(Ne)return s(Ne.long);l==="bar"&&!t&&le.length&&(F="die"),t&&t.level==="wafer"&&t.weights&&le.length&&(t=st(u,t),F="die"),F==="die"&&t?.weights&&!t.perDie&&!le.length&&(F="wafer");const T=F==="die"?a.dies.length:r.length,ee=n=>F==="die"?a.item[n]:n,ue=n=>({item:ee(n),die:F==="die"?a.dies[n]:void 0}),Ce=e.aggregate&&e.aggregate!=="yield"?e.aggregate:"mean",O=n=>{if(!n.num)throw new Error("numeric field expected");if(n.level===F)return n.num;if(n.level==="wafer"){const m=new Float64Array(T);for(let f=0;f<T;f++)m[f]=n.num[ee(f)];return m}const d=r.map(()=>[]);for(let m=0;m<n.num.length;m++)d[a.item[m]].push(n.num[m]);return Float64Array.from(d,m=>combine(m,Ce))},Ae=n=>{if(!n.cat)throw new Error("category field expected");if(n.level===F)return n.cat;if(n.level==="wafer")return Array.from({length:T},(d,m)=>n.cat[ee(m)]);throw new Error("a per-die category cannot be used at wafer level")},We=n=>n.weights&&n.level===F?n.weights:void 0;let ce=[""],D=new Int32Array(T),H,I;if(y&&Q)H=y.label,I=O(y);else if(y){H=y.label;const n=Ae(y),d=new Map,m=[];for(let x=0;x<T;x++){const v=n[x]??De;d.has(v)||(d.set(v,0),m.push(v))}const S="builtin"in y.field&&y.field.builtin==="wafer"?m:y.num&&"meta"in y.field?[...m].sort((x,v)=>(Number(x)||0)-(Number(v)||0)):[...m].sort(Te);S.forEach((x,v)=>d.set(x,v)),ce=S;for(let x=0;x<T;x++)D[x]=d.get(n[x]??De)}const fe=new Map,M=n=>fe.set(n,(fe.get(n)??0)+1),B=[],Ie=F==="die"?"dies":"wafers";let X,E,_,Y,Fe,z=0;const U=ce.length,te=n=>n.level==="die"&&F==="wafer"?`${re[Ce].toLowerCase()} of ${n.label} per wafer`:void 0;if(l==="scatter"){const n=O(g),d=O(t),m=[];for(let f=0;f<T;f++){if(!Number.isFinite(n[f])){M(g.label);continue}if(!Number.isFinite(d[f])){M(t.label);continue}if(I&&!Number.isFinite(I[f])){M(y.label);continue}m.push({x:n[f],y:d[f],group:D[f],item:ee(f),die:F==="die"?a.dies[f]:void 0,...I?{value:I[f]}:{}})}if(z=m.length,I&&m.length){const f=m.map(S=>S.value);Fe={label:y.label,unit:y.unit,lo:Ee(f),hi:Oe(f)}}X={type:"scatter",points:m},E=W("x",g.label,g.unit,e,m.map(f=>f.x),B),_=W("y",t.label,t.unit,e,m.map(f=>f.y),B),Y=[te(g),te(t)].filter(Boolean).join("; ")||void 0}else if(l==="histogram"){const n=O(t),d=Array.from({length:U},()=>[]),m=Array.from({length:U},()=>[]);for(let f=0;f<T;f++){if(!Number.isFinite(n[f])){M(t.label);continue}d[D[f]].push(n[f]),m[D[f]].push(f),z++}X={type:"histogram",values:d,units:m,unit:ue},E=W("x",t.label,t.unit,e,d.flat(),B),_={label:"Count",scale:"linear",...e.axes?.y?.label?{label:e.axes.y.label}:{}},Y=te(t)}else if(l==="line"){const n=O(g),d=O(t),m=new Set,f=new Map,S=new Map;for(let N=0;N<T;N++){if(!Number.isFinite(n[N])){M(g.label);continue}if(!Number.isFinite(d[N])){M(t.label);continue}m.add(n[N]);const A=`${D[N]}|${n[N]}`;(f.get(A)??f.set(A,[]).get(A)).push(d[N]),z++,(S.get(A)??S.set(A,[]).get(A)).push(N)}const x=[...m].sort((N,A)=>N-A),v=e.aggregate??"mean",j=Array.from({length:U},(N,A)=>x.map(P=>{const K=f.get(`${A}|${P}`);return K?combine(K,v==="yield"?"mean":v):NaN})),L=Array.from({length:U},(N,A)=>x.map(P=>f.get(`${A}|${P}`)?.length??0)),R=Array.from({length:U},(N,A)=>x.map(P=>S.get(`${A}|${P}`)??[]));X={type:"line",xs:x,values:j,counts:L,cellUnits:R,unit:ue},E=W("x",g.label,g.unit,e,x,B);const q=v==="yield"?"mean":v;_=W("y",t.perDie?t.label:`${re[q]} ${t.label}`,t.unit,e,j.flat(),B),Y=t.perDie?`passing dies over judged dies, per ${g.label.toLowerCase()}`:`${re[q].toLowerCase()} of ${t.label} per ${g.label}`}else{const n=g,d="builtin"in n.field&&(n.field.builtin==="x"||n.field.builtin==="y");if(n.kind==="numeric"&&n.level==="die"&&!d)return s(`${n.label} is continuous, so a ${l} cannot have one ${l==="bar"?"bar":"box"} per value; use a scatter or line, or choose a categorical X such as wafer, ring or bin`);const m=n.cat?Ae(n):Array.from(O(n),p=>Number.isFinite(p)?nt(p):void 0),f=new Map,S=[];for(let p=0;p<T;p++){const C=m[p];C!==void 0&&!f.has(C)&&(f.set(C,0),S.push(C))}const x="builtin"in n.field&&n.field.builtin==="wafer",v=x?S:n.kind==="numeric"?[...S].sort((p,C)=>Number(p)-Number(C)):[...S].sort(Te);v.forEach((p,C)=>f.set(p,C));const j=l==="bar"&&!t,L=e.aggregate??(j?"count":t?.weights?"yield":"mean");if(L==="yield"&&!t?.weights)return s("Pooled yield needs Yield as the Y field");if(l==="box"&&L==="count")return s("A box plot needs a measured field for Y");const R=t?O(t):void 0,q=t?We(t):void 0,N=Array.from({length:U},()=>v.map(()=>[])),A=Array.from({length:U},()=>v.map(()=>[])),P=Array.from({length:U},()=>v.map(()=>[]));for(let p=0;p<T;p++){const C=m[p]===void 0?void 0:f.get(m[p]);if(C===void 0){M(n.label);continue}if(R&&!Number.isFinite(R[p])){M(t.label);continue}N[D[p]][C].push(R?R[p]:1),A[D[p]][C].push(p),q&&P[D[p]][C].push(q[p]),z++}const K=N.map((p,C)=>p.map((Z,Ge)=>{if(Z.length===0)return NaN;if(L==="yield"){const ke=P[C][Ge],Le=ke.reduce((ge,he)=>ge+he,0);return Le>0?Z.reduce((ge,he,Ve)=>ge+he*ke[Ve],0)/Le:NaN}return combine(Z,L)})),Re=x?v.map(p=>m.findIndex((C,Z)=>C===p&&Z>=0)):void 0;if(X={type:l==="box"?"box":"bar",categories:v,cells:N,cellUnits:A,unit:ue,values:K,categoryItems:Re?.map(p=>F==="die"?a.item[p]:p)},E={label:e.axes?.x?.label??n.label,scale:"linear"},l==="bar"){const p=L==="count"?"Count":re[L],C=j?`Count of ${Ie}`:L==="yield"?"Pooled yield":`${p} ${t.label}`;_=W("y",C,L==="yield"?"%":L==="count"?void 0:t?.unit,e,K.flat(),B),Y=j?void 0:L==="yield"?`passing dies over judged dies, pooled per ${n.label.toLowerCase()}`:`${p.toLowerCase()} of ${t.label}${t.level==="die"&&F==="wafer"?" per wafer":""} per ${n.label.toLowerCase()}`}else _=W("y",t.label,t.unit,e,N.flat(2),B),Y=te(t)}const de=(n,d)=>n&&!n.perDie&&(d===void 0||d==="mean"||d==="median"||d==="min"||d==="max")?n.limits:void 0,Ye=e.aggregate??"mean";E&&(l==="scatter"||l==="line")&&(E.limits=de(g)),_&&l!=="histogram"&&(_.limits=de(t,l==="scatter"||l==="box"?void 0:Ye)),l==="histogram"&&E&&(E.limits=de(t));const je=()=>{const n=g?.label,d=t?.label,m=l==="scatter"?`${d} vs ${n}`:l==="histogram"?`${d}`:l==="line"?`${d} over ${n}`:l==="box"?`${d} by ${n}`:d?`${d} by ${n}`:`Dies by ${n}`;return H&&y&&!ye(y.field,c)?`${m} \xB7 by ${H}`:m},Se=[];let me;for(const n of new Set([g,t,y])){if(!n||!("test"in n.field))continue;const d=n.field.test;let m=0;for(const f of a.dies)ze(f,d)!==void 0&&(m++,me??=Ke(Xe(f)));m>0&&Se.push({field:n.label,count:m})}return{spec:e,issues:[],notes:B,marks:X,level:F,...me?{excluded:{limitSet:me,fields:Se}}:{},autoTitle:je(),x:E,y:_,groups:ce,colorScale:Fe,colorLabel:H,aggregation:Y,population:{wafers:r.length,dies:a.dies.length},plotted:z,omitted:[...fe].map(([n,d])=>({field:n,count:d}))}}export function plotTitle(e){return e.spec.title?.trim()?e.spec.title:e.autoTitle}export function plotFootnote(e){const{wafers:r,dies:i}=e.population,o=[`${r.toLocaleString("en-GB")} wafer${r===1?"":"s"} \xB7 ${i.toLocaleString("en-GB")} dies`];e.aggregation&&o.push(e.aggregation);for(const s of e.omitted)o.push(`${s.count.toLocaleString("en-GB")} ${e.level==="die"?"dies":"wafers"} without ${s.field} not plotted`);if(e.excluded)for(const s of e.excluded.fields)o.push(`${s.count.toLocaleString("en-GB")} ${s.field} value${s.count===1?"":"s"} outside ${e.excluded.limitSet} excluded`);return o.join(" \xB7 ")}export function fieldKey(e){return"test"in e?`test:${e.test}`:"builtin"in e?`builtin:${e.builtin}`:`meta:${e.meta}`}export function fieldCatalogue(e,r={}){const i=[],o=e.flatMap(t=>t.dies),s=new Set(o.length?pe(o,"values"):[]),a=r.testDefs??[],u=new Map;for(const t of a)t.testType!=="F"&&(s.has(t.testNumber)||!o.length)&&u.set(t.testNumber,t.name);for(const t of s)!u.has(t)&&!a.some(b=>b.testNumber===t&&b.testType==="F")&&u.set(t,void 0);for(const[t,b]of[...u].sort((k,y)=>k[0]-y[0]))i.push({field:{test:t,...b?{name:b}:{}},label:b?`${b} \xB7 ${t}`:`Test ${t}`,name:b||`Test ${t}`,group:"Tests",kind:"numeric",level:"die",categorical:!1});const l=new Set(o.length?pe(o,"all"):[]);for(const t of a){if(ne(t)||!(l.has(t.testNumber)||!o.length))continue;const b=t.name||`Test ${t.testNumber}`;i.push({field:{test:t.testNumber,...t.name?{name:t.name}:{}},label:`${b} \xB7 ${t.testNumber} (pass/fail)`,name:b,group:"Verdicts",kind:"categorical",level:"die",categorical:!0})}const $=t=>o.some(t),c=(t,b,k)=>i.push({field:{builtin:t},label:J[t],name:J[t],group:"Die",kind:b,level:"die",categorical:k});$(t=>be(t))&&(c("x","numeric",!1),c("y","numeric",!1));const w=$(t=>be(t));for(const t of He)e.some(b=>G[t].available({wafer:b.wafer,ringCount:b.ringCount},w))&&c(t,"categorical",!0);$(t=>t.hbin!==void 0)&&c("hbin","categorical",!0),$(t=>t.sbin!==void 0)&&c("sbin","categorical",!0),$(t=>t.siteNum!==void 0)&&c("site","categorical",!0);const h=(t,b,k)=>i.push({field:{builtin:t},label:J[t],name:J[t],group:"Wafer",kind:b,level:"wafer",categorical:k});h("wafer","categorical",!0),e.length>1&&h("waferOrder","numeric",!1),h("yield","numeric",!1),h("dieCount","numeric",!1);const g={items:e,rows:{dies:[],item:new Uint32Array(0)},ctx:r};for(const t of Qe(e.map(b=>({metadata:b.metadata,dieCount:b.dies.length})),{facetableOnly:!0,curation:r.curation})){if(t.values.length===0)continue;const b=V({meta:t.key},g);i.push({field:{meta:t.key},label:t.label||ie(t.key),name:t.label||ie(t.key),group:"Wafer",kind:b.kind,level:"wafer",categorical:!0,distinct:t.values.length})}return i}export function fieldsForRole(e,r,i){const o=i==="y"||i==="x"&&(r==="scatter"||r==="line"||r==="histogram");return i==="color"?e.filter(s=>s.categorical||r==="scatter"&&s.kind==="numeric"):o?e.filter(s=>s.kind==="numeric"):e.filter(s=>s.categorical)}export function defaultPlot(e,r){const i=e.filter(o=>o.group==="Tests");return i.length>=2?{id:r,chart:"scatter",fields:{x:i[0].field,y:i[1].field}}:i.length===1?{id:r,chart:"histogram",fields:{y:i[0].field}}:{id:r,chart:"scatter",fields:{x:{builtin:"waferOrder"},y:{builtin:"yield"}}}}const $e=new Set(["wafer","dies","die x","die y","wafer order"]),at=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),xe=(e,r)=>r.length>=3&&new RegExp(`(^|[^A-Za-z0-9_])${at(r)}($|[^A-Za-z0-9_])`,"i").test(e);export function titleDrift(e,r){const i=e.title?.trim(),o={names:[],omits:[]};if(!i)return o;const s=e.fields?.color,a=[e.fields?.x,e.fields?.y,s].filter(t=>we(t)),u=t=>a.some(b=>ye(b,t)),l=r.filter(t=>!$e.has(t.name.toLowerCase())&&!("meta"in t.field)&&!u(t.field)&&xe(i,t.name)).map(t=>t.name),$=[e.fields?.x,e.fields?.y].filter(t=>we(t)),c=t=>r.find(b=>ye(b.field,t))?.name??fieldLabel(t),w=$.filter(t=>!$e.has(c(t).toLowerCase())&&xe(i,c(t))),h=$.filter(t=>!$e.has(c(t).toLowerCase())&&!xe(i,c(t))),g=w.length>0||l.length>0?h.map(c):[];return{names:l,omits:g}}const _e=e=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;export function describeTitleDrift(e){const r=[];return e.names.length&&r.push(`The title names ${_e(e.names)}, which this plot does not show.`),e.omits.length&&r.push(`It does not name ${_e(e.omits)}, which this plot shows.`),r.length?r.join(" "):null}export function examplePlots(e,r,i){const o=e.filter(u=>u.group==="Tests").map(u=>u.field),s=[],a=r>1;if(o.length>=2&&s.push({id:i(),chart:"scatter",fields:{x:o[0],y:o[1]}}),o.length>=1&&s.push({id:i(),chart:"histogram",fields:{y:o[0],color:{none:!0}}}),o.length>=1&&a&&s.push({id:i(),chart:"box",fields:{x:{builtin:"wafer"},y:o[0],color:{none:!0}}}),a){const u=e.find(l=>"meta"in l.field&&l.distinct!==void 0&&l.distinct>=2&&l.distinct<=Math.max(2,Math.floor(r/2)));s.push({id:i(),chart:"bar",fields:{x:u?u.field:{builtin:"wafer"},y:{builtin:"yield"},color:{none:!0}}})}return o.length>=1&&a&&s.push({id:i(),chart:"line",fields:{x:{builtin:"waferOrder"},y:o[0],color:{none:!0}},aggregate:"mean"}),o.length>=2&&s.push({...Ue(o.flatMap(u=>"test"in u?[u]:[]),i()),title:"Example sweep"}),s}export function plotTestNumber(e){const{x:r,y:i,color:o}=e.fields??{},s=e.chart==="scatter"?[r,i,o]:e.chart==="histogram"?[i,r]:[i];for(const a of s)if(we(a)&&"test"in a)return a.test}export function defaultSweep(e,r){return Ue(e.filter(ne).map(i=>({test:i.testNumber,name:i.name})),r)}function Ue(e,r){const i=[...e].sort((s,a)=>s.test-a.test).slice(0,5),o=Object.fromEntries(i.flatMap(s=>s.name?[[String(s.test),s.name]]:[]));return{id:r,chart:"sweep",sweep:{series:[{label:"Series 1",tests:i.map(s=>s.test),...Object.keys(o).length?{testNames:o}:{}}]}}}
|
|
@@ -44,6 +44,12 @@ export declare function buildRegionYieldData(diesByWafer: Die[][], allWafers: Wa
|
|
|
44
44
|
* ring or quadrant of the yield diagram stands for.
|
|
45
45
|
*/
|
|
46
46
|
export declare function diesInRegion(dies: readonly Die[], wafer: Wafer, ringCount: number, key: string, regionBuilder: (dies: PositionedDie[], wafer: Wafer, ringCount: number) => StatsRegion[]): Die[];
|
|
47
|
+
/**
|
|
48
|
+
* The compass bucket of a direction `dx, dy` from the wafer centre, of `count` (4, 8 or 16) buckets each
|
|
49
|
+
* centred on its bearing: east spans −11.25° to 11.25° of 16. The one rule for naming a direction, read by
|
|
50
|
+
* the sectors and by the edge arcs.
|
|
51
|
+
*/
|
|
52
|
+
export declare function compassBucket(dx: number, dy: number, count: number): number;
|
|
47
53
|
/** Compass bearing names for a given sector count, ordered CCW from East. */
|
|
48
54
|
export declare function sectorCompassNames(sectorCount: number): string[];
|
|
49
55
|
/** Quadrants going round the wafer, counter-clockwise from the north-east. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{DIE_REGIONS as
|
|
1
|
+
import{DIE_REGIONS as h}from"./dieRegions.js";import{isPositionedDie as E,diePassStatus as x,getDieKey as b}from"../core/dies.js";function N(e){return b(e)}export function buildRegionYieldData(e,t,o,i,s){const r=new Map,n=[];for(let c=0;c<t.length;c++){const a=e[c];if(!a?.length)continue;const l=new Set(typeof i=="function"?i(c):i),f=s(a.filter(E),t[c],o);for(const u of f){n.includes(u.key)||n.push(u.key);const S=r.get(u.key)??{label:u.label,pass:0,total:0};for(const d of u.dies){if(d.partial||d.edgeExcluded)continue;const p=x(d,l);p!==void 0&&(S.total++,p&&S.pass++)}r.set(u.key,S)}}return n.map(c=>{const a=r.get(c);return a.total===0?null:{key:c,label:a.label,n:a.total,passDies:a.pass,yieldPercent:a.pass/a.total*100}}).filter(c=>c!==null)}export function diesInRegion(e,t,o,i,s){const r=s(e.filter(E),t,o).find(n=>n.key===i);return r?r.dies.filter(n=>!n.partial&&!n.edgeExcluded&&(n.hbin??n.sbin)!==void 0):[]}const W=["E","ENE","NE","NNE","N","NNW","NW","WNW","W","WSW","SW","SSW","S","SSE","SE","ESE"],R=["E","NE","N","NW","W","SW","S","SE"],M=["E","N","W","S"];export function compassBucket(e,t,o){const i=Math.PI/o,s=(Math.atan2(t,e)+2*Math.PI+i)%(2*Math.PI);return Math.floor(s/(2*Math.PI)*o)%o}export function sectorCompassNames(e){const t=[4,8,16].includes(e)?e:16;return t===4?M:t===8?R:W}export const QUADRANT_CYCLE=["NE","NW","SW","SE"];const A={NE:["NW","SE"],NW:["NE","SW"],SE:["NE","SW"],SW:["NW","SE"]};export function areQuadrantsAdjacent(e,t){return A[e]?.includes(t)??!1}const g=1440;export function regionAngleBins(e,t){const o=parseRegionKey(e);let i,s;if(o.family==="quadrant"){const n=QUADRANT_CYCLE.indexOf(o.quadrant);if(n<0)return;i=n*g/4,s=g/4}else if(o.family==="sector"){const n=[4,8,16].includes(t)?t:void 0,c=n?sectorCompassNames(n).indexOf(o.sector??""):-1;if(!n||c<0)return;s=g/n,i=c*s-s/2}else return;const r=new Set;for(let n=0;n<s;n++)r.add(((i+n)%g+g)%g);return r}export function parseReticleCellKey(e){const t=/^reticle-position:cell:(-?\d+),(-?\d+)$/.exec(e);return t?{column:Number(t[1]),row:Number(t[2])}:void 0}export function parseRegionKey(e){return e.startsWith("ring:")?{family:"ring",ring:Number(e.slice(5))}:e.startsWith("quadrant:")?{family:"quadrant",quadrant:e.slice(9)}:e.startsWith("sector:")?{family:"sector",sector:e.slice(7)}:{family:"unknown"}}function m(e,t,o){const i=h[t].grouping,s=new Map;for(const r of e){const n=i.place(r,o);if(!n)continue;const c=s.get(n.key)??{family:i.family,key:n.key,label:n.label,dieKeys:[],dies:[]};c.dieKeys.push(N(r)),c.dies.push(r),s.set(n.key,c)}return[...s.values()].sort((r,n)=>i.order(r.key,n.key))}export function buildRingRegions(e,t,o){return m(e,"ring",{wafer:t,ringCount:o})}export function buildQuadrantRegions(e,t,o){return m(e,"quadrant",{wafer:t,ringCount:o})}export function buildReticlePositionRegions(e,t){return t?m(e,"reticleCell",{ringCount:0,reticle:t}):[]}const I=3;export function buildTestSiteRegions(e,t=!1){const o=new Map;for(const i of e){if(i.siteNum===void 0)continue;const s=o.get(i.siteNum)??[];s.push(i),o.set(i.siteNum,s)}if(!t){let i=0;for(const s of o.values())s.length>=I&&i++;if(i<2)return[]}return[...o.entries()].sort(([i],[s])=>i-s).map(([i,s])=>({family:"test-site",key:`test-site:${i}`,label:`Site ${i}`,dieKeys:s.map(N),dies:s}))}export function buildSectorRegions(e,t,o){const i=[4,8,16].includes(o)?o:16,s=sectorCompassNames(i),r=new Map,n=t.center.x,c=t.center.y,a=t.radius;for(const l of e){const f=l.physX-n,u=l.physY-c;if(Math.hypot(f,u)/a<.2)continue;const d=s[compassBucket(f,u,i)],p=`sector:${d}`,y=r.get(p)??{family:"sector",key:p,label:`Sector ${d}`,dieKeys:[],dies:[]};y.dieKeys.push(N(l)),y.dies.push(l),r.set(p,y)}return[...r.values()].sort((l,f)=>l.key.localeCompare(f.key))}
|