%Faraday isolation measurements

%we are always measuring PD1/PD2 because we have PD1 plugged into chan 1
%and PD2 plugged into chanel 2

%starting with PD2 in pos A, plugged into channel 2 on 785 so these
%measurements are all PD2/PD1, with positions indicated by measurement name
%posA is incoming beam reflected off 50/50 BS
% pos B is beam transmitted by 50/50 before faraday
% pos C is after Faraday
% pos D is retroreflected beam off 50/50, which is measured with a HR
% mirror retroreflecting for isolation measurement and a beam dump for
% scatter measurement

%SR785 uses amplitude ratio dB
amp_dB2mag=@(db)10.^(db./10);

%measurements in dB
A2_over_B = -0.2475;
A2_over_C = 0.022; 
A2_over_D_HR = 51.2;
A2_over_D_BD = 74.6;

%PD1 is now in position A, still plugged into to channel one of 785
%, repeat all 4 measurements with this PD combo 
B_over_A1 = 0.217;
C_over_A1 = -0.094;
D_over_A1_HR = -51.2;
D_over_A1_BD = -75.1;

transFI1 = amp_dB2mag(A2_over_B-A2_over_C)
transFI2 = amp_dB2mag(C_over_A1-B_over_A1)

Iso1=A2_over_C-A2_over_D_HR
Iso2=D_over_A1_HR-C_over_A1

Backscatter1=A2_over_C-A2_over_D_BD
Backscatter2=D_over_A1_BD-C_over_A1

% transBS= 1/(1+sqrt(amp_dB2mag(A2_over_B)/amp_dB2mag(B_over_A1)))
% isolation = sqrt(amp_dB2mag(D_over_A1_HR)/amp_dB2mag(A2_over_D_HR))/(transBS*transFI1)
% isolation_dB=10*log10(isolation)
% backscatter = sqrt(amp_dB2mag(D_over_A1_BD)/amp_dB2mag(A2_over_D_BD))/(transBS)
% backscatter_dB = 10*log10(backscatter)
% with HR retroreflector in place,we measured the reflection off the black
% glass on the near TFP (that gets most of the power in this configuration)
% we had 3.09 mW into the Faraday and 233 uW coming off the glass




