source: issm/trunk-jpl/src/modules/InterpFromGridToMesh/InterpFromGridToMesh.cpp@ 13236

Last change on this file since 13236 was 13236, checked in by Mathieu Morlighem, 13 years ago

CHG: preparing files for python inclusion

File size: 2.5 KB
Line 
1/*!\file InterpFromGridToMesh.c
2 * \brief: data interpolation from a list of (x,y,values) into mesh vertices
3*/
4
5#include "./InterpFromGridToMesh.h"
6
7void InterpFromGridToMeshUsage(void){/*{{{*/
8 _pprintLine_("INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points");
9 _pprintLine_("");
10 _pprintLine_(" This function is a multi-threaded mex file that interpolates a field");
11 _pprintLine_(" defined on a grid onto a list of points");
12 _pprintLine_("");
13 _pprintLine_(" Usage:");
14 _pprintLine_(" data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);");
15 _pprintLine_("");
16 _pprintLine_(" data: matrix holding the data to be interpolated onto the mesh.");
17 _pprintLine_(" x,y: coordinates of matrix data. (x and y must be in increasing order)");
18 _pprintLine_(" x_mesh,y_mesh: coordinates of the points onto which we interpolate.");
19 _pprintLine_(" default_value: default value if no data is found (holes).");
20 _pprintLine_(" data_mesh: vector of mesh interpolated data.");
21 _pprintLine_("");
22 _pprintLine_(" Example:");
23 _pprintLine_(" load('velocities.mat');");
24 _pprintLine_(" md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);");
25 _pprintLine_("");
26}/*}}}*/
27WRAPPER(InterpFromGridToMesh){
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 int interpolationenum;
42
43 /* output: */
44 SeqVec<double>* data_mesh=NULL;
45
46 /*Boot module: */
47 MODULEBOOT();
48
49 /*checks on arguments on the matlab side: */
50 if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=7)){
51 InterpFromGridToMeshUsage();
52 _error_("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(&interpolationenum,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,interpolationenum);
67 }
68 else{
69 InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value);
70 }
71
72 /*Write data: */
73 WriteData(DATAMESH,data_mesh);
74
75 /*end module: */
76 MODULEEND();
77}
Note: See TracBrowser for help on using the repository browser.