Appending Data to Existing Wave
astrotool
Is there anyway I can append the files together so I don't have a bunch of segmented data?
Searching IGOR's Help only gives me options to append to graphs not to waves.
If you're just asking how to append points to a wave, you can use either the Redimension or InsertPoints operations to add additional points onto a wave. You could then re-save the entire wave to your data file, overwriting the file in the process.
If overwriting the data file every hour is too time consuming or otherwise not a good solution, you could create a new wave each hour in your acquisition program, and append each successive wave to your data file every hour. To avoid the need to overwrite your data file every time you save to it, you'll want to either save each new wave in an unpacked experiment or save your data file as a type that can be appended to. Igor text files can be appended. For my data acquisition, I use the HDF5 XOP included with Igor to add new waves to a HDF5 file that I save my data into.
When you then open your data file, if you want all points to be in one single wave, it's easy to combine all of your waves into a single wave for analysis. You can do this in a loop, or the Concatenate operation will possibly be of use to you.
May 22, 2008 at 06:50 am - Permalink
I have 3 columns of data with about 3600 points each, per file.
I want to append one file to another so I then have
3 columns of data with 7200 points each, then 1080 points each and so on as I add on the data from other files
May 22, 2008 at 09:51 am - Permalink
So, as an example, you can try something like this:
<acquire some data and fill out the wave>
<save that wave to a data file>
Make/O/N(3600,3) myDataWave // This line isn't really necessary
<acquire some more data into myDataWave>
// After another hour has passed, the following code gets executed
<open your data file>
<read in the data in your data file into a wave called savedData>
Variable savedRows = DimSize(savedData, 0)
Redimension/N=(savedRows + 3600, -1) savedData
savedData[savedRows - 1, savedRows - 1 + 3600] = myDataWave[p - savedRows]
<save the wave savedRows to your data file again>
Does this help?
May 22, 2008 at 12:08 pm - Permalink
I uploaded the two actual data files I am using. The only columns I am concerned about really are Time, Current SS, and CCN Count Number
I just want to make these two files into one basically. That way I can analyze the data for the day, not just per hour.
Eventually I will want to take like 24 of these and put them into one, but figuring out how to join 2 of them together is what I am trying for
May 22, 2008 at 01:03 pm - Permalink
Create a function to load a file into a wave ...
// load the file into wave MyWave
...
end
Create a function to add waves together into CatWave ...
...
npntsMyWave = numpnts(MyWave)
npntsCatWave = numpnts(CatWave)
npntsTotal = npntsMyWave + npntsCatWave
redimension/N=(npntsTotal) CatWave
CatWave[npntsCatWave,npntsTotal-1] = MyWave[p-npntsCatWave]
return 0
end
Run these two in a loop function ...
variable howmany
...
for(ic=0;ic<howmany;ic+=1)
LoadMyFile()
CatMyWave()
endfor
return 0
end
HTH
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
May 22, 2008 at 01:47 pm - Permalink
Make/O/N=5 wave0=p, wave1=5+p
Variable numPoints = numpnts(wave0)
Make/O/N=(2*numPoints) wave2
wave2[0,numPoints-1] = wave0[p]
wave2[numPoints,] = wave1[p-numPoints]
Edit wave0, wave1, wave2
End
Function Demo2()
Make/O/N=5 wave0=p, wave1=5+p
Concatenate/O/NP {wave0, wave1}, wave2
Edit wave0, wave1, wave2
End
Obviously the second function is easier but you may learn about wave indexing from the first.
May 22, 2008 at 01:51 pm - Permalink
May 22, 2008 at 02:49 pm - Permalink
Make/O/N=0 megaWave
Variable currentNumRows, newNumRows
do
LoadWave/J/M/U={0,0,1,0}/D/A=wave/K=0/L={4,6,0,0,0}
if (V_flag == 0) // Break if user hit the cancel button.
break
endif
WAVE loadedWave = $(StringFromList(0, S_waveNames, ";"))
// Make sure that megaWave has the right number of rows and columns
currentNumRows = DimSize(megaWave, 0)
newNumRows = DimSize(loadedWave, 0)
if (numpnts(megaWave) == 0) // This is here to copy the dimension labels.
Duplicate/O loadedWave, megaWave
endif
Redimension/N=(currentNumRows + newNumRows, -1) megaWave
megaWave[currentNumRows, currentNumRows + newNumRows][] = loadedWave[p - currentNumRows][q]
KillWaves loadedWave
while(1)
Edit megaWave.ld
End
May 22, 2008 at 04:12 pm - Permalink
I took that code and modified it into this to work for me how I needed it
do
LoadWave/J/D/A=wave/K=0/L={4,6,0,0,0}
if (V_flag == 0) // Break if user hit the cancel button.
break
endif
Concatenate/NP {wave0}, TimeAll
Concatenate/NP {wave1}, CurrentSSAll
Concatenate/NP {wave45}, CCNNumberAll
KillWaves wave0,wave1,wave2,wave3,wave4,wave5,wave6,wave7,wave8,wave9,wave10,wave11,wave12,wave13,wave14,wave15,wave16,wave17,wave18,wave19,wave20,wave21,wave22,wave23,wave24,wave25,wave26,wave27,wave28,wave29,wave30,wave31,wave32,wave33,wave34,wave35,wave36,wave37,wave38,wave39,wave40,wave41,wave42,wave43,wave44,wave45,wave46,wave47
while(1)
End
May 23, 2008 at 02:28 pm - Permalink
You could also do ...
theList = WaveList("wave*",";","")
do
theOne = StringFromList(ic,theList)
if (strlen(theOne)==0)
break
endif
killwaves/Z $theOne
ic+=0
while(1)
... to cover for cases where wave0 ... wave47 might skip something.
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
May 23, 2008 at 02:31 pm - Permalink