Save wave "tweak" preferences; perform an action for each loaded wave
| hmayes | May 16, 2012 - 12:11 | ||
|---|---|---|---|
|
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, |
|||

Joined: 2007-06-21
Location: United States
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.
Joined: 2012-05-16
Location: United States
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
Joined: 2007-06-21
Location: United States
Add a parameter named index to ProcessWave. In ProcessWave, change the call to Display to this:
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:
Joined: 2007-06-29
Location: United States
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:
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
Joined: 2007-06-21
Location: United States
John is right (as usual:).
I have created a snippet showing how to break this up into three tasks: loading, processing and displaying.
Joined: 2012-05-16
Location: United States
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