Exemplo n.º 1
0
        sigmas = absorp.get_cross_section(omegas)
        x_data.append(lambdas)
        y_data.append(sigmas)
        dopant_name = dopant[0].upper() + dopant[1:]
        plot_titles.append(
            'Cross sections {} from formula'.format(dopant_name))

    for i, file in enumerate(files):
        nbr_samples = 1000
        lambdas = np.linspace(file_range[i][0], file_range[i][1], nbr_samples)
        omegas = Domain.omega_to_lambda(lambdas)
        file_name = folder + file + '.txt'
        predict = CSVFit(file_name=file_name, conv_factor=[1e9, 1e18])  # in nm
        absorp = Absorption(predict=predict)
        sigmas = absorp.get_cross_section(omegas)
        x_data.append(lambdas)
        y_data.append(sigmas)
        dopant_name = file[0].upper() + file[1:]
        plot_titles.append(
            'Absorption cross sections {} from data file'.format(dopant_name))

    plot.plot(x_data,
              y_data,
              x_labels=['Lambda'],
              y_labels=['sigma_a'],
              split=True,
              plot_colors='red',
              plot_titles=plot_titles,
              plot_linestyles='-.',
              opacity=0.0)
Exemplo n.º 2
0
    beta_2 = Dispersion.calc_beta_deriv(omega, 2, "SiO2")
    x_data = [Lambda]
    y_data = [beta_2]

    x_labels = ['Lambda']
    y_labels = ['beta2']
    plot_titles = ["Group velocity dispersion coefficients in Silica"]

    disp = Dispersion.calc_dispersion(Lambda, beta_2)
    x_data.append(Lambda)
    y_data.append(disp)
    x_labels.append('Lambda')
    y_labels.append('dispersion')
    plot_titles.append('Dispersion of Silica')

    beta_3 = Dispersion.calc_beta_deriv(omega, 3, "Sio2")
    slope = Dispersion.calc_dispersion_slope(Lambda, beta_2, beta_3)
    x_data.append(Lambda)
    y_data.append(slope)
    x_labels.append('Lambda')
    y_labels.append('dispersion_slope')
    plot_titles.append('Dispersion slope of Silica')

    plot.plot(x_data,
              y_data,
              x_labels=x_labels,
              y_labels=y_labels,
              plot_titles=plot_titles,
              split=True,
              opacity=0.0)
Exemplo n.º 3
0
        CSVFit


    lt = layout.Layout(domain.Domain(samples_per_bit=512,bit_width=20.0))
    pulse = gaussian.Gaussian(channels=2, peak_power=[10.0, 10e-1],
                              width=[1.0, 5.0], center_lambda=[1050.0, 1048.0])
    gamma_data = CSVFit('./data/gamma_test.txt')
    fiber = Fiber(length=.10, method="ssfm_symmetric", alpha=[0.046],
                  alpha_order=4, beta_order=4, gamma=1.5,
                  nl_approx=False, ATT=True, DISP=True,
                  SPM=True, XPM=False, SS=False, RS=False, approx_type=1,
                  steps=1000, medium='sio2')
    lt.link((pulse[0], fiber[0]))
    lt.run(pulse)

    x_datas = [pulse.fields[0].nu, fiber.fields[1].nu,
               pulse.fields[0].time, fiber.fields[1].time]

    y_datas = [spectral_power(pulse.fields[0].channels),
               spectral_power(fiber.fields[1].channels),
               temporal_power(pulse.fields[0].channels),
               temporal_power(fiber.fields[1].channels)]

    x_labels = ['nu', 'nu', 't', 't']
    y_labels = ['P_nu', 'P_nu', 'P_t', 'P_t']
    plot_titles = ["Original Pulse", "Pulse at the end of the fiber"]
    plot_titles.extend(plot_titles)

    plot.plot(x_datas, y_datas, x_labels = x_labels, y_labels = y_labels,
              plot_titles=plot_titles, plot_groups=[0,1,2,3], opacity=0.3)
