R_1 = gaussian_parameters[1] R_2 = gaussian_parameters[2] TSTR_parameters = TSTR_fit.fit_parameters(points) rho_L = TSTR_parameters[0] n = TSTR_parameters[1] gamma = TSTR_parameters[2] semi_empirical_parameters = semi_empirical_fit.fit_parameters(points) rho_L_ = semi_empirical_parameters[0] n_ = semi_empirical_parameters[1] K_ = semi_empirical_parameters[2] gamma_ = semi_empirical_parameters[3] semi_empirical_fitted_data = semi_empirical_fit.BRIDF_plotter( theta_r_in_degrees_array, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, semi_empirical_parameters) gaussian_fitted_data = gaussian_fit.BRIDF_plotter(theta_r_in_degrees_array, theta_i_in_degrees, gaussian_parameters) TSTR_fitted_data = TSTR_fit.BRIDF_plotter(theta_r_in_degrees_array, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, TSTR_parameters) plt.plot(theta_r_in_degrees_array, intensity_array, label="experimental") plt.plot(theta_r_in_degrees_array, gaussian_fitted_data, label="Gaussian model")
def plot_with_semi_empirical_fit(points, title): one_pass_x_data = [] run_name_list = [] points_by_run_name = [] for point in points: if point.theta_r_in_degrees not in one_pass_x_data: one_pass_x_data.append(point.theta_r_in_degrees) if point.run_name not in run_name_list: run_name_list.append(point.run_name) points_by_run_name.append([point]) else: index = 0.5 # to error if not overridden for i in range(len(run_name_list)): run_name = run_name_list[i] if point.run_name == run_name: index = i points_by_run_name[index].append(point) one_pass_x_data = sorted(one_pass_x_data) phi_r_in_degrees = points[0].phi_r_in_degrees semi_empirical_parameters = semi_empirical_fit.fit_parameters(points) # make a plot for each angle for i in range(len(run_name_list)): run_name = run_name_list[i] points = points_by_run_name[i] n_0 = points[0].n_0 polarization = points[0].polarization theta_i_in_degrees = points[0].theta_i_in_degrees photodiode_angle = points[0].photodiode_angular_width x_data = [point.theta_r_in_degrees for point in points] y_data = [point.intensity for point in points] max_y = max(y_data) semi_empirical_y = semi_empirical_fit.BRIDF_plotter( one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, photodiode_angle, semi_empirical_parameters) plt.figure() plt.title(run_name) plt.scatter(x_data, y_data, color="r", s=2, label="experimental") plt.plot(one_pass_x_data, semi_empirical_y, label="Semi-Empirical Fit") rho_L = semi_empirical_parameters[0] n = semi_empirical_parameters[1] K = semi_empirical_parameters[2] gamma = semi_empirical_parameters[3] string = "theta_i: " + str(theta_i_in_degrees) + "\n\nSemi-Empirical Parameters:\nrho_L: " + \ str(rho_L) + "\nn: " + str(n) + "\nK: " + str(K) + "\ngamma: " + str(gamma) axes = plt.gca() axes.set_ylim([0, 1.2 * max_y]) plt.legend() plt.xlabel("viewing angle (degrees)") plt.ylabel("intensity (flux/str)/(input flux)") plt.annotate(string, xy=(0.05, 0.6), xycoords='axes fraction', size=6) plt.figure() current_min_y = 1000 current_max_y = 0 for i in range(len(run_name_list)): run_name = run_name_list[i] points = points_by_run_name[i] n_0 = points[0].n_0 polarization = points[0].polarization theta_i_in_degrees = points[0].theta_i_in_degrees x_data = [point.theta_r_in_degrees for point in points] y_data = [point.intensity for point in points] current_min_y = min(current_min_y, min(y_data)) current_max_y = max(current_max_y, max(y_data)) semi_empirical_y = semi_empirical_fit.BRIDF_plotter( one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, photodiode_angle, semi_empirical_parameters) plt.scatter(x_data, y_data, s=2, label=run_name + " experimental") plt.plot(one_pass_x_data, semi_empirical_y, label=run_name + " TSTR Fit") plt.title(title) axes = plt.gca() axes.set_ylim([current_min_y, 1.2 * current_max_y]) plt.legend() plt.xlabel("viewing angle (degrees)") plt.ylabel("intensity (flux/str)/(input flux)") rho_L = semi_empirical_parameters[0] n = semi_empirical_parameters[1] K = semi_empirical_parameters[2] gamma = semi_empirical_parameters[3] string = "\n\nSemi-Empirical Parameters:\nrho_L: " + str( rho_L) + "\nn: " + str(n) + "\nK: " + str(K) + "\ngamma: " + str(gamma) plt.annotate(string, xy=(0.05, 0.6), xycoords='axes fraction', size=6) plt.show()
def plot_with_semi_empirical_and_gaussian_fits(points): one_pass_x_data = [] run_name_list = [] points_by_run_name = [] for point in points: if point.theta_r_in_degrees not in one_pass_x_data: one_pass_x_data.append(point.theta_r_in_degrees) if point.run_name not in run_name_list: run_name_list.append(point.run_name) points_by_run_name.append([point]) else: index = 0.5 # to error if not overridden for i in range(len(run_name_list)): run_name = run_name_list[i] if point.run_name == run_name: index = i points_by_run_name[index].append(point) plot_gaussian = len(run_name_list) == 1 phi_r_in_degrees = points[0].phi_r_in_degrees n_0 = points[0].n_0 polarization = points[0].polarization photodiode_solid_angle = points[0].photodiode_solid_angle semi_empirical_parameters = semi_empirical_fit.fit_parameters(points) TSTR_parameters = TSTR_fit.fit_parameters(points) if plot_gaussian: gaussian_parameters = gaussian_fit.fit_parameters(points) for i in range(len(run_name_list)): run_name = run_name_list[i] points = points_by_run_name[i] theta_i_in_degrees = points[0].theta_i_in_degrees x_data = [point.theta_r_in_degrees for point in points] y_data = [point.intensity for point in points] max_y = max(y_data) semi_empirical_y = semi_empirical_fit.BRIDF_plotter( one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, photodiode_solid_angle, semi_empirical_parameters) TSTR_y = TSTR_fit.BRIDF_plotter(one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, TSTR_parameters) if plot_gaussian: gaussian_y = gaussian_fit.BRIDF_plotter(one_pass_x_data, theta_i_in_degrees, gaussian_parameters) plt.figure() plt.title(run_name) plt.scatter(x_data, y_data, marker="x", color="r", label="experimental") plt.plot(one_pass_x_data, semi_empirical_y, label="Semi-Empirical Fit") plt.plot(one_pass_x_data, TSTR_y, label="TSTR Fit") if plot_gaussian: plt.plot(one_pass_x_data, gaussian_y, label="Gaussian Fit") rho_L_ = semi_empirical_parameters[0] n_ = semi_empirical_parameters[1] K_ = semi_empirical_parameters[2] gamma_ = semi_empirical_parameters[3] rho_L = TSTR_parameters[0] n = TSTR_parameters[1] gamma = TSTR_parameters[2] if plot_gaussian: sigma = gaussian_parameters[0] R_1 = gaussian_parameters[1] R_2 = gaussian_parameters[2] string = "theta_i: " + str(theta_i_in_degrees) + "\n\nSemi-Empirical Parameters:\nrho_L: " + str(rho_L_) + \ "\nn: " + str(n_) + "\nK: " + str(K_) + "\ngamma: " + str(gamma_) + "\n\nTSTR Parameters:\nrho_L: " + \ str(rho_L) + "\nn: " + str(n) + "\ngamma: " + str(gamma) if plot_gaussian: string += "\n\nsigma: " + str(sigma) + "\nR_1: " + str( R_1) + "\nR_2: " + str(R_2) axes = plt.gca() axes.set_ylim([0, 1.2 * max_y]) plt.legend() plt.xlabel("viewing angle (degrees)") plt.ylabel("intensity (flux/str)/(input flux)") plt.annotate(string, xy=(0.05, 0.6), xycoords='axes fraction', size=6) plt.show()
def plot_semi_empirical_components(points): one_pass_x_data = [] run_name_list = [] points_by_run_name = [] for point in points: if point.theta_r_in_degrees not in one_pass_x_data: one_pass_x_data.append(point.theta_r_in_degrees) if point.run_name not in run_name_list: run_name_list.append(point.run_name) points_by_run_name.append([point]) else: index = 0.5 # to error if not overridden for i in range(len(run_name_list)): run_name = run_name_list[i] if point.run_name == run_name: index = i points_by_run_name[index].append(point) phi_r_in_degrees = points[0].phi_r_in_degrees n_0 = points[0].n_0 polarization = points[0].polarization photodiode_solid_angle = points[0].photodiode_solid_angle semi_empirical_parameters = semi_empirical_fit.fit_parameters(points) for i in range(len(run_name_list)): run_name = run_name_list[i] points = points_by_run_name[i] theta_i_in_degrees = points[0].theta_i_in_degrees x_data = [point.theta_r_in_degrees for point in points] y_data = [point.intensity for point in points] max_y = max(y_data) semi_empirical_y_diffuse = semi_empirical_fit.BRIDF_diffuse_plotter( one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, photodiode_solid_angle, semi_empirical_parameters) semi_empirical_y_specular_lobe = semi_empirical_fit.BRIDF_specular_lobe_plotter( one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, photodiode_solid_angle, semi_empirical_parameters) semi_empirical_y_specular_spike = semi_empirical_fit.BRIDF_specular_spike_plotter( one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, photodiode_solid_angle, semi_empirical_parameters) semi_empirical_y_total = semi_empirical_fit.BRIDF_plotter( one_pass_x_data, phi_r_in_degrees, theta_i_in_degrees, n_0, polarization, photodiode_solid_angle, semi_empirical_parameters) plt.figure() plt.title(run_name + "\nSemi-Empirical Fit Components") plt.scatter(x_data, y_data, marker="x", color="r", label="experimental") plt.plot(one_pass_x_data, semi_empirical_y_diffuse, label="diffuse") plt.plot(one_pass_x_data, semi_empirical_y_specular_lobe, label="specular_lobe") plt.plot(one_pass_x_data, semi_empirical_y_specular_spike, label="specular_spike") plt.plot(one_pass_x_data, semi_empirical_y_total, label="total") rho_L_ = semi_empirical_parameters[0] n_ = semi_empirical_parameters[1] K_ = semi_empirical_parameters[2] gamma_ = semi_empirical_parameters[3] string = "theta_i: " + str(theta_i_in_degrees) + "\n\nSemi-Empirical Parameters:\nrho_L: " + str(rho_L_) + \ "\nn: " + str(n_) + "\nK: " + str(K_) + "\ngamma: " + str(gamma_) axes = plt.gca() axes.set_ylim([0, 1.2 * max_y]) plt.legend() plt.xlabel("viewing angle (degrees)") plt.ylabel("intensity (flux/str)/(input flux)") plt.annotate(string, xy=(0.05, 0.8), xycoords='axes fraction', size=6) plt.show()