lsd.py 文件源码

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

项目:nmmn 作者: rsnemmen 项目源码 文件源码
def regrid(x,y,z,xnew,ynew,method='cubic'):
    """
Regrid 1D arrays (x,y,z) -- where z is some scalar field mapped at positions
x,y -- to a 2d array Z defined in the cartesian grids xnew,ynew (1D arrays with 
new grid).

For the interpolation method, choose nearest, linear or cubic.

>>> rho=regrid(d.x,d.y,d.rho,xnew,ynew)

.. todo:: need to create a 3d version of this method, paving the road for the 3d simulations.
    """
    import scipy.interpolate

    # regrid the data to a nice cartesian grid
    Z = scipy.interpolate.griddata((x, y), z, (xnew[None,:], ynew[:,None]), method=method)

    # get rid of NaNs
    return nanzero(Z)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号