Exporting multiple 2D waves
mssmtrainee
Basically, I'd like to export N-2D waves of an experiment into N-text files. Of course, I can just open the wave table, copy the 2 columns and past into a text file, but it is getting intense when I have few hundreds of waves.
I did some coding in the past, but I am totally new to Igor, so any help and advice will be much appreciated. Thanks!
But first . . .
If you are not familiar with the important concept of Igor symbolic paths, execute this and read the corresponding help:
If you are not familiar with the important concept of Igor data folders, execute this and read the corresponding help:
Also, if you have not already done it, do the first half of the Igor Guided Tour which you can find by choosing Help->Getting Started.
Here is the routine:
String pathName // Name of Igor symbolic path
String fileNameList = ""
Variable index = 0
do
Wave/Z w = WaveRefIndexed("", index, 4) // Next wave in current data folder
if (!WaveExists(w))
break // No more waves
endif
if (WaveType(w) == 0)
index += 1
continue // Skip text waves
endif
if (WaveDims(w) != 2)
index += 1
continue // 2D waves only
endif
String fileName = NameOfWave(w) + ".dat"
Save /P=$pathName /J /O w as fileName // Save to text file
fileNameList += fileName + ";"
index += 1
while(1)
return fileNameList
End
November 30, 2011 at 07:12 pm - Permalink
First, I'd like to name my text files 1.dat, 2.dat, 3.dat etc. Is there away to convert an Integer into a String? (7th line from the end)
And second, to make the code work, I need to load my waves. Is there a way to load, let say 50 waves in the same time?
//Save 2D waves to text files *.dat
//Modified by Vireak Yim 12/02/2011:
// Extract points from waves, rearrange them into 2 columns, and save in a text file *.dat
Function/S SaveAllNumeric2DWaveToTextFiles(pathName)
String pathName // Name of Igor symbolic path
String fileNameList = ""
Variable index = 0
do
Wave/Z w = WaveRefIndexed("", index, 4) // Next wave in current data folder
if (!WaveExists(w))
break // No more waves
endif
if (WaveType(w) == 0)
index += 1
continue // Skip text waves
endif
if (WaveDims(w) != 2)
index += 1
continue // 2D waves only
endif
Make /N = (199,3) Subwave // Create an intermediate wave with 200 rows
Variable ind = 0
do
Subwave[ind][0] = w[ind][2]*10^9
Subwave[ind][1] = w[ind][0]*10^9 // Rearrange the data columns and convert them to nm to fit the pointwise requirements
Subwave[ind][2] = w[ind][1]*10^9
ind += 1
while(ind<200)
String fileName = %index + ".dat" // Convert integer 'index' into string (trying to get 1.dat, 2.dat, 3.dat...)
Save /P=$pathName /J /O Subwave as fileName // Save to text file
fileNameList += fileName + ";"
index += 1
while(1)
return fileNameList
End
Cheers,
December 2, 2011 at 03:26 pm - Permalink
Sure, it's
num2istr
.Maybe you can start by modifying this function posted by Adam Light.
A
December 3, 2011 at 03:02 am - Permalink
Execute this:
December 3, 2011 at 06:06 am - Permalink