def plotEn(basename): filelist = getIntFileSlices(basename) print(filelist) axLab = 'Energy (J)' ens = np.zeros(len(filelist)) zData = np.zeros(len(filelist)) fcount = 0 for ij in filelist: ens[fcount] = getEnFromInt(ij, qScale = 0) zData[fcount] = getZData(ij) fcount += 1 ax1 = plt.subplot(111) plt.semilogy(zData, ens) plt.xlabel(r'$z (m)$') plt.ylabel(axLab) ax1.set_title('Energy') opname = basename + "-Energy.png" plt.savefig(opname)
def plotPowVsZ(basename): filelist = getIntFileSlices(basename) print filelist mdata = fdata(filelist[0]) sampleFreq = 1.0 / mdata.vars.dz2 lenz2 = (mdata.vars.nz2 - 1) * mdata.vars.dz2 z2axis = (np.arange(0, mdata.vars.nz2)) * mdata.vars.dz2 xaxis = (np.arange(0, mdata.vars.nx)) * mdata.vars.dxbar yaxis = (np.arange(0, mdata.vars.ny)) * mdata.vars.dybar fcount = 0 pows = np.zeros(len(filelist)) zData = np.zeros(len(filelist)) if (mdata.vars.iMesh == iPeriodic): gAv = iav # for average... plotLab = 'Power' axLab = 'Power (W)' else: gAv = ipeak # for peak... plotLab = 'Peak Power' axLab = 'Power (W)' for ij in filelist: pows[fcount] = getPowFromInt(ij, irtype=gAv, qScale=0) zData[fcount] = getZData(ij) fcount += 1 ax1 = plt.subplot(111) plt.semilogy(zData, pows, label=plotLab) #ax1.set_title(axLab) plt.xlabel('z (m)') plt.ylabel(axLab) #plt.legend() opname = basename + "-unfiltered-power.png" plt.savefig(opname) # plt.show() outfilename = 'powers.h5' h5o = tables.open_file(outfilename, 'w') h5o.create_array('/', 'power_SI', pows) h5o.create_array('/', 'z_SI', zData) h5o.close()
def plotEn(basename): filelist = getIntFileSlices(basename) print filelist mdata = fdata(filelist[0]) sampleFreq = 1.0 / mdata.vars.dz2 lenz2 = (mdata.vars.nz2 - 1) * mdata.vars.dz2 z2axis = (np.arange(0, mdata.vars.nz2)) * mdata.vars.dz2 saxis = z2axis * mdata.vars.lc * 1e6 xaxis = (np.arange(0, mdata.vars.nx)) * mdata.vars.dxbar yaxis = (np.arange(0, mdata.vars.ny)) * mdata.vars.dybar z = mdata.vars.z gAv = iav # for average... plotLab = 'Energy' axLab = 'Energy (J)' ens = np.zeros(len(filelist)) zData = np.zeros(len(filelist)) fcount = 0 for ij in filelist: ens[fcount] = getEnFromInt(ij, qScale=0) zData[fcount] = getZData(ij) fcount += 1 ax1 = plt.subplot(111) plt.semilogy(zData, ens) plt.xlabel(r'$z (m)$') plt.ylabel(axLab) ax1.set_title('Energy') #plt.legend() opname = basename + "-Energy.png" plt.savefig(opname)
def plotPowVsZ(basename): filelist = getIntFileSlices(basename) print(filelist) mdata = fdata(filelist[0]) fcount = 0 pows = np.zeros(len(filelist)) zData = np.zeros(len(filelist)) if (mdata.vars.iMesh == iPeriodic): gAv = iav # for average... plotLab = 'Power' axLab = 'Power (W)' else: gAv = ipeak # for peak... plotLab = 'Peak Power' axLab = 'Power (W)' for ij in filelist: pows[fcount] = getPowFromInt(ij, irtype = gAv, qScale = 0) zData[fcount] = getZData(ij) fcount += 1 plt.semilogy(zData, pows, label=plotLab) plt.xlabel('z (m)') plt.ylabel(axLab) opname = basename + "-unfiltered-power.png" plt.savefig(opname) outfilename = 'powers.h5' h5o = tables.open_file(outfilename,'w') h5o.create_array('/','power_SI',pows) h5o.create_array('/','z_SI',zData) h5o.close()
def plotPowZZ2(basename): filelist = getIntFileSlices(basename) print(filelist) mdata = fdata(filelist[0]) sampleFreq = 1.0 / mdata.vars.dz2 lenz2 = (mdata.vars.nz2 - 1) * mdata.vars.dz2 z2axis = (np.arange( 0, mdata.vars.nz2)) * mdata.vars.dz2 * mdata.vars.lc * 1.e6 xaxis = (np.arange(0, mdata.vars.nx)) * mdata.vars.dxbar yaxis = (np.arange(0, mdata.vars.ny)) * mdata.vars.dybar fcount = 0 pows = np.zeros(len(filelist)) zData = np.zeros(len(filelist)) # if (mdata.vars.iMesh == iPeriodic): # gAv = 1 # for average... # else: # gAv = 2 # for peak... gAv = 0 # for temporal (no cycle averaging) pows = np.ones([len(filelist), mdata.vars.nz2]) powsN = np.ones([len(filelist), mdata.vars.nz2]) for ij in filelist: pows[-1 - fcount, :] = getPowFromInt(ij, irtype=gAv, qScale=0) mv = np.max(pows[-1 - fcount, :]) if (mv != 0.): powsN[-1 - fcount, :] = pows[-1 - fcount, :] / np.max( pows[-1 - fcount, :]) else: powsN[-1 - fcount, :] = 0. zData[fcount] = getZData(ij) fcount += 1 # print fcount # plotLab = 'SI Power' # axLab = 'Power (W)' # if (mdata.vars.iMesh == iPeriodic): # plotLab = 'SI Power' # axLab = 'Power (W)' # else: # plotLab = 'SI Peak Power' axLab = 'Power (W)' ax1 = plt.subplot(111) im = plt.imshow(powsN, aspect='auto', interpolation='bilinear', \ extent=[z2axis[0], z2axis[-1], zData[0], zData[-1]]) ax1.set_title('Power') plt.xlabel(r'$ct-z (\mu m)$') plt.ylabel('z (m)') cb = plt.colorbar(im) plt.tight_layout() #plt.legend() opname = basename + "-powerALL.png" plt.savefig(opname)