Skip to content

Commit 5ee7514

Browse files
CHG: Bug in Python wrapper; cleanup
1 parent c285b96 commit 5ee7514

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

src/m/modules/InterpFromGridToMesh.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,20 @@
33

44

55
def InterpFromGridToMesh(x, y, data, x_mesh, y_mesh, default_value):
6-
"""
7-
INTERPFROMGRIDTOMESH - Interpolation from a grid onto a list of points
6+
"""InterpFromGridToMesh - Interpolation from a grid onto a list of points
87
9-
Usage:
10-
data_mesh = InterpFromGridToMesh(x, y, data, x_mesh, y_mesh, default_value)
8+
Usage:
9+
data_mesh = InterpFromGridToMesh(x, y, data, x_mesh, y_mesh, default_value)
1110
12-
data: matrix holding the data to be interpolated onto the mesh
13-
x, y: coordinates of matrix data (x and y must be in increasing order)
14-
x_mesh, y_mesh: coordinates of the points onto which we interpolate
15-
default_value: vector of mesh interpolated data
11+
data: matrix holding the data to be interpolated onto the mesh
12+
x, y: coordinates of matrix data (x and y must be in increasing order)
13+
x_mesh, y_mesh: coordinates of the points onto which we interpolate
14+
default_value: vector of mesh interpolated data
1615
1716
Example:
1817
load('velocities.mat')
1918
md.inversion.vx_obs = InterpFromGridToMesh(x_n, y_m, vx, md.mesh.x, md.mesh.y, 0)
2019
"""
21-
# Call mex module
22-
data_mesh = InterpFromGridToMesh_python(x, y, data, x_mesh, y_mesh, default_value)
23-
# Return
24-
return np.squeeze(data_mesh)
20+
21+
# Call Python module
22+
return np.squeeze(InterpFromGridToMesh_python(x, y, data, x_mesh, y_mesh, default_value))

src/m/modules/InterpFromMeshToGrid.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
% Usage:
55
% grid = InterpFromMeshToGrid(index,x,y,data,xgrid,ygrid,default_value)
66
%
7-
% This function is a multi-threaded mex file that interpolates a field defined on a triangular
8-
% mesh onto a regular grid.
7+
% This function is a wrapper to a multi-threaded mex file that interpolates a
8+
% field defined on a triangular mesh onto a regular grid.
99
%
1010
% index,x,y: delaunay triangulation defining the mesh
1111
% meshdata: vertex values of data to be interpolated
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
1+
import numpy as np
12
from InterpFromMeshToGrid_python import InterpFromMeshToGrid_python
23

3-
44
def InterpFromMeshToGrid(index, x, y, data, xgrid, ygrid, default_value):
5-
"""
6-
INTERPFROMMESHTOGRID - Interpolation of a data defined on a mesh onto a grid
5+
"""InterpFromMeshToGrid - Interpolation of a data defined on a mesh onto a
6+
grid
77
8-
This function is a multi - threaded mex file that interpolates a field defined
9-
on a triangular mesh onto a regular grid
8+
This function is a wrapper to a multi-threaded Python module that
9+
interpolates a field defined on a triangular mesh onto a regular grid.
1010
11-
index, x, y: delaunay triangulation defining the mesh
12-
meshdata: vertex values of data to be interpolated
11+
index, x, y: delaunay triangulation defining the mesh
12+
meshdata: vertex values of data to be interpolated
1313
14-
xgrid, ygrid, : parameters that define the grid
15-
default_value: value of points located out of the mesh
14+
xgrid, ygrid: parameters that define the grid
15+
default_value: value of points located out of the mesh
1616
"""
17-
# Call mex module
18-
grid = InterpFromMeshToGrid_python(index, x, y, data, xgrid, ygrid, default_value)
19-
# Return
20-
return grid
17+
18+
# Call Python module
19+
return np.squeeze(InterpFromMeshToGrid_python(index, x, y, data, xgrid, ygrid, default_value))

src/wrappers/InterpFromMeshToGrid/InterpFromMeshToGrid.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
#define MESHDATA PyTuple_GetItem(args,3)
4848
#define XGRID PyTuple_GetItem(args,4)
4949
#define YGRID PyTuple_GetItem(args,5)
50-
#define DEFAULTVALUE PyTuple_GetItem(args,10)
50+
#define DEFAULTVALUE PyTuple_GetItem(args,6)
5151
/* serial output macros: */
5252
#define GRIDDATA output,0
5353
#endif

0 commit comments

Comments
 (0)