
Average all traces between marquee limits

Goure
You can see from the comments that I have tried a number of things. The version left in the actual code is the version that works for some traces, but not the for the waves with more indices (other versions I've tried mess up the placement of all tags). Any ideas?
I think the problem is that I can't figure out how to tell the Tag command what XWave to use when placing the tag. The only thing I can guess after reading through help files is that I need to declare an XY pair or do something with X scaling of the Y wave (those might be the same thing, I'm just unfamiliar with that part of Igor), but my X waves are not evenly spaced so I don't know if I can set a scale or not.
Thanks for the help.
Menu "GraphMarquee" "-" "Average the data", /Q, AveragetheData() End Function AveragetheData() GetMarquee left,bottom variable leftindex,rightindex,avgIndex,ii=0 string TraceList,TraceName,TraceYName,TraceXName,tagName="tag" //,tagPosName="tagPos" TraceList=TraceNameList("",";",5) // bit 5 mean include normal and contour traces and omit hidden traces // TraceList=SortList(TraceList,";",1) do // loop over however many traces are on the plot TraceName=StringFromList(ii,TraceList) if(strlen(TraceName)==0) break endif //do something with tracename // print TraceName // print StringByKey("XWAVE",TraceInfo("",TraceName,0)) // print StringByKey("XWAVEDF",TraceInfo("",TraceName,0)) // Need to fix the fact that some traces have #1 or #2 etc behind them and this makes using them as wave names fail // sscanf TraceName, "%s%*[#]%f",TraceYName,dummyNum // print TraceYName // SplitString/E="*#" TraceName // Print S_value // this is not really a good solution, but should work for now // print ReplaceString("#1",TraceName,"") TraceYName=ReplaceString("#1",TraceName,"") TraceYName=ReplaceString("#2",TraceYName,"") // hopefully no more than this TraceXName = StringByKey("XWAVE",TraceInfo("",TraceName,0)) SetDataFolder StringByKey("XWAVEDF",TraceInfo("",TraceName,0)) FindLevel/Q $TraceXName,V_left leftindex=V_LevelX FindLevel/Q $TraceXName,V_right rightindex=V_LevelX avgIndex=(leftIndex+rightIndex)/2 // avgIndex=(V_left+V_right)/2 // print avgIndex WaveStats/Q/R=[leftindex,rightindex] $TraceYName // save results in variables/waves ? tagName+=num2str(ii) // tagPosName+=num2str(ii) // wave traceX=$TraceXName // tagPosition=traceX[avgIndex] // variable $tagPosName // variable tagPosition=$tagPosName // tagPosition=avgIndex // variable tagPosition // tagPosition=traceX[avgIndex] Tag/C/N=$tagName/F=0/L=1/TL=0 $TraceName, avgIndex,TraceName+" = "+num2str(V_avg) // even though avgIndex is correct, Tag is assigning things to the Dp wave instead of the longer fitX waves ii+=1 while(1) // exit via break statement End // AveragetheData
Suggestions are welcomed! You'll see in the comments that I still am not doing everything completely elegantly.
March 5, 2013 at 12:01 am - Permalink