Accessing two colum from two table (or two graph) and subtract them and plot a new graph
supra
Now what I want to do (programmatically) is
1) Take the 2nd column of first table and subtract it from the 2nd column of 2nd table and make a new column entry in any one of the table and plot the diff wave (2nd columa-2nd column) wrt 1st column of any one of the table.
2) Is there any way to cursor access the 2nd column of 1st table and then hold it in memory and then click on the 2nd column of the 2nd table to get the 2nd column name(wave name) and then subtract that two column (wave) and add it to one of the table and then plot it (diff of two 2nd column wave) wrt the 1st column.
3) Can it be done on the graph itself without accessing the table. Then first I need to add both the graphs in one graph programmatically ?
Is there any function that return the wave name once I click and highlight a column of a table
I thought various ways ...but none of them yet successful for example
I can get the wave name from the graph by WaveRefCursors()
Function
WAVE/Z w = CsrWaveRef(A)
if (!WaveExists(w)) // Cursor is not on any wave.
return NaN
endif
Variable xA = xcsr(A)
Variable xB = xcsr(B)
return xB
End
the question how I hold xb from first graph when I move to next graph.
Then if I can add two graph in one graph then probably I can also have wave reference function to operate on the waves displayed in a graph...I saw this function...then how to add two graph ( drag drop) in one. There is a ipd file in Igor exchange that does it ...but I dont have Igor6.2 ( mine is Igor 6.0 and that ipf file does not work).
Function SmoothWavesInGraph()
String list = TraceNameList("", ";", 1)
String traceName
Variable index = 0
do
traceName = StringFromList(index, list)
if (strlen(traceName) == 0)
break // No more traces.
endif
WAVE w = TraceNameToWaveRef("", traceName)
Smooth 5, w
index += 1
while(1)
End
I would really appreciate if somebody can give me a clue.
The code in the attached procedure file should give you some ideas but it is very simplified. When you try to create a slick user interface, you find that the UI takes far, far, far more time than the actual functional code because validating all of the input and keeping all the data straight is time consuming.
For a fully-worked out example of something similar to what you are doing, choose File->Example Experiments->Analysis->Wave Arithmetic Panel Demo. Read the notebook and do the tutorial. The Wave Arithmetic Panel might do what you need, in which case you won't need to do further programming.
January 20, 2012 at 05:46 pm - Permalink
2) Since I need to select 2 column ( x and Y ) each time ...so after the import data wave get loaded in the table ....and calculations are done ...my table has 3 column ( x1, y1, y2) and 2 graph ( Graph 1=y1 vs x1 and Graph 2:y2 vs x1 ) ..( see Fig attch ) then I have to select manually by cursor the (x1, y2) which are not side by side ....so I thought to swap the position of (x1, y1, y2) to (x1, y2, y1) in Table 1..so that I can select (x1, y2) but dont know how to do it. Other option is just to delete the y1 but then I first have to delete the graph 1 also and I want to still keep them. So how can I swap to have (x1, y1, y2) to (x1, y2, y1) in Table 1 ?
3) also as I am not using x1 at all ..so I thought why not use have option only to select y2 etc ...so I tried ( just removed the x wave save path, waves etc) and then....but it does not give proper y wave ( dont know why ? ) and since I also want to plot dif wave wrt x so I need a x wave ...so I tried to extract x wave from Table 2 ( 2nd data set : Top Table) but fails ..Other options that I used and work is that just to use the xwave from the saved path and use it to plot the "dif" vs xwave. So if I want to use only to select one column and to creat a x wave from top table ...
How usally a certain x wave is extracted from a Table ( Top Table) that has 3 column.. programmatically (using StringFromList(index, list) ?
//--------------------
/ if (numColumnsSelected != 1)
Abort "Select only one Y column"
endif
String yName = StringFromList(1, columnNameList)
yName = RemoveEnding(yName, ".d") // Convert column name to wave name
String yDF = StringFromList(1, dataFolderNameList)
String yPath = yDF + yName
if (AorB == 0)
String/G root:gSupraYWaveAPath=yPath // Save for future use
Printf "Y set to: %s", yPath
else
String/G root:gSupraYWaveBPath = yPath // Save for future use
Printf "Y set to: %s", yPath
endif
End
------------------------------------------------------------------------------------------
3) I am still looking in the Arithmetic panel..but it seems I still I need to learn more and will need more time to incorporate in my code.
January 22, 2012 at 09:40 am - Permalink
Manually, press the Alt key and drag the column label.
Programmatically you must remove the columns and append them in the right order.
However, I would revise the procedure to use the order that you have. I have attached a revised procedure that does this. Hopefully this will give you an idea of how you might approach this task.
January 22, 2012 at 03:33 pm - Permalink
I want to ask you another thing. I have a procedure file (testimport1.ipf --attached) that have some parameter variable (lamda, alpha etc ) inside that I need to change time to time depend upon the type of experimental import file.
Is is possible to write a another procedure file that will pass that value /or will modify the values of "lamda" , "alpha" etc in the first procedure file. How can I write a small window where it will allow me to type value of "lamda" and "alpha and whenever I click some button it will pass/modify that value in the first procedure file (testimport1.ipf). { may be will open, pass new values of lamda and alpha and recompile testimport1.ipf to get ready)
January 24, 2012 at 09:47 am - Permalink
constant alpha =652.3 // 652.3 is practical value of peak taken from spectrum. Depend on optical setting and changes often
Then in your code, refer to "lamda" and "alpha" just as if they were variables.
The most obvious thing is to add them as function parameters:
String fileName // Name of file to load or "" to get dialog
String pathName // Name of path or "" to get dialog
Variable lamda
Variable alpha
You can change them every time you run the function now. But you have to remember them and type them every time.
If they almost always have the same values, but sometimes you need something a bit different, you could make them optional parameters:
String fileName // Name of file to load or "" to get dialog
String pathName // Name of path or "" to get dialog
Variable lamda
Variable alpha
if (ParamIsDefault(lamda))
lambda = 803.506
endif
if (ParamIsDefault(alpha))
alpha = 652.3
endif
Now, if you simply leave out lambda and alpha they will get default values. If you include values in the function invocation they will override the defaults
Finally, you can create a Simple Input Dialog to make it easy to enter values. You can establish default values for the dialog. Read about Simple Input Dialog:
DisplayHelpTopic "The Simple Input Dialog"
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
January 24, 2012 at 02:16 pm - Permalink
January 25, 2012 at 08:59 am - Permalink