# Name: usr_curved_monitor.lsf # Description: This file shows how to use the interpolation # function to get field data along an arbitrary # path. clear; closeall; # get original data m="field"; x=getdata(m,"x"); y=getdata(m,"y"); E2=getelectric(m); E2=pinch(E2); E2=log10(E2); # It is easier to compare plots if we look at log10(E2) # plot 2D data image(x*1e6,y*1e6,E2,"x (um)","y (um)","log10(E^2)"); # Define new x,y corrdinates along a line from -5,-5 to 5,5 n=51; xnew=linspace(-5e-6,5e-6,n); ynew=linspace(-5e-6,5e-6,n); pos= xnew/abs(xnew+1e-15) * sqrt(xnew^2 + ynew^2); # 1e-15 avoids /0 errors # interpolate field data onto this line E2line=matrix(n); for (i=1:n) { E2line(i)=interp(E2,x,y,xnew(i),ynew(i)); } plot(xnew*1e6,ynew*1e6,"x (um)","y (um)","straight path line"); plot(pos*1e6,E2line,"position (um)","log10(E^2)","straight path data"); # Define new x,y corrdinates along semi-circle centered at # 1,0 um with a radius of 4um n=50; theta=linspace(0,pi,n); r=matrix(n)+4e-6; x0=1e-6; y0=0; xnew=x0+r*cos(theta); ynew=y0+r*sin(theta); # interpolate field data onto this line E2line=matrix(n); for (i=1:n) { E2line(i)=interp(E2,x,y,xnew(i),ynew(i)); } plot(xnew*1e6,ynew*1e6,"x (um)","y (um)","curved path line"); plot(theta*180/pi,E2line,"angle (deg)","log10(E^2)","curved path data");