Exemplo n.º 4
0
                                          n_clad=n_clad))

    effective_area = EffectiveArea(core_radius=core_radius, NA=NA)
    print(effective_area(omega))
    print(
        EffectiveArea.calc_effective_area(omega,
                                          core_radius=core_radius,
                                          NA=NA))

    # With numpy ndarray
    lambdas = np.linspace(900, 1550, 100)
    omegas = Domain.lambda_to_omega(lambdas)
    n_core = np.linspace(1.42, 1.43, 100)
    n_clad = np.linspace(1.415, 1.425, 100)
    NA = NumericalAperture.calc_NA(n_core, n_clad)

    effective_area = EffectiveArea(core_radius=core_radius, NA=NA)
    res = effective_area(omegas)

    x_labels = ['Lambda']
    y_labels = ['Effective Area']
    plot_titles = ["Effective Area as a function of the wavelength"]

    plot.plot(lambdas,
              res,
              x_labels=x_labels,
              y_labels=y_labels,
              plot_titles=plot_titles,
              opacity=0.0,
              y_ranges=[2.5 * 1e-20, 3.5 * 1e-20])
Exemplo n.º 5
0
    arms = 3
    ratios = [round(random.uniform(0, 1), 2) for i in range(arms)]
    divider = IdealDivider(arms=arms, ratios=ratios, save=True)

    lt.link((pulse[0], divider[0]))

    lt.run(pulse)

    plot_titles = ([
        "Original pulse", "Pulses coming out of the {} with "
        "ratios {}".format(default_name, str(ratios))
    ])
    plot_groups: List[int] = [0] + [1 for i in range(arms)]
    plot_labels: List[Optional[str]] = [None]
    plot_labels.extend(["port {}".format(str(i)) for i in range(arms)])

    fields = [temporal_power(pulse.fields[0].channels)]
    times = [pulse.fields[0].time]
    for i in range(1, arms + 1):
        fields.append(temporal_power(divider.fields[i].channels))
        times.append(divider.fields[i].time)

    plot.plot(times,
              fields,
              plot_groups=plot_groups,
              plot_titles=plot_titles,
              x_labels=['t'],
              y_labels=['P_t'],
              plot_labels=plot_labels,
              opacity=0.3)
