Write same note to multiple waves
It would be nice if there was a way to write the same note to multiple waves in one line, either by explicitly listing the names or passing a string list of names, rather than having to write the note to each wave individually. I am often filtering waves by certain parameters, and I use the notes as a handy way to keep track of the filter criteria. For example, I might extract data where the RMS is below a certain threshold, and I then write that value to the note for all the waves filtered that way. I can sometimes put the filtering and note writing into a loop, but other times this isn't possible, and I have to hardcode it. For large numbers of waves, having to repeat the "Note wavename, notestring" command is rather tedious. I'm not sure if and how a multiple wave note command would work with the current syntax. If the wave names are required, then maybe something like the current Sort syntax, where the sortkey is either a wave name or a bracketed list of wave names would work?
Hi,
One fast wave to do this is through wave browser. Highlight all the waves you would like to have the same note. The press "Execute Cmd" button. This allows you to run the same command over all the highlighted waves. In the field enter:
Note %s "the note string, yada yada yada.." and hit ok. the term %s is a placeholder for the wave name and it will cycle through all the waves and attache the same note.
Bam! you are done.
Andy
July 24, 2021 at 02:54 pm - Permalink
Hi Andy
That's a nice tip! However, I'm looking for a way to do this programmatically, so the Data Browser method isn't a complete fix.
July 24, 2021 at 08:21 pm - Permalink
int i
for (i=numpnts(wrefs)-1;i>=0;i--)
note wrefs[i], strNote
endfor
end
usage example
SetWaveRefWaveNotes({w1,w2,w3}, "test")
you could do the same thing with a list of wavenames if you prefer.
int i
for (i=itemsinlist(listofwaves)-1;i>=0;i--)
note $stringfromlist(i, listofwaves), strNote
endfor
end
SetWaveListWaveNotes("w1;w2;w3;", "test2")
July 25, 2021 at 01:10 am - Permalink
Here is a version using a wave reference wave instead of a for loop
// Test function
// Creates a bunch of dummy waves
DFREF MyFolder=root:
Make/O/N=10 MyFolder:Wave1, MyFolder:Wave2, MyFolder:Wave3, MyFolder:Wave4, MyFolder:Wave5, MyFolder:Wave6
// Counts the number of waves in the MyFolder
Variable n=CountObjectsDFR(MyFolder, 1)
// Creates a list of all waves in the folder
Make/FREE/O/WAVE/N=(n) AllWaves=WaveRefIndexedDFR(MyFolder, p)
// Adds the note "1234" too all waves in the list
MultiThread AllWaves[]=AddWaveNote("1234", AllWaves[p])
end
ThreadSafe Function/WAVE AddWaveNote(MyNote, MyWave)
// Adds MyNote to MyWave
String MyNote
Wave MyWave
// Adds the note to the wave
Note/K MyWave, MyNote
// Returns the wave. This is needed because of how the mulithreading is done
Return MyWave
end
July 25, 2021 at 03:44 am - Permalink