def get_mean_error(self, bp, parameter, err_type='std', bp_range=True, merge_bp=1, merge_method='mean', masked=False, tool='gmx analyze'):
        """To calculate average and error of the given parameter for the given set of base-pairs/steps

        .. warning::
                To calculate errors by using ``error = 'acf'`` or ``error = 'block'``,
                GROMACS tool ``g_analyze`` or ``gmx analyze`` should be present in ``$PATH``.

        Parameters
        ----------

        bp : 1D list or array
            base-pairs to analyze
            Example: ::

                bp = [6]                                # bp_range = False
                bp = [4,15]                             # bp_range = True
                bp = range(4,15)                        # bp_range = False
                bp = np.arange(4,15)                    # bp_range = False
                bp = [2,5,6,7,9,12,18]                  # bp_range = False

        parameter : str
            Name of a parameter. For details about accepted keywords, see ``parameter`` in the method :meth:`DNA.get_parameters`.

        error : str
            Method of error estimation.
            Currently accepted method as follows:

                * ``error = 'std'``   : Standard Deviation
                * ``error = 'acf'``   : Standard error using autocorrelation time (requires: ``g_analyze`` or ``gmx analyze``)
                * ``error = 'block'`` : Standard error using block averaging method (requires: ``g_analyze`` or ``gmx analyze``)

        bp_range : bool
            ``Default=True``: As shown above, if ``True``, bp is taken as a range otherwise list or numpy array.

        merge_bp : int
            Number of base-pairs or steps to merge for creating the small DNA segments

        merge_method : str
            Method to calculate the parameter of a DNA segment from local
            parameters of all base-pairs/steps that are between the range
            given through ``bp``.
            Currently accepted keywords are as follows:

                * ``merge_method = mean``: Average of local parameters
                * ``merge_method = sum``: Sum of local parameters

        masked : bool
            ``Default=False``. To skip specific frames/snapshots.
            ``DNA.mask`` array should be set to use this functionality.
            This array contains boolean (either ``True`` or ``False``) value
            for each frame to mask the frames. Presently, mask array is
            automatically generated during :meth:`DNA.generate_smooth_axis` to
            skip those frames where 3D fitting curve was not successful within
            the given criteria

        tool : str
            Gromacs tool ``g_analyze`` or ``gmx analyze`` or ``gmx_mpi analyze`` etc.
            It will be used to calculate autocorrelation time or  block averaging error.
            It should be present in ``$PATH``

        Returns
        -------
        basepairs/steps : 1D array
            Number of base pair-steps. If ``merge_bp>1``, middle number will be returned.
        values : 1D array
            Average values of the parameter
        errors : 1D array
            Error values for corresponding average values

        """

        merge = False

        if(not bp_range) and (merge_bp > 1):
            print (
                "\nERROR: Merging of base pairs/steps only possible with given base pair/steps range\n")
            exit(1)

        if(bp_range) and (merge_bp > 1):
            merge = True

        if (merge == True) and not ((merge_method == 'mean') or (merge_method == 'sum')):
            raise AssertionError(
                "merge method %s is not available." % merge_method)
            exit(1)

        data, bp_idx = self.get_parameters(parameter, bp, bp_range, masked=masked)

        bp_number = np.add(bp_idx, self.startBP)
        data = np.array(data)

        # Merging base pairs/step data for the given parameters
        merge_data = []
        mid_bin = []
        if(merge):
            i = 0
            while(1):
                start = i
                if((i + merge_bp) >= len(bp_idx)):
                    end = i + (len(bp_idx) - i)
                else:
                    end = i + merge_bp

                if(start < end):
                    mid_bin.append(
                        int(start + (end - start) / 2) + bp_number[0])
                    if (merge_method == 'mean'):
                        merge_data.append(np.mean(data[start:end], axis=0))
                    if (merge_method == 'sum'):
                        merge_data.append(np.sum(data[start:end], axis=0))

                if(i >= len(bp_idx)):
                    break

                i += merge_bp

            merge_data = np.array(merge_data)

        if (err_type == 'std'):
            if(merge):
                error = np.std(merge_data, axis=1)
            else:
                error = np.std(data, axis=1)

        if (err_type == 'acf') or (err_type == 'block'):
            if(merge):
                error = get_error(self.time, merge_data, len(mid_bin), err_type=err_type, tool=tool)
            else:
                error = get_error(self.time, data, len(bp_idx), err_type=err_type, tool=tool)

        if(merge):
            return mid_bin, np.mean(merge_data, axis=1), error
        else:
            return bp_number, np.mean(data, axis=1), error
