Hashmap based wave indexing
thomas_braun
UpdateIndex is used to create an index of all waves in the current folder.
Then FetchWave can be used to convert the wave name to a wave reference.
Example
variable numWaves = 1000
for(i = 0; i < numWaves; i+=1)
string wvName = "X_" + num2str(i)
Make/O/D $wvName
endfor
UpdateIndex
Make/O/I/N=(numWaves) indexWave
indexWave[] = abs(enoise(numWaves-1.0))
Wave/Z wv
for(i = 0; i < numWaves; i+=1)
wvName = "X_" + num2istr(indexWave[i])
FetchWave/L=wvName /DEST=wv
if(!WaveExists(wv))
printf "Error at %s\r", wvName
endif
endfor
for(i = 0; i < numWaves; i+=1)
string wvName = "X_" + num2str(i)
Make/O/D $wvName
endfor
UpdateIndex
Make/O/I/N=(numWaves) indexWave
indexWave[] = abs(enoise(numWaves-1.0))
Wave/Z wv
for(i = 0; i < numWaves; i+=1)
wvName = "X_" + num2istr(indexWave[i])
FetchWave/L=wvName /DEST=wv
if(!WaveExists(wv))
printf "Error at %s\r", wvName
endif
endfor
The experiment in the zip archive was then used to create the attached benchmark.
DO NOT USE THAT IN PRODUCTION CODE AS IT MIGHT FAIL HORRIBLY!
Forum
Support
Gallery
Igor Pro 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More
interesting XOP, might all go a bit wrong if someone kills a wave and your XOP tries to access it at a later stage. Still, you did mention it was a playground.
A.
August 2, 2013 at 12:07 am - Permalink
yes its definitly a proof-of-concept XOP. Involving HoldWave and ReleaseWave would be good idea if you want to delete waves between UpdateIndex and FetchWave.
Thomas
August 2, 2013 at 03:09 am - Permalink