コード例 #1
0
def effect_thickness_on_gvd():
    """
    Compare the effects of two different thicknesses on the pulse length.
    """
    path_to_file = "database/glass/schott/N-BK7.yml"
    paf = path_to_ri_database + path_to_file

    # initialize plot
    fig = plt.figure()
    n_ax = 1
    ax = [0] * n_ax
    ax[0] = fig.add_subplot(111)

    # pulse length as a function of wavelength, for 2 thicknesses
    um_range = [0.3, 2.5]
    wl_um, gvd = RI.get_gvd(paf, um_range=um_range)
    # t_fs and d_mm can be a number, a list or an ndarray
    t_fs = 35
    d_mm = [5, 10]
    # t_out is a 3D matrix with shape wavelengths x (initial) t_fs x d_mm
    t_out = RI.effect_gvd(wl_um, gvd, t_fs, d_mm)
    ax_i = 0
    ax[ax_i].plot(wl_um, t_out[:, 0, 0], label="5 mm")
    ax[ax_i].plot(wl_um, t_out[:, 0, 1], label="10 mm")
    ax[ax_i].legend()
    ax[ax_i].set_title("Initial pulse length is 35 fs, for BK7 glass")
    ax[ax_i].set_xlabel("Wavelength (micron)")
    ax[ax_i].set_ylabel("Pulse length (fs)")
コード例 #2
0
def example_ri_gvd_plot():
    """
    Calculate the index of refraction and GVD as a function of wavelengths.
    um_range gives the start and end of the range to be calculated. 
    """
    path_to_file = "database/main/CaF2/Daimon-20.yml"
    paf = path_to_ri_database + path_to_file  # paf = path and filename

    # initialize plot
    fig = plt.figure()
    n_ax = 2
    ax = [0] * n_ax
    ax[0] = fig.add_subplot(211)
    ax[1] = fig.add_subplot(212)

    # for a plot, you can specify a range
    um_range = [0.2, 2.3]

    # RI
    ax_i = 0
    wl_um, ri = RI.get_ri(paf, um_range=um_range)
    ax[ax_i].plot(wl_um, ri, color="blue")
    ax[ax_i].set_ylabel("Index of refraction")

    # GVD
    ax_i = 1
    wl_um, gvd = RI.get_gvd(paf, um_range=um_range)
    ax[ax_i].plot(wl_um, gvd, color="red")
    ax[ax_i].set_ylabel("GVD (fs^2/mm)")

    ax[0].set_title("Index of refraction and GVD for CaF2")
    ax[1].set_xlabel("Wavelength (micron)")
