def loadPointCorrespondences(filename): """Loads and returns the corresponding points in world (first 2 lines) and image spaces (last 2 lines)""" from numpy.lib.npyio import loadtxt from numpy import float32 points = loadtxt(filename, dtype=float32) return (points[:2, :].T, points[2:, :].T) # (world points, image points)
def makeUserSED(filename): """ Returns a model of an SED supplied by the user """ from numpy.lib.io import loadtxt SED = loadtxt(filename) return SED[:,0],SED[:,1]
def matlab2PointCorrespondences(filename): '''Loads and converts the point correspondences saved by the matlab camera calibration tool''' from numpy.lib.io import loadtxt, savetxt from numpy.lib.function_base import append points = loadtxt(filename, delimiter=',') savetxt(utils.removeExtension(filename)+'-point-correspondences.txt',append(points[:,:2].T, points[:,3:].T, axis=0))
def makeUserSED(filename): """ Returns a model of an SED supplied by the user """ from numpy.lib.io import loadtxt SED = loadtxt(filename) return SED[:, 0], SED[:, 1]
def getSED(name): """ Returns a model of the SED, a tuple of (wave,data) """ try: from numpy.lib.io import loadtxt except: from numpy import loadtxt f = open(SEDpath + name + ".sed") SED = loadtxt(f) f.close() return SED[:, 0], SED[:, 1]
def getSED(name): """ Returns a model of the SED, a tuple of (wave,data) """ try: from numpy.lib.io import loadtxt except: from numpy import loadtxt f = open(SEDpath+name+".sed") SED = loadtxt(f) f.close() return SED[:,0],SED[:,1]
def filterfromfile(file): """ Create a filter model from a file. """ try: from numpy.lib.io import loadtxt except: from numpy import loadtxt from scipy.interpolate import splrep import scipy f = open(filterpath + file + ".res") filter = loadtxt(f) f.close() return splrep(filter[:, 0], filter[:, 1], k=1, s=0)
def filterfromfile(file): """ Create a filter model from a file. """ try: from numpy.lib.io import loadtxt except: from numpy import loadtxt from scipy.interpolate import splrep import scipy f = open(filterpath+file+".res") filter = loadtxt(f) f.close() return splrep(filter[:,0],filter[:,1],k=1,s=0)
import os.path import numpy.lib.io as io import numpy.core.multiarray as ma import matplotlib.pyplot as plt ###################### ### Main body ###################### # base name of files base = "N16_dr10_fr10_br1_bd5" # plot average throughput x, y = io.loadtxt(base + ".thr", usecols=[0,1], unpack=True) plt.close() plt.plot(x, y, 'o-', linewidth=3) #plt.axis([0, 100, 0, 40]) plt.xlabel("Number of Sessions per ONU ($n$)") plt.ylabel("Average Throughput [Mbps]") #plt.yticks(ma.arange(0, 50, 10)) plt.grid(linestyle='-') plt.minorticks_on() plt.show() plt.savefig(base + ".thr.png", format='png') # raw_input("Press ENTER to continue ...") # # plot ECR # x, y = io.loadtxt(base + ".ecr", usecols=[0,1], unpack=True)
import os.path import numpy.lib.io as io import numpy.core.multiarray as ma import matplotlib.pyplot as plt ###################### ### Main body ###################### # base name of files base = "N1_br1_bd5" # plot web page delay x, y = io.loadtxt(base + "_n5.dly.org", usecols=[0,1], unpack=True) plt.close() plt.plot(x, y, linewidth=3) plt.axis([0, 10, 0, 4]) plt.xlabel("Access Rate ($R_D$=$R_F$) [Mbps]") plt.ylabel("$D_W$ [s]") plt.xticks(ma.arange(0, 11)) #plt.yticks(ma.arange(0, 50, 10)) plt.grid(linestyle='-') plt.minorticks_on() plt.show() plt.savefig(base + "_n5.dly.png", format='png')
import numpy.core.multiarray as ma import numpy.lib.function_base as num_base from scipy import interpolate, optimize ###################### ### Main body ###################### # base name of files base1 = "N16_dr10" base2 = "br1_bd5" # get data plt.close() x1, y1 = io.loadtxt("../TdmPonWithHttp/N16_dr10_fr10_br1_bd5.ecr", usecols=[0,1], unpack=True) x2, y2 = io.loadtxt(base1 + "_fr20_" + base2 + ".ecr.new", usecols=[0,1], unpack=True) x3, y3 = io.loadtxt(base1 + "_fr30_" + base2 + ".ecr.new", usecols=[0,1], unpack=True) x4, y4 = io.loadtxt(base1 + "_fr40_" + base2 + ".ecr.new", usecols=[0,1], unpack=True) # # obain 1-d spline curves # smoothing = 2 # # tck = interpolate.splrep(x1, y1, s=smoothing) # x1_new = num_base.linspace(0.01, 100, 100) # y1_new = interpolate.splev(x1_new, tck, der=0) # # tck = interpolate.splrep(x2, y2, s=smoothing) # x2_new = num_base.linspace(0.01, 100, 100) # y2_new = interpolate.splev(x2_new, tck, der=0) #
c='orange' elif 'Other Pathogen' in d[n]: c='m' colorList.append(c) if s.has_key(n): sizeList.append(int(s[n])) else: sizeList.append(0) return colorList, sizeList fileName1="MCL_1.6_OutputModified.txt" % (projectDir1) #output file from MCL clustering fileName2="phiBase_version4.0_content.txt" % (projectDir1)#file created with script: gettingHostTaxa_fromPHIbase_4.0.py fileName3="pathClassOnGeneId_PHIid_phiBase_4.0.csv.csv" % (projectDir1) #file created with script: analysisOfPHIbase_v4.0.py #Read the cluster information into an array data1=loadtxt(fileName1, dtype='S') data2=loadtxt(fileName2, dtype='S', delimiter=';') #d=dict([(e.split(';')[0], e.split(';')[7]) for e in data2]) d=dict() for e in data2: k='PHI:'+e[0] v=e[7] d.setdefault(k, set()).add(v) data3=loadtxt(fileName3, dtype='S', delimiter=';') s=dict([('PHI:'+e[0], e[1]) for e in data3]) #Create an empty dictionary cluster=dict() phi=dict() G=nx.Graph() #For each element of the array, that is for each line of the file for row in data1:
# returns a single-argument function which returns interpolated delay given a rate def f(delay): return lambda x: interpolate.splev(x, tck, der=0) - delay ###################### ### Main loop ###################### # get file name of delay data from the user in_name = raw_input("The name of the delay data file: ") # extract the number of sessions & web page delay to X & Y X, Y = io.loadtxt(in_name, usecols=[0, 1], unpack=True) # DEBUG plt.close() for i in range(0, len(X)): # calculate ECR for a given pair of the number of sessions (n) & web page delay (web_page_delay) n = X[i] delay = Y[i] # DEBUG #print "for n = %d and delay = %f:" % (n, delay) # extract rate & delay to x & y from the data file for ECR reference model ecr_basename = "../EcrReferenceWithHttp/N1_br1_bd5_n" ecr_name = ecr_basename + str(int(n)) + ".dly"
import os.path import numpy.lib.io as io import numpy.core.multiarray as ma import matplotlib.pyplot as plt ###################### ### Main body ###################### # base name of files base = "N1_br1_bd5" # plot web page delay x1, y1 = io.loadtxt(base + "_n1.dly", usecols=[0,1], unpack=True) x2, y2 = io.loadtxt(base + "_n10.dly", usecols=[0,1], unpack=True) x3, y3 = io.loadtxt(base + "_n100.dly", usecols=[0,1], unpack=True) x4, y4 = io.loadtxt(base + "_n400.dly", usecols=[0,1], unpack=True) plt.close() l1, l2, l3, l4 = plt.plot(x1, y1, 'bo-', x2, y2, 'r*-', x3, y3, 'gD-', x4, y4, 'c^-', linewidth=3) plt.legend((l1, l2, l3, l4), ('$n$=1', '$n$=10', '$n$=100', '$n$=400'), 'center right') plt.axis([0, 10, 0, 100]) plt.xlabel("Access Rate ($R_D$=$R_F$) [Mbps]") plt.ylabel("$D_W$ [s]") plt.xticks(ma.arange(0, 11)) #plt.yticks(ma.arange(0, 50, 10)) plt.grid(linestyle='-') plt.minorticks_on() plt.show()
import numpy.core.multiarray as ma import numpy.lib.function_base as num_base from scipy import interpolate, optimize ###################### ### Main body ###################### # base name of files base1 = "N16_dr10" base2 = "br1_bd5" # get data plt.close() x1, y1 = io.loadtxt("../TdmPonWithHttp/N16_dr10_fr10_br1_bd5.ecr", usecols=[0, 1], unpack=True) x2, y2 = io.loadtxt(base1 + "_fr20_" + base2 + ".ecr.new", usecols=[0, 1], unpack=True) x3, y3 = io.loadtxt(base1 + "_fr30_" + base2 + ".ecr.new", usecols=[0, 1], unpack=True) x4, y4 = io.loadtxt(base1 + "_fr40_" + base2 + ".ecr.new", usecols=[0, 1], unpack=True) # # obain 1-d spline curves # smoothing = 2 # # tck = interpolate.splrep(x1, y1, s=smoothing)
def loadPointCorrespondences(filename): '''Loads and returns the corresponding points in world (first 2 lines) and image spaces (last 2 lines)''' from numpy import loadtxt, float32 points = loadtxt(filename, dtype=float32) return (points[:2,:].T, points[2:,:].T) # (world points, image points)
# (C) 2009 Kyeong Soo (Joseph) Kim import os.path import numpy.lib.io as io import numpy.core.multiarray as ma import matplotlib.pyplot as plt ###################### ### Main body ###################### # base name of files base = "N16_dr10_fr10_br1_bd5" # plot average throughput x, y = io.loadtxt(base + ".thr", usecols=[0, 1], unpack=True) plt.close() plt.plot(x, y, 'o-', linewidth=3) #plt.axis([0, 100, 0, 40]) plt.xlabel("Number of Sessions per ONU ($n$)") plt.ylabel("Average Throughput [Mbps]") #plt.yticks(ma.arange(0, 50, 10)) plt.grid(linestyle='-') plt.minorticks_on() plt.show() plt.savefig(base + ".thr.png", format='png') # raw_input("Press ENTER to continue ...") # # plot ECR # x, y = io.loadtxt(base + ".ecr", usecols=[0,1], unpack=True)
if s.has_key(n): sizeList.append(int(s[n])) else: sizeList.append(0) return colorList, sizeList fileName1="MCL_1.6_Output.txt" #% (projectDir1) fileName2="phiBaseFile_withHostTaxaGrouping_noPHIid.txt" #% (projectDir1) fileName3="pathClassOnGeneId.csv" #% (projectDir1) #Read the cluster information into an array data1=loadtxt(fileName1, dtype='S') data2=loadtxt(fileName2, dtype='S', delimiter=';') #d=dict([(e.split(';')[0], e.split(';')[7]) for e in data2]) d=dict() for e in data2: k='PHI:'+e[0] v=e[7] d.setdefault(k, set()).add(v) data3=loadtxt(fileName3, dtype='S', delimiter=';') s=dict([('PHI:'+e[0], e[1]) for e in data3]) #Create an empty dictionary cluster=dict()
tck = () # returns a single-argument function which returns interpolated delay given a rate def f(delay): return lambda x: interpolate.splev(x, tck, der=0) - delay ###################### ### Main loop ###################### # get file name of delay data from the user in_name = raw_input("The name of the delay data file: ") # extract the number of sessions & web page delay to X & Y X, Y = io.loadtxt(in_name, usecols=[0,1], unpack=True) # DEBUG plt.close() for i in range(0, len(X)): # calculate ECR for a given pair of the number of sessions (n) & web page delay (web_page_delay) n = X[i] delay = Y[i] # DEBUG #print "for n = %d and delay = %f:" % (n, delay) # extract rate & delay to x & y from the data file for ECR reference model ecr_basename = "../EcrReferenceWithHttp/N1_br1_bd5_n" ecr_name = ecr_basename + str(int(n)) + ".dly"
import os.path import numpy.lib.io as io import numpy.core.multiarray as ma import matplotlib.pyplot as plt ###################### ### Main body ###################### # base name of files base = "N16_dr10_fr10_br1_bd5" # plot web page delay x, y = io.loadtxt(base + ".dly", usecols=[0,1], unpack=True) plt.close() plt.plot(x, y, 'o-', linewidth=3) plt.axis([0, 100, 0, 40]) plt.xlabel("Number of Sessions per ONU ($n$)") plt.ylabel("$D_W$ [s]") plt.yticks(ma.arange(0, 50, 10)) plt.grid(linestyle='-') plt.minorticks_on() plt.show() plt.savefig(base + ".dly.png", format='png') raw_input("Press ENTER to continue ...") # plot ECR x, y = io.loadtxt(base + ".ecr", usecols=[0,1], unpack=True)