Save wave "tweak" preferences; perform an action for each loaded wave
hmayes
Two questions:
1) How do I make using the "space" delimiter character a default? I currently go to Load Data > Tweaks and check this option, but Igor resets to the default (unchecked "spaces") when I reopen.
2) I will many times want to open a data file with different numbers of columns, and then perform the same actions on every loaded wave (histogram, then graph). The wave names will be read from the first line of the data file, and will change from one file to the next. Is there a syntax for doing someone on every wave loaded?
Thank you,
-Heather
You can not make it the default but you can execute this or create a user-defined function to execute it:
You might want to create a file loader function that incorporates this. For an example, see http://www.igorexchange.com/node/3054.
The example also answers your second question. Read the comments to see how it works.
May 16, 2012 at 03:52 pm - Permalink
This is just wonderful. The comments you included really help, too.
I have a follow-up newbie questions: how do get Igor to plot all the resulting histograms on one plot? Of course, I'll be altering the colors of each histogram to make them look distinct.
Thank you,
-Heather
May 17, 2012 at 07:50 am - Permalink
Add a parameter named index to ProcessWave. In ProcessWave, change the call to Display to this:
Display dest
else
AppendToGraph dest
endif
Then in LoadSpaceDelimitedFile, in the call to ProcessWave, add i as the second parameter.
Here is a function that returns a color given an index: http://www.igorexchange.com/node/3056
You can use it in ProcessWave like this:
GetIndexedRGBColor(index, red, green, blue)
ModifyGraph rgb($destWaveName)=(red, green, blue)
May 17, 2012 at 09:17 am - Permalink
Variable i
For(i = 0; i < nwaves; i += 1)
String wavename = StringFromList(i, listofwaves)
AppendToGraph/W=<name of graph> $wavename
endfor
This pseudo-code assumes that you are plotting waveforms (not XY pairs of waves). That would be appropriate for histograms.
I used a string containing a list of wave names, but you might have a wave reference from another source. It would be tempting to write one loop that both makes the histogram and adds the histogram wave to the graph. When I have done such things in the past, I usually regret it and wind up putting in extra effort at a later time to separate analysis from display. It's easier to make the separation from the start.
That means you would write a function that processes all the histograms, perhaps returning a string containing a list of histogram waves. Then pass that list to a function that makes the graph you want.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
May 17, 2012 at 09:24 am - Permalink
John is right (as usual:).
I have created a snippet showing how to break this up into three tasks: loading, processing and displaying.
May 18, 2012 at 04:41 pm - Permalink
-Heather
May 22, 2012 at 06:55 am - Permalink