4Misc_Start@4Platform@@9VersionCheck xHH@Rg(HHdh xHH@Rg(HHdh x HH@Rg(HHdh ^Graph*WDashSettings#  ! J6Normal@ Monaco<HHHH$$4 4 4 4 4 4 homeOdhd:Old Stuff:2018:2018-04-30:RemoveDuplicatesXY:FhdBDRemoveDuplicatesXY cu 2018-04-30//:Old Stuff:2018:2018-04-30:RemoveDuplicatesXY/&RemoveDuplicatesXYhd,Old Stuff/2018/2018-04-30/RemoveDuplicatesXY/1RecentWindows3D Graphics.ihfAdvanced Topics.ihfAnalysis.ihfAnnotations.ihfControls.ihfCurve Fitting.ihfData Folders.ihfDemoLoader.ipfDialog Help.ihfDrawing.ihfErrors.ihfExperiments, Files and Folders.ihfFreeMem.ipfGetting Started.ihfIgor Reference.ihf 4Misc_End@XOPState_Start`@WindowXOP1-64acos;VISA64lysis.ihfHDF5-64s.ihfCurve Fitting.ihSQL64olders.ihfDemoLoader.ip XTest3-64p.ihfDrawing.ihf XTest7-64`Ӄ IgorNeuronBridge-64fIgorGIS64Igor Reference.ihfXTestStructs64JDPeakFunctions2-64FVDT2-64/4XOPState_End@\(•RemoveDuplicatesXYTestAll() // Tests four cases on small waves All tests passed •RemoveDuplicatesXYTest(49000, 2000) // Runs on XY pair with 49000 points and roughly 2000 duplicate X values Number of input points=49000, number of output points=46958, elapsed time=0.0303609 seconds !bkk Xs  xWave0?????@@@@@XH  yWave0?????@@@@@\'  xWaveOriginal?????@@@@@@k\{   yWaveOriginal?????@@@@@@*{// Platform=Macintosh, IGORVersion=8.000, architecture=Intel, systemTextEncoding="MacRoman", historyTextEncoding="UTF-8", procwinTextEncoding="UTF-8", recreationTextEncoding="UTF-8", build=31741 #pragma TextEncoding = "UTF-8" Silent 101 // use | as bitwise or -- not comment. DefaultFont "Helvetica" RemoveDuplicatesXYTable() MoveWindow/P 7,74,1201,945 MoveWindow/C 2,667,1278,1022 KillStrings/Z root:gWMSetNextTextFilesTextEncoding Window RemoveDuplicatesXYTable() : Table PauseUpdate; Silent 1 // building window... Edit/K=1/W=(5,45,683,458) xWaveOriginal,yWaveOriginal,xWave0,yWave0 ModifyTable format(Point)=1 EndMacro #pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. Menu "Macros" "RemoveDuplicatesXY Test All/1", RemoveDuplicatesXYTestAll() End // Does not consider consecutive NaNs to be duplicates. // Does not handle triplicates, quadruplicates, ... // See RemoveDuplicatesXYDemo below. Function RemoveDuplicatesXY(xWave, yWave) Wave xWave, yWave Duplicate/FREE xWave, xWaveCopy Duplicate/FREE yWave, yWaveCopy Variable numPointsIn = numpnts(xWave) Variable numPointsOut = 0 Variable previousX = xWaveCopy[0] Variable previousY = yWaveCopy[0] Variable currentX, currentY Variable numPointsWithThisX = 1 Variable sumOfYValuesWithThisX = previousY Variable i for(i=1; i (numPoints/2)) Abort "RemoveDuplicatesXYTest invalid parameters" endif Make/O/N=(numPoints) xTest = p Make/O/N=(numPoints) yTest = p Variable skip = trunc(numPoints / numDuplicates) xTest[1,numPoints-1;skip] = xTest[p-1] Variable timerRefNum = StartMSTimer RemoveDuplicatesXY(xTest, yTest) Variable elapsed = StopMSTimer(timerRefNum) / 1E6 // In seconds Variable numPointsOut = numpnts(xTest) Printf "Number of input points=%d, number of output points=%d, elapsed time=%g seconds\r", numPoints, numPointsOut, elapsed End