def interpolate_xarray(xpoints, ypoints, values, shape, kind='cubic',
                       blocksize=CHUNK_SIZE):
    """Interpolate, generating a dask array."""
    vchunks = range(0, shape[0], blocksize)
    hchunks = range(0, shape[1], blocksize)

    token = tokenize(blocksize, xpoints, ypoints, values, kind, shape)
    name = 'interpolate-' + token

    from scipy.interpolate import interp2d
    interpolator = interp2d(xpoints, ypoints, values, kind=kind)

    dskx = {(name, i, j): (interpolate_slice,
                           slice(vcs, min(vcs + blocksize, shape[0])),
                           slice(hcs, min(hcs + blocksize, shape[1])),
                           interpolator)
            for i, vcs in enumerate(vchunks)
            for j, hcs in enumerate(hchunks)
            }

    res = da.Array(dskx, name, shape=list(shape),
                   chunks=(blocksize, blocksize),
                   dtype=values.dtype)
    return DataArray(res, dims=('y', 'x'))
def interpolate_xarray ( xpoints , ypoints , values , shape , kind = 'cubic' , blocksize = CHUNK_SIZE ) : vchunks = range ( 0 , shape [ 0 ] , blocksize ) hchunks = range ( 0 , shape [ 1 ] , blocksize ) token = tokenize ( blocksize , xpoints , ypoints , values , kind , shape ) name = 'interpolate-' + token from scipy . interpolate import interp2d interpolator = interp2d ( xpoints , ypoints , values , kind = kind ) dskx = { ( name , i , j ) : ( interpolate_slice , slice ( vcs , min ( vcs + blocksize , shape [ 0 ] ) ) , slice ( hcs , min ( hcs + blocksize , shape [ 1 ] ) ) , interpolator ) for i , vcs in enumerate ( vchunks ) for j , hcs in enumerate ( hchunks ) } res = da . Array ( dskx , name , shape = list ( shape ) , chunks = ( blocksize , blocksize ) , dtype = values . dtype ) return DataArray ( res , dims = ( 'y' , 'x' ) )
Interpolate, generating a dask array.