Skip to content

Commit

Permalink
FIX: error in shepard domain interpolation.
Browse files Browse the repository at this point in the history
  • Loading branch information
phmbressan committed Nov 16, 2023
1 parent 322e332 commit 0f76b3e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions rocketpy/mathutils/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,8 +836,8 @@ def get_value(self, *args):

# Returns value for shepard interpolation
elif self.__interpolation__ == "shepard":
if isinstance(args[0], Iterable):
x = list(args[0])
if all(isinstance(arg, Iterable) for arg in args):
x = list(np.column_stack(args))
else:
x = [[float(x) for x in list(args)]]
ans = x
Expand Down Expand Up @@ -1298,10 +1298,11 @@ def plot2D(
x = np.linspace(lower[0], upper[0], samples[0])
y = np.linspace(lower[1], upper[1], samples[1])
mesh_x, mesh_y = np.meshgrid(x, y)
mesh = np.column_stack((mesh_x.flatten(), mesh_y.flatten()))

# Evaluate function at all mesh nodes and convert it to matrix
z = np.array(self.get_value(mesh[:, 0], mesh[:, 1])).reshape(mesh_x.shape)
z = np.array(self.get_value(mesh_x.flatten(), mesh_y.flatten())).reshape(
mesh_x.shape
)
z_min, z_max = z.min(), z.max()
color_map = plt.cm.get_cmap(cmap)
norm = plt.Normalize(z_min, z_max)
Expand Down

0 comments on commit 0f76b3e

Please sign in to comment.