def average_signals(directory, files, channels): avg_signals = np.zeros((3, 5119)) for file in files: (times, signals) = labview.load_data(directory, file, channels=channels) avg_signals += signals avg_signals /= len(files) return (times, avg_signals)
mpl.rcParams['figure.subplot.top'] = 0.9 mpl.rcParams['figure.subplot.bottom'] = 0.1 mpl.rcParams['figure.subplot.wspace'] = 0.2 mpl.rcParams['figure.subplot.hspace'] = 0.2 reset_plot_params() lv_directory = "C:\\Users\\plane\\Desktop\\Data\\HPRF\\HPRF 20120605\sparks_29p5MV-M_15Hz\\" #lv_file = "reduced_53_55.npz" lv_file = "spark_53_55.npz" #(times, signals) = labview.load_data(lv_directory, lv_file, t0=286.4e-3, t1=286.6e-3, (times, signals) = labview.load_data(lv_directory, lv_file, t0=286.377e-3, t1=286.8e-3, channels=[0, 1, 2, 3, 4, 5, 6]) signal = signals[5] / np.max(signals[5]) damped_signal = [ signal[x] * (math.exp(1 - times[x] / 2.0e-5)) for x in range(len(signal)) ] damped_signal = damped_signal / np.max(damped_signal) fig = plt.figure(figsize=(12, 7)) fig.text(0.04, 0.52, 'Normalized Amplitude', ha='center', va='center', rotation='vertical') plt.subplot(211)
mpl.rcParams['figure.subplot.right'] = 0.98 mpl.rcParams['figure.subplot.top'] = 0.9 mpl.rcParams['figure.subplot.bottom'] = 0.1 mpl.rcParams['figure.subplot.wspace'] = 0.2 mpl.rcParams['figure.subplot.hspace'] = 0.2 reset_plot_params() plt.figure(figsize=(12, 9)) lv_directory = "C:\\Users\\plane\\Desktop\\Data\\HPRF\\HPRF 20120605\sparks_29p5MV-M_15Hz\\" lv_file = "spark_66_68.npz" (times, raw_signals) = labview.load_data(lv_directory, lv_file, t0=221.524e-3, t1=222.324e-3, channels=[0, 1, 2]) dt = 1.0e-6 flip_time = 310.e-6 flip_offset = int(round(flip_time / dt)) raw_signals[2, flip_offset:] = -raw_signals[2, flip_offset:] plt.subplot(311) plt.ylim((-1.2, 1.2)) plot.plot_signals(times * 1e6, raw_signals, norm=True) # 22us wavefront delay data_dir = "C:\\Users\\plane\\Dropbox\\Research\\MTA\\Analysis\\HPRF\\" if platform.system() == 'Linux': data_dir = "/home/lane/Dropbox/Research/MTA/Analysis/HPRF/" comsol_file = "hpc_wall_shock.npy"
comsol_file = "ring_under_disk_0.25ms_30.5cm_25ms_1.5e8_1.5e8_1.5e8.csv" plot_all(tek_dir, tek_file, comsol_dir, comsol_file, -1) # # High-Pressure Cavity # ## HC Observed vs. Simulated RF Hammer Comparison # In[ ]: #get_ipython().magic(u'matplotlib qt') lv_dir = "C:\\Users\\peter\\Development\\Dissertation\\data\\HC\\" if platform.system() == 'Linux': lv_dir = "/home/lane/Data/HPRF/HPRF 20120614/sparks_36MV-M_15Hz/" lv_file = "spark_66_68.npz" (times, real_hammer_signals) = labview.load_data(lv_dir, lv_file, t0=0.029342, t1=0.039342, channels=(0,5,3,)) # channels=(0,5,3,6,)) (frequencies, magnitudes, phases) = psig.spectra(times, real_hammer_signals) fig = plt.figure(figsize=(20.0, 8.0)) plt.subplot(221) #plt.xlabel('Time (s)') plt.ylabel('Normalized Voltage') plot.plot_signals(times*1e6, real_hammer_signals, tlim=300, ylim=1.5, norm=True) plt.subplot(222) #plt.xlabel('Frequency (Hz)') plt.ylabel('Normalized Magnitude') plot.plot_signals(frequencies*1e-3, magnitudes, ylim=(0,1.2), tlim=30, norm=True) comsol_dir = "C:\\Users\\peter\\Development\\Dissertation\\data\\HC\\" if platform.system() == 'Linux': comsol_dir = "/home/lane/Data/COMSOL/HPRF/RF Hammer with Thin Elastic Layer/" comsol_file = "\S0_TEL_r_1e9_z_21e6_S1_TEL_r_15e6_z_1e9_S5_TEL_r_1e9_z_37e6_10ms.npy"
upsampled_signals = np.zeros((np.shape(breakdown_signals)[0], np.shape(breakdown_signals)[1]*2)) upsampled_times = np.linspace(0, times[-1], np.shape(upsampled_signals)[1]) for i,signal in enumerate(breakdown_signals): upsampled_signals[i] = np.roll(sig.resample(signal, len(signal)*2), -i) plot.plot_signals(upsampled_times*1e6, upsampled_signals, tlim=50) plt.show() fig = plt.figure(figsize=(15,10)) location_predictions = np.zeros((len(lv_files), 2)) """ for index, lv_file in enumerate(lv_files): #(times, breakdown_signals) = labview.load_data(lv_dir, lv_file, t0=40e-6, t1=90e-6, channels=[4,5,6,7]) #(times, breakdown_signals) = labview.load_data(lv_dir, lv_file, t0=40e-6, t1=90e-6, channels=[4,5,6,7]) (times, breakdown_signals) = labview.load_data(lv_dir, lv_file, t0=40e-6, t1=130e-6, channels=[4, 5, 6, 7]) #(times, breakdown_signals) = labview.load_data(lv_dir, lv_file, t0=20e-6, t1=130e-6, channels=[0,1,2,3]) #(times, breakdown_signals) = mc.condition_signals(times, breakdown_signals, window_width=200e-6) plt.subplot(231 + index) """ dt = times[1] - times[0] signal = breakdown_signals[3] frequency_spectrum = np.fft.fft(signal)[:int(round(signal.size/2))] spectrum_magnitudes = np.sqrt( np.real(frequency_spectrum)**2 + np.imag(frequency_spectrum)**2) frequencies = np.fft.fftfreq(frequency_spectrum.size*2, d=dt)\ [:int(round(signal.size/2))] #plt.plot(frequencies, spectrum_magnitudes) f_peak = frequencies[np.argmax(spectrum_magnitudes[1:])]
labview.load_data(lv_dir, lv_file, t0=229.386e-3, t1=229.686e-3, channels=[0,1,2,3,5])[1])) avg_hammer = np.average(hammers, axis=0) times,spark = labview.load_data(lv_dir, lv_file, t0=296.092e-3, t1=296.392e-3, channels=[0,1,2,3,5]) """ lv_dir = "C:\\Users\\plane\\Desktop\\Data\\MC\\2016-01-13\\" lv_files = [ "raw_data_2016-01-13@20_47_30.401.npz", "raw_data_2016-01-13@21_02_29.931.npz", "raw_data_2016-01-13@21_17_29.865.npz", "raw_data_2016-01-13@21_32_29.923.npz", "raw_data_2016-01-13@21_47_29.931.npz" ] hammers = np.array([ labview.load_data(lv_dir, lv_file, t0=30e-6, t1=430e-6, channels=[ 6, ])[1] for lv_file in lv_files ]) avg_hammer = np.average(hammers, axis=0) lv_file = "reduced_data_2016-01-13@18_43_18.362.npz" times, spark = labview.load_data(lv_dir, lv_file, t0=30e-6, t1=430e-6, channels=[ 6, ]) times = times * 1e6 fig = plt.figure(figsize=(16.0, 8.0)) #fig.text(0.5, 0.05, r'Time ($ms$)', ha='center', va='center', size=26)