Example #1
0
def write_discrete_trajectory(filename, dtraj):
    r"""Write discrete trajectory to ascii file.   
    
    Parameters
    ---------- 
    filename : str 
        The filename of the discrete state trajectory file. 
        The filename can either contain the full or the 
        relative path to the file.
    dtraj : array-like of int
        Discrete state trajectory

    See also
    --------
    read_discrete_trajectory

    Notes
    -----
    The discrete trajectory is written to a 
    single column ascii file with integer entries.

    Examples
    --------

    >>> from tempfile import NamedTemporaryFile    
    >>> from pyemma.msm.io import write_discrete_trajectory, load_discrete_trajectory

    Use temporary file
    
    >>> tmpfile = NamedTemporaryFile()

    Discrete trajectory
    
    >>> dtraj = np.array([0, 1, 0, 0, 1, 1, 0])

    Write to disk (as ascii file)
    
    >>> write_discrete_trajectory(tmpfile.name, dtraj)

    Read from disk

    >>> X = read_discrete_trajectory(tmpfile.name)
    >>> X
    array([0, 1, 0, 0, 1, 1, 0])    
    
    """
    trajectory.write_discrete_trajectory(filename, dtraj)
Example #2
0
def write_discrete_trajectory(filename, dtraj):
    r"""Write discrete trajectory to ascii file.   
    
    Parameters
    ---------- 
    filename : str 
        The filename of the discrete state trajectory file. 
        The filename can either contain the full or the 
        relative path to the file.
    dtraj : array-like of int
        Discrete state trajectory

    See also
    --------
    read_discrete_trajectory

    Notes
    -----
    The discrete trajectory is written to a 
    single column ascii file with integer entries.

    Examples
    --------

    >>> from tempfile import NamedTemporaryFile    
    >>> from pyemma.msm.io import write_discrete_trajectory, load_discrete_trajectory

    Use temporary file
    
    >>> tmpfile = NamedTemporaryFile()

    Discrete trajectory
    
    >>> dtraj = np.array([0, 1, 0, 0, 1, 1, 0])

    Write to disk (as ascii file)
    
    >>> write_discrete_trajectory(tmpfile.name, dtraj)

    Read from disk

    >>> X = read_discrete_trajectory(tmpfile.name)
    >>> X
    array([0, 1, 0, 0, 1, 1, 0])    
    
    """
    trajectory.write_discrete_trajectory(filename, dtraj)
Example #3
0
 def test_write_discrete_trajectory(self):
     dt.write_discrete_trajectory(self.filename, self.dtraj)
     dtraj_n = np.loadtxt(self.filename)
     self.assertTrue(np.all(dtraj_n == self.dtraj))
 def test_write_discrete_trajectory(self):
     dt.write_discrete_trajectory(self.filename, self.dtraj)
     dtraj_n=np.loadtxt(self.filename)
     self.assertTrue(np.all(dtraj_n==self.dtraj))