Esempio n. 1
0
 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
Esempio n. 2
0
 def __init__(self, file, column, bin_decimal, unit):
     self.file_name = file
     self.name = file[8:-3]
     self.bin_decimal = bin_decimal
     self.unit = unit
     self.array_y = np.sort(basic_file_app.load_1d_array(file, column, 3))
     self.result = np.zeros([len(self.array_y), 2])
     self.sigma = float
     self.amp = float
     self.center = float
     self.count_event()
     self.fit_gaussian()
Esempio n. 3
0
        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"
        plt.vlines(self.back_roi[2], ymax=2048, ymin=0)

    def figure_raw(self):
        plt.figure(8)
        plt.imshow(self.picture)
        plt.colorbar()


path_background = "data/stray_light/945ms_straylight/"
name_background = path_background
path_picture = "data/A9_Lrot56_105ms_Gonio1460/LT18350/"

# roi on image ( [x1, y1, x2, y2])
roi_list = ([0, 380, 1730, 1670])

emission_lines = basic_file_app.load_1d_array(
    "calibration_files/Fe_XPL_detected_20210202.txt", 1, 3)

# px size in um, angle alpha degree, d in nm, angle beta in degree, distance RZP - Chip, offset in px
rzp_structure_parameter = np.array(
    [1.350e-02, 2.130e+00, 1.338e+03, 3.714e+00, 2.479e+03, 0.000e+00])
laser_gate_time_data = 105  # ms
per_second_correction = 1000 / laser_gate_time_data
rzp_structure_name = "RZPA9-S3_" + str(laser_gate_time_data) + "ms"

# create input pictures

file_list_background = basic_image_app.get_file_list(path_background)
batch_background = basic_image_app.ImageStackMeanValue(file_list_background,
                                                       path_background)
my_background = batch_background.average_stack()
Esempio n. 5
0
        parameter_info = (
            ['description:', description1])
        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.xlabel("eV")
        plt.ylabel("counts/s")
        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])
Esempio n. 7
0
 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_single_file(self, file_name):
     return basic_file_app.load_1d_array(self.path + '/' + file_name,
                                         self.column, 6)
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)
Esempio n. 10
0
 def __init__(self, calibration_file_path, file_path, directory):
     self.calibration_parameter = basic_file_app.load_1d_array(
         calibration_file_path, 0, 0)
     print(self.calibration_parameter, 'used calibration_files')
     self.file_path = file_path
     self.directory = directory
Esempio n. 11
0
# reference positions (px) for minimum in roi for px shift evaluation
reference_point_list = [557]
# path_binned_array_files to be opened for px-shifted arrays (usually excecution path for this python routine)
Test = PxCorrectionOnStack(path_picture, reference_point_list, bin_path)
Test.pre_process_stack()
Test.px_shift()

# CALIBRATION ON BINNED SPECTRA

calibration_path = "calibration_files/20210714_calibration_RZP_S2.txt"
cal_path = str("cal_") + bin_path[14:]

create_result_directory(cal_path)
calibration = BatchCalibration(calibration_path, bin_path + "/", cal_path)
calibration.calibrate_array()
my_avg = calibration.avg_of_stack()

mylar_positions = basic_file_app.load_1d_array(
    "calibration_files/NiO_on_Si_S2.txt", 0, 0)

for x in mylar_positions:
    plt.figure(10)
    plt.vlines(x=x, ymin=-20, ymax=6, color="m")

plt.xlim(524, 560)
plt.ylim(3, 5)
plt.legend()
save_pic = os.path.join(cal_path, cal_path[4:] + "_mean2" + ".png")
plt.savefig(save_pic, bbox_inches="tight", dpi=500)
plt.show()
 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)
 def get_x_axis(self):
     return basic_file_app.load_1d_array(
         self.path + '/' + self.file_list[0], self.column - 1, 6)
 def size_of_input_data(self):
     return len(
         basic_file_app.load_1d_array(self.path + '/' + self.file_list[0],
                                      self.column, 6))
Esempio n. 15
0
            ['description:', description1])
        return np.vstack((parameter_info, names, header_names, result))

    def save_data(self, description1):
        result = self.prepare_header(description1)
        print('...saving:', self.name)
        plt.figure(1)
        plt.savefig(self.name + ".png", bbox_inches="tight", dpi=500)
        np.savetxt(self.name + '_calibration' + ".txt", result, delimiter=' ',
                   header='string', comments='',
                   fmt='%s')



input_file = "data/stack_105ms/S3_NiO_px_corrected_105ms_avg_variant_1.txt"
counts_input = basic_file_app.load_1d_array(input_file, 1, 4)

input_calibration = "data/S3_reference/S3_reference_fit20210412_quadratic_fit.txt"
fit = basic_file_app.load_1d_array(input_calibration, 0, 0)

#reference in eV
fit_points = "data/S3_reference/S3_reference_Ni.txt"
reference_points = basic_file_app.load_1d_array(fit_points, 0,2)


calibrate_Ni = CalibrateSpectrum(counts_input, fit, "NiO single var 1")
# shift of spectrum to reference in [px]
calibrate_Ni.calibrate_x_axis(-3)
calibrate_Ni.reference_points(reference_points)
plt.xlim(700, 900)
#plt.ylim(0.E6, 1.E6)
Esempio n. 16
0
                          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()
                   header='string',
                   comments='',
                   fmt='%s')


my_path = "results_cal_5000ms_pos2/"
avg_path = "results_avg"

result_file_name = "20210628_5000ms_pos2_avg"
#os.mkdir(avg_path)
my_files = basic_file_app.get_file_list(my_path)
#class(path, scale, column) -> skiprows in the code
test = AvgOnStack1Column(my_path, 1., 2)
my_avg = test.integrate_over_stack()
#create x-axis from one of the files (path+name, column, skip-rows)
my_x = basic_file_app.load_1d_array(my_path + '/' + my_files[0], 1, 6)
my_error = test.standard_deviation()
test.save_statistics(avg_path, result_file_name)

#plt.scatter(my_x[:], my_avg[:])
plt.figure(1)
plt.errorbar(my_x[:],
             my_avg[:],
             yerr=my_error,
             fmt="o",
             label=result_file_name)
plt.xlim(520, 550)
plt.legend()

save_name = os.path.join(avg_path, result_file_name + ".png")
plt.savefig(save_name, bbox_inches="tight", dpi=500)