예제 #1
0
    def calculate_intensities(self):
        refractive_indices = self.calculate_refractive_indices()
        angle = np.deg2rad(
            self.single_wp_settings[self.single_wp_angle_input_key])
        width = np.array(
            self.single_wp_settings[self.single_wp_width_input_key]) * um
        values = (angle, width, None)
        if self.single_wp_settings[self.calculation_method_key] in 'Stokes':
            m_matrix_stack = make_m_matrix_stack(self.erf_setup,
                                                 refractive_indices, values)
            int_x, int_y = calc_final_stokes_intensities(m_matrix_stack)
        else:
            j_matrix_stack = make_j_matrix_stack(self.erf_setup,
                                                 refractive_indices, values)
            int_x, int_y = calc_final_jones_intensities(j_matrix_stack)

        if self.ui_values[self.add_simple_transmission_checkbox_key]:
            db_transmission_coeff = 10 * np.log10(
                simple_transmission_coeff(self.erf_setup.eps_mat1))
        else:
            db_transmission_coeff = 10 * np.log10(
                np.ones_like(self.erf_setup.eps_mat1))

        db_transmission_coeff = db_transmission_coeff.reshape(int_x.shape)

        return db_transmission_coeff + int_x, db_transmission_coeff + int_y
예제 #2
0
    def add_errors(self, ui_values):
        angles, widths, stripes = self.get_values()
        new_angles, new_widths, new_stripes = angles.copy(), widths.copy(), stripes.copy()
        angle_err_enabled = ui_values[self.angle_err_checkbox_key]
        width_err_enabled = ui_values[self.width_err_checkbox_key]
        stripe_err_enabled = ui_values[self.stripe_err_checkbox_key]

        new_stripes = self.replace_stripes(ui_values, new_stripes)

        # add random errors
        title = ''

        if angle_err_enabled:
            multiplier = ui_values[self.angle_err_slider_key]
            angle_error = 2 * multiplier * np.random.random(angles.shape) - multiplier
            new_angles += np.deg2rad(angle_error)
            title += 'Angle err: ' + str(np.round(angle_error, 2)) + ' (deg)' + '\n'
        if width_err_enabled:
            multiplier = ui_values[self.width_err_slider_key]
            width_error = 2 * multiplier * np.random.random(widths.shape) - multiplier
            new_widths += width_error * um
            title += 'Width err: ' + str(np.round(width_error, 2)) + ' (μm)' + '\n'
        if stripe_err_enabled:
            multiplier = ui_values[self.stripe_err_slider_key]
            stripe_error = 2 * multiplier * np.random.random(stripes.shape) - multiplier
            new_stripes += stripe_error * um
            title += 'Stripe err: ' + str(np.round(stripe_error, 2)) + ' (μm)'

        self.error_values['title'] = title
        self.error_values['new_values'] = np.abs(new_angles), np.abs(new_widths), np.abs(new_stripes)
        self.error_values['refractive_indices'] = self.erf_setup.setup_ri(new_stripes)
        self.error_values['m_matrix_stack'] = make_m_matrix_stack(self.erf_setup,
                                                                  self.error_values['refractive_indices'],
                                                                  (new_angles, new_widths, new_stripes))
        self.error_values['j_matrix_stack'] = make_j_matrix_stack(self.erf_setup,
                                                                  self.error_values['refractive_indices'],
                                                                  (new_angles, new_widths, new_stripes))
        if ui_values[self.calculation_method_key] in 'Stokes':
            self.error_values['intensities'] = calc_final_stokes_intensities(self.error_values['m_matrix_stack'])
            self.error_values['pol_comps'] = calc_polarization_degrees_m(self.error_values['m_matrix_stack'])
        else:
            self.error_values['intensities'] = calc_final_jones_intensities(self.error_values['j_matrix_stack'])
            self.error_values['pol_comps'] = calc_polarization_degrees_j(self.error_values['j_matrix_stack'])

        return self.error_values
