Exemple #1
0
    def kinetic_network(self, traj=None, ranges=None, bins=None, labels=True, verbose=False):

        if traj in ["CLUSTERS", "Clusters", "clusters"]:
            if type(self.traj_clusters) not in [numpy.ndarray]:
                self.traj_clusters = numpy.array(self.traj_clusters, order="Fortran")

            self.network_clusters = kinetic_network(
                self.traj_clusters, ranges=[self.traj_clusters.min(), self.traj_clusters.max()], verbose=verbose
            )
            return

        elif traj in ["NODES", "Nodes", "nodes"]:
            if type(self.traj_nodes) not in [numpy.ndarray]:
                self.traj_nodes = numpy.array(self.traj_nodes, order="Fortran")
            self.network = kinetic_network(
                self.traj_nodes, ranges=[self.traj_nodes.min(), self.traj_nodes.max()], verbose=verbose
            )
            return

        else:
            self.traj = pyn_math.standard_traj(self.traj, particles=self.particles, dimensions=self.dimensions)
            if ranges == None:
                ranges = pyn_math.build_ranges(self.traj)
            else:
                ranges = pyn_math.standard_ranges(ranges)
            self.network, self.traj_nodes = kinetic_network(
                self.traj, ranges=ranges, bins=bins, traj_out=True, labels=labels, verbose=verbose
            )
            return
Exemple #2
0
def kinetic_network(traj=None,ranges=None,bins=None,traj_out=False,labels=True,verbose=True):

    prov_net=network(directed=True,kinetic=True,verbose=False)

    ranges=pyn_math.standard_ranges(ranges)
    dimensions=ranges.shape[0]
    traj=pyn_math.standard_traj(traj,dimensions)
    num_frames=traj.shape[0]
    num_parts=traj.shape[1]

    opt_labels=0
    if labels:
        opt_labels=1

    if bins!=None:
        if type(bins) in [int]:
            bins=[bins]
        if len(bins)!=dimensions:
            print '# The length of bins must be equal to the length of ranges'
            return
        bins=numpy.array(bins,dtype=int,order='F')
        traj_net=f_kin_anal.trajbinning2net(opt_labels,traj,ranges,bins,num_frames,num_parts,dimensions)
    else:
        traj_net=f_kin_anal.traj2net(opt_labels,traj,ranges,num_frames,num_parts,dimensions)

    traj_net=pyn_math.standard_traj(traj_net,particles=num_parts,dimensions=1)

    prov_net.Ts=True
    prov_net.T_ind=copy.deepcopy(f_kin_anal.t_ind)
    prov_net.T_wl=copy.deepcopy(f_kin_anal.t_tau)
    prov_net.T_start=copy.deepcopy(f_kin_anal.t_start)
    prov_net.build_from_Ts()
    if opt_labels:
        if bins==None:
            for ii in range(prov_net.num_nodes):
                label=str(f_kin_anal.labels[ii])
                prov_net.node[ii].label=label
                prov_net.labels[label]=ii
        else:
            for ii in range(prov_net.num_nodes):
                label=str(f_kin_anal.labels_daux[ii])
                prov_net.node[ii].label=label
                prov_net.labels[label]=ii


    f_kin_anal.free_memory_ts()
    if verbose:
        prov_net.info(update=False,verbose=True)
        pass
    else:
        pass

    if traj_out:
        return prov_net,traj_net
    else:
        del(traj_net)
        return prov_net
    def kinetic_network(self,traj=None,ranges=None,verbose=False):

        if traj in ['CLUSTERS','Clusters','clusters']:
            if type(self.traj_clusters) not in [numpy.ndarray]:
                self.traj_clusters=numpy.array(self.traj_clusters,order="Fortran")

            self.network_clusters=kinetic_network(self.traj_clusters,ranges=[self.traj_clusters.min(),self.traj_clusters.max()],verbose=verbose)
            return

        elif traj in ['NODES','Nodes','nodes']:
            if type(self.traj_nodes) not in [numpy.ndarray]:
                self.traj_nodes=numpy.array(self.traj_nodes,order="Fortran")
            self.network_nodes=kinetic_network(self.traj_nodes,ranges=[self.traj_nodes.min(),self.traj_nodes.max()],verbose=verbose)
            return

        else:
            self.traj=pyn_math.standard_traj(self.traj,particles=self.particles,dimensions=self.dimensions)
            if ranges==None:
                ranges=pyn_math.build_ranges(self.traj)
            else:
                ranges=pyn_math.standard_ranges(ranges)
            self.network_nodes,self.traj_nodes=kinetic_network(self.traj,ranges=ranges,traj_out=True,verbose=verbose)                
            return