def compare(f1, f2): s = open(f1) table = ft.read(s) time = table[:, 0] q = table[:, 1:22] s2 = open(f2) table2 = ft.read(s2) time2 = table2[:, 0] q2 = table2[:, 1:22] return time, time2, q, q2
def plot_rover(filename): s = open(filename) table = ft.read(s) time = table[:, 0] q = table[:, 1:22] velo = table[:, 22:25] y = table[:, 25:31] lamb = table[:, 31] plt.subplot(2, 1, 1) plt.plot(time, q[:, 0:3], 'o-') plt.subplot(2, 1, 2) plt.plot(time, y[:, 0:3], 'o-') plt.show()
def analyze_filedata(): """ Reads ``f C r`` from the command line, where ``f`` is the name of a file, ``C`` and ``r`` are the initial guesses of the parameters in the error model E = C*h^r. A 4th command-line argument can be the plot title. """ # read filename and initial guess of C and r in error formula E=C*h^r f = open(sys.argv[1], 'r') C = float(sys.argv[2]) r = float(sys.argv[3]) try: plot_title = sys.argv[4] except: plot_title = '' from scitools.filetable import read data = read(f) print data OneDiscretizationPrm.analyze(data[:,0], data[:,1], initial_guess=(C,r), plot_title=plot_title)
def analyze_filedata(): """ Reads ``f C r`` from the command line, where ``f`` is the name of a file, ``C`` and ``r`` are the initial guesses of the parameters in the error model E = C*h^r. A 4th command-line argument can be the plot title. """ # read filename and initial guess of C and r in error formula E=C*h^r f = open(sys.argv[1], 'r') C = float(sys.argv[2]) r = float(sys.argv[3]) try: plot_title = sys.argv[4] except: plot_title = '' from scitools.filetable import read data = read(f) print data OneDiscretizationPrm.analyze(data[:, 0], data[:, 1], initial_guess=(C, r), plot_title=plot_title)
f=open('mz'+str(bandindex)+'.txt','r') B=float(f.readline()) C=float(f.readline()) f.close() f=open('mxy'+str(bandindex)+'.txt','r') A=float(f.readline()) f.close() def func(kx,ky,kz,p): A, B, C = p return A*(kx**2+ky**2)+B*kz**2+C s=open('go7CIISeso.dat','r') table=ft.read(s) s.close() end=int(datsf) kx = table[0:end, 0] ky = table[0:end, 1] kz = table[0:end, 2] e1=(table[0:end,bandindex]+table[0:end,bandindex-1])/2*ry r4=sqrt(kx**2+ky**2+(kz_factor*kz)**2) plot(r4,e1,'r-') hold('on')
fileListLambda2=(('d129_4'),('d129_5'),('drag_06'),('d129_7'),('d129_12')) fileListLambda3=(('d129_5'),('d257_5'))#,('d257_7')) fileListLambda4=(('drag_06'),('d257_6'))#,('d257_7')) legendLayer=('layer=0.1', 'layer=0.2','layer=0.3') legendLambda=('lambda=1e5','lambda=1e6','lambda=1e7','lambda=1e9','lambda=1e11', 'Ref from Folke : 0.6726') legendLambda2=('lambda=1e4','lambda=1e5','lambda=1e6','lambda=1e7','lambda=1e12','Ref from Folke : 0.6726') legendLambda3=('lambda=1e5','257 - lambda=1e5','Ref from Folke : 0.6726') legendLambda3=('lambda=1e6','257 - lambda=1e6','Ref from Folke : 0.6726') plt.hold('off') plt.xlabel('time') plt.hold('on') plt.ylabel('drag') plt.axis([0,70,0.3,1]) plt.grid('on') for filename in fileListLambda3: print ("my file is ", filename) file=open(filename) table=ft.read(file) time=table[:,0] drag=table[:,1] file.close() plt.plot(time,drag,'--') plt.axhline(y=0.6726,xmin=0,xmax=22,color='r') plt.legend(legendLambda3) #plt.hold('on') plt.savefig('DragRe133_CompLambda3.pdf') plt.show()
def loaddata(filename): datafile=open(filename,'r') data=ft.read(datafile) datafile.close() return data