Exemplo n.º 6
0
        pump.fields[0].time, fiber.fields[1].nu, fiber.fields[1].time
    ]
    y_datas = [
        spectral_power(pulse.fields[0].channels),
        spectral_power(pump.fields[0].channels),
        temporal_power(pulse.fields[0].channels),
        temporal_power(pump.fields[0].channels),
        spectral_power(fiber.fields[1].channels),
        temporal_power(fiber.fields[1].channels)
    ]
    x_labels = ['nu', 'nu', 't', 't', 'nu', 't']
    y_labels = ['P_nu', 'P_nu', 'P_t', 'P_t', 'P_nu', 'P_t']

    plot.plot(x_datas,
              y_datas,
              x_labels=x_labels,
              y_labels=y_labels,
              plot_groups=[0, 0, 1, 1, 2, 3],
              opacity=0.3)

    x_data_raw = np.linspace(0.0, length, steps)
    x_data = np.zeros((0, len(x_data_raw)))
    for i in range(nbr_ch_s + 2 + nbr_ch_p):
        x_data = np.vstack((x_data, x_data_raw))

    x_data = [x_data, x_data_raw.reshape((1, -1))]

    power_signal = fiber.power_signal_forward + fiber.power_signal_backward
    power_ase_forward = np.sum(fiber.power_ase_forward, axis=0)
    power_ase_backward = np.sum(fiber.power_ase_backward, axis=0)
    power_pump = fiber.power_pump_forward + fiber.power_pump_backward
    powers = np.vstack(
Exemplo n.º 7
0
    channels = 3
    center_lambda = [1552.0, 1549.0, 1596.0]
    position = [0.3, 0.5]
    width = [5.3, 6]
    peak_power = [1e-3, 2e-3, 6e-3]
    bit_rate = [0.03, 0.04]
    offset_nu = [1.56, -1.6]
    chirp = [0.5, 0.1]
    init_phi = [1.0, 0.0]

    sech = Sech(channels=channels,
                center_lambda=center_lambda,
                position=position,
                width=width,
                peak_power=peak_power,
                bit_rate=bit_rate,
                offset_nu=offset_nu,
                chirp=chirp,
                init_phi=init_phi,
                save=True)

    lt.run(sech)

    plot.plot([sech.fields[0].time, sech.fields[0].nu], [
        temporal_power(sech.fields[0].channels),
        spectral_power(sech.fields[0].channels)
    ], ["t", "nu"], ["P_t", "P_nu"],
              plot_titles=["Sech pulse"],
              split=True)
Exemplo n.º 8
0
                                            phase

    lt = layout.Layout(Domain(samples_per_bit=4096))

    channels = 3
    center_lambda = [1552.0, 1549.0, 1596.0]
    peak_power = [1e-3, 2e-3, 6e-3]
    offset_nu = [0.0, 1.56, -1.6]
    init_phi = [1.0, 1.0, 0.0]

    cw = CW(channels=channels,
            center_lambda=center_lambda,
            peak_power=peak_power,
            offset_nu=offset_nu,
            init_phi=init_phi,
            save=True)

    lt.run(cw)

    plot_titles = [
        "CW pulse temporal power", "CW pulse spectral power", "CW pulse phase"
    ]

    plot.plot([cw.fields[0].time, cw.fields[0].nu, cw.fields[0].time], [
        temporal_power(cw.fields[0].channels),
        spectral_power(cw.fields[0].channels),
        phase(cw.fields[0].channels)
    ], ["t", "nu", "t"], ["P_t", "P_nu", "phi"],
              plot_titles=plot_titles,
              split=True)
Exemplo n.º 9
0
if __name__ == "__main__":

    import optcom.utils.plot as plot
    from optcom.domain import Domain

    V = 2.0
    a = 5.0
    d = 15.0
    n_0 = 1.02
    norm_d = d/a
    cpl = Coupling(V=V, a=a, d=d, n_0=n_0)

    Lambda = 1550.0
    omega = Domain.lambda_to_omega(Lambda)
    print(cpl.get_kappa(omega))

    Lambda = np.linspace(900, 1600, 3)
    omega = Domain.lambda_to_omega(Lambda)
    print(cpl.get_kappa(omega))


    Lambda = np.linspace(900, 1600, 1000)
    omega = Domain.lambda_to_omega(Lambda)
    kappas = cpl.get_kappa(omega)

    plot_titles = ['Coupling coefficient as a function of the wavelength '
                   'for norm. spacing = {}'.format(norm_d)]

    plot.plot(Lambda, kappas, x_labels=['Lambda'], y_labels=['Kappa km^{-1}'],
              plot_titles=plot_titles, split=True, opacity=0.0)
Exemplo n.º 10
0
    print(resonant.n(omega, n_0, N_1))

    Lambda = np.linspace(500, 1500, 1000)
    omega = Domain.lambda_to_omega(Lambda)
    delta_n = resonant.n(omega, n_0, N_1)
    delta_n_data = [delta_n]

    x_labels = ['Lambda']
    y_labels = ['Index change']
    plot_titles = [
        'Resonant index change with constant n_0 = {} (pumped)'.format(n_0)
    ]

    sellmeier = Sellmeier("siO2")
    n_0 = sellmeier.n(omega)
    delta_n = resonant.n(omega, n_0, N_1)
    delta_n_data.append(delta_n)

    x_labels.append('Lambda')
    y_labels.append('Index change')
    plot_titles.append("Resonant index change with n_0 from Silica Sellmeier "
                       "equations. (pumped)")

    plot.plot([Lambda, Lambda],
              delta_n_data,
              x_labels=x_labels,
              y_labels=y_labels,
              plot_titles=plot_titles,
              split=True,
              opacity=0.0)
Exemplo n.º 11
0
    center_lambda = [1552.0, 1549.0, 1596.0]
    position = [0.5, 0.3, 0.5]
    width = [2.0, 5.3, 6]
    peak_power = [1e-3, 2e-3, 6e-3]
    bit_rate = [0.0, 0.03, 0.04]
    offset_nu = [0.0, 1.56, -1.6]
    order = [1, 2, 1]
    chirp = [0.0, 0.5, 0.1]
    init_phi = [0.0, 1.0, 0.0]

    gssn = Gaussian(channels=channels,
                    center_lambda=center_lambda,
                    position=position,
                    width=width,
                    peak_power=peak_power,
                    bit_rate=bit_rate,
                    offset_nu=offset_nu,
                    order=order,
                    chirp=chirp,
                    init_phi=init_phi,
                    save=True)

    lt.run(gssn)

    plot.plot([gssn.fields[0].time, gssn.fields[0].nu], [
        temporal_power(gssn.fields[0].channels),
        spectral_power(gssn.fields[0].channels)
    ], ["t", "nu"], ["P_t", "P_nu"],
              plot_titles=["Gaussian pulse"],
              split=True)
Exemplo n.º 12
0
        mz = IdealMZ(phase_shift=phase_shift, loss=loss)
        lt.link((pulse[0], mz[0]))
        lt.run(pulse)
        lt.reset()
        # Plot parameters and get waves
        fields.append(temporal_power(mz.fields[1].channels))
        if (isinstance(phase_shift[0], float)):
            temp_phase = phase_shift
        else:
            temp_phase = [phase_shift[0](0), phase_shift[1](0)]
        plot_titles += ["Pulses coming out of the {} with phase "
                        "shift {} and {}"
                        .format(default_name, str(round(temp_phase[0], 2)),
                                str(round(temp_phase[1], 2)))]

    v_pi = [1.0]
    v_mod = [lambda t: math.sin(math.pi*t), lambda t: math.sin(math.pi/2.0*t)]
    v_bias = [1.2, 2.1]
    mz = IdealMZ(v_pi=v_pi, v_mod=v_mod, v_bias=v_bias)
    lt.link((pulse[0], mz[0]))
    lt.run(pulse)
    # Plot parameters and get waves
    fields.append(temporal_power(mz.fields[1].channels))
    plot_titles += ["Pulses coming out of the {}".format(default_name)]

    fields  = [temporal_power(pulse.fields[0].channels)] + fields
    time = [pulse.fields[0].time, mz.fields[1].time]

    plot.plot(time, fields, split=True, plot_titles=plot_titles,
              x_labels=['t'], y_labels=['P_t'], opacity=0.3)
Exemplo n.º 13
0
                res += (self._Bs[i] * Lambda**2) / (Lambda**2 - self._Cs[i])
            res = np.sqrt(res)

        return res


if __name__ == "__main__":

    import optcom.utils.plot as plot
    from optcom.domain import Domain

    sellmeier = Sellmeier("sio2")

    center_omega = Domain.lambda_to_omega(1050.0)
    print(sellmeier.n(center_omega))

    Lambda = np.linspace(120, 2120, 2000)
    omega = Domain.lambda_to_omega(Lambda)
    n = sellmeier.n(omega)

    x_labels = ['Lambda']
    y_labels = ['Refractive index']
    plot_titles = ["Refractive index of Silica from Sellmeier equations"]

    plot.plot(Lambda,
              n,
              x_labels=x_labels,
              y_labels=y_labels,
              plot_titles=plot_titles,
              opacity=0.0)
Exemplo n.º 14
0
    f_c: float = cst.F_C
    x_data.append(time)
    h_R = Raman.calc_h_R(time, f_a=f_a, f_b=f_b, f_c=f_c)
    y_data.append(h_R)
    plot_labels.append('Isotropic and anisotropic part')
    f_a = 1.0
    f_b = 0.0
    f_c = 1.0
    x_data.append(time)
    h_R = Raman.calc_h_R(time, f_a=f_a, f_b=f_b, f_c=f_c)
    y_data.append(h_R)
    plot_labels.append('W/o anisotropic part')
    f_a = 0.0
    f_b = 1.0
    f_c = 0.0
    x_data.append(time)
    h_R = Raman.calc_h_R(time, f_a=f_a, f_b=f_b, f_c=f_c)
    y_data.append(h_R)
    plot_labels.append('W/o isotropic part')

    plot_titles = ['Raman response function', 'Raman gain']

    plot.plot(x_data,
              y_data,
              x_labels=['t'],
              y_labels=['h_R'],
              plot_groups=[0, 0, 0],
              plot_titles=plot_titles,
              opacity=0.0,
              plot_labels=plot_labels)