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
But whenever I fit a data set (that I can plot by PlotXY procedure) to a Gaussian and then tried to plot the fitted wave set (fit_wave1.d and fit_wave1.x) the PlotXY code does not work..its give a error " expected wave name"..
Can anybody tell me how to solve this.
#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
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
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 24, 2012 at 10:11 am - Permalink
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 ?
June 24, 2012 at 12:39 pm - Permalink
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
June 24, 2012 at 04:04 pm - Permalink
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 )
June 24, 2012 at 08:51 pm - Permalink
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 y1
instead.June 25, 2012 at 02:44 am - Permalink
Display x1
Display y2 vs x1
I kept both
Display y2 vs x1
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
July 10, 2012 at 07:01 pm - Permalink
With your current code, you could use
WaveExists
to check if there is a second wave. Like so:Display x1 vs y2
else
Display x1
endif
But it would also be possible to see if a second wave was selected in the first place:
if (V_startCol == V_endCol) // look if only one col is selected
// process one wave
Wave x1 = WaveRefindexed(tableName, V_startCol, 1)
Display x1
else
// process two waves
Wave x1 = WaveRefindexed(tableName, V_startCol, 1)
Wave y2 = WaveRefindexed(tableName, V_endCol, 1) // use end col directly
// this way they don't need to be adjacent
// you still would need to have them in the right order
Display y2 vs x1
endif
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.
July 11, 2012 at 02:00 am - Permalink
July 11, 2012 at 07:32 pm - Permalink