#R = 625 nm, G = 525 nm, B = 460 nm - we use B = 420nm for this example because the far field pattern has more structure
clear; closeall;
loaddata("example_farfields_for_zemax_export.ldf");
polarimage(ux,uy,E2_red,"","","Red");
polarimage(ux,uy,E2_green,"","","Green");
polarimage(ux,uy,E2_blue,"","","Blue");
plot( asin(ux)*180/pi,
0.5*sqrt(eps0/mu0)*pinch(E2_blue,2,find(uy,0)),
0.5*sqrt(eps0/mu0)*pinch(E2_green,2,find(uy,0)),
0.5*sqrt(eps0/mu0)*pinch(E2_red,2,find(uy,0)),
"angle (degrees)","Radiance (Watts/m2/steradian)","Radiance","linewidth=2");
legend("Blue","Green","Red");
?Power_Red = 0.5*sqrt(eps0/mu0)*farfield3dintegrate(E2_red,ux,uy);
?Power_Green = 0.5*sqrt(eps0/mu0)*farfield3dintegrate(E2_green,ux,uy);
?Power_Blue = 0.5*sqrt(eps0/mu0)*farfield3dintegrate(E2_blue,ux,uy);
Ncopies = 6; # number of copies of the rays to be written
# actual number of rays is Ncopies * pi/4* length(ux)*length(uy)
frequency = f_red;
Total_radiated_power = 1; # in Watts
xspan = 0.25e-3;
yspan = 0.4e-3;
radiant_intensity = E2_red;
export_filename = "zemax_patterned_rayset_red.txt";
zemax_rayset_farfield_write_v1;
frequency = f_green;
Total_radiated_power = Power_Green/Power_Red; # in Watts
radiant_intensity = E2_green;
export_filename = "zemax_patterned_rayset_green.txt";
zemax_rayset_farfield_write_v1;
frequency = f_blue;
Total_radiated_power = Power_Blue/Power_Red; # in Watts
radiant_intensity = E2_blue;
export_filename = "zemax_patterned_rayset_blue.txt";
zemax_rayset_farfield_write_v1;