Beispiel #1
0
def _rotdif(arr,
            nvecs=1000,
            rvecin=None,
            rseed=80531,
            order=2,
            ncorr=-1,
            tol=1E-6,
            d0=0.03,
            nmesh=2,
            dt=0.002,
            ti=0.0,
            tf=-1,
            itmax=-1.,
            dtype='ndarray'):
    '''

    Parameters
    ----------
    arr : array-like, shape (n_frames, 3, 3) or (n_frames, 9)
    '''
    _nvecs = 'nvecs ' + str(nvecs)
    _rvecin = 'rvecin ' + rvecin if rvecin is not None else ''
    _rseed = 'rseed ' + str(rseed)
    _order = 'order ' + str(order)
    _ncorr = 'ncorr ' + str(ncorr) if ncorr > 0 else ''
    _tol = 'tol ' + str(tol)
    _d0 = 'd0 ' + str(d0)
    _nmesh = 'nmesh ' + str(nmesh)
    _dt = 'dt ' + str(dt)
    _ti = 'ti ' + str(ti)
    _tf = 'tf ' + str(tf)
    _itmax = 'itmax ' + str(itmax)
    _rmatrix = 'rmatrix mymat'

    act = CpptrajAnalyses.Analysis_Rotdif()
    dslist = CpptrajDatasetList()
    dslist.add_set('mat3x3', 'mymat')

    arr = np.asarray(arr, dtype='f8')
    msg = 'array must have shape=(n_frames, 9) or (n_frames, 3, 3)'
    shape = arr.shape
    if arr.ndim == 2:
        assert shape[1] == 9, msg
    elif arr.ndim == 3:
        assert shape[1:3] == (3, 3), msg
        # need to reshape to (n_frames, 9)
        arr = arr.reshape(shape[0], shape[1] * shape[2])
    else:
        raise ValueError(msg)
Beispiel #2
0
def _rotdif(arr,
            nvecs=1000,
            rvecin=None,
            rseed=80531,
            order=2,
            ncorr=-1,
            tol=1E-6,
            d0=0.03,
            nmesh=2,
            dt=0.002,
            ti=0.0,
            tf=-1,
            itmax=-1.,
            dtype='ndarray'):
    '''

    Parameters
    ----------
    arr : array-like, shape (n_frames, 3, 3) or (n_frames, 9)
    '''
    _nvecs = 'nvecs ' + str(nvecs)
    _rvecin = 'rvecin ' + rvecin if rvecin is not None else ''
    _rseed = 'rseed ' + str(rseed)
    _order = 'order ' + str(order)
    _ncorr = 'ncorr ' + str(ncorr) if ncorr > 0 else ''
    _tol = 'tol ' + str(tol)
    _d0 = 'd0 ' + str(d0)
    _nmesh = 'nmesh ' + str(nmesh)
    _dt = 'dt ' + str(dt)
    _ti = 'ti ' + str(ti)
    _tf = 'tf ' + str(tf)
    _itmax = 'itmax ' + str(itmax)
    _rmatrix = 'rmatrix mymat'

    act = CpptrajAnalyses.Analysis_Rotdif()
    dslist = CpptrajDatasetList()
    dslist.add_set('mat3x3', 'mymat')

    arr = np.asarray(arr, dtype='f8')
    msg = 'array must have shape=(n_frames, 9) or (n_frames, 3, 3)'
    shape = arr.shape
    if arr.ndim == 2:
        assert shape[1] == 9, msg
    elif arr.ndim == 3:
        assert shape[1:3] == (3, 3), msg
        # need to reshape to (n_frames, 9)
        arr = arr.reshape(shape[0], shape[1] * shape[2])
    else:
        raise ValueError(msg)
Beispiel #3
0
def lifetime(data, cut=0.5, rawcurve=False, more_options='', dtype='ndarray'):
    """lifetime (adapted lightly from cpptraj doc)

    Parameters
    ----------
    data : 1D-array or 2D array-like
    cut : cutoff to use when determining if data is 'present', default 0.5
    more_options : str, more cpptraj's options. Check cpptraj's manual.
    """
    data = np.asarray(data)
    if data.ndim == 1:
        data_ = [
            data,
        ]
    else:
        data_ = data

    _outname = 'name lifetime_'
    _cut = 'cut ' + str(cut)
    _rawcurve = 'rawcurve' if rawcurve else ''
    # do not sorting dataset's names. We can accessing by indexing them.
    _nosort = 'nosort'

    namelist = []
    cdslist = CpptrajDatasetList()
    for idx, arr in enumerate(data_):
        # create datasetname so we can reference them
        name = 'data_' + str(idx)
        if 'int' in arr.dtype.name:
            cdslist.add_set("integer", name)
        else:
            cdslist.add_set("double", name)
        cdslist[-1].data = np.asarray(arr)
        namelist.append(name)

    act = CpptrajAnalyses.Analysis_Lifetime()
    _cm = ' '.join(namelist)
    command = " ".join((_cm, _outname, _cut, _rawcurve, _nosort, more_options))
    act(command, dslist=cdslist)

    for name in namelist:
        cdslist.remove_set(cdslist[name])
    return get_data_from_dtype(cdslist, dtype=dtype)
Beispiel #4
0
def lifetime(data, cut=0.5, rawcurve=False, more_options='', dtype='ndarray'):
    """lifetime (adapted lightly from cpptraj doc)

    Parameters
    ----------
    data : 1D-array or 2D array-like
    cut : cutoff to use when determining if data is 'present', default 0.5
    more_options : str, more cpptraj's options. Check cpptraj's manual.
    """
    data = np.asarray(data)
    if data.ndim == 1:
        data_ = [data, ]
    else:
        data_ = data

    _outname = 'name lifetime_'
    _cut = 'cut ' + str(cut)
    _rawcurve = 'rawcurve' if rawcurve else ''
    # do not sorting dataset's names. We can accessing by indexing them.
    _nosort = 'nosort'

    namelist = []
    cdslist = CpptrajDatasetList()
    for idx, arr in enumerate(data_):
        # create datasetname so we can reference them
        name = 'data_' + str(idx)
        if 'int' in arr.dtype.name:
            cdslist.add_set("integer", name)
        else:
            cdslist.add_set("double", name)
        cdslist[-1].data = np.asarray(arr)
        namelist.append(name)

    act = CpptrajAnalyses.Analysis_Lifetime()
    _cm = ' '.join(namelist)
    command = " ".join((_cm, _outname, _cut, _rawcurve, _nosort, more_options))
    act(command, dslist=cdslist)

    for name in namelist:
        cdslist.remove_set(cdslist[name])
    return get_data_from_dtype(cdslist, dtype=dtype)