コード例 #3
0
    def test_formula_6b_ri(self):
        wl_um = numpy.array([0.15, 0.3, 0.4, 0.55])
        ri = RI.ri_for_wavelengths(self.f6b, wl_um, verbose=self.verbose)
        ri_check = numpy.array([1.0003733, 1.0002952, 1.0002870, 1.0002823])
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))

        wl_um, ri = RI.get_ri(self.f6b_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #4
0
    def test_formula_4_ri(self):
        wl_um = numpy.array([0.25, 0.6, 1.0])
        ri = RI.ri_for_wavelengths(self.f4, wl_um, verbose=self.verbose)
        ri_check = numpy.array([1.7754, 1.6699, 1.6564])
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))

        wl_um, ri = RI.get_ri(self.f4_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #5
0
    def test_formula_5_ri(self):
        wl_um = numpy.array([0.35, 0.5, 0.63])
        ri = RI.ri_for_wavelengths(self.f5, wl_um, verbose=self.verbose)
        ri_check = numpy.array([1.4189, 1.4028, 1.3976])
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))

        wl_um, ri = RI.get_ri(self.f5_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #6
0
    def test_formula_3_ri(self):
        wl_um = numpy.array([0.5, 1.0, 1.5])
        ri = RI.ri_for_wavelengths(self.f3, wl_um, verbose=self.verbose)
        ri_check = numpy.array([1.5053, 1.4810, 1.4770])
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))

        wl_um, ri = RI.get_ri(self.f3_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #7
0
    def test_formula_6_ri(self):
        wl_um = numpy.array([0.17, 0.7, 1.2, 1.65])
        ri = RI.ri_for_wavelengths(self.f6, wl_um, verbose=self.verbose)
        ri_check = numpy.array([1.0001874, 1.0001379, 1.0001365, 1.0001361])
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))

        wl_um, ri = RI.get_ri(self.f6_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #8
0
    def test_formula_1_ri(self):
        wl_um = numpy.array([0.6, 4.0, 5.0, 6.0, 10.0, 18.0])
        ri = RI.ri_for_wavelengths(self.f1, wl_um, verbose=self.verbose)
        ri_check = numpy.array(
            [2.6141, 2.4331, 2.4295, 2.4258, 2.4065, 2.3306])
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))

        wl_um, ri = RI.get_ri(self.f1_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #9
0
    def test_formula_2_ri(self):
        wl_um = numpy.array([0.15, 0.4, 0.6, 0.8, 1.5, 2.3])
        ri = RI.ri_for_wavelengths(self.f2, wl_um, verbose=self.verbose)
        ri_check = numpy.array(
            [1.5817, 1.4419, 1.4336, 1.4306, 1.4263, 1.4223])
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))

        wl_um, ri = RI.get_ri(self.f2_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #10
0
def example_ri_gvd_table():
    """
    Calculate the index of refraction and GVD as a function of wavelengths.
    By using wl_um, the RI and GVD for exactly these wavelengths are returned.
    """
    path_to_file = "database/main/CaF2/Daimon-20.yml"
    paf = path_to_ri_database + path_to_file  # paf = path and filename

    # to get specific wavelengths, use wl_um
    wl_um = [0.3, 0.6, 0.9]
    wl_um, ri = RI.get_ri(paf, wl_um)
    wl_um, gvd = RI.get_gvd(paf, wl_um)
    print("WL (um)  RI       GVD (fs^2/mm)")
    for i in range(len(wl_um)):
        print("%2.1f      %5.4f   %5.4f" % (wl_um[i], ri[i], gvd[i]))
コード例 #11
0
    def test_tabulated_nk_with_interpolation(self):

        wl_um = numpy.array([0.24, 1.2, 10.0])
        ri_check = numpy.array([1.2038, 0.093133, 4.0038])
        wl_um, ri = RI.get_ri(self.tab_nk_paf,
                              wl_um=wl_um,
                              verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #12
0
def effect_reflection_for_angles():

    path_to_file = "database/main/CaF2/Daimon-20.yml"
    paf = path_to_ri_database + path_to_file

    # initialize plot
    fig = plt.figure()
    n_ax = 2
    ax = [0] * n_ax
    ax[0] = fig.add_subplot(121)
    ax[1] = fig.add_subplot(122)

    # wavelength range
    wl_um = [1]

    a_range = (0, 90)
    a_deg = numpy.linspace(0, 90, 1000)
    # air -> caf2
    wl_um, a_deg, Rs1, Rp1 = RI.get_reflectance(
        paf2=paf, wl_um=wl_um, a_deg=a_deg)  #a_range = a_range)
    # caf2 -> air
    wl_um, a_deg, Rs2, Rp2 = RI.get_reflectance(
        paf1=paf, wl_um=wl_um,
        a_deg=a_deg)  #a_range = a_range) #a_deg = a_deg)

    _wl = 0

    ax_i = 0
    ax[ax_i].plot(a_deg, 100 * Rs1[:, _wl], label="s-pol")
    ax[ax_i].plot(a_deg, 100 * Rp1[:, _wl], label="p-pol")
    ax[ax_i].set_title("air -> CaF2")

    ax_i = 1
    ax[ax_i].plot(a_deg, 100 * Rs2[:, _wl], label="s-pol")
    ax[ax_i].plot(a_deg, 100 * Rp2[:, _wl], label="p-pol")
    ax[ax_i].set_title("CaF2 -> air")

    for ax_i in range(2):
        ax[ax_i].legend()
        ax[ax_i].set_ylabel("Reflection (%)")
        ax[ax_i].set_xlabel("Angle (degrees)")

        ax[ax_i].set_xlim(0, 90)
        ax[ax_i].set_ylim(0, 100)

    fig.suptitle("Reflection for 1 micron light for CaF2")
コード例 #13
0
    def test_tabulated_nk(self):

        wl_um = numpy.array([0.2066, 0.3999, 8.266])
        ri_check = numpy.array([1.079, 0.054, 3.227])
        wl_um, ri = RI.get_ri(self.tab_nk_paf,
                              wl_um=wl_um,
                              verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #14
0
    def test_tabulated_n_with_interpolation(self):

        wl_um = numpy.array([0.31, 3.1, 13.3])
        ri_check = numpy.array([1.7324, 1.6319, 1.4632])
        wl_um, ri = RI.get_ri(self.tab_n_paf,
                              wl_um=wl_um,
                              verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #15
0
    def test_tabulated_n(self):

        wl_um = numpy.array([0.30, 7.2822, 18.003])
        ri_check = numpy.array([1.73756, 1.41644, 2.43259])
        wl_um, ri = RI.get_ri(self.tab_n_paf,
                              wl_um=wl_um,
                              verbose=self.verbose)
        self.assertTrue(numpy.allclose(ri, ri_check, rtol=self.rtol_ri))
コード例 #16
0
    def test_formula_5_gvd(self):
        wl_um = numpy.array([0.35, 0.5, 0.63])
        wl_um, gvd = RI.gvd_for_wavelengths(self.f5,
                                            wl_um,
                                            verbose=self.verbose)
        gvd_check = numpy.array([129.69, 86.012, 64.982])
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))

        wl_um, gvd = RI.get_gvd(self.f5_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))
コード例 #17
0
    def test_formula_4_gvd(self):
        wl_um = numpy.array([0.25, 0.6, 1.0])
        wl_um, gvd = RI.gvd_for_wavelengths(self.f4,
                                            wl_um,
                                            verbose=self.verbose)
        gvd_check = numpy.array([637.15, 111.14, 45.633])
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))

        wl_um, gvd = RI.get_gvd(self.f4_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))
