def plot_chgload_dt(data, time_scale=1., loadv_scale=1., chgv_scale=1., alpha=0.8, colors=cs.clist(), center=False, figsize=(5, 4)): # """ Returns a lineplot figure of osrs in the order of the dataset provided. # requres time/chgv/loadv dataset. Note time does not currently work but # time scale can be used to adjust the time bins""" fig, ax1 = plt.subplots(figsize=figsize) time = data['time'] * time_scale maxt = max(time) chgv = data['chgv'] * chgv_scale loadv = data['loadv'] * loadv_scale #time = np.linspace(0,maxt,len(time),endpoint=True) if center: time = time - np.median(time) ax1.plot(time, loadv, color=colors[0], label='Load', alpha=alpha) ax2 = ax1.twinx() ax2.plot(time, chgv, color=colors[1], label='Charge', alpha=alpha) ax1.set_title('Charge/Load Pulses') fig.tight_layout() return fig
def plot_mTrace(dataset, time_scale=1., channel='loadv', channel_scale=1., alpha=0.8, colors=cs.clist(), labels=None, center=False): """ Returns a figure, axes, and lines for a single channel from a dataset of multiple traces """ fig, ax = plt.subplots(sharex=True) mykeys = sorted(dataset.keys()) lines = [] for i, data in enumerate(mykeys): time = dataset[data]['time'] * time_scale maxt = max(time) chanv = dataset[data][channel] * channel_scale if center: time = time - np.median(time) if labels is None: lbl = None else: lbl = labels[i] #print len(time), len(chanv) line, = ax.plot(time, chanv, color=colors[i], label=lbl, alpha=alpha) lines.append(line) ax.set_title('Channel Voltage') fig.tight_layout() return fig, ax, lines
def plot_mCH_dt(dataset, time_scale=1., channel='loadv', channel_scale=1., alpha=0.8, colors=cs.clist(), labels=None, center=False): # """ Returns a lineplot figure of osrs in the order of the dataset provided. # requres time/chgv/loadv dataset. Note time does not currently work but # time scale can be used to adjust the time bins""" fig = plt.figure(figsize=(5, 4)) Plot = fig.add_subplot(111) mykeys = sorted(dataset.keys()) for i, data in enumerate(mykeys): time = dataset[data]['time'] * time_scale maxt = max(time) chanv = dataset[data][channel] * channel_scale #time = np.linspace(0,maxt,len(time),endpoint=True) if center: time = time - np.median(time) if labels is None: lbl = data else: lbl = labels[i] Plot.plot(time, chanv, color=colors[i], label=lbl, alpha=alpha) Plot.set_title('Channel Voltage') fig.tight_layout() return fig
def plot_osrs_scatter(dataset, loadR=3.9, time_scale=1., alt_x=None, chgv_scale=1., loadv_scale=.1, color=cs.clist()[0]): """ Returns a scatterplot figure of osrs in the order of the dataset provided. requres time/chgv/loadv dataset """ fig = plt.figure(figsize=(5, 4)) Plot = fig.add_subplot(111) mykeys = sorted(dataset.keys()) for i, data in enumerate(mykeys): minosr = [] chgv = dataset[data]['chgv'] * chgv_scale loadv = dataset[data]['loadv'] * loadv_scale minosr = (max(chgv) / 2 - max(loadv)) * loadR / max(loadv) if alt_x is None: Plot.scatter(i, minosrs[i], color=color) else: Plot.scatter(alt_x[i], minosr, color=color) del chgv, loadv Plot.set_title('On-state Resistance') fig.tight_layout() return fig
def plot_osrs_dt(dataset, time_scale=1., chgv_scale=1., loadv_scale=.1, alpha=0.8, colors=cs.clist(), loadR=3.9, labels=None, center=False): """ Returns a lineplot figure of osrs in the order of the dataset provided. requres time/chgv/loadv dataset. Note time does not currently work but time scale can be used to adjust the time bins""" fig = plt.figure(figsize=(5, 4)) Plot = fig.add_subplot(111) mykeys = sorted(dataset.keys()) for i, data in enumerate(mykeys): osr = [] time = dataset[data]['time'] * time_scale maxt = max(time) chgv = dataset[data]['chgv'] * chgv_scale loadv = dataset[data]['loadv'] * loadv_scale #osr = (max(chgv)/2-max(loadv))*loadR/loadv osr = (max(chgv) / 2 - (loadv)) * loadR / loadv #time = np.linspace(0,maxt,len(time)) time = time - np.mean(time) print len(osr), len(time) time = time[[osr > 0] and [osr < 50]] osr = osr[[osr > 0] and [osr < 50]] #time = time - np.median(time) if labels is None: lbl = data else: lbl = labels[i] Plot.plot(time, osr, color=colors[i], label=lbl, alpha=alpha) Plot.set_title('On-state Resistance') fig.tight_layout() return fig
import numpy as np import matplotlib.pyplot as plt import colors as cs import pandas as pd colors = cs.clist() def del_nonfloat(filename, delim=',', header=None): """ reads file and removes all lines after header which do not contain float-like strings then overwrites the file after adding the header back in""" filein = open(filename, 'r') lines = '' deleted = 0 if header is None: rlines = filein.readlines() else: rlines = filein.readlines()[header:] filein.close() for l in rlines: words = l.rstrip('/n').split(delim) try: [float(w) for w in words] lines += l except: deleted += 1 fileout = open(filename, 'w') fileout.write(lines) fileout.close() return deleted
Min = np.min(dataset[key][channel]) Max = np.max(dataset[key][channel]) Avg = np.average(dataset[key][channel]) print '%s\t%.2e\t%.2e\t%.2e' % (Name, Min, Max, Avg) sys.stdout.close() os.system('unix2dos %s' % (folder + calc_filename)) sys.stdout = temp # Plot the data fig, ax, lines = scplt.plot_mTrace(dataset, channel='chgv', time_scale=t_scale, channel_scale=chgv_scale, labels=labels, center=False, colors=cs.clist(len(dataset) / ch_skip)) # LEGEND PARAMS if legends: legend = ax.legend(fontsize=11, bbox_to_anchor=(1, 1), ncol=2) legend.get_frame().set_alpha(.5) # PLOT LAYOUT for line in lines: line.set_linewidth(0.8) line.set_alpha(.6) for line in lines[-4:]: line.set_linewidth(2) line.set_alpha(0.8) ax.set_title('EHT RCC Hipot Test') ax.set_xlabel('Time (ns)')
#sys.exit() Plaser = Plaser * E_laser / NRJ #normalize laser power function for energy per pulse #check1_Elaser=np.max(integ.cumtrapz(t,Plaser)) # check elaser is correct #print check1_Elaser t_recomb_logarray = np.linspace( -4, -7, 10) # array of 10^-4 to 10^-7 recombination times, arraysize=10 fig, ax1 = plt.subplots() for i, logt_recomb in enumerate( t_recomb_logarray): #loop through recombination times in seconds t_recomb = 10**logt_recomb #calculate carrier concnetration as a function of time based on Nunally (eq8) K = (1 - R) / (w * l * d) / (h * c / lmbda) * ( 1 - np.exp(-Abs * d) ) #constant factor to include switch volume and light efficiency n = n0 + K * np.exp(-t / t_recomb) * integ.cumtrapz( np.exp(t / t_recomb) * Plaser, x=t, initial=0) #carrier concetration in m^-3 lab = '%.2f-us' % (t_recomb * 1e6) logt = np.log10(t) ax1.plot(logt, n, label=lab, color=cs.clist()[i]) #ax2 = ax1.twinx() #ax2.plot(t, Plaser, linestyle='--') plt.xlabel('Log10(Time) (s)') ax1.set_ylabel('Carrier Density (#/cm3)') #ax2.set_ylabel('Laser Intensity') legend = ax1.legend() #legend.get_frame().set_facecolor('none') legend.get_frame().set_alpha(0.6) [i.set_lw(2.) for i in legend.get_lines()] plt.show()
rf = recovery_factor cols = [(1, 0, 0), (0, 1, 0), (0, 0, 1)] lines = ['--', '-', ':'] #plot heat plt.figure(figsize=(5, 4)) plt.subplots_adjust(right=.6) heat_v = [] for i, s in enumerate([5, 34]): sarea = 2. rf = s print s for j, x in enumerate([.5, 1, 1.5, 3, 5]): freq = x * 1e5 heat_V = (Vlt / 2 / (osr + Z))**2 * osr * pulsewidth * freq heat_I = (Cur)**2 * osr * pulsewidth * freq trans_coef_ratio = np.log10((heat_V / heat_I) / dT / sarea * rf) plt.plot(Vlt, trans_coef_ratio, label='%.0f-kHz' % (freq/1e3), \ color=colors.clist()[j], linestyle=lines[i+1], linewidth=2) plt.xlabel('Charge Voltage/Current $(V)$', fontsize=12) plt.ylabel('log(H) (W/cm$^2$K)', fontsize=12) plt.xticks(fontsize=10) plt.yticks(fontsize=10) plt.ylim((-4, 3)) legend = plt.legend(loc='best', fontsize=10, ncol=2) legend.get_frame().set_alpha(0.6) plt.tight_layout() plt.savefig('Heat_Flux_V_%s.png' % time.time(), transparent=True) plt.close()
intensity = [1] for i, k in enumerate(z): intensity.append(intensity[-1] * np.exp(-Abs * d)) #constant factor to include switch volume and light efficiency K = (1 - R) / (w * l * d) / (h * c / lmbda) * (intensity[-1]) R = 0 #carrier concetration in m^-3 n = n0 + K * np.exp(-t / t_recomb) * integ.cumtrapz( np.exp(t / t_recomb) * Plaser, x=t, initial=0) lab = '%.2f-us' % (t_recomb * 1e6) logt = np.log10(t) carrier_peak.append(np.max(n)) if i % (len(z) / 10) == 0: print 'Intensity(x=%.2fmm) =\t%.2e' % (k * 1e3, intensity[-1]) fig, ax1 = plt.subplots() ax1.plot(z * 1e3, carrier_peak, c=cs.clist()[1], lw=2) ax2 = ax1.twinx() ax2.plot(z * 1e3, intensity[:-1], c=cs.clist()[2], lw=2) ax1.set_xlabel('Depth (mm)') ax1.set_ylabel('Carrier Density (#/cm3)') ax2.set_ylabel('Relative Intensity (AU)') ax1.set_title('Peak Carrier Density Profile') ax1col = cs.clist()[1] ax2col = cs.clist()[2] ax1.yaxis.label.set_color(ax1col) ax1.spines['left'].set_color(ax1col) ax2.spines['left'].set_color(ax1col) ax1.tick_params(axis='y', colors=ax1col) ax2.yaxis.label.set_color(ax2col) ax1.spines['right'].set_color(ax2col) ax2.spines['right'].set_color(ax2col)