grid icon indicating copy to clipboard operation
grid copied to clipboard

Interpolating on Cubic Grids Using Scipy

Open Ali-Tehrani opened this issue 1 year ago • 1 comments

Rather than re-inventing the wheel, Scipy has interpn that only works on regular grids (grid axes are orthogonal to coordinate axes) and offers many different kinds of interpolating "linear”, “nearest”, “slinear”, “cubic”, “quintic”, “pchip”, and “splinef2d”. “splinef2d” i"

The following code shows how easy it is using Grid to incorporate inside UniformGrid (assuming grid axes are orthogonal)

    
    x, y, z = grid_cube.get_points_along_axes()
    electro = interpn((x, y, z), electro_cube, kverts, method="linear")#method="cubic", bounds_error=True)

    print("Electro static mean, std, min, max", electro,np.mean(electro), np.std(electro), np.min(electro), np.max(electro))

Ali-Tehrani avatar Jan 29 '25 18:01 Ali-Tehrani