コード例 #1
0
ファイル: NP_sphere.py プロジェクト: cdknorow/MD
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
コード例 #2
0
ファイル: dna.py プロジェクト: cdknorow/MD
def find_networks(M, VW, L,x,ndna=25):
    import MD.canalysis.connections as con
    import MD.analysis.connections as conn
    import MD.analysis.graph as graph
    #plot total number of connections
    connections = _connections(M)
    num_connections=conn.num_connections(connections,VW.shape[1])
    con_all = []
    for i in range(len(connections)):
        con_all.append(len(connections[i][0]))
    print len(x),len(num_connections)
    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.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.plot(x,net,xlabel='t',ylabel='networks',save='net')
    label = ['networks','1','2','3','4','5','6','7','8','9']
    x = [x for i in range(len(deg))]
    #pyplot.plot(x,num_networks,xlabel='t',ylabel='Networks',save='net')
    #pyplot.plot_multi(x[:4],deg[:4],label,xlabel='time',ylabel='number',save='con_net')
    plt.close()
    return networks, num_networks, deg, neighbors, num_n, gr

    #pyplot.plot_multi(x[:4],deg[:4],label,xlabel='time',ylabel='number',save='con_net')
    plt.close()
    return networks, num_networks, deg, neighbors, num_n, gr