wham.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:AdK_analysis 作者: orbeckst 项目源码 文件源码
def interpolationFunction(self,data=None,spline_order=3,cval=None):
        """Returns a function W(x,y) that interpolates any values on the PMF.

        W = interpolationFunction(self,data=None,spline_order=3,cval=None)

        cval is set to data.max() by default (works for the PMF) but for the
        probability this should be 0 or data.min(). cval cannot be chosen too large
        or too small or NaN because otherwise the spline interpolation breaks down
        near the region and produces wild oscillations.
        """
        # see http://www.scipy.org/Cookbook/Interpolation
        from scipy import ndimage

        if data is None:
            data = self.free_energy

        if cval is None:
            cval = data.max()
        _data = data.filled(cval)   # fill with max, not 1000 to keep spline happy

        coeffs = ndimage.spline_filter(_data,order=spline_order)
        x0,y0 = self.X[0], self.Y[0]
        dx,dy = self.X[1] - x0, self.Y[1] - y0
        def _transform(cnew, c0, dc):
            return (numpy.atleast_1d(cnew) - c0)/dc
        def interpolatedF(NMP,LID):
            """B-spline function over the PMF, W(NMP,LID).

            Example usage:
            >>> XX,YY = numpy.mgrid[40:75:0.5,96:150:0.5]
            >>> FF = FreeEnergy.W(XX,YY)
            >>> contourf(XX,YY,FF, numpy.linspace(-3,11,100),extend='both')
            """
            return ndimage.map_coordinates(coeffs,
                                           numpy.array([_transform(NMP,x0,dx),_transform(LID,y0,dy)]),
                                           prefilter=False,mode='constant',cval=cval)
        return interpolatedF
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号