def intgrals_calc_25(): #magnetron_in_vals = [8.7, 10.7, 13] test = ProcessSignal('201008') csv_files_list = os.listdir(test.csv_files_path) csv_types = test.read_type_file() csv_signals = csv_types['signal_files'] csv_signal_nums = csv_types['signal_nums'] excel_dicts = test.read_excel(csv_signal_nums)['numbers'] magnetron_nums = excel_dicts['magnetron'] reb_nums = excel_dicts['noise'] #m_classif_dict = m_signals_classification(magnetron_in_vals, magnetron_nums) magnetron_dict = {} reb_dict = {} for csv_signal in csv_signals: if csv_signal in csv_files_list: num = csv_signal[3:6] file = test.open_file(csv_signal, reduced=True) t, u = file['time'], file['voltage'] pl_density = test.read_excel(csv_signal)['dicts'][num]['Ток плазмы, А'] full_integral = np.round(test.e_square(t, u) / 1e-8, 3) if num in reb_nums: reb_dict[num] = {'n': pl_density, 'full_integral': full_integral, 'num': num} else: len_t = len(t) dt = np.abs(t[1] - t[0]) fft_u = rfft(u) freqs_fft = rfftfreq(len_t, dt) ind_mask = np.logical_and(2.695e9 < freqs_fft, freqs_fft < 2.725e9) u_empty = np.zeros(len(ind_mask)) u_empty[ind_mask] = fft_u[ind_mask] fft_filtered_u = irfft(u_empty) #plt.plot(t, u, color='k') #plt.plot(t, fft_filtered_u) #plt.show() absorbers = test.read_excel(csv_signal)['dicts'][num]['Поглотители в тракте магнетрона'] filtered_integral = np.round(test.e_square(t, fft_filtered_u) / 1e-8, 3) pedestal_integral = full_integral - filtered_integral magnetron_dict[num] = {'n': pl_density, 'full_integral': full_integral, 'peak_integral': filtered_integral, 'pedestal_integral': pedestal_integral, 'abs': absorbers, 'num': num} plt.plot(pl_density, full_integral, color='blue', marker='o') plt.plot(pl_density, filtered_integral, color='red', marker='o', linestyle='-') return reb_dict, magnetron_dict
def noise_integrals_block(exp_num, file_nums): proc = ProcessSignal(str(exp_num)) shot_nums, density_vals, full_ints = [], [], [] for num in file_nums: file_name = f'str{num}.csv' file = proc.open_file(file_name, reduced=True) u = file['voltage'] t = file['time'] dt_2 = (t[-1] - t[0])**2 pl_density = proc.read_excel(file_name)['dicts'][num]['Ток плазмы, А'] freqs, amps = proc.fft_amplitude(t, u)['frequency'], proc.fft_amplitude( t, u)['amplitude'] full_int = np.round(dt_2 * proc.e_square(freqs, amps) / 2e-8, 3) density_vals.append(pl_density) shot_nums.append(num) full_ints.append(full_int) sorted_inds = np.argsort(density_vals) density_vals = np.asarray(density_vals)[sorted_inds] shot_nums = np.asarray(shot_nums)[sorted_inds] full_ints = np.asarray(full_ints)[sorted_inds] integrals_dict = { 'nums': shot_nums, 'density': density_vals, 'full_ints': full_ints } return integrals_dict
def magnetron_integrals_bloc(exp_num, file_nums, central_freq=2.714, band_half_width=0.05): proc = ProcessSignal(str(exp_num)) shot_nums, density_vals, full_ints, peak_ints, exp_nums = [], [], [], [], [] for num in file_nums: file_name = f'str{num}.csv' file = proc.open_file(file_name, reduced=True) u = file['voltage'] t = file['time'] f_low = (central_freq - band_half_width) * 1e9 f_high = (central_freq + band_half_width) * 1e9 dt_2 = (t[-1] - t[0])**2 #pl_num = f'{(int(num) - 1):03d}' pl_density = proc.read_excel(file_name)['dicts'][num]['Ток плазмы, А'] freqs, amps = proc.fft_amplitude(t, u)['frequency'], proc.fft_amplitude( t, u)['amplitude'] peak_inds = np.logical_and(freqs >= f_low, freqs <= f_high) p_freqs, p_amps = freqs[peak_inds], amps[peak_inds] full_int = np.round(dt_2 * proc.e_square(freqs, amps) / 2e-8, 3) peak_int = np.round(dt_2 * proc.e_square(p_freqs, p_amps) / 2e-8, 3) density_vals.append(pl_density) shot_nums.append(num) full_ints.append(full_int) peak_ints.append(peak_int) exp_nums.append(exp_num) sorted_inds = np.argsort(density_vals) density_vals = np.asarray(density_vals)[sorted_inds] shot_nums = np.asarray(shot_nums)[sorted_inds] full_ints, peak_ints = np.asarray(full_ints)[sorted_inds], np.asarray( peak_ints)[sorted_inds] integrals_dict = { 'nums': shot_nums, 'density': density_vals, 'full_ints': full_ints, 'peak_ints': peak_ints, 'exp_nums': exp_nums } return integrals_dict
def two_exp_integrals(exp_num, table=False, data=True): test = ProcessSignal('{}'.format(exp_num)) csv_types = test.read_type_file() csv_signals = csv_types['signal_files'] pl_densities = np.zeros(len(csv_signals)) integrals = np.zeros(len(csv_signals)) nums = np.zeros(len(csv_signals)) csv_path = test.csv_files_path csv_dir_files = os.listdir(csv_path) test.reduce_fft() for i, csv_signal in enumerate(csv_signals): csv_signal_num = csv_signal[3:6] if csv_signal in csv_dir_files: file = test.open_file(csv_signal, reduced=True) pl_density = test.read_excel(csv_signal)['dicts'][csv_signal_num]['Ток плазмы, А'] pl_densities[i] = pl_density nums[i] = csv_signal_num t, u, dt = file['time'], file['voltage'], file['time_resolution'] plt.plot(t, u) integrals[i] = np.round(test.e_square(t, u) / 1e-7, 2) print(csv_signal_num, integrals[i]) plt.title("№ {}, e^2 = {}".format(csv_signal_num, integrals[i])) #plt.show() sorted_inds = np.argsort(pl_densities) pl_densities = pl_densities[sorted_inds] integrals = integrals[sorted_inds] nums = nums[sorted_inds] if table: ex_table = excel.Workbook() ex_table.create_sheet(title='Integral', index=0) sheet = ex_table['Integral'] sheet['A1'] = 'Номер' sheet['B1'] = 'Плотность плазмы, отн.ед.' sheet['C1'] = 'Интеграл, *10-8' table_size = integrals.size for k in range(table_size): cell = sheet.cell(row=k+2, column=1) cell.value = nums[k] cell = sheet.cell(row=k+2, column=2) cell.value = pl_densities[k] cell = sheet.cell(row=k+2, column=3) cell.value = integrals[k] path = test.excel_folder_path / 'Integral_{}.xlsx'.format(exp_num) ex_table.save(path) if data: integral_dict = {'pl_ds': pl_densities, 'integral_vals': integrals, 'shot_nums': nums} return integral_dict
nums = np.zeros(len(csv_signals)) test.reduce_fft() for i, csv_signal in enumerate(csv_signals): csv_signal_num = csv_signal[3:6] file = test.open_file(csv_signal, reduced=True) pl_density = test.read_excel( csv_signal)['dicts'][csv_signal_num]['Ток плазмы, А'] pl_densities[i] = pl_density time = file['time'] voltage = file['voltage'] t, u, dt = file['time'], file['voltage'], file['time_resolution'] fft = test.fft_amplitude(t, u, dt) freqs = fft['frequency'] amps = fft['amplitude'] n_dt_2 = (t[-1] - t[0])**2 full_integral = 2 * n_dt_2 * test.e_square(freqs, amps) / 1e-8 integrals[i] = full_integral nums[i] = csv_signal_num ex_table = excel.Workbook() ex_table.create_sheet(title='Integral', index=0) sheet = ex_table['Integral'] sheet['A1'] = 'Номер' sheet['B1'] = 'Плотность плазмы, отн.ед.' sheet['C1'] = 'Интеграл, *10-8' table_size = integrals.size for k in range(table_size): cell = sheet.cell(row=k + 2, column=1) cell.value = nums[k] cell = sheet.cell(row=k + 2, column=2) cell.value = pl_densities[k]
print(reb_nums) reb_dict = {} ambigous_nums = [] dt_list = [] for csv_signal in csv_signals: if csv_signal in csv_files_list: num = csv_signal[3:6] if num in magnetron_nums or num in reb_nums: full_file = test.open_file(csv_signal, reduced=False) t_full, u_full = full_file['time'], full_file['voltage'] file = test.open_file(csv_signal, reduced=True) t, u = file['time'], file['voltage'] dt = np.abs(t[1] - t[0]) pl_density = test.read_excel( csv_signal)['dicts'][num]['Ток плазмы, А'] full_integral = np.round(test.e_square(t, u) / 1e-8, 2) full_file_full_integral = np.round( test.e_square(t_full, u_full) / 1e-8, 2) filtered_u = fft_filter(t, u) filtered_u_full = fft_filter(t_full, u_full) filt_integral = np.round(test.e_square(t, filtered_u) / 1e-8, 3) filt_integral_full = np.round( test.e_square(t_full, filtered_u_full) / 1e-8, 2) b_filtered_u = test.bandpass_filter(t, u, 2.695e9, 2.725e9) b_filtered_u_full = test.bandpass_filter(t_full, u_full, 2.695e9, 2.725e9) b_filt_integral = np.round( test.e_square(t, b_filtered_u) / 1e-8, 2) b_filt_integral_full = np.round(
else: t_min, t_max = 60e-9, 322e-9 cut_inds = np.logical_and(t >= t_min, t <= t_max) t_cut = t[cut_inds] u_cut = u[cut_inds] print(t[0]) dt_2 = (t_cut[-1] - t_cut[0])**2 u_filt = proc.bandpass_filter(t, u, 2.68e9, 2.74e9) ''' plt.plot(t, u) plt.plot(t_cut, u_cut) plt.plot(t, u_filt) plt.title(signal) plt.show() ''' integral = np.round(proc.e_square(t_cut, u_cut) / 1e-8, 3) freqs, amps = proc.fft_amplitude(t_cut, u_cut)['frequency'], proc.fft_amplitude( t_cut, u_cut)['amplitude'] peak_inds = np.logical_and(freqs >= 2.695e9, freqs <= 2.725e9) p_freqs, p_amps = freqs[peak_inds], amps[peak_inds] plt.plot(freqs, amps) plt.title(signal) plt.xlim(left=0e9, right=4e9) plt.show() full_int = np.round(dt_2 * proc.e_square(freqs, amps) / 2e-8, 3) peak_int = np.round(dt_2 * proc.e_square(p_freqs, p_amps) / 2e-8, 3) print('num =', signal, integral, full_int) n = proc.read_excel(
import numpy as np import openpyxl as excel from ProcessClass_10 import ProcessSignal test = ProcessSignal('191120') file_name = 'str018.csv' file = test.open_file(file_name, reduced=True) t, u, dt = file['time'], file['voltage'], file['time_resolution'] fft = test.fft_amplitude(t, u, dt) freqs = fft['frequency'] amps = fft['amplitude'] n_dt_2 = (t[-1] - t[0])**2 full_integral = 2 * n_dt_2 * test.e_square(freqs, amps) / 1e-8 print(full_integral) df_s = np.arange(5, 105, 5) * 1e6 noise_integrals = np.zeros(len(df_s)) peak_integrals = np.zeros(len(df_s)) magnetron_freq = 2.74e9 for i, df in enumerate(df_s): low_freq = magnetron_freq - df high_freq = magnetron_freq + df noise_inds_l = freqs < low_freq noise_inds_r = freqs > high_freq peak_inds = np.logical_and(freqs > low_freq, freqs < high_freq) noise_freqs_l, noise_amps_l = freqs[noise_inds_l], amps[noise_inds_l] noise_freqs_r, noise_amps_r = freqs[noise_inds_r], amps[noise_inds_r] peak_freqs, peak_amps = freqs[peak_inds], amps[peak_inds]
magnetron_nums = excel_dicts['magnetron'][0:0:] nums, n_s, l_ints, r_ints = [], [], [], [] l_noise_ints, r_noise_ints, noise_ns, n_nums = [], [], [], [] for signal in csv_signals: num = signal[3:6] file = proc.open_file(signal, reduced=True) u = file['voltage'] t = file['time'] dt = file['time_resolution'] dt_2 = (t[-1] - t[0])**2 fft_data = proc.fft_amplitude(t, u) freqs, amps = fft_data['frequency'][1::], fft_data['amplitude'][1::] left_inds = freqs <= 2.71e9 - 50e6 l_freqs = freqs[left_inds] l_amps = amps[left_inds] l_int = np.round(dt_2 * proc.e_square(l_freqs, l_amps) / 2e-8, 3) r_inds = freqs >= 2.71e9 + 50e6 r_freqs = freqs[r_inds] r_amps = amps[r_inds] r_int = np.round(dt_2 * proc.e_square(r_freqs, r_amps) / 2e-8, 3) ''' plt.plot(freqs, amps) plt.plot(l_freqs, l_amps) plt.plot(r_freqs, r_amps) plt.title(f'l_int = {l_int}, r_int = {r_int}') plt.xlim(right=6e9) plt.show() ''' pl_density = proc.read_excel(signal)['dicts'][num]['Ток плазмы, А'] if num in magnetron_nums: nums.append(num)
def all_integrals_proc(exp_num, nums, table=True, central_freq=2.714, band_half_width=0.05): proc = ProcessSignal(str(exp_num)) csv_types = proc.read_type_file() csv_signals = csv_types['signal_files'] csv_signal_nums = csv_types['signal_nums'] excel_dicts = proc.read_excel(csv_signal_nums)['numbers'] noise_nums = [ str(int(excel_dicts['noise'][i]) + 1) for i in range(len(excel_dicts['noise'])) if int(excel_dicts['noise'][i]) + 1 in nums ] magnetron_nums = [ str(int(excel_dicts['magnetron'][i]) + 1) for i in range(len(excel_dicts['magnetron'])) if int(excel_dicts['magnetron'][i]) + 1 in nums ] print('Noise:', noise_nums, '\n', 'Amplifier:', magnetron_nums) nums, n_s, full_ints, peak_ints = [], [], [], [] noise_ints, noise_ns, n_nums = [], [], [] for signal in csv_signals: num = signal[3:6] if num in magnetron_nums: file = proc.open_file(signal, reduced=True) u = file['voltage'] t = file['time'] f_low = (central_freq - band_half_width) * 1e9 f_high = (central_freq + band_half_width) * 1e9 u_filt = proc.fft_filter(t, u, f_low, f_high) dt_2 = (t[-1] - t[0])**2 pl_density = proc.read_excel(signal)['dicts'][num]['Ток плазмы, А'] integral = np.round(proc.e_square(t, u) / 1e-8, 3) filt_int = np.round(proc.e_square(t, u_filt) / 1e-8, 3) freqs, amps = proc.fft_amplitude( t, u)['frequency'], proc.fft_amplitude(t, u)['amplitude'] peak_inds = np.logical_and(freqs >= f_low, freqs <= f_high) p_freqs, p_amps = freqs[peak_inds], amps[peak_inds] full_int = np.round(dt_2 * proc.e_square(freqs, amps) / 2e-8, 3) peak_int = np.round(dt_2 * proc.e_square(p_freqs, p_amps) / 2e-8, 3) n_s.append(pl_density) nums.append(num) full_ints.append(full_int) peak_ints.append(peak_int) print('peak_int = ', np.round(integral, 2), 'noise_int =', np.round(integral - filt_int, 2), 'noise_fft =', np.round(full_int - peak_int, 2)) if num in noise_nums: file = proc.open_file(signal, reduced=True) u = file['voltage'] t = file['time'] dt = file['time_resolution'] f_low = (central_freq - band_half_width) * 1e9 f_high = (central_freq + band_half_width) * 1e9 u_filt = proc.fft_filter(t, u, f_low, f_high) dt_2 = (t[-1] - t[0])**2 pl_density = proc.read_excel(signal)['dicts'][num]['Ток плазмы, А'] freqs, amps = proc.fft_amplitude( t, u)['frequency'], proc.fft_amplitude(t, u)['amplitude'] noise_int = np.round(dt_2 * proc.e_square(freqs, amps) / 2e-8, 3) noise_ints.append(noise_int) noise_ns.append(pl_density) n_nums.append(num) ind_sort = np.argsort(np.asarray(n_s)) ns_sort = np.asarray(n_s)[ind_sort] nums_sort = np.asarray(nums)[ind_sort] full_ints_sort, peak_ints_sort = np.asarray( full_ints)[ind_sort], np.asarray(peak_ints)[ind_sort] print('Sorted amplifier numbers:', nums_sort) n_ind_sort = np.argsort(np.asarray(noise_ns)) noise_ns_sort, n_nums_sort, noise_ints_sort = np.asarray( noise_ns)[n_ind_sort], np.asarray(n_nums)[n_ind_sort], np.asarray( noise_ints)[n_ind_sort] print('Sorted noise numbers:', n_nums_sort) if table: ex_table = excel.Workbook() ex_table.create_sheet(title='Integral', index=0) sheet = ex_table['Integral'] sheet['A1'] = 'Номер(шум)' sheet['B1'] = 'Плотность плазмы, отн.ед.' sheet['C1'] = 'W_f0, *10-8' sheet['D1'] = 'W_1, *10-8' sheet['F1'] = 'Номер' sheet['G1'] = 'Плотность плазмы, отн.ед.' sheet['H1'] = 'W_2, *10-8' for z in range(full_ints_sort.size): cell = sheet.cell(row=z + 2, column=1) cell.value = int(nums_sort[z]) cell = sheet.cell(row=z + 2, column=2) cell.value = ns_sort[z] cell = sheet.cell(row=z + 2, column=3) cell.value = peak_ints_sort[z] cell = sheet.cell(row=z + 2, column=4) cell.value = full_ints_sort[z] - peak_ints_sort[z] for k in range(noise_ints_sort.size): cell = sheet.cell(row=k + 2, column=6) cell.value = int(n_nums_sort[k]) cell = sheet.cell(row=k + 2, column=7) cell.value = noise_ns_sort[k] cell = sheet.cell(row=k + 2, column=8) cell.value = noise_ints_sort[k] path = proc.excel_folder_path / f'Integrals_{exp_num}_2_antennas.xlsx' ex_table.save(path) else: noise_dict = { 'nums': n_nums_sort, 'density_vals': noise_ns_sort, 'w_2': noise_ints_sort } magnetron_dict = { 'nums': nums_sort, 'density_vals': ns_sort, 'w_f0': peak_ints_sort, 'w_1': full_ints_sort - peak_ints_sort } return noise_dict, magnetron_dict
def left_right_power(): test = ProcessSignal('191011') csv_types = test.read_type_file() csv_signals = csv_types['signal_files'] csv_signal_nums = csv_types['signal_nums'] excel_dicts = test.read_excel(csv_signal_nums)['numbers'] magnetron_nums = excel_dicts['magnetron'] print('All magnetron nums:', magnetron_nums) m_1_nums = [] m_2_nums = [] for num in magnetron_nums: if 66 <= int(num) < 112: m_1_nums.append(num) elif 112 <= int(num) < 152: m_2_nums.append(num) m_lists = [m_1_nums, m_2_nums] labels_list = ['№2, 3', '№2, 3, A'] for i, m_list in enumerate(m_lists): e_left = [] e_right = [] pl_d = [] fig = plt.figure(num=1, dpi=200, figsize=[11.69, 8.27]) ax = fig.add_subplot(111) ax.set_prop_cycle(color=['orange', 'indigo']) for signal in csv_signals: num = signal[3:6] if num in m_list: file = test.open_file(signal, reduced=True) u = file['voltage'] t = file['time'] dt = file['time_resolution'] u_highpass = test.highpass(t, u, 2.769e9) u_lowpass = test.lowpass(t, u, 2.706e9) fft_pass = test.fft_signal(t, u, dt) freqs = fft_pass['frequency'] amps = fft_pass['amplitude'] high_inds = freqs > 2.769e9 low_inds = freqs < 2.709e9 high_freqs = freqs[high_inds] low_freqs = freqs[low_inds] high_amps = amps[high_inds] low_amps = amps[low_inds] e_high = test.e_square(high_freqs, high_amps) e_low = test.e_square(low_freqs, low_amps) ''' e_high = test.e_square(t, u_highpass) e_low = test.e_square(t, u_lowpass) ''' pl_density = test.read_excel(csv_signal_nums)['dicts'][num]['Ток плазмы, А'] #plt.plot(fft_high['frequency'], fft_high['amplitude'], color='blue') #plt.plot(high_freqs, high_amps, color='red') #plt.plot(low_freqs, low_amps, color='k') e_left.append(e_low) e_right.append(e_high) pl_d.append(pl_density) #plt.show() pl_d = np.array(pl_d) inds = np.argsort(pl_d) pl_d = pl_d[inds] e_left = np.array(e_left)[inds] line1, = ax.plot(pl_d, e_left, marker='o') line1.set_label('f < 2,72 GHz') line2, = ax.plot(pl_d, e_right, marker='o') line2.set_label('f > 2,76 GHz') ax.set_ylim(bottom=0) ax.set_xlim(left=5) ax.set_xlabel(r'$Plasma\/density, arb.units $', fontsize=16) ax.set_ylabel(r'$\int E^2 dt $', fontsize=16) ax.legend(loc='best', fontsize=12) ax.grid(which='both', axis='both') ax.set_title('191011, {}'.format(labels_list[i]), fontsize=20) mean_png = test.pics_path / 'left_right_power{}.png'.format(i) fig.savefig(mean_png) plt.close(fig) plt.show()
def integral_plots(exp, type='integrals', table=True): fft_test = ProcessSignal(exp) csv_types = fft_test.read_type_file() csv_signals = csv_types['signal_files'] csv_signal_nums = csv_types['signal_nums'] print(csv_signals) excel_dicts = fft_test.read_excel(csv_signal_nums)['numbers'] magnetron_nums = excel_dicts['magnetron'] print('All magnetron nums:', magnetron_nums) m_1_nums = magnetron_nums m_2_nums = [] ''' for num in magnetron_nums: if 11 <= int(num) < 67: m_1_nums.append(num) elif 125 <= int(num) <= 184: m_2_nums.append(num) ''' m_lists = [m_1_nums, m_2_nums] labels_list = ['№2, 3 (четверть)', '№2, 3, A'] for j, list in enumerate(m_lists): if len(list) != 0: fig = plt.figure(num=1, dpi=200, figsize=[11.69, 8.27]) ax = fig.add_subplot(111) flist_len = len(list) print('We have {} nums'.format(flist_len)) print('Magnetron nums are:', list) pl_densities = np.zeros(flist_len) e_noise_ints = np.zeros(flist_len) e_peak_ints = np.zeros(flist_len) csv_nums = np.zeros(flist_len) magnetron_nums = np.zeros(flist_len) e_noise_ls = [] e_noise_rs = [] power_koefs = np.zeros(flist_len) for i, num in enumerate(list): for csv_signal in csv_signals: csv_num = csv_signal[3:6] if csv_num == num: magnetron_nums[i] = int(num) print('I am working on {} signal'.format(csv_num)) pl_density = fft_test.read_excel(csv_signal_nums)['dicts'][num]['Ток плазмы, А'] pl_densities[i] = pl_density csv_nums[i] = csv_num file = fft_test.open_file(csv_signal, reduced=True) time = file['time'] voltage = file['voltage'] dt = file['time_resolution'] n_dt = time[-1] - time[0] n_dt_2 = n_dt ** 2 fft = fft_test.fft_amplitude(time, voltage, dt) freqs = fft['frequency'] amps = fft['amplitude'] noise_inds_left = freqs < 2.725e9 noise_inds_right = freqs > 2.755e9 peak_inds = np.logical_and(freqs > 2.725e9, freqs < 2.755e9) freq_noise_l = freqs[noise_inds_left] amp_noise_l = amps[noise_inds_left] freq_noise_r = freqs[noise_inds_right] amp_noise_r = amps[noise_inds_right] freq_peak = freqs[peak_inds] amp_peak = amps[peak_inds] amp_noise_l = 2 * n_dt_2 * fft_test.e_square(freq_noise_l, amp_noise_l) amp_noise_r = 2 * n_dt_2 * fft_test.e_square(freq_noise_r, amp_noise_r) amp_noise = amp_noise_l + amp_noise_r amp_peak = 2 * n_dt_2 * fft_test.e_square(freq_peak, amp_peak) e_noise_ls.append(amp_noise_l) e_noise_rs.append(amp_noise_r) e_noise_ints[i] = amp_noise e_peak_ints[i] = amp_peak power_koefs[i] = amp_noise_r / amp_noise_l print('Creating plasma plot ...') pl_plot = noise_signal_plot(int(exp), type='amp_freq', left_right=True) pl_ds = pl_plot['pl_ds'] pl_nums = pl_plot['plasma_nums'] pl_e_ints = pl_plot['e_integs'] pl_koefs = pl_plot['koefs'] ind_sort = np.argsort(pl_densities) pl_densities = pl_densities[ind_sort] e_noise_ints = e_noise_ints[ind_sort] e_peak_ints = e_peak_ints[ind_sort] x_min = min(pl_ds[0], pl_densities[0]) - 0.5 x_max = max(pl_ds[-1], pl_densities[-1]) + 0.5 if type == 'integrals': ax.set_prop_cycle(color=['orange', 'indigo', 'green']) line3, = ax.plot(pl_ds, pl_e_ints, marker='D', linewidth=2) line3.set_label('Энергия в шумовом импульсе') line, = ax.plot(pl_densities, e_peak_ints, marker='o', linewidth=2) line.set_label('Энергия в пике') line2, = ax.plot(pl_densities, e_noise_ints, marker='^', linewidth=2) line2.set_label('Энергия в шумовом пъедестале') ax.set_ylabel(r'$K\int A^2 df $', fontsize=16) path_png = fft_test.pics_path / 'integral_{}.png'.format(labels_list[j]) if table: magnetron_nums = magnetron_nums[ind_sort] fft_test.integrals_table(magnetron_nums, pl_densities, e_peak_ints, e_noise_ints, pl_nums, pl_ds, pl_e_ints, labels_list[j]) if type == 'left_right': e_noise_ls = e_noise_ls[ind_sort] e_noise_rs = e_noise_rs[ind_sort] ax.set_prop_cycle(color=['red', 'blue']) line_pl_1, = ax.plot(pl_densities, e_noise_ls, marker='o') line_pl_1.set_label(r'$f < 2.725\/GHz$') line_pl_2, = ax.plot(pl_densities, e_noise_rs, marker='^') line_pl_2.set_label(r'$f > 2.755\/GHz$') ax.set_ylabel(r'$K\int A^2 df $', fontsize=16) path_png = fft_test.pics_path / 'left_right_power{}.png'.format(labels_list[j]) if table: magnetron_nums = magnetron_nums[ind_sort] fft_test.left_right_table(magnetron_nums, e_noise_ints, e_noise_ls, e_noise_rs, pl_densities, labels_list[j]) if type == 'left_right_koef': power_koefs = power_koefs[ind_sort] line, = ax.plot(pl_densities, power_koefs, marker='o', linewidth=2) line.set_label(r'$ P_{in} \ne 0 $') line1, = ax.plot(pl_ds, pl_koefs, marker='^', linewidth=2) line1.set_label(r'$P_{in} = 0$') ax.set_ylabel(r'$\frac{W(f>2.755\/ГГц)}{W(f<2.725\/ГГц)} $', fontsize=22) path_png = fft_test.pics_path / 'power_koef_{}.png'.format(labels_list[j]) ax.set_ylim(bottom=0) ax.set_xlim(left=x_min, right=x_max) ax.legend(loc='best', fontsize=12) ax.grid(which='both', axis='both') ax.set_xlabel(r'$Plasma\/density, arb.units $', fontsize=16) ax.set_title('{}, {}'.format(exp, labels_list[j]), fontsize=20) fig.savefig(path_png) plt.close(fig)
test = ProcessSignal('201026') csv_types = test.read_type_file() csv_signals = csv_types['signal_files'][1::] csv_signal_nums = csv_types['signal_nums'] excel_dicts = test.read_excel(csv_signal_nums)['numbers'] magnetron_nums = excel_dicts['magnetron'] reb_nums = excel_dicts['noise'] for csv_signal in csv_signals: num = csv_signal[3:6] file = test.open_file(csv_signal, reduced=False) t, u = file['time'], file['voltage'] cut_file_inds = np.logical_and(t > 70e-9, t < 332e-9) t_cut, u_cut = t[cut_file_inds], u[cut_file_inds] simple_cut_integral = np.round(test.e_square(t_cut, u_cut) / 1e-8, 2) pl_density = test.read_excel(csv_signal)['dicts'][num]['Ток плазмы, А'] #plt.plot(t, u) #plt.title(f'{u[0], u[-1], t[-1]-t[0]}') #plt.show() dt_2 = (t[-1] - t[0])**2 fft_old = fft_amplitude_old(t, u) amps_old, freqs_old = fft_old['amplitude'], fft_old['frequency'] fft_new = fft_amplitude_new(t, u) amps_new, freqs_new = fft_new['amplitude'], fft_new['frequency'] integral_u = np.round(test.e_square(t, u) / 1e-8, 2) fft_signal = test.fft_signal(t, u, np.abs(t[1] - t[0])) simple_amps_fft, simple_freqs_fft = fft_signal['amplitude'], fft_signal[ 'frequency'] simple_fft_integral = np.round( dt_2 * test.e_square(simple_freqs_fft, simple_amps_fft) / 2e-8, 2)