Simple Plot routine ( ywave vs x wave) from Table does not work on the Fitted ( fit_wave1.d vs fit_wave1.x ) data set
| supra | June 23, 2012 - 21:14 | ||||||
|---|---|---|---|---|---|---|---|
|
This code plot ywave vs xwave from a table (mark/select the wave/data sets in the table by mouse and then click "Plot XY" menu) #pragma rtGlobals=1 // Use modern global access method. Menu "Plot XY" "Simple Plot Select XY Pair A/1", SimplePlot(0) End Function SimplePlot(AorB) Variable AorB // 0 for A, 1 for B String tableName = WinName(0, 2,1) if (strlen(tableName) == 0) Abort "There are no tabels" endif GetSelection table, $tableName, 1 //Get selection row and column indices Variable startColumn = V_startCol //Index of first selected column - assumed to be x wave //First selected column is assumed to be x1 Wave x1 = WaveRefindexed(tableName, startColumn, 1) //Second column after first selected column is assumed to be y2 Wave y2 = WaveRefindexed(tableName, startColumn+1, 1) Display y2 vs x1 End
|
|||||||

Joined: 2007-07-19
Location: United States
The fitted result is not an XY Pair of waves; it is one wave with the x part as "wave scaling".
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Joined: 2011-08-10
Location: United States
Hi Jim..Thanks
How can I generate two wave ( wave0, wave 1) from this this single wave with two column ...and then can use the same plot routine...ort may there is some other way ?
Joined: 2007-07-19
Location: United States
You'd need to check the column name for ending with ".x" and not try to plot that column; just plot the other column using "Display y2".
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
Joined: 2011-08-10
Location: United States
So if I try to plot by " Display fit_wave1 " then it works....but
1. How I extract column name "fit_wave1" from the wave data " fit_wave1.d" ?
the command " Wave y2 = WaveRefindexed(tableName, startColumn+1, 1) " does define a wave ..but the fit_wave1.d is already defined as wave..
Somehow I dont fully understand how to extract column name from 1D waveform with data and scaling attached...--. d ---. x )
Joined: 2010-05-14
Location: Germany
You could make a new wave and then insert the scaling of fit_wave1 to have a separate x wave. Like so (this wave has to be of course of the same size as the fit-wave):
fit_wave1_x = DimOffset(fit_wave1,0) + p*DimDelta(fit_wave1,0)But why would you want to do that? I'd suggest you modify the code to accept scaled 1D-waves, since this is the normal way for data in Igor. Actually, I would try to bring the original data in this format to avoid a lot of hassle (assuming the x wave is evenly spaced, and even if not you could always go for interpolate), but thats maybe personal preference. But anyway, in the current state the code is very prone to errors since its assuming a lot (wave has to be XY, data was selected in the right order, x and y data directly adjacent, etc.). You could use more of the information which GetSelection provides, at least V_endcol. This way, it would also be very easy to check for scaled data and have just
Display y1instead.Joined: 2011-08-10
Location: United States
Thanks Chozo ... extremely sorry for writing so late...just took me some time to come back and again started coding in Igor...indeed you are right...I should change the code...but for time being I used display command for plotting of wave data ...I changed it to
I kept both
so it works for both on XY and and also on wave...although on wave it does gives a error for Display y2 vs x1 command as it doesn’t find wave...
Its a kind of crude way ...but at least it works on both situation.
I don’t know how I can distinguish programmatically between XY ( individual wave) and waveform data and then can use either Display y2 vs x1 or Display x1..so I used both
Joined: 2010-05-14
Location: Germany
Hi Supra,
With your current code, you could use
WaveExiststo check if there is a second wave. Like so:But it would also be possible to see if a second wave was selected in the first place:
Hope this helps. There are more ways to get the information needed to distinguish cases. You may have your reasons to work with tables. But if it's only for the sake of selecting waves, it would be possible/much easier to skip this step and directly read selected waves from the data browser and work with them.
Joined: 2011-08-10
Location: United States
Thank you so much Chozo ...."WaveExists" worked perfectly...thanks a lot.