예제 #3
0
    def set_selected_result(self, ui_values_dict):
        self.selected_result = Result(ui_values_dict)
        self.selected_result.erf_setup = ErfSetup(self.selected_result.result_settings)

        # calculate stuff that's required everytime a result is selected
        refractive_indices = self.selected_result.erf_setup.setup_ri(self.selected_result.stripes)
        self.selected_result.calculated_values['refractive_indices'] = refractive_indices

        m_matrix_stack = make_m_matrix_stack(self.selected_result.erf_setup, refractive_indices,
                                             self.selected_result.get_values())
        self.selected_result.calculated_values['m_matrix_stack'] = m_matrix_stack

        j_matrix_stack = make_j_matrix_stack(self.selected_result.erf_setup, refractive_indices,
                                             self.selected_result.get_values())
        self.selected_result.calculated_values['j_matrix_stack'] = j_matrix_stack

        if ui_values_dict[self.calculation_method_key] in 'Stokes':
            self.selected_result.calculated_values['intensities'] = calc_final_stokes_intensities(m_matrix_stack)
        else:
            self.selected_result.calculated_values['intensities'] = calc_final_jones_intensities(j_matrix_stack)

        self.selected_result.calculated_values['phase shift'] = calc_phase_shift(j_matrix_stack)

        self.result_selected = True
예제 #4
0
    settings_dict[keys.const_widths_key] = [0] * int(
        settings_dict[keys.wp_cnt_key])
    #settings_dict[keys.x_slicing_key] = [[0,4], [4,8], [8,16]]

    erf_setup = ErfSetup(settings_dict)

    angles_ = np.load(dir_path / 'angles.npy')
    d_ = np.load(dir_path / 'widths.npy')
    stripes_ = np.load(dir_path / 'stripes.npy')

    x_res = np.concatenate((angles_, d_, stripes_))

    freqs = erf_setup.frequencies

    j_stack = erf_setup.get_j_stack(x_res)
    intensity_x, intensity_y = calc_final_jones_intensities(j_stack)

    angles_test = np.deg2rad([79.3, 58.6, 37.9, 15.6, 9.1])
    d_test = np.array([635, 495, 495, 495, 310]) * um
    stripes_test = np.array([75, 67, 65, 74, 77, 29, 31, 28, 26, 28]) * um
    """
    [79.33, 58.55, 37.88, 15.56, 9.07]
    [635.0, 495.0, 495.0, 495.0, 310.0]
    [74.6, 66.5, 64.5, 73.5, 77.0, 29.4, 30.6, 27.9, 26.3, 28.2]
    """

    # errors
    #d_test += 1*np.random.random(d_test.shape) * um
    #stripes_test += 1*np.random.random(stripes_test.shape) * um
    #stripes_test[0:5] += 10*np.ones(5)*um
    #angles_test += np.deg2rad(np.random.random(angles_test.shape))
예제 #5
0
erf_settings[keys.calculation_method_key] = 'Jones'
erf_settings[keys.anisotropy_p_key] = 1
erf_settings[keys.anisotropy_s_key] = 1
erf_settings[keys.const_widths_key] = [0] * int(erf_settings[keys.wp_cnt_key])
erf_settings[keys.x_slicing_key] = [[0, 5], [5, 10], [10, 20]]

erf_setup = ErfSetup(erf_settings)
angles = np.load(base_path / 'angles.npy')
widths = np.load(base_path / 'widths.npy')
stripes = np.load(base_path / 'stripes.npy')

x = np.concatenate((angles, widths, stripes))

j_stack = erf_setup.get_j_stack(x)

intensity_x = calc_final_jones_intensities(j_stack)[0]
intensity_y = calc_final_jones_intensities(j_stack)[1]

erf_freqs = erf_setup.frequencies

cst_data_reader = CSTData(cst_path)
cst_freqs = cst_data_reader.f_s_parameters * 10**12
xp1, xp2 = 2, 4
yp1, yp2 = 2, 3

x_cst_data = cst_data_reader.get_s_parameters(xp1, xp2)
y_cst_data = cst_data_reader.get_s_parameters(yp1, yp2)

int_x_cst = 20 * np.log10(x_cst_data)
int_y_cst = 20 * np.log10(y_cst_data)