def prepare_calibration_files(self, electron_calibration_file, quantum_efficiency_calibration_file): calibration_energy = basic_file_app.load_1d_array( quantum_efficiency_calibration_file, 0, 0) calibration_quantum = basic_file_app.load_1d_array( quantum_efficiency_calibration_file, 1, 0) self.quantum_efficiency = basic_file_app.stack_arrays( calibration_energy, calibration_quantum, axis=1) self.calibration_photon_number = basic_file_app.load_1d_array( electron_calibration_file, 0, 0) return self.calibration_photon_number, self.quantum_efficiency
self.reference_points[:, 1], self.order) def give_fit(self): return self.poly_coefficients def compare_fit(self): #x_axis = np.linspace(np.min(self.reference_points[:, 1]), np.max(self.reference_points[:, 1]),2548) x_axis = np.linspace(0, 2048, 2048) #fit_y = np.linspace(np.min(self.reference_points[:, 1]), np.max(self.reference_points[:, 1]), 2048) fit_y = np.linspace(0, 2048, 2048) for counter, value in enumerate(x_axis): fit_y[counter] = self.poly_coefficients[ -1] + self.poly_coefficients[-2] * x_axis[counter] plt.figure(1) plt.scatter(self.reference_points[:, 1], self.reference_points[:, 0]) plt.plot(x_axis, fit_y) plt.plot() reference_path = "data/S3_20210412_reference.txt" reference_eV = basic_file_app.load_1d_array(reference_path, 0, 2) reference_px = basic_file_app.load_1d_array(reference_path, 1, 2) reference_points = basic_file_app.stack_arrays(reference_eV, reference_px, 1) print(reference_points) Test_Ni = CalibrationFit(reference_points, 1, "S3_Ni_20210412") Test_Ni.fit_reciproce() Test_Ni.compare_fit() print(Test_Ni.give_fit()) plt.show()
plt.xlabel('eV') plt.ylabel('Nphoton/ s*sr @0.1% bw') plt.savefig(file_name + 'Nphoton' + ".png", bbox_inches="tight", dpi=500) np.savetxt(file_name + 'Nphoton' + ".txt", result, delimiter=' ', header='string', comments='', fmt='%s') data_file = "Intensity_evaluation/data_intensity/S1_W_per_s/210205_PM043550_calibrated_analytical.txt" data = basic_file_app.stack_arrays( basic_file_app.load_1d_array(data_file, 1, 5), basic_file_app.load_1d_array(data_file, 2, 5), axis=1) data_below_1000ev = data calibration_number_e_per_photon = "Intensity_evaluation/electrons_per_photon_poly_fit.txt" calibration_q_a = "Intensity_evaluation/QE_greateyesGE_BI_interpolation_bin_size_0.01.txt" al_filter_file = "Intensity_evaluation/Al_500nm_eV_interpolation_bin_size_0.05.txt" al_filter = basic_file_app.stack_arrays( basic_file_app.load_1d_array(al_filter_file, 0, 0), basic_file_app.load_1d_array(al_filter_file, 1, 0), axis=1) mylar_filter_file = "Intensity_evaluation/Mylar_900nm_eV_interpolation_bin_size_0.05.txt" mylar_filter = basic_file_app.stack_arrays(
return np.vstack((parameter_info, names, header_names, result)) def save_data(self, description1): result = self.prepare_header(description1) print('...saving:', description1) plt.figure(1) plt.savefig(description1 + ".png", bbox_inches="tight", dpi=500) np.savetxt(description1 + '_optical_density' + ".txt", result, delimiter=' ', header='string', comments='', fmt='%s') reference_path = "data/stack_105ms/calibrated/SiN single_wo_calibration.txt" reference_x = basic_file_app.load_1d_array(reference_path, 0, 4) reference_y = basic_file_app.load_1d_array(reference_path, 1, 4) reference = basic_file_app.stack_arrays(reference_x, reference_y, 1) sample_path = "data/stack_105ms/calibrated/NiO single var 1_calibration.txt" sample_x = basic_file_app.load_1d_array(sample_path, 0, 4) sample_y = basic_file_app.load_1d_array(sample_path, 1, 4) sample = basic_file_app.stack_arrays(sample_x, sample_y, 1) Test = OpticalDensity(reference, sample, "SiN", "NiO") Test.process_optical_density() Test.plot_result() plt.ylim(-0.2, 2.5) plt.xlim(850, 890) Test.save_data("S2_SiN_NiO_px_corrected_var1_with_wo")
plt.legend() def scale_y(self, scale_factor): self.array[:,1] = self.array[:,1] * scale_factor return self.array def substract_y(self, factor): self.array[:,1] = self.array[:,1] - factor return self.array file_1_path = "data/20210426/210426_S2_mylar_high_98_stack_processing_Mylar.txt" file_1_x = basic_file_app.load_1d_array(file_1_path, 0, 4) file_1_y = basic_file_app.load_1d_array(file_1_path,1,4) file_1 = basic_file_app.stack_arrays(file_1_x, file_1_y, 1) file_2_path = "data/reference_2021041_stack_pre_processing.txt" file_1_x = basic_file_app.load_1d_array(file_2_path, 0, 4) file_1_y = basic_file_app.load_1d_array(file_2_path,1,4) file_2 = basic_file_app.stack_arrays(file_1_x, file_1_y, 1) scale_1 = np.amax(file_1[:,1]) scale_2 = np.amax(file_2[:,1])
def load_data(self): x = basic_file_app.load_1d_array(self.path + '/' + self.filename, 0, 2) y = basic_file_app.load_1d_array(self.path + '/' + self.filename, 1, 2) return basic_file_app.stack_arrays(x, y, 1)
def open_file(file_name, path): spectral = basic_file_app.load_1d_array(path + '/' + file_name, 0, 4) counts = basic_file_app.load_1d_array(path + '/' + file_name, 2, 4) return basic_file_app.stack_arrays(spectral, counts, 1)
def prepare_file(self, skip_row): # ToDo: test if not empty, otherwise raise error array_x = basic_file_app.load_1d_array(self.file, 1, skip_row) array_y = basic_file_app.load_1d_array(self.file, 0, skip_row) return basic_file_app.stack_arrays(array_x, array_y, 1)