Пример #1
0
def scatter_plot(M,Label,delta=100):
    x = []
    y = []
    count = 0
    for i in M:
        if i[1][0] < 0.5:
            print 'Boosting', Label[count],count
            x.append(i[0])
            y.append(i[1]*5.)
        else:
            x.append(i[0])
            y.append(i[1])
        count+=1
    Mark = ['x','x','o','o','v','1','1','8','8','D','D']
    Mark = ['x','x','o','o','v','v','1','1','8','8','D','D','o','o']
    print len(x),len(Mark)
    pyplot.plot_multi(x,y,Label,logx=True,limx=(0,100),limy=(0,1),loc=1,make_marker=True,M=Mark,
            showleg=True,save='kowasaki')
    fid = open('intstat.dat','w')
    for i in Label:
        fid.write((' %s'%(i)))
    fid.write('\n')
    for i in range(delta):
        fid.write((' %.2f'%(i)))
        for j in range(len(y)):
            fid.write((' %.4f'%(y[j][i])))
        fid.write('\n')
    fid.close()
Пример #2
0
def scatter_plot_sort(M,Label,sort, delta=100):
    x = []
    y = []
    print Label
    count = 0
    yf = np.zeros((delta))
    new_label = []
    for j,i in enumerate(M):
        if Label[j] == sort:
            new_label.append(Label[j])
            if i[1][0] < 0.5:
                x.append(i[0])
                y.append(i[1]*5.)
            else:
                x.append(i[0])
                y.append(i[1])
            yf += y[count][0:delta]
            count+=1
    yf = yf/len(new_label)
    new_label.append('average')
    print len(x[0])
    x.append(x[0][0:delta])
    y.append(yf)
    pyplot.plot(x[0][0:delta],yf,'average',logx=True,limx=(0,100),limy=(0,1),save='average')
    Mark = ['x','x','o','o','v','v','1','1','8','8','D','D']
    Mark = ['x','x','o','o','v','1','1','8','8','D','D']
    pyplot.plot_multi(x,y,new_label,logx=True,limx=(0,100),limy=(0,1),loc=1,make_marker=True,M=Mark,
            showleg=True,save='kowasaki_%s'%sort)
    fid = open('intstat_avg_%s.dat'%sort,'w')
    for j in range(yf.shape[0]):
        fid.write(('%.2f %.4f\n'%(x[0][j],yf[j])))
    fid.close()
Пример #3
0
def find_networks(M, VW, L, n_finish=1, n_start=0, delta=30, rcut=1.0, ndna=25):
    #The total number of frames we are going to look at
    x=np.arange(n_start,n_finish,delta)
    print len(x)
    #Find the number of connections at specific points x
    import MD.canalysis.connections as con
    import MD.analysis.connections as conn
    import MD.analysis.graph as graph
    try:
        connections = util.pickle_load('con.pkl')
    except:
        try:
            C = util.pickle_load('C.pkl')
            G = util.pickle_load('G.pkl')
        except:
            G=M.cord_auto(['G'])
            C=M.cord_auto(['C'])
            util.pickle_dump(C,'C.pkl')
            util.pickle_dump(G,'G.pkl')
        connections = con.connections(C[x],G[x],L,rcut=rcut)
        util.pickle_dump(connections,'con.pkl')
    #plot total number of connections
    num_connections=conn.num_connections(connections,VW.shape[1])
    con_all = []
    for i in range(len(connections)):
        con_all.append(len(connections[i])/2.)
    pyplot.plot(x,num_connections,xlabel='Time',
            ylabel='hyrbid. density', save='connections')
    pyplot.plot(x,con_all,xlabel='Time',
            ylabel='hyrbid', save='connections_all')
    plt.close()
    #get the info
    networks, num_networks, deg, neighbors, num_n, gr = graph.grapher(connections,VW.shape[1],ndna)
    util.pickle_dump(networks,'net.pkl')
    #plot the number of neighbors at each timesteps
    pyplot_eps.plot(x,num_n,xlabel='Time',
            ylabel='num neighbors', save='neighbors')
    plt.close()
    print 'making plot'
    net = []
    for i in networks:
        net.append(len(i))
    pyplot_eps.plot(x,net,xlabel='t',ylabel='networks',save='net')
    label = ['networks','1','2','3','4','5','6','7','8','9']
    pyplot_eps.plot(x,networks,xlabel='t',ylabel='Networks',save='net')
    pyplot.plot_multi(x,deg,label,xlabel='time',ylabel='number',save='con_net')
    return x, networks, connections