Data collection devices are generating larger, more dense data sets each year. This resolution can be enormously helpful in many ways but it can also lead to increased processing time and increased noise. If you have a large set of data and don't require the resolution provided, a script like the one below can be used to reduce the number of overall points (thin the data).
To run this script:
- Copy the script below, or download the attached BAS file: DataThin.bas .
- In a Windows Explorer window, navigate to C:\Program Files\Golden Software\Surfer.
- Double click on Scripter.exe to launch Scripter.
- Press Ctrl+A to select all of the existing lines then press Delete.
- If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
- Click Script | Run to run the script.
'DataThin.bas reads the data file and writes every nth point to a new file. Sub Main Debug.Print "----- ";Time;" -----" file1 = GetFilePath(,"dat;txt;xyz",,"Open Data File") n = InputBox("Read every n-th data point","Enter 'n'","2") file2 = Left(file1,Len(file1)-4)+"_Thinned_"+n+".dat" Open file1 For Input As #1 Open file2 For Output As #2 linenum = 0 While Not EOF(1) For i = 1 To n Line Input #1,a Next i Print #2,a Wend Debug.Print file2+" has been created." MsgBox(file2+" has been created.") End Sub
Updated November 2021
Please sign in to leave a comment.