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
评论列表
文章目录