def plotSimul(axR2, flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials): lblB2B = latex_float(float(strB2B)) sd = SimulData() sd.metadata(flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials, loadData=True) #sd.getData() estilo = lineStyDAT(sd) linea, = axR2.plot(sd.ttime, sd.DelR2, **estilo) popt, pcov, i_min, i_max = fitPowLawFromTo(sd.ttime, sd.DelR2, xmin=1e4, xmax=1e6, returnIndx=True) print popt[0], popt[1] #axR2.plot(sd.ttime, sd.DelR2[0]*sd.ttime, "--", color='r') XXX = sd.ttime[i_min:i_max] YYY = powLaw(XXX, popt[0], popt[1]) #axR2.plot(XXX, YYY, ":", color='k') xpos = 10**(0.5 * (np.log10(XXX[0]) + np.log10(XXX[-1]))) ypos = 10**(0.4 * (np.log10(YYY[0]) + np.log10(YYY[-1]))) xpos = 1e4 ypos = 2 lblExponente = str(popt[0]) #axR2.text(xpos, ypos, "$ \\sim t^{"+lblExponente+"} "+"$") #scaXX, scaYY = ScaleFunction(sd) #linea, = axR2Sca.plot(scaXX, scaYY, **estilo) return True, linea, ""
def plotSimulData(axR2, flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials): sd = SimulData() sd.metadata(flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials, loadData=True) i_min = 1 ymax = 0.1 * sd.Hrad**2 i_max = len(sd.DelR2[sd.DelR2 < ymax]) # print sd.Hrad, len(tmpo), tmpo, tmpo[:12], tmpo[11] popt, pcov = fitPowLaw(sd.ttime[i_min:i_max], sd.DelR2[i_min:i_max]) print popt[0], popt[1] # axR2.plot(sd.ttime, sd.DelR2[0]*sd.ttime, "--", color='r') #lblExponente = str(popt[0]) lblExponente = "{:03.2f}".format(popt[0]) estilo = lineStyDAT(sd) estilo["label"] = estilo["label"] + ", " + lblExponente linea, = axR2.plot(sd.ttime, sd.DelR2, **estilo) XXX = sd.ttime[i_min:i_max] YYY = powLaw(XXX, popt[0], popt[1]) axR2.plot(XXX, YYY, ":", color='k') #scaXX, scaYY = ScaleFunction(sd) #linea, = axR2Sca.plot(scaXX, scaYY, **estilo) return True, linea, ""
def plotSimul(axR2,flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials ): lblB2B = latex_float( float(strB2B) ) sd = SimulData() sd.metadata(flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials, loadData=True ) #sd.getData() estilo = lineStyDAT(sd) linea, = axR2.plot(sd.ttime, sd.DelR2, **estilo) axR2.plot(sd.ttime, sd.ttime, "--") axR2.plot(sd.ttime, 1.5*sd.ttime, "--") #scaXX, scaYY = ScaleFunction(sd) #linea, = axR2Sca.plot(scaXX, scaYY, **estilo) return True, linea, ""
def plotSimul(axR2, axR2Sca, dirList, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials ): lblB2B = latex_float( float(strB2B) ) flag = False idir = 0 while idir < len(dirList): try: sd = SimulData() #print dirList[idir] flnPrefix02 = dirList[idir]+flnPrefix sd.metadata(flnPrefix02, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials ) sd.getData() estilo = lineStyDAT(sd) # titulo = "$p_{FB} = "+lblF2B+", p_{BF} = "+lblB2F+", p_{BB} = "+lblB2B+", R_H = "+strHrad+"$" # if fit_params[strHrad]["lambFlag"]: # Figuras[hr], Conexions[hr] = sd.calcDwithLamb(fit_params[strHrad], colorcito, titulo) # else: # sd.calcDiffCoeff(fit_params[strHrad]) # DiffCoeff[hr] = sd.DiffCoeff # D_err_mim[hr] = sd.D_err_min # D_err_max[hr] = sd.D_err_max axR2.plot(sd.ttime, sd.DelR2, **estilo) #axR2.plot(sd.ttime[sd.imin:sd.imax], line(sd.ttime[sd.imin:sd.imax], sd.popt[0], sd.popt[1]), '--', color='k' ) scaXX, scaYY = ScaleFunction(sd) #linea, = axR2Sca.plot(sd.pB2B*sd.ttime/sd.Hrad**2.0, sd.DelR2/(sd.pB2B*sd.ttime), **estilo) linea, = axR2Sca.plot(scaXX, scaYY, **estilo) flag = True return flag, linea, estilo['label'] break; except IOError as e: flag = False #print e pass idir = idir + 1 return False, None, None
#!/usr/bin/python # Read files from csv file and check if file exists? import csv from SimulData import * with open("RunJobs.csv") as csvfile: mpg = list(csv.DictReader(csvfile)) for i in range(len(mpg)): sd = SimulData() sd.metadataFromCSVentry("", mpg[i]) sd.defineFiles() print sd.arguments
axR2.tick_params(axis='y', which='minor', right='off') axR2.tick_params(axis='y', which='major', right='on') axR2.tick_params(axis='y', which='minor', left='off') axR2.tick_params(axis='y', which='major', left='on') colvals = np.abs(np.log(map(float, strB2BList))) + 3.0 colvals = (colvals / colvals.max())[::-1] #print colvals #ofile = open(outfln_DAT,"w") #linea="#prob DiffCoeff\n" #ofile.write(linea) for b2b in range(len(strB2BList)): strB2B = strB2BList[b2b] sd = SimulData() try: sd.metadata(flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials, loadData=False) if sd.isDatafile(): sd.getData() else: sd.metadata(flnPrefix, strF2B, strB2F,
axR2_a.tick_params(axis='y', which='minor', left='off') axR2_a.tick_params(axis='y', which='major', left='on') lblF2B = latex_float02(float(strF2B)) lblB2B = latex_float02(float(strB2B)) titulo_a = "(a) $ p_{S} = " + lblB2B + " $" + ", $R = " + strHrad + "$" axR2_a.text(0.25, 0.95, titulo_a, transform=axR2_a.transAxes, verticalalignment='top', fontsize=20) for b2f in range(len(strB2FList)): strB2F = strB2FList[b2f] sd = SimulData() try: sd.metadata(flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials, loadData=False) if sd.isDatafile(): sd.getData() else: sd.metadata(flnPrefix, strF2B, strB2F,
return True, linea, "" ########################################################################### #flag, tmpLinea, tmpEtiqueta = plotSimul(axR2, flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials ) #if flag: # print "ok" # ### lineas .append(tmpLinea) # ### etiquetas.append(tmpEtiqueta) #else: # print strF2B, strB2F, strB2B, strHrad, strBrad, "# MISSING SIMULATION" for b2f in range(len(strB2FList)): strB2F = strB2FList[b2f] lblB2F = latex_float( float(strB2F) ) sd = SimulData() sd.metadata(flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials, loadData=True ) estilo = lineStyDAT(sd) axR2.plot(sd.ttime, sd.DelR2, **estilo) linea, = axR2.plot(sd.ttime, sd.ttime, "--", color='r') drD = DraggableLogLogLine(linea) drD.connect() legs = axR2.legend( bbox_to_anchor=(0.8, 0.4), loc="upper left", title="$p_{BF} $", prop={'size':12}, frameon=False, handlelength=2) #legs= axR2.legend(lineas, etiquetas, bbox_to_anchor=(0.8, 0.4), loc="upper left", title="$R_H $", prop={'size':12}, frameon=False, handlelength=2) figR2.tight_layout() #figR2.savefig(outfln_PDF) ### print legs if legs:
dataFiley = dataFilePrefix +".hisy" dataFilez = dataFilePrefix +".hisz" datax = np.loadtxt(dataFilex) datay = np.loadtxt(dataFiley) dataz = np.loadtxt(dataFilez) freq = (datax[:,2]+datay[:,2]+dataz[:,2])/3.0 posx = 0.5*(datax[:,0]+datax[:,1]) axHis .plot(posx, freq, **estilo ) # "-o", color=colorcito, label="$"+strHistoTime+"$") posxSca = posx/np.sqrt(histoTime) freqSca = freq*np.sqrt(histoTime) axHisSca.plot(posxSca, freqSca, **estilo ) #"-o", color=colorcito, label="$"+strHistoTime+"$") ########### INSET PLOT ############3 sd = SimulData() #print dirList[idir] flnPrefix02 = "./"+flnPrefix sd.metadata(flnPrefix02, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials ) sd.getData() estilo = lineStyDAT(sd) axR2.plot(sd.ttime, sd.DelR2, linestyle='-', color='k') #**estilo) axR2.plot(sd.ttime, sd.ttime, linestyle='--', color='r') #estilo['color']) DifCoeff = get_D_from_DB("RandomIniCond_02/", sd) #popt, pcov = fitGaussian(posxSca, freqSca) #print popt #XX = np.linspace(-0.25,0.25, num=100) #YY = gaussian(XX, popt[0], popt[1])
estilo = { 'linestyle': tipoLinea, # (0, (5, 10)), 'color': colorcito, 'linewidth': anchoLinea, 'label': etiqueta, 'alpha': alfa # 'marker' : marcador, # 'markersize' : 9, # 'markeredgewidth' : 2, # 'markeredgecolor' : colorcito, } return estilo #'solid' sd = SimulData() sd.metadata("RandomIniCond_02/" + flnPrefix, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials, loadData=True) sdOld = SimulData() sdOld.metadata("../rw3D_RegularPorousNEWRANDOM/" + flnPrefix, strF2B, strB2F, strB2B, strHrad,
freq = (datax[:,2]+datay[:,2]+dataz[:,2])/3.0 posx = 0.5*(datax[:,0]+datax[:,1]) axHis .plot(posx, freq, **estilo ) # "-o", color=colorcito, label="$"+strHistoTime+"$") axHis .plot(posx, normalDistri(posx, 0.25, histoTime), '--', color='k') posxSca = posx/np.sqrt(histoTime) freqSca = freq*np.sqrt(histoTime) axHisSca.plot(posxSca, freqSca, **estilo ) #"-o", color=colorcito, label="$"+strHistoTime+"$") axHisSca.plot(posxSca, normalDistri(posxSca, 0.25, 1.0), '--', color='k') ############ INSET PLOT ############3 #rw3D_TotalFree__nt_100000.dat sd = SimulData() #print dirList[idir] #sd.metadata(flnPrefix02, strF2B, strB2F, strB2B, strHrad, strBrad, strNtrials ) sd.dataFile = flnPrefix+"__nt_100000.dat" sd.getData() sd.imin = 10 sd.imax = len(sd.ttime) - 10 sd.popt, sd.pcov = fitLine(sd.ttime[sd.imin:sd.imax], sd.DelR2[sd.imin:sd.imax]) sd.DiffCoeff = sd.popt[0]/6.0 print "D = ", sd.DiffCoeff #axR2. plot(sd.ttime[sd.imin:sd.imax], line(sd.ttime[sd.imin:sd.imax], sd.popt[0], sd.popt[1]), ':', linewidth=2.5, color='k') #estilo = lineStyDAT(sd) axR2.plot(sd.ttime, sd.DelR2) axR2.plot(sd.ttime, sd.ttime, linestyle='--', color='r')