Hi, I'm working on curve fitting a large collection of waves and the data comes in with an offset artifact. Since the curvefit needs the data to begin at the origin, all of the waves need to be zeroed. The function to do this is simple enough, however there are a large number of waves with different naming conventions, and it's going to be laborious to run the function for each wave individually. I'm wondering if there is some shortcut that allows me to take every wave in an experiment as the argument for a function?
You will need to send the wave list in as a string, with each wave separated by semicolons or another marker, and then use a loop to iterate through the list and apply your adjustments to the wave.
Here's a function that will return such a string from a selection in the Data browser
Function/S SelectedWaveList()//all selected waves...string SelectedWaves=""variableidoif(waveexists($(GetBrowserSelection(i))))
SelectedWaves+=GetBrowserSelection(i)+";"endifi+=1while(strlen(GetBrowserSelection(i))>0)return SelectedWaves
end
Using this, you can create a function that will accept the returned list as an input, which you can parse and act upon, such as the following:
Function ParseList(list)string list
variableifor(i=0;i<itemsinlist(list);i+=1)WAVE wavenm=$stringfromlist(i,list,";")
wavenm=//modify the wave hereendforend
To run these, you would then do the following:
1. Make a selection in the Data Browser
2. Run the following command:
The idea of using the Data Browser is good if you want to pick and choose the waves to operate on. However if you truly want to apply this to all numeric waves then I would write the function to work on all of the numeric waves in the current data folder, like this:
Function SubtractInitialValueFromWaves(dfr, recurse)
DFREF dfr // : for current data folderVariable recurse // 0 for just specified data folder, 1 to recurse through sub-data foldersVariable index = 0doWave/Z w = WaveRefIndexedDFR(dfr, index)// Requires Igor Pro 6.30 or laterif(!WaveExists(w))break// No more waves in this data folderendifif(WaveType(w)!= 0)// Numeric wave?Variable initialValue = w[0]// This must be done
w -= initialValue // in two separate statementsendif
index += 1while(1)if(recurse)Variable numChildDataFolders = CountObjectsDFR(dfr, 4)Variableifor(i=0; i<numChildDataFolders; i+=1)String childDFName = GetIndexedObjNameDFR(dfr, 4, i)
DFREF childDFR = dfr:$childDFName
SubtractInitialValueFromWaves(childDFR, 1)endforendifEnd
Here's a function that will return such a string from a selection in the Data browser
Using this, you can create a function that will accept the returned list as an input, which you can parse and act upon, such as the following:
To run these, you would then do the following:
1. Make a selection in the Data Browser
2. Run the following command:
ParseList(SelectedWaveList())
August 20, 2013 at 02:20 pm - Permalink
August 20, 2013 at 05:06 pm - Permalink
August 21, 2013 at 07:14 am - Permalink