def get_mean_error ( self , bp , parameter , err_type = 'std' , bp_range = True , merge_bp = 1 , merge_method = 'mean' , masked = False , tool = 'gmx analyze' ) : merge = False if ( not bp_range ) and ( merge_bp > 1 ) : print ( "\nERROR: Merging of base pairs/steps only possible with given base pair/steps range\n" ) exit ( 1 ) if ( bp_range ) and ( merge_bp > 1 ) : merge = True if ( merge == True ) and not ( ( merge_method == 'mean' ) or ( merge_method == 'sum' ) ) : raise AssertionError ( "merge method %s is not available." % merge_method ) exit ( 1 ) data , bp_idx = self . get_parameters ( parameter , bp , bp_range , masked = masked ) bp_number = np . add ( bp_idx , self . startBP ) data = np . array ( data ) merge_data = [ ] mid_bin = [ ] if ( merge ) : i = 0 while ( 1 ) : start = i if ( ( i + merge_bp ) >= len ( bp_idx ) ) : end = i + ( len ( bp_idx ) - i ) else : end = i + merge_bp if ( start < end ) : mid_bin . append ( int ( start + ( end - start ) / 2 ) + bp_number [ 0 ] ) if ( merge_method == 'mean' ) : merge_data . append ( np . mean ( data [ start : end ] , axis = 0 ) ) if ( merge_method == 'sum' ) : merge_data . append ( np . sum ( data [ start : end ] , axis = 0 ) ) if ( i >= len ( bp_idx ) ) : break i += merge_bp merge_data = np . array ( merge_data ) if ( err_type == 'std' ) : if ( merge ) : error = np . std ( merge_data , axis = 1 ) else : error = np . std ( data , axis = 1 ) if ( err_type == 'acf' ) or ( err_type == 'block' ) : if ( merge ) : error = get_error ( self . time , merge_data , len ( mid_bin ) , err_type = err_type , tool = tool ) else : error = get_error ( self . time , data , len ( bp_idx ) , err_type = err_type , tool = tool ) if ( merge ) : return mid_bin , np . mean ( merge_data , axis = 1 ) , error else : return bp_number , np . mean ( data , axis = 1 ) , error
To calculate average and error of the given parameter for the given set of base-pairs/steps

        .. warning::
                To calculate errors by using ``error = 'acf'`` or ``error = 'block'``,
                GROMACS tool ``g_analyze`` or ``gmx analyze`` should be present in ``$PATH``.

        Parameters
        ----------

        bp : 1D list or array
            base-pairs to analyze
            Example: ::

                bp = [6]                                # bp_range = False
                bp = [4,15]                             # bp_range = True
                bp = range(4,15)                        # bp_range = False
                bp = np.arange(4,15)                    # bp_range = False
                bp = [2,5,6,7,9,12,18]                  # bp_range = False

        parameter : str
            Name of a parameter. For details about accepted keywords, see ``parameter`` in the method :meth:`DNA.get_parameters`.

        error : str
            Method of error estimation.
            Currently accepted method as follows:

                * ``error = 'std'``   : Standard Deviation
                * ``error = 'acf'``   : Standard error using autocorrelation time (requires: ``g_analyze`` or ``gmx analyze``)
                * ``error = 'block'`` : Standard error using block averaging method (requires: ``g_analyze`` or ``gmx analyze``)

        bp_range : bool
            ``Default=True``: As shown above, if ``True``, bp is taken as a range otherwise list or numpy array.

        merge_bp : int
            Number of base-pairs or steps to merge for creating the small DNA segments

        merge_method : str
            Method to calculate the parameter of a DNA segment from local
            parameters of all base-pairs/steps that are between the range
            given through ``bp``.
            Currently accepted keywords are as follows:

                * ``merge_method = mean``: Average of local parameters
                * ``merge_method = sum``: Sum of local parameters

        masked : bool
            ``Default=False``. To skip specific frames/snapshots.
            ``DNA.mask`` array should be set to use this functionality.
            This array contains boolean (either ``True`` or ``False``) value
            for each frame to mask the frames. Presently, mask array is
            automatically generated during :meth:`DNA.generate_smooth_axis` to
            skip those frames where 3D fitting curve was not successful within
            the given criteria

        tool : str
            Gromacs tool ``g_analyze`` or ``gmx analyze`` or ``gmx_mpi analyze`` etc.
            It will be used to calculate autocorrelation time or  block averaging error.
            It should be present in ``$PATH``

        Returns
        -------
        basepairs/steps : 1D array
            Number of base pair-steps. If ``merge_bp>1``, middle number will be returned.
        values : 1D array
            Average values of the parameter
        errors : 1D array
            Error values for corresponding average values