コード例 #18
0
    def test_formula_6_gvd(self):
        wl_um = numpy.array([0.17, 0.7, 1.2, 1.65])
        wl_um, gvd = RI.gvd_for_wavelengths(self.f6,
                                            wl_um,
                                            verbose=self.verbose)
        gvd_check = numpy.array([0.22527, 0.016515, 0.010617, 0.0081099])
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))

        wl_um, gvd = RI.get_gvd(self.f6_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))
コード例 #19
0
    def test_formula_3_gvd(self):
        wl_um = numpy.array([0.5, 1.0, 1.5])
        wl_um, gvd = RI.gvd_for_wavelengths(self.f3,
                                            wl_um,
                                            verbose=self.verbose)
        gvd_check = numpy.array([253.85, 81.590, 56.390])
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))

        wl_um, gvd = RI.get_gvd(self.f3_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))
コード例 #20
0
    def test_formula_1_gvd(self):
        wl_um = numpy.array([0.6, 4.0, 5.0, 6.0, 10.0, 18.0])
        wl_um, gvd = RI.gvd_for_wavelengths(self.f1,
                                            wl_um,
                                            verbose=self.verbose)
        gvd_check = numpy.array(
            [2271.1, 75.299, -17.134, -136.21, -1221.0, -14134])
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))

        wl_um, gvd = RI.get_gvd(self.f1_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))
コード例 #21
0
    def test_formula_2_gvd(self):
        wl_um = numpy.array([0.15, 0.4, 0.6, 0.8, 1.5, 2.3])
        wl_um, gvd = RI.gvd_for_wavelengths(self.f2,
                                            wl_um,
                                            verbose=self.verbose)
        gvd_check = numpy.array(
            [846.01, 67.513, 40.230, 27.796, 1.8579, -39.704])
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))

        wl_um, gvd = RI.get_gvd(self.f2_paf, wl_um=wl_um, verbose=self.verbose)
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))
コード例 #22
0
    def test_formula_6b_gvd(self):
        wl_um = numpy.array([0.15, 0.3, 0.4, 0.55])
        wl_um, gvd = RI.gvd_for_wavelengths(self.f6b,
                                            wl_um,
                                            verbose=self.verbose)
        gvd_check = numpy.array([0.40387, 0.068418, 0.046791, 0.030277])
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))

        wl_um, gvd = RI.get_gvd(self.f6b_paf,
                                wl_um=wl_um,
                                verbose=self.verbose)
        self.assertTrue(
            numpy.allclose(gvd,
                           gvd_check,
                           rtol=self.rtol_gvd,
                           atol=self.atol_gvd))
