Time-Domain Spectroscopy Tools
Basics of THz spectroscopy
Installation
PacletRepositories[{
Github -> "https://github.com/JerryI/wl-tds-tools" -> "master"
}]
Get["JerryI`TDSTools`Trace`"];
Get["JerryI`TDSTools`Transmission`"];
Get["JerryI`TDSTools`Material`"];
Let's get started
(*BB[*)(*asumming you imported it somehow*)(*,*)(*"1:eJxTTMoPSmNhYGAo5gcSAUX5ZZkpqSn+BSWZ+XnFaYwgCS4g4Zyfm5uaV+KUXxEMUqxsbm6exgSSBPGCSnNSg9mAjOCSosy8dLBYSFFpKpoKkDkeqYkpEFXBILO1sCgJSczMQVYCAOFrJEU="*)(*]BB*)
ref = NotebookStore["ref"];
sam = NotebookStore["sam"];
ListLinePlot[{sam, ref}, PlotRange->Full, AxesLabel->{"t, ps", "I, nA"}]
sam = TDTrace[QuantityArray[sam, {"Picoseconds", 1}]];
ref = TDTrace[QuantityArray[ref, {"Picoseconds", 1}]]
sam["Properties"] // TableForm
ListLinePlot[sam["PowerSpectrum"], PlotRange->Full]
sam["FDCI"]
Reconstructing transmission function
tr = TransmissionObject[sam, ref, "Thickness"->Quantity[0.584994, "Millimeters"]]
utr = TransmissionUnwrap[tr, "Basic", "PhaseThreshold"->5.3]
ListLinePlot[{tr["Phase"], utr["Phase"]}, PlotLegends->{"Wrapped", "Unwrapped"}]
Material Parameters
m1 = MaterialParameters[utr, "FabryPerotCancellation"->False]
ListLinePlot[{
MaterialParameters[
Append[utr, "PhaseShift"->0]
, "FabryPerotCancellation"->False]["n"]
,
MaterialParameters[
Append[utr, "PhaseShift"->-2]
, "FabryPerotCancellation"->False]["n"]
}, PlotRange->{{20,100}, {3.5,5.5}}, PlotLegends->{"PhaseShift = 0", "PhaseShift = -2"}]
ListLinePlot[m1["k"], PlotRange->{{10,100}, {-0.03,0.2}}]
Fabry-Perot Cancellation
{fp, nofp} = {
MaterialParameters[
Append[utr, "PhaseShift"->-2]
, "FabryPerotCancellation"->False]
,
MaterialParameters[
Append[utr, "PhaseShift"->-2]
, "FabryPerotCancellation"->True]
};
ListLinePlot[{fp["k"], nofp["k"]}, PlotRange->{{10,100}, {-0.03,0.2}}, PlotLegends->{"FP", "no FP"}]
#["FPReduction"] &/@ {fp, nofp}
Thickness and Gain correction
map = Table[With[{
t = Append[utr, {"PhaseShift"->-2, "Gain"->gain, "Thickness"->Quantity[thickness,"Millimeters"]}]
},
{thickness, gain, t}
], {thickness, 0.585-0.1, 0.585+0.1, 0.02}, {gain, 0.8, 1.2, 0.1}];
map = Flatten[map, 1];
map[[All,3]] = #["FPReduction"] &/@ MaterialParameters[map[[All,3]], "Target"->"CPU"];
ListContourPlot[map, PlotLegends->Automatic]
map = Table[With[{
t = Append[utr, {"PhaseShift"->-2, "Gain"->gain, "Thickness"->Quantity[thickness,"Millimeters"]}]
},
{thickness, gain, t}
], {thickness, 0.585-0.15, 0.585+0.15, 0.01}, {gain, 0.7, 1.2, 0.02}];
map = Flatten[map, 1];
map[[All,3]] = #["FPReduction"] &/@ MaterialParameters[map[[All,3]], "Target"->"GPU"];
ListContourPlot[map, PlotLegends->Automatic]
optimized = MaximalBy[map, Last] // First
With[{m = MaterialParameters[Append[utr, {
"Gain"->optimized[[2]],
"PhaseShift"->-2,
"Thickness" -> Quantity[optimized[[1]],"Millimeters"]
}]]},
ListLinePlot[{m["Raw \[Alpha]"], m["\[Alpha]"]}, PlotRange->{{10,100}, {-5,100}}, PlotLegends->{"Raw", "Processed"}]
]
Live calculations
Module[{
material,
plotA, plotB
},
{EventHandler[InputGroup[<|
"Phase" -> InputRange[-2,2,1, "Label"->"Phase shift"],
"Thickness" -> InputRange[0.5, 0.6, 0.005, "Label"->"Thickness"]
|>], Function[result,
material = MaterialParameters[
Append[utr, {"PhaseShift"->result["Phase"], "Thickness"->Quantity[result["Thickness"], "Millimeters"]}]
, "FabryPerotCancellation"->True, "Target"->"GPU"];
{plotA, plotB} = QuantityMagnitude /@ {material["Best Raw \[Alpha]"], material["Best \[Alpha]"]};
]] // EventFire,
Graphics[{ColorData[97][1], Line[plotA//Offload], ColorData[97][2], Line[plotB//Offload]}, Frame->True, Axes->True]
} // Row
]