Difference between revisions of "Igor Code"

From Jimenez Group Wiki
Jump to: navigation, search
(Regridding a Wave into the Time Axis of Another Wave)
(Regridding a Wave into the Time Axis of Another Wave)
Line 9: Line 9:
  
 
Function Interp_1 ()  
 
Function Interp_1 ()  
<br> Wave xwave1, ywave1, xwave2 //ywave2 is not used  
+
: Wave xwave1, ywave1, xwave2 //ywave2 is not used  
<br> duplicate/o xwave2 ywave_regrid  
+
: duplicate/o xwave2 ywave_regrid  
<br> ywave_regrid = ywave1 [binarysearchinterp(xwave1, xwave2[p])]  
+
: ywave_regrid = ywave1 [binarysearchinterp(xwave1, xwave2[p])]  
<br> appendtotable ywave_regrid  
+
: appendtotable ywave_regrid  
<br>End Function
+
End Function
 +
 
  
 
Function Interp_2 ()  
 
Function Interp_2 ()  
<br> Wave xwave1, ywave2, xwave2  
+
: Wave xwave1, ywave2, xwave2  
<br> duplicate/o xwave1 ywave_regrid  
+
: duplicate/o xwave1 ywave_regrid  
<br> ywave_regrid = ywave1 [fAverageXY(xwave2, xwave1, xwave2[p-1], xwave2[p])]  
+
: ywave_regrid = ywave1 [fAverageXY(xwave2, xwave1, xwave2[p-1], xwave2[p])]  
<br>End Function
+
End Function
  
 
Compiled by Qi Zhang and Alex Huffman, 2004.
 
Compiled by Qi Zhang and Alex Huffman, 2004.

Revision as of 16:32, 17 June 2009

The objective of this page is to serve a repository of useful Igor code that we keep needing for different applications. Feel free to add new code or to comment on existing code, but please don't delete old code w/o discussing with Jose.

Regridding a Wave into the Time Axis of Another Wave

To regrid a wave into another framework, use the following functions. For example you might have one curve, defined by a certain x- and y-wave (xwave1, ywave1). Let's say there are 10 points in these waves, and the maximum is 20 (and extreme case of length discrepancy). Another curve is defined by two other x- and y-waves, also with a maximum of 20, but with 20 points each (xwave2, ywave2). It is important that they have approximately the same bound values, or it will have a hard time interpolating between them.

If I want to look at the first curve in terms of the second x-wave, you have to regrid the first y-wave into the x-wave of the second. This can be done in two ways, and that is dependent on which inintial set of waves has more data points. If the wave you want to regrid into has more points than the original, then use the first of these functions (Interp_1). If the opposite is true (wave you want to regrid to has less points) use the second function (Interp_2). They can be run as is, after changing the wave names appropriately. The [p] refers to each point, and should stay with this syntax (replacing it with a number refers only to that specified cell).

Function Interp_1 ()

Wave xwave1, ywave1, xwave2 //ywave2 is not used
duplicate/o xwave2 ywave_regrid
ywave_regrid = ywave1 [binarysearchinterp(xwave1, xwave2[p])]
appendtotable ywave_regrid

End Function


Function Interp_2 ()

Wave xwave1, ywave2, xwave2
duplicate/o xwave1 ywave_regrid
ywave_regrid = ywave1 [fAverageXY(xwave2, xwave1, xwave2[p-1], xwave2[p])]

End Function

Compiled by Qi Zhang and Alex Huffman, 2004.