コード例 #23
0
def effect_reflection_for_wavelengths():
    """
    Compare the effects of two different thicknesses on the pulse length.
    """
    path_to_file = "database/main/CaF2/Daimon-20.yml"
    paf = path_to_ri_database + path_to_file

    # initialize plot
    fig = plt.figure()
    n_ax = 1
    ax = [0] * n_ax
    ax[0] = fig.add_subplot(111)

    # wavelength range
    um_range = [0.21, 2.3]

    a_deg = [0]
    # air -> caf2
    wl_um, a_deg, Rs1, Rp1 = RI.get_reflectance(paf2=paf,
                                                um_range=um_range,
                                                a_deg=a_deg)
    # caf2 -> air
    wl_um, a_deg, Rs2, Rp2 = RI.get_reflectance(paf1=paf,
                                                um_range=um_range,
                                                a_deg=a_deg)
    Rs = Rs1 + Rs2

    ax_i = 0
    _a = 0

    ax[ax_i].plot(wl_um, 100 * Rs1[_a, :], label="air -> CaF2")
    ax[ax_i].plot(wl_um, 100 * Rs2[_a, :], label="CaF2 -> vacuum")
    ax[ax_i].plot(wl_um, 100 * Rs[_a, :], label="total")

    ax[ax_i].legend()
    ax[ax_i].set_title("Reflection for 0 deg AOI for CaF2")
    ax[ax_i].set_xlabel("Wavelength (micron)")
    ax[ax_i].set_ylabel("Reflection (%)")
    ax[ax_i].set_ylim(0, 8)
コード例 #24
0
def effect_gvd_for_pulselengths():
    """
    Plot the pulse length before and after a material. This is done for two materials.
    """
    # initialize plot
    fig = plt.figure()
    n_ax = 1
    ax = [0] * n_ax
    ax[0] = fig.add_subplot(111)
    ax_i = 0

    # use only 1 wavelength
    wl_um = [0.2]
    # make an array of initial times. ndarray: [10, 11, 12, ..., 149]
    t_fs = numpy.arange(5, 100)
    # only one thickness
    d_mm = [0.5]
    #
    #     # BK7
    #     path_to_file = "database/glass/schott/N-BK7.yml"
    #     paf = path_to_ri_database + path_to_file
    #     wl_um, gvd = RI.get_gvd(paf, wl_um = wl_um)
    #     t_out = RI.effect_gvd(wl_um, gvd, t_fs, d_mm)
    #     ax[ax_i].plot(t_fs, t_out[0,:,0], label = "BK7")
    #
    #     # CaF2
    #     path_to_file = "database/main/CaF2/Daimon-20.yml"
    #     paf = path_to_ri_database + path_to_file
    #     wl_um, gvd = RI.get_gvd(paf, wl_um = wl_um)
    #     t_out = RI.effect_gvd(wl_um, gvd, t_fs, d_mm)
    #     ax[ax_i].plot(t_fs, t_out[0,:,0], label = "CaF2")

    # Quartz
    d_mm = [0.2 * numpy.sqrt(2)]
    path_to_file = "database/main/SiO2/Ghosh-e.yml"
    paf = path_to_ri_database + path_to_file
    wl_um, gvd = RI.get_gvd(paf, wl_um=wl_um)
    t_out = RI.effect_gvd(wl_um, gvd, t_fs, d_mm)
    ax[ax_i].plot(t_fs, t_out[0, :, 0], label="Quartz, 0.28 mm")

    # Sapphire
    d_mm = [0.5]
    path_to_file = "database/main/Al2O3/Malitson-e.yml"
    paf = path_to_ri_database + path_to_file
    wl_um, gvd = RI.get_gvd(paf, wl_um=wl_um)
    t_out = RI.effect_gvd(wl_um, gvd, t_fs, d_mm)
    ax[ax_i].plot(t_fs, t_out[0, :, 0], label="Sapphire, 0.5 mm")

    # Sapphire
    d_mm = [0.2]
    path_to_file = "database/main/Al2O3/Malitson-e.yml"
    paf = path_to_ri_database + path_to_file
    wl_um, gvd = RI.get_gvd(paf, wl_um=wl_um)
    t_out = RI.effect_gvd(wl_um, gvd, t_fs, d_mm)
    ax[ax_i].plot(t_fs, t_out[0, :, 0], label="Sapphire, 0.2 mm")

    # plot
    ax[ax_i].legend()
    ax[ax_i].grid()
    ax[ax_i].set_xlim(0, 60)
    ax[ax_i].set_ylim(0, 80)
    # diagonal line
    ax[ax_i].plot([0, 200], [0, 200], color="black", linewidth=1)
    ax[ax_i].plot([35, 35], [0, 200], color="grey", linewidth=1)
    #     ax[ax_i].set_title("Effect on pulse length for {:2.1f} mm material at 800 nm".format(d_mm[0]))
    ax[ax_i].set_title("Effect on pulse length at {:3d} nm".format(
        int(1000 * wl_um[0])))
    ax[ax_i].set_xlabel("Initial pulse length (fs)")
    ax[ax_i].set_ylabel("Resulting pulse length (fs)")
