def oscillograms(): test = ProcessSignal('191106') 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'] for signal in csv_signals: file = test.open_file(signal, reduced=True) u = file['voltage'] t = file['time'] dt = file['time_resolution'] u_filt = test.bandpass_filter(t, u, 2.725e9, 2.755e9) num = signal[3:6] if int(num) < 66: absorbers = '№2, 3' elif 66 <= int(num) < 125 and num in magnetron_nums: absorbers = 0 elif 125 <= int(num) <= 184 and num in magnetron_nums: absorbers = '№2, 3, A' else: absorbers = 0 pl_d_nums = test.read_excel(csv_signal_nums)['dicts'].keys() if num in pl_d_nums: pl_density = test.read_excel(csv_signal_nums)['dicts'][num]['Ток плазмы, А'] test.oscill_picture(num, t, u, u_filt, pl_density, absorbers, save=True)
def amp_max(): test = ProcessSignal('191001') 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'] m_1_nums = [] m_2_nums = [] m_3_nums = [] for num in magnetron_nums: if 35 <= int(num) < 79: m_1_nums.append(num) elif 79 <= int(num) < 111: m_2_nums.append(num) elif 127 <= int(num) <= 150: m_3_nums.append(num) m_lists = [m_1_nums, m_2_nums, m_3_nums] labels_list = ['№2, 3', '№2, 3, A, Б, В', '№2, 3, A', 'Шум'] fig = plt.figure(num=1, dpi=200, figsize=[11.69, 8.27]) ax = fig.add_subplot(111) ax.set_prop_cycle(color=['blue', 'green', 'deepskyblue']) for i, list in enumerate(m_lists): u_maxs = [] pl_ds = [] for csv_signal in csv_signals: csv_num = csv_signal[3:6] for num in list: if csv_num == num: file = test.open_file(csv_signal) u = file['voltage'] t = file['time'] red_dict = test.proc_part_130_290(t, u) red_u = red_dict['part_u'] red_t = red_dict['part_t'] u_filt = test.bandpass_filter(red_t, red_u, 2.709e9, 2.769e9) u_max = np.max(np.array(u_filt)) pl_d = test.read_excel(csv_signal_nums)['dicts'][num]['Ток плазмы, А'] u_maxs.append(u_max) pl_ds.append(pl_d) sorted_inds = np.argsort(np.array(pl_ds)) pl_ds = np.array(pl_ds) pl_ds = pl_ds[sorted_inds] u_maxs = np.array(u_maxs) u_maxs = u_maxs[sorted_inds] line, = plt.plot(pl_ds, u_maxs, marker='o', linewidth=2) line.set_label('{}'.format(labels_list[i])) ax.set_ylim(bottom=0) ax.set_xlim(left=4, right=9) ax.set_xlabel(r'$Plasma\/density, arb.units $', fontsize=14) ax.set_ylabel(r'$Max\/amplitude$', fontsize=14) ax.grid(which='both', axis='both') ax.legend(loc='best', fontsize=16) ax.set_title('Max amplitude', fontsize=20) png_name = test.pics_path / 'max_amp.png' plt.savefig(png_name) plt.show()
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( test.e_square(t_full, b_filtered_u_full) / 1e-8, 2) ''' fft = test.fft_amplitude(t, u, dt) freqs = fft['frequency'] amps = fft['amplitude'] n_dt_2 = (t[-1] - t[0]) ** 2 amp_full_integral = np.round(2 * n_dt_2 * test.e_square(freqs, amps) / 1e-8, 2) #peak_fft = test.fft_amplitude(t, filtered_u, dt) peak_inds = np.logical_and(freqs > 2.695e9, freqs < 2.725e9) freq_peak = freqs[peak_inds]
nums = [] for signal in signal_list[1]: signal_file = f'str{signal:03d}.csv' file = proc.open_file(signal_file, reduced=False) t, u = file['time'], file['voltage'] if signal < 95: t_min, t_max = 960e-9, 1222e-9 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)
ind_mask = np.logical_and(low_freq < freqs_fft, freqs_fft < high_freq) bandpass_filter = np.zeros(len(fft_u)) bandpass_filter[ind_mask] = 1 b_filt_u = irfft(fft_u * bandpass_filter) return b_filt_u ''' file_data = open_file(file) t, u = file_data['t'], np.asarray(file_data['u']) fft_u = fft_filter(t, u) origin_data = open_file(origin_filt_file, filtered=True) t_filt_or, u_filt_or = origin_data['t_filt'], origin_data['u_filt'] ''' #plt.plot(t, u) #plt.plot(t, fft_u) #plt.plot(t_filt_or, u_filt_or) #plt.show() proc = ProcessSignal('201111') file = 'str019.csv' file_data = proc.open_file(file) t, u = file_data['time'], file_data['voltage'] fft_filt_u = proc.fft_filter(t, u) bandpass_u = proc.bandpass_filter(t, u, 2.695e9, 2.725e9) new_file_path = path / 'new_file_19_1.csv' new_file = open(str(new_file_path), 'w', newline='') with new_file: writer = csv.writer(new_file) for i in range(0, len(t)): writer.writerow([0, 0, 0, t[i], u[i], fft_filt_u[i], bandpass_u[i]])