r"""Calculate local elastic properties as a function of time for convergence check

        It can be used to obtained elastic properties as a function of time.

        .. note:: Elastic properties cannot be calculated using a single frame because fluctuations are required.
                  Therefore, here time means trajectory between zero time to given time.


        When ``helical='False'``, following is obtained:

            1) Shift (:math:`K_{Dx}`)
            2) Slide (:math:`K_{Dy}`)
            3) Rise (:math:`K_{Dz}`)
            4) Tilt (:math:`K_{\tau}`)
            5) Roll (:math:`K_{\rho}`)
            6) Twist (:math:`K_{\omega}`)
            7) :math:`K_{Dx,Dy}`
            8) :math:`K_{Dy,Dz}`
            9) :math:`K_{Dz,\tau}`
            10) :math:`K_{\tau, \rho}`
            11) :math:`K_{\rho,\omega}`
            12) :math:`K_{Dx,Dz}`
            13) :math:`K_{Dy,\tau}`
            14) :math:`K_{Dz,\rho}`
            15) :math:`K_{\tau,\omega}`
            16) :math:`K_{Dx,\tau}`
            17) :math:`K_{Dy,\rho}`
            18) :math:`K_{Dz,\omega}`
            19) :math:`K_{Dx,\rho}`
            20) :math:`K_{Dy,\omega}`
            21) :math:`K_{Dx,\omega}`

        When ``helical='True'``, following is obtained:

            1) Shift (:math:`K_{Dx}`)
            2) Slide (:math:`K_{Dy}`)
            3) Rise (:math:`K_{h}`)
            4) Tilt (:math:`K_{\eta}`)
            5) Roll (:math:`K_{\theta}`)
            6) Twist (:math:`K_{\Omega}`)
            7) :math:`K_{dx,dy}`
            8) :math:`K_{dy,h}`
            9) :math:`K_{h,\eta}`
            10) :math:`K_{\eta, \theta}`
            11) :math:`K_{\theta,\Omega}`
            12) :math:`K_{dx,h}`
            13) :math:`K_{dy,\eta}`
            14) :math:`K_{h,\theta}`
            15) :math:`K_{\tau,\Omega}`
            16) :math:`K_{dx,\eta}`
            17) :math:`K_{dy,\theta}`
            18) :math:`K_{h,\Omega}`
            19) :math:`K_{dx,\theta}`
            20) :math:`K_{dy,\Omega}`
            21) :math:`K_{dx,\Omega}`

        .. currentmodule:: dnaMD

        Parameters
        ----------
        bp : list
            List of two base-steps forming the DNA segment.
            For example: with ``bp=[5, 50]``, 5-50 base-step segment will be considered.

        frameGap : int
            How many frames to skip for next time-frame. Lower the number, slower will be the calculation.

        helical : bool
            If ``helical=True``, elastic matrix for **helical base-step** parameters are calculated. Otherwise,
            by default, elastic matrix for **base-step** parameters are calculated.

        unit : str
            Unit of energy. Allowed units are: ``'kT', 'kJ/mol' and 'kcal/mol'``.

        outFile : str
            Output file in csv format.


        Returns
        -------
        time : numpy.ndarray
            1D array containing time values of shape (nframes).

        Elasticities : OrderedDict
            A ordered dictionary of 1D arrays of shape (nframes). The keys in dictionary are name of the elasticity in
            the same order as listed above.
            e.g. ``Elasticities['shift']`` will give elasticity along shift parameters as a function of time.

def getLocalElasticityByTime(self, bp, frameGap, helical=False, unit='kT', outFile=None):
        r"""Calculate local elastic properties as a function of time for convergence check

        It can be used to obtained elastic properties as a function of time.

        .. note:: Elastic properties cannot be calculated using a single frame because fluctuations are required.
                  Therefore, here time means trajectory between zero time to given time.


        When ``helical='False'``, following is obtained:

            1) Shift (:math:`K_{Dx}`)
            2) Slide (:math:`K_{Dy}`)
            3) Rise (:math:`K_{Dz}`)
            4) Tilt (:math:`K_{\tau}`)
            5) Roll (:math:`K_{\rho}`)
            6) Twist (:math:`K_{\omega}`)
            7) :math:`K_{Dx,Dy}`
            8) :math:`K_{Dy,Dz}`
            9) :math:`K_{Dz,\tau}`
            10) :math:`K_{\tau, \rho}`
            11) :math:`K_{\rho,\omega}`
            12) :math:`K_{Dx,Dz}`
            13) :math:`K_{Dy,\tau}`
            14) :math:`K_{Dz,\rho}`
            15) :math:`K_{\tau,\omega}`
            16) :math:`K_{Dx,\tau}`
            17) :math:`K_{Dy,\rho}`
            18) :math:`K_{Dz,\omega}`
            19) :math:`K_{Dx,\rho}`
            20) :math:`K_{Dy,\omega}`
            21) :math:`K_{Dx,\omega}`

        When ``helical='True'``, following is obtained:

            1) Shift (:math:`K_{Dx}`)
            2) Slide (:math:`K_{Dy}`)
            3) Rise (:math:`K_{h}`)
            4) Tilt (:math:`K_{\eta}`)
            5) Roll (:math:`K_{\theta}`)
            6) Twist (:math:`K_{\Omega}`)
            7) :math:`K_{dx,dy}`
            8) :math:`K_{dy,h}`
            9) :math:`K_{h,\eta}`
            10) :math:`K_{\eta, \theta}`
            11) :math:`K_{\theta,\Omega}`
            12) :math:`K_{dx,h}`
            13) :math:`K_{dy,\eta}`
            14) :math:`K_{h,\theta}`
            15) :math:`K_{\tau,\Omega}`
            16) :math:`K_{dx,\eta}`
            17) :math:`K_{dy,\theta}`
            18) :math:`K_{h,\Omega}`
            19) :math:`K_{dx,\theta}`
            20) :math:`K_{dy,\Omega}`
            21) :math:`K_{dx,\Omega}`

        .. currentmodule:: dnaMD

        Parameters
        ----------
        bp : list
            List of two base-steps forming the DNA segment.
            For example: with ``bp=[5, 50]``, 5-50 base-step segment will be considered.

        frameGap : int
            How many frames to skip for next time-frame. Lower the number, slower will be the calculation.

        helical : bool
            If ``helical=True``, elastic matrix for **helical base-step** parameters are calculated. Otherwise,
            by default, elastic matrix for **base-step** parameters are calculated.

        unit : str
            Unit of energy. Allowed units are: ``'kT', 'kJ/mol' and 'kcal/mol'``.

        outFile : str
            Output file in csv format.


        Returns
        -------
        time : numpy.ndarray
            1D array containing time values of shape (nframes).

        Elasticities : OrderedDict
            A ordered dictionary of 1D arrays of shape (nframes). The keys in dictionary are name of the elasticity in
            the same order as listed above.
            e.g. ``Elasticities['shift']`` will give elasticity along shift parameters as a function of time.

        """
        if helical:
            props_name = helical_local_props_vector
        else:
            props_name = local_props_vector

        time, elasticity = [], OrderedDict()
        for name in props_name:
            elasticity[name] = []

        length = len(self.dna.time[:])
        for i in range(frameGap, length, frameGap):
            mean, esy_t = self.calculateLocalElasticity(bp, frames=[0, i], helical=helical, unit=unit)
            esy_t = matrixToVector(esy_t)
            for p in range(len(props_name)):
                elasticity[props_name[p]].append(esy_t[p])
            time.append(self.dna.time[i])

        # Write output file
        if outFile is not None:
            with open(outFile, 'w') as fout:
                fout.write('#Time')
                for name in props_name:
                    fout.write(', {0}'.format(name))
                fout.write('\n')
                for t in range(len(time)):
                    fout.write('{0:.3f}'.format(time[t]))
                    for name in props_name:
                        fout.write(', {0:.5f}'.format(elasticity[name][t]))
                    fout.write('\n')

        return time, elasticity