pyfrp_simulation.py 文件源码

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

项目:PyFRAP 作者: alexblaessle 项目源码 文件源码
def computeInterpolatedSolutionToImg(self,vals,roi=None,method='linear',res=None):

        """Interpolates solution back onto 2D image.

        Uses ``scipy.interpolate.griddata``, see also http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.griddata.html

        If ``roi`` is specified, will only interpolate nodes of this ROI. 

        For more details about interpolation methods, check out 
        https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.griddata.html .

        Keyword Args:
            vals (numpy.ndarray): Solution to be interpolated.
            roi (pyfrp.subclasses.pyfrp_ROI.ROI): A PyFRAP ROI.
            method (str): Interpolation method.
            fillVal (float): Value applied outside of ROI.
            res (int): Resolution of resulting images in pixels.

        Returns:
            tuple: Tuple containing:

                * X (numpy.ndarray): Meshgrid x-coordinates.
                * Y (numpy.ndarray): Meshgrid y-coordinates.
                * interpIC (numpy.ndarray): Interpolated solution.

        """

        #Get image resolution and center of geometry
        if res==None:
            res=self.ICimg.shape[0]

        #Build Empty Img
        X,Y=np.meshgrid(np.arange(res),np.arange(res))

        #Get cellcenters
        x,y,z=self.mesh.getCellCenters()
        ##print x
        ##print y
        ##print z
        ##print roi.meshIdx
        #print max(roi.meshIdx)
        #print len(x)

        if roi!=None:
            xInt=x[roi.meshIdx]
            yInt=y[roi.meshIdx]
            val=vals[roi.meshIdx]
        else:
            xInt=x
            yInt=y
            val=vals

        interpIC=interp.griddata((xInt,yInt),val,(X,Y),method=method)

        return X,Y,interpIC
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号