Appending Data to Existing Wave
| aclight | May 22, 2008 - 07:50 | ||
|---|---|---|---|
|
I'm not quite sure what you want to do here. 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. |
|||
| astrotool | May 22, 2008 - 10:51 | ||
|---|---|---|---|
|
|
|||
| aclight | May 22, 2008 - 13:08 | ||
|---|---|---|---|
|
Ok, so that's basically what I said initially. So, as an example, you can try something like this: Make/O/N=(3600, 3) myDataWave <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? |
|||
| astrotool | May 22, 2008 - 14:03 | ||
|---|---|---|---|
|
I tried using what you posted but things didn't quite work out for me 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 |
|||
| jjweimer | May 22, 2008 - 14:47 | ||
|---|---|---|---|
|
Here is a brief example for a "one-column" wave. I prefer a multi-step approach, with "subroutines" that can be separately tested before moving to the next stage. Create a function to load a file into a wave ... Function LoadMyFile() // load the file into wave MyWave ... end Create a function to add waves together into CatWave ... Function CatMyWave() ... 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 ... Function GetMyData(howmany) variable howmany ... for(ic=0;ic<howmany;ic+=1) LoadMyFile() CatMyWave() endfor return 0 end HTH -- |
|||
| May 22, 2008 - 14:51 | |||
|---|---|---|---|
|
You say you want to concatenate files. Here is a way to concatenate waves assuming that you have loaded the data from the files into the waves. Function Demo1() 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. |
|||
| astrotool | May 22, 2008 - 15:49 | ||
|---|---|---|---|
|
|
|||
| aclight | May 22, 2008 - 17:12 | ||
|---|---|---|---|
|
Give this code a try: Function Magic() 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 [ last edited May 22, 2008 - 17:13 ]
|
|||
| astrotool | May 23, 2008 - 12:50 | ||
|---|---|---|---|
|
Thanks for the help!!! I took that code and modified it into this to work for me how I needed it Function CCNLoader() 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 [ last edited May 23, 2008 - 15:28 ]
|
|||
| jjweimer | May 23, 2008 - 15:31 | ||
|---|---|---|---|
|
Thanks for the help!!!
I took that code and modified it into this to work for me how I needed it ... You could also do ... ic=0
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. -- |
|||

Joined: 2008-05-12
Location: United States
My instrument runs continuously and takes measurements every second. It outputs a new file every 60 minutes. So I want to connect them all together
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.