コード例 #25
0
def import_transmission_data(compound_name, wl_range=(), verbose=0):
    """
    Takes a name for a material and outputs the wavelength axis (in eV) and the absorption for 1 micron.
    
    INPUT:
    material: name of material. The data for the gas has to be in '/Data/TransmissionSpectra/' and in the python file there. 
    
    OUTPUT:
    - wl_nm (ndarray): wavelength axis
    - tr_norm (ndarray): transmission, normalized to 1 mm
    
    CHANGELOG:
    
    """
    # find path
    path = NPCTools.Data.TransmissionSpectra.TransmissionSpectraData.data_path(
    )

    # convert to title case
    compound_name = compound_name.lower()
    files_list = NPCTools.Data.TransmissionSpectra.TransmissionSpectraData.files_list(
    )

    # find the name in the list
    mat = [item for item in files_list if compound_name in item["compound"]]

    # if not name was found, throw an error
    if len(mat) == 0:
        DEBUG.printError("Compound %s not found" % compound_name,
                         inspect.stack())
        return [0], [0]
    else:
        mat = mat[0]

    if verbose > 0:
        s = "TransmissionSpectra.py:import_transmission_data: Found this item for element %s: %s" % (
            compound_name, str(mat))
        DEBUG.verbose(s, verbose, 1)

    print("Importing data for compound %s" % (compound_name))

    # import data
    data = numpy.loadtxt(path + "/" + mat["filename"],
                         comments="#",
                         delimiter=",")
    wl = data[:, 0]
    tr = data[:, 1]

    if wl[0] > wl[-1]:
        wl = wl[::-1]
        tr = tr[::-1]

    if mat["wl_unit"] == "nm":
        wl_nm = wl
        wl_um = wl / 1000
    elif mat["wl_unit"] == "um":
        wl_nm = 1000 * wl
        wl_um = wl

    temp = numpy.where(wl_um <= wl_range[0])[0]
    if len(temp) > 0:
        wl_nm = wl_nm[temp[-1]:]
        wl_um = wl_um[temp[-1]:]
        tr = tr[temp[-1]:]

    temp = numpy.where(wl_um >= wl_range[1])[0]
    if len(temp) > 0:
        wl_nm = wl_nm[:temp[0]]
        wl_um = wl_um[:temp[0]]
        tr = tr[:temp[0]]

    a_deg = [0]

    path_to_ri_database = "/Users/rbloem/Developer/NPCTools/Data/RefractiveIndexDB/"
    paf = path_to_ri_database + mat["refractive_index_path"]

    # air -> material
    wl_um, a_deg, Rs, Rp = RI.get_reflectance(paf2=paf,
                                              wl_um=wl_um,
                                              a_deg=a_deg)

    Rs = Rs[0, :]
    Rp = Rp[0, :]

    if mat["tr_unit"] == "pct":
        tr /= 100

    R = (1 - Rs)**2
    absorption_component = tr / R  #(1 - R)
    abs = -numpy.log10(absorption_component)
    abs_mm = abs / mat["mm"]

    numpy.putmask(abs_mm, abs_mm < 0, 0)

    return wl_nm, abs_mm, Rs, Rp