Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

How to interpolate a slice in 2d non regular griddata?

$
0
0

I want to interpolate a slice (blue line) in 2d griddata (non-regular).

Minimal Example. I want to interpolate the data of psi in that blue line

import numpy as npimport matplotlib.pyplot as pltx = np.linspace(-50,50,100)y = np.linspace(400,500,100)X, Y = np.meshgrid(x,y)Vec = np.array([X, Y])psi = 90 - np.rad2deg(np.arccos(Vec[0,:,:] / np.linalg.norm(Vec, axis=0)))R = np.sqrt(X ** 2 + Y ** 2)# points for interpolationx_points = np.linspace(x.min(), x.max())y_points = [480] * len(x_points)fig, ax = plt.subplots()ax.contourf(X, R, psi, level=20)ax.plot(x_points, y_points)

My Problem with the scipy function I found, was that they can either not read non-regular meshgrid data or just interpolate on a new grid -> expensive.

Is there a function which just interpolates a few points (x_points and y_points) in that minimal example?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>