Data analysis MZI

Data analysis MZI#

We analyze the following MZI samples from the edx course

MZI1: dL_wg=0

MZI2: r=5 dL_path = (208.40000 - 148.15000) * 2 dL_wg = dL_path + 2pir - 42r = 111.915

MZI3: r=5 dL_path = (259.55000-148.15000) * 2 dL_wg = dL_path + 2pir - 42r ; dL_wg = 214.215

MZI4: r1 = 435.90000-427.60000; r1 r2 = 10 dL_path = (259.55000-148.15000) * 2 dL_wg = dL_path + pi*(r1+r2) - 4*(r1+r2) ; dL_wg = 207.08945

MZI5: r1 = 556.35000-547.60000; r1 r2 = 10 dL_path = (259.55000-148.15000) * 2 dL_wg = dL_path + pi*(r1+r2) - 4*(r1+r2) ; dL_wg = 206.703125

MZI6: r=4 dL_path = (259.55000-148.15000) * 2 dL_wg = dL_path + 2pir - 42r ; dL_wg = 215.932

MZI8: r=3 dL_path = (259.55000-148.15000) * 2 dL_wg = dL_path + 2pir - 42r ; dL_wg = 217.649

MZI17: r=2 dL_path = (259.55000-148.15000) * 2 dL_wg = dL_path + 2pir - 42r ; dL_wg = 219.366

import matplotlib.pyplot as plt
import numpy as np

import ubcpdk
from ubcpdk.simulation.circuits.mzi_spectrum import mzi_spectrum
w, p = ubcpdk.data.read_mat(ubcpdk.PATH.mzi1, port=0)
plt.plot(w, p)
[<matplotlib.lines.Line2D at 0x7f9916c5e990>]
../_images/b46f8ec84994726d02e724bf3dc814d1a9818d9661a888dea73ef57de8397250.png

For some reason this MZI has an interference pattern. This is strange because the lengths of both arms are the same. This means that there was a strong height variation on the chip.

w, p = ubcpdk.data.read_mat(ubcpdk.PATH.mzi3, port=0)
plt.plot(w, p)
[<matplotlib.lines.Line2D at 0x7f9912bbd610>]
../_images/c3469eef2e1ccad46f6aa5e9e9981c5981f025d2947c6cdd5b74d0689eaf4003.png
wr = np.linspace(1520, 1580, 1200) * 1e-3
pr = mzi_spectrum(L1_um=0, L2_um=214.215, wavelength_um=wr)
plt.plot(wr * 1e3, 10 * np.log10(pr))
[<matplotlib.lines.Line2D at 0x7f9912767690>]
../_images/1d0b13aa720f7674e53e4d8281e15feeee0392223cd80d8f8449056b90f7081c.png
w, p = ubcpdk.data.read_mat(ubcpdk.PATH.mzi3, port=0)
pb = ubcpdk.data.remove_baseline(w, p)
plt.plot(w, pb)
[<matplotlib.lines.Line2D at 0x7f991230d210>]
../_images/146918d22d2a592eebf5b1492c283863aefbb667e20d3c8e1fd28fb4fe5bbaa3.png
plt.plot(w, pb, label="measurement")
plt.plot(wr * 1e3, 10 * np.log10(pr), label="analytical")
plt.legend()
<matplotlib.legend.Legend at 0x7f9912b3fed0>
../_images/be0c3a125e539f7b4480fbcf9dedd07294889131007dbd567dd8023921569ba0.png
ms.sweep_wavelength?
Object `ms.sweep_wavelength` not found.
from scipy.optimize import curve_fit

L1_um = 40
L2_um = L1_um + 215.932


def mzi_logscale(wavelength_um, alpha, n1, n2, n3):
    return 10 * np.log10(
        mzi_spectrum(
            L1_um=L1_um,
            L2_um=L2_um,
            wavelength_um=wavelength_um,
            alpha=alpha,
            n1=n1,
            n2=n2,
            n3=n3,
        )
    )


w, p = ubcpdk.data.read_mat(ubcpdk.PATH.mzi6, port=0)
wum = w * 1e-3
pb = ubcpdk.data.remove_baseline(w, p)

p0 = [1e-3, 2.4, -1, 0]
plt.plot(w, pb, label="data")
plt.plot(w, mzi_logscale(wum, *p0), label="initial condition")
plt.legend()
<matplotlib.legend.Legend at 0x7f9912388510>
../_images/778a0d5e7fc8fc2f83bd86f9a54f95085ea432fab716cc3439abd3449b9cf8b3.png
params, params_covariance = curve_fit(mzi_logscale, wum, pb, p0=[1e-3, 2.4, -1, 0])
params
array([ 0.00555726,  2.39711747, -1.01841085,  4.99322188])
plt.plot(w, pb, label="data")
plt.plot(w, mzi_logscale(wum, *params), label="fit")
plt.legend()
<matplotlib.legend.Legend at 0x7f9911f0ba50>
../_images/dd8473c6042598b640ed247baee815e3531c238433efd6d7deb20461e3fcf45f.png
L1_um = 40
L2_um = L1_um + 215.932


def mzi(wavelength_um, alpha, n1, n2, n3):
    return mzi_spectrum(
        L1_um=L1_um,
        L2_um=L2_um,
        wavelength_um=wavelength_um,
        alpha=alpha,
        n1=n1,
        n2=n2,
        n3=n3,
    )


w, p = ubcpdk.data.read_mat(ubcpdk.PATH.mzi6, port=0)
wum = w * 1e-3
pb = ubcpdk.data.remove_baseline(w, p)
pb_linear = 10 ** (pb / 10)

p0 = [1e-3, 2.4, -1, 0]
plt.plot(w, pb_linear, label="data")
plt.plot(w, mzi(wum, *p0), label="initial condition")
plt.legend()
<matplotlib.legend.Legend at 0x7f9911f9ba50>
../_images/b7ea748f7050a8236a3587bbacb5c1ccfb04a5328351a3280c1cd00109800795.png
params, params_covariance = curve_fit(mzi, wum, pb, p0=p0)
2024-04-12 23:31:07.783 | WARNING  | __main__:<module>:1 - OptimizeWarning: Covariance of the parameters could not be estimated
plt.plot(w, pb_linear, label="data")
plt.plot(w, mzi(wum, *params), label="fit")
plt.legend()
<matplotlib.legend.Legend at 0x7f991238b150>
../_images/bc09922d763690eb4ae15fabab8c7f472672468b5a228104bff031c8093443ff.png