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

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

moved _error_ to _error2_ and added circular dependencies in Makefile.am to resolve all symbols

File size: 3.0 KB
RevLine 
[2290]1/*!\file InterpFromGridToMesh.c
[8306]2 * \brief: data interpolation from a list of (x,y,values) into mesh vertices
[1172]3
[2290]4 InterpFromGridToMesh.c
[1172]5
6 usage:
[2290]7 data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh);
[1172]8
9 where:
10
11 input:
12 x,y: coordinates of matrix data
13 data - matrix holding the data to be interpolated onto the mesh.
[8306]14 x_mesh,y_mesh: coordinates of the mesh vertices onto which we interpolate.
[1172]15
16 output:
17 data_mesh: vector of mesh interpolated data.
18*/
19
[2290]20#include "./InterpFromGridToMesh.h"
[1172]21
22void mexFunction( int nlhs, mxArray* plhs[], int nrhs, const mxArray* prhs[]) {
23
24 int i,j;
25
26 /*input: */
27 double* x=NULL;
[1174]28 double* y=NULL;
[7519]29 int x_rows,y_rows;
[1172]30 double* data=NULL;
31 int data_rows,data_cols;
32 double* x_mesh=NULL;
33 double* y_mesh=NULL;
[7519]34 int x_mesh_rows,y_mesh_rows;
35 double default_value;
36 int interpolationenum;
[1172]37
38 /* output: */
[11695]39 Vector* data_mesh=NULL;
[1172]40
41 /*Boot module: */
42 MODULEBOOT();
43
44 /*checks on arguments on the matlab side: */
[7519]45 //CheckNumMatlabArguments(nlhs,NLHS,nrhs,NRHS,__FUNCT__,&InterpFromGridToMeshUsage);
46 if((nlhs!=NLHS) || (nrhs!=6 && nrhs!=7)){
47 InterpFromGridToMeshUsage();
[12497]48 _error2_("usage. See above");
[7519]49 }
[1172]50
51 /*Input datasets: */
[11933]52 FetchData(&x,&x_rows,NULL,XHANDLE);
53 FetchData(&y,&y_rows,NULL,YHANDLE);
54 FetchData(&data,&data_rows,&data_cols,DATAHANDLE);
55 FetchData(&x_mesh,&x_mesh_rows,NULL,XMESHHANDLE);
56 FetchData(&y_mesh,&y_mesh_rows,NULL,YMESHHANDLE);
57 FetchData(&default_value,DEFAULTHANDLE);
[1172]58
59 /* Run core computations: */
[7519]60 if(nrhs==7){
[11933]61 FetchData(&interpolationenum,INTERPENUM);
[7519]62 InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value,interpolationenum);
63 }
64 else{
65 InterpFromGridToMeshx(&data_mesh, x, x_rows, y, y_rows, data, data_rows,data_cols, x_mesh, y_mesh, x_mesh_rows,default_value);
66 }
[1172]67
68 /*Write data: */
[11933]69 WriteData(DATAMESH,data_mesh);
[1172]70
71 /*end module: */
72 MODULEEND();
73}
74
[2290]75void InterpFromGridToMeshUsage(void)
[1172]76{
[6412]77 _printf_(true,"INTERPFROMGRIDTOMESH - interpolation from a grid onto a list of points\n");
78 _printf_(true,"\n");
79 _printf_(true," This function is a multi-threaded mex file that interpolates a field\n");
80 _printf_(true," defined on a grid onto a list of points\n");
81 _printf_(true,"\n");
82 _printf_(true," Usage:\n");
83 _printf_(true," data_mesh=InterpFromGridToMesh(x,y,data,x_mesh,y_mesh,default_value);\n");
84 _printf_(true,"\n");
85 _printf_(true," data: matrix holding the data to be interpolated onto the mesh.\n");
86 _printf_(true," x,y: coordinates of matrix data. (x and y must be in increasing order)\n");
87 _printf_(true," x_mesh,y_mesh: coordinates of the points onto which we interpolate.\n");
88 _printf_(true," default_value: default value if no data is found (holes).\n");
89 _printf_(true," data_mesh: vector of mesh interpolated data.\n");
90 _printf_(true,"\n");
91 _printf_(true," Example:\n");
92 _printf_(true," load('velocities.mat');\n");
[10949]93 _printf_(true," md.inversion.vx_obs=InterpFromGridToMesh(x_n,y_m,vx,md.mesh.x,md.mesh.y,0);\n");
[6412]94 _printf_(true,"\n");
[1172]95}
Note: See TracBrowser for help on using the repository browser.