コード例 #1
0
def plot_all(tek_dir, tek_file, comsol_dir, comsol_file, sign):
    plt.figure(figsize=(18.9, 10.3))
    (xs, ys) = tektronix.load_csv_data(tek_dir, tek_file)
    xs = xs[0]
    ys = sign*ys[0] / np.max(sign*ys[0])
    plt.subplot(221)
    plt.xlabel('Time (ms)')
    plt.ylabel('Normalized Amplitude')
    plt.xlim((0, 14))
    plt.ylim((-1.2,1.2))
    plt.plot(xs*1e3, ys)

    dt = xs[1] - xs[0]
    df = 1.0 / dt / len(xs)
    print "".join(("dt: ", str(dt), " s\tdf: ", str(df), " Hz"))
    frequency_spectrum = np.fft.fft(ys)\
      [:round(ys.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)\
      [:round(ys.size/2)]
    plt.subplot(222)
    plt.xlabel('Frequency (kHz)')
    plt.ylabel('Normalized Magnitude')
    plt.xlim((0,7))
    plt.ylim((0,1))
    plt.plot(frequencies*1e-3, spectrum_magnitudes / np.max(spectrum_magnitudes))

    #(xs, ys) = comsol.load_csv_data(comsol_dir, comsol_file)
    (xs, ys) = comsol.load_data(comsol_dir, comsol_file, dt=25e-6)
    print np.shape(xs)
    print np.shape(ys)
    #xs = xs[0]
    ys = ys[0,0] / np.max(ys[0,0])
    plt.subplot(223)
    plt.xlabel('Time (ms)')
    plt.ylabel('Normalized Amplitude')
    plt.xlim((0,14))
    plt.ylim((-1.2,1.2))
    plt.plot(xs*1e3, ys)

    dt = xs[1] - xs[0]
    df = 1.0 / dt / len(xs)
    print "".join(("dt: ", str(dt), " s\tdf: ", str(df), " Hz"))
    frequency_spectrum = np.fft.fft(ys)\
      [:round(ys.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)\
      [:round(ys.size/2)]
    plt.subplot(224)
    plt.xlabel('Frequency (kHz)')
    plt.ylabel('Normalized Magnitude')
    plt.xlim((0,7))
    plt.ylim((0,1))
    plt.plot(frequencies*1e-3, spectrum_magnitudes / np.max(spectrum_magnitudes))
コード例 #2
0
def load_signals(data_dir, data_file, dt):
    (times, signal_sets) = comsol.load_data(data_dir, data_file, dt=dt)
    return [(index, times, signals)
            for index, signals in enumerate(signal_sets)]
コード例 #3
0
def load_signals(data_dir, data_file, dt):
    (times, signal_sets) = comsol.load_data(data_dir, data_file, dt=dt)
    #return [mc.condition_signals(times, signals, window_width=150e-6) for signals in signal_sets]
    return [(times, signals) for signals in signal_sets]
コード例 #4
0
                                         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"
(times, breakdown_signals) = comsol.load_data(data_dir, comsol_file, dt=2.0e-6)
dt = times[1]
plt.subplot(312)
plt.ylim((-1.2, 1.2))
plt.ylabel('Normalized Amplitude')
plot.plot_signals(times * 1e6, breakdown_signals[0],
                  norm=True)  # 22us wavefront delay

comsol_file = "hpc_gas_shock.npy"
(times, breakdown_signals) = comsol.load_data(data_dir, comsol_file, dt=2.0e-6)
plt.subplot(313)
plt.ylim((-1.2, 1.2))
plt.xlabel('Time (us)')
plot.plot_signals(times * 1e6, breakdown_signals[0],
                  norm=True)  # 22us wavefront delay
コード例 #5
0
plt.figure(figsize=(12, 20))
#comsol_file = "test_[9]_400kHz.npy"
#comsol_file = "test_0_10x4_400kHz.npy"
#comsol_file = "test_0_10x4_2MHz.npy"
#comsol_file = "test_0_10x4_2MHz_finer.npy"
#comsol_file = "random1_8MHz.npy"
#comsol_file = "random1_40MHz.npy"
#comsol_file = "random100_4MHz.npy"
comsol_file = "random100_400kHz.npy"
#comsol_file = "random100_1MHz.npy"
#comsol_file = "random100_2MHz.npy"
#comsol_file = "random100.npy"
actual_locations = np.load("".join((data_dir, "actual_locations.npy")))[:5]
mic_coordinates = np.array(zip([5, -5, -5, 5], [6, 6, -6, -6]))
dt = 2.5e-6
(times, signal_sets) = comsol.load_data(data_dir, comsol_file, dt=dt)
#signals = signal_sets[8]
for index, signals in enumerate(signal_sets[:5]):
    #for index,signals in enumerate(signal_sets):
    print actual_locations[index]
    distances = np.sqrt(
        np.sum((mic_coordinates - actual_locations[index])**2, axis=1))
    print 'Source-Mic Times:', distances / 2.3e5
    plt.subplot(511 + index)
    #plt.xlim(0,120)
    plot.plot_signals(times * 1e6, signals)
    cwts = mc.signals_to_cwts(times, signals)
    #plot.plot_signals(times*1e6, cwts)
    print order_by_time(times, signals, False)

    #plot.plot_signals(times*1e6, cwts)
コード例 #6
0
    mpl.rcParams['figure.subplot.hspace'] = 0.2


reset_plot_params()

data_dir = "C:\\Users\\plane\\Dropbox\\Research\\MTA\\Analysis\\MC\\"
if platform.system() == 'Linux':
    data_dir = "/home/lane/Dropbox/Research/MTA/Analysis/MC/"

signals_list = []
"""
filenames = ["random100_400kHz_inner.npy", "random100_400kHz_mid_inner.npy",
             "random100_400kHz_mid_outer.npy", "random100_400kHz_outer.npy"]
dt = 2.5e-6
"""
filenames = [
    "random100_2MHz_inner.npy", "random100_2MHz_mid_inner.npy",
    "random100_2MHz_mid_outer.npy", "random100_2MHz_outer.npy"
]
dt = 0.5e-6

signals_list = np.array(
    [comsol.load_data(data_dir, filename, dt=dt) for filename in filenames])
times = signals_list[0, 0]
signals_list = signals_list[:, 1]
combined_signals = np.vstack(signals_list)

#filename = "random100_400kHz.npy"
filename = "random100_2MHz.npy"
np.save(filename, combined_signals)
コード例 #7
0
(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"
(times, sim_hammer_signals_set) = comsol.load_data(comsol_dir, comsol_file, dt=2e-6)

sim_hammer_signals = sim_hammer_signals_set[0]
(frequencies, magnitudes, phases) = psig.spectra(times, sim_hammer_signals)
print(psig.peaks(frequencies, magnitudes[2])[:10])
plt.subplot(223)
plt.xlabel(r'Time ($\mu s$)')
plt.ylabel('Normalized Voltage')
plot.plot_signals(times*1e6, sim_hammer_signals, tlim=300, ylim=1.2, norm=True)
plt.subplot(224)
plt.xlabel(r'Frequency ($kHz$)')
plt.ylabel('Normalized Magnitude')
#plot.plot_spectra(times, sim_hammer_signals, flim=3e4, ylim=1.2, norm=True)
plot.plot_signals(frequencies*1e-3, magnitudes, ylim=(0,1.2), tlim=30, norm=True)
# plt.show()
コード例 #8
0
import pgl.tektronix as tektronix
import pgl.mc as mc
import pgl.progress as prog
import pgl.cluster as clust
import pgl.hpc as hpc


def reset_plot_params():
    mpl.rcParams['ytick.labelsize'] = 22
    mpl.rcParams['xtick.labelsize'] = 22
    mpl.rcParams['axes.labelsize'] = 26
    mpl.rcParams['font.size'] = 26
    mpl.rcParams['mathtext.default'] = 'regular'
    mpl.rcParams['figure.subplot.left'] = 0.02
    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()

directory = 'C:/Users/plane/Dropbox/Research/MTA/Analysis/AMC/'
filename = 'al_disk_spring_foundation.npy'
(times, signals) = comsol.load_data(directory, filename, dt=25e-6)
plt.xlabel('Time (ms)')
plt.ylabel('Norm. Acceleration (m/s)')
plot.plot_signals(times * 1e3, signals[0], norm=True)
plt.tight_layout()