Ice Sheet System Model  4.18
Code documentation
Functions
InterpFromGridToMesh.cpp File Reference
#include "./InterpFromGridToMesh.h"

Go to the source code of this file.

Functions

void InterpFromGridToMeshUsage (void)
 
 WRAPPER (InterpFromGridToMesh_python)
 

Function Documentation

◆ InterpFromGridToMeshUsage()

void InterpFromGridToMeshUsage ( void  )

Definition at line 7 of file InterpFromGridToMesh.cpp.

7  {/*{{{*/
8  _printf0_("INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points\n");
9  _printf0_("\n");
10  _printf0_(" This function is a multi-threaded mex file that interpolates a field\n");
11  _printf0_(" defined on a grid onto a list of points based on a bilinear interpolation\n");
12  _printf0_("\n");
13  _printf0_(" Usage:\n");
14  _printf0_(" data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);\n");
15  _printf0_("\n");
16  _printf0_(" data: matrix holding the data to be interpolated onto the mesh.\n");
17  _printf0_(" x,y: coordinates of matrix data. (x and y must be in increasing order)\n");
18  _printf0_(" x_mesh,y_mesh: coordinates of the points onto which we interpolate.\n");
19  _printf0_(" default_value: default value if no data is found (holes).\n");
20  _printf0_(" data_mesh: vector of mesh interpolated data.\n");
21  _printf0_("\n");
22  _printf0_(" Example:\n");
23  _printf0_(" load('velocities.mat');\n");
24  _printf0_(" md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);\n");
25  _printf0_("\n");
26 }/*}}}*/

◆ WRAPPER()

WRAPPER ( InterpFromGridToMesh_python  )

Definition at line 27 of file InterpFromGridToMesh.cpp.

27  {
28 
29  int i,j;
30 
31  /*input: */
32  double *x = NULL;
33  double *y = NULL;
34  int x_rows,y_rows;
35  double *data = NULL;
36  int data_rows,data_cols;
37  double *x_mesh = NULL;
38  double *y_mesh = NULL;
39  int x_mesh_rows,y_mesh_rows;
40  double default_value;
41  char* interpolationtype = NULL;
42 
43  /* output: */
44  IssmSeqVec<double>* data_mesh=NULL;
45 
46  /*Boot module: */
47  MODULEBOOT();
48 
49  /*checks on arguments on the matlab side: */
50  if(nrhs!=6 && nrhs!=7){
52  _error_("Wrong usage. See above");
53  }
54 
55  /*Input datasets: */
56  FetchData(&x,&x_rows,NULL,XHANDLE);
57  FetchData(&y,&y_rows,NULL,YHANDLE);
58  FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
59  FetchData(&x_mesh,&x_mesh_rows,NULL,XMESHHANDLE);
60  FetchData(&y_mesh,&y_mesh_rows,NULL,YMESHHANDLE);
61  FetchData(&default_value,DEFAULTHANDLE);
62 
63  /* Run core computations: */
64  if(nrhs==7){
65  FetchData(&interpolationtype,INTERPENUM);
66  InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,interpolationtype);
67  xDelete<char>(interpolationtype);
68  }
69  else{
70  InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,"bilinear");
71  }
72 
73  /*Write data: */
74  WriteData(DATAMESH,data_mesh);
75 
76  /*end module: */
77  xDelete<double>(x);
78  xDelete<double>(y);
79  xDelete<double>(data);
80  xDelete<double>(x_mesh);
81  xDelete<double>(y_mesh);
82  MODULEEND();
83 }
_printf0_
#define _printf0_(StreamArgs)
Definition: Print.h:29
WriteData
void WriteData(IssmPDouble **pmatrix, int *pnel, int *matrix, int M, int N)
Definition: WriteJavascriptData.cpp:16
IssmSeqVec
Definition: IssmSeqVec.h:31
FetchData
void FetchData(char **pstring, char *stringin)
Definition: FetchJavascriptData.cpp:16
InterpFromGridToMeshUsage
void InterpFromGridToMeshUsage(void)
Definition: InterpFromGridToMesh.cpp:7
InterpFromGridToMeshx
int InterpFromGridToMeshx(IssmSeqVec< IssmPDouble > **pdata_mesh, double *x_in, int x_rows, double *y_in, int y_rows, double *data, int M, int N, double *x_mesh, double *y_mesh, int nods, double default_value, const char *interptype)
Definition: InterpFromGridToMeshx.cpp:17
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49