// X Stitching Measurement (v1.2) // Demonstration of measuring X-Stitch error from the position difference between two gratings. // Provided as-is by GenISys. // // Define Functions // // compare the x positions of two features; used to sort the features into order var compareX = function(a, b) { return a[0].CenterX - b[0].CenterX; } // compare the y positions of two features; used to sort the features into order var compareY = function(a, b) { return a[0].CenterY - b[0].CenterY; } // must have exactly 4 groups of stored measurements. if (image.length != 4) { "Error: Must have 4 groups." } else { // extract first four groups from image, sort by coodinates of first measurements var groups = [0, 1, 2, 3].map(function(i) { return image[i]; }).sort(compareX); var left = [groups[0], groups[1]].sort(compareY); var right = [groups[2], groups[3]].sort(compareY); // use convenient labels for the 2 gratings in the lower two quadrants, using the sorted lists just created. var LL = left[0]; var LR = right[0]; // compare the spacing of the rightmost feature of the left quadrant with the leftmost feature of the right quadrant var m1 = LL[LL.length - 1]; var m2 = LR[0]; var xcenter1 = (m1.E0CenterX + m1.E1CenterX) / 2; var xcenter2 = (m2.E0CenterX + m2.E1CenterX) / 2; var xpitch = (LL.GratingPitchMean + LR.GratingPitchMean) / 2; // the stitch error is the difference in this spacing from the mean grating pitch var xstitch = (xcenter2 - xcenter1) - xpitch; xstitch; }