Save wave "tweak" preferences; perform an action for each loaded wave

Hello!

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
Quote:
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.


You can not make it the default but you can execute this or create a user-defined function to execute it:
LoadWave /J /V={" ", "", 0, 0}


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.
Howard,

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
Quote:
how do get Igor to plot all the resulting histograms on one plot?


Add a parameter named index to ProcessWave. In ProcessWave, change the call to Display to this:
if (index == 0)
    Display dest
else
    AppendToGraph dest
endif


Then in LoadSpaceDelimitedFile, in the call to ProcessWave, add i as the second parameter.

Quote:
I'll be altering the colors of each histogram to make them look distinct.


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:
    Variable red, green, blue
    GetIndexedRGBColor(index, red, green, blue)
    ModifyGraph rgb($destWaveName)=(red, green, blue)

To add a trace to a graph, use AppendToGraph. If I have a bunch of wave I want to display all on the same graph, I usually use a something like this:
    Display     // make an empty graph
    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
johnweeks wrote:
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.


John is right (as usual:).

I have created a snippet showing how to break this up into three tasks: loading, processing and displaying.


Thank you all very much. I've been using this now very often since your help, and it has been saving **so** much time and tedium. Everything works very well.
-Heather