Estimation of losses in the time reversal cavity

data=Import["/home/qitlab/Desktop/workspace/projects/fourwavemixing/data/time_reversal/cavity_linewidth/020114/cavity_TR_0.dat","Table"];

dataR=((data[[2800;;3500,2]])/(data[[2800;;3500,4]]));dataT=((data[[2800;;3500,3]])/(data[[2800;;3500,4]]));

dataR[[1]]

errorR=(0.032/(data[[2800;;3500,4]]));

dataplotR=ListLinePlot[dataR,PlotRange->All];

dataplotT=ListLinePlot[dataT,PlotRange->All];

fitR=1-((l ((((γ/2)))^2))/(((((γ/2)))^2)+(((x-x0))^2)));
fitT=b+((a((((γ/2)))^2))/(((((γ/2)))^2)+(((x-x0))^2)));

nlmR=NonlinearModelFit[dataR,fitR,{{l,0.1},{γ,200},{x0,350}},x,Weights->(1/errorR)];
nlmT=NonlinearModelFit[dataT,fitT,{{a,0.04},{b,0.01},{γ,200},{x0,350}},x];

nlmR["ParameterTable"]
nlmT["ParameterTable"]

fitplotR=Plot[fitR/.nlmR["BestFitParameters"],{x,0,700},PlotStyle->{Red,Thickness[0.002],Dashed}];
fitplotT=Plot[fitT/.nlmT["BestFitParameters"],{x,0,700},PlotStyle->{Red,Thickness[0.002],Dashed}];

p1=Show[{dataplotT,fitplotT}];
p2=Show[{dataplotR,fitplotR}];

GraphicsArray[{p1,p2}]

Length[dataR]

fitdata=Transpose[{Table[i,{i,-360,340,1}],dataR}];

Needs["ErrorBarPlots`"]

pl1=ErrorListPlot[Transpose[{fitdata,Map[ErrorBar,errorR]}]];

r1=(Sqrt[0.941]);t1=(Sqrt[0.059]);r2=(Sqrt[0.9982]);t2=(Sqrt[0.0006]);L=0.055;α=(Sqrt[1]);c=3 (10^8);

xr=r1-(((t1^2) r2 (α^2) (E^(I  ((2 L ω  )/c))))/(1-(α^2) r1 r2 (E^(I (( 2 L ω  )/c))))) ;xt=((t1 t2 α (E^(I ((ω L)/c))))/(1- (α^2)r1 r2 (E^(I ((2 ω L)/c)))));

nlm=NonlinearModelFit[fitdata,((Abs[xr])^2)/.{δ->2400},{{α1,0.9997}},ω,PrecisionGoal->10000000]

nlm["ParameterTable"]

nlm["BestFitParameters"]

pl2=Plot[((Abs[xr])^2)/.{α1->0.9997,δ->2400},{ω,-400,400}];

Show[{pl1,pl2}]

xlabel=Graphics[Text[Style["Detuning from cavity resonance (MHz)",FontFamily->"Helvetica",FontSize->13,PrivateFontOptions->{"OperatorSubstitution"->False}],{0,0}],ImageSize->600,AspectRatio->1/15];

plotTR=GraphicsArray[{Plot[{((Abs[xr/.{ω->2 π ν (10^6)}])^2)},{ν,-100,100},PlotRange->All,PlotStyle->{Red,Thickness[0.003]},AxesLabel->{"",Style["Cavity Reflection %",FontFamily->"Helvetica",FontSize->13,PrivateFontOptions->{"OperatorSubstitution"->False}]},AspectRatio->1,ImageSize->220,TicksStyle->Directive[FontFamily->"Helvetica",FontSize->13,PrivateFontOptions->{"OperatorSubstitution"->False}]],Plot[Arg[xr/.{ω->2 π ν (10^6)}],{ν,-200,200},PlotRange->All,PlotStyle->{Blue,Thickness[0.003]},AxesLabel->{"",Style["Phase Shift (Radians)",FontFamily->"Helvetica",FontSize->13,PrivateFontOptions->{"OperatorSubstitution"->False}]},AspectRatio->1,ImageSize->220,TicksStyle->Directive[FontFamily->"Helvetica",FontSize->13,PrivateFontOptions->{"OperatorSubstitution"->False}]]}];

GraphicsColumn[{plotTR,xlabel},Spacings->-100]

Export["/home/qitlab/Dropbox/time_reversal/figure2.eps",GraphicsColumn[{plotTR,xlabel},Spacings->-100],"EPS"]

Transformation of Exponential rising pulse using the above cavity (with losses)

τ=5.9 (10^(-9));δτ=0.1 (10^(-9));

f=Table[{t,(E^((-t)/τ)) UnitStep[t] },{t,-(10^(-6)),(10^(-6)),0.1 (10^(-9))}];(* (1.5/(2 π)) MHz per point in DFT *)

p3=ListLinePlot[((f[[All,2]])^2),PlotRange->{{9700,10300},{0,1}},PlotStyle->{Blue,Thickness[0.002]}];

ft=Fourier[f[[All,2]]];

ft1=ft;ft2=ft;

For[i=1,i≤10000,i++,
ft1[[i]]=ft[[i]] xr/.{ω->i 1.5 (10^6)};
]
For[i=10001,i≤20001,i++,
ft1[[i]]=ft[[i]] xr/.{ω->(i-20001)1.5 (10^6)};
]

ift1=InverseFourier[ft1];

p4=ListLinePlot[((Abs[InverseFourier[ft1]])^2),PlotRange->{{9800,10300},{0,1}},PlotStyle->{Red,Thickness[0.002]}];

GraphicsArray[{p3,p4}]