Index: /issm/trunk/src/m/utils/DataProcessing/TracksToMatrix.m
===================================================================
--- /issm/trunk/src/m/utils/DataProcessing/TracksToMatrix.m	(revision 1088)
+++ /issm/trunk/src/m/utils/DataProcessing/TracksToMatrix.m	(revision 1089)
@@ -1,11 +1,13 @@
-function [x_f y_f MatData MatTracks]=TracksToMatrix(xmin,ymin,nx,ny,posting,track_coord,track_values,theta,varargin),
+function [x_f y_f MatData]=TracksToMatrix(xmin,ymin,nx,ny,posting,track_coord,track_values,theta,varargin),
 %TRACKSTOMATRIX - Create a map from tracks
 %
-%   This routine creates a map with average values of tracks using the DACE toolbox.
-%   xmin and ymin are two scalars are the extreme values of the data matrix
+%   This routine creates a map from tracks using Kriging with the DACE package.
+%   xmin and ymin are two scalars are the extreme values of the data matrix one wants to create
+%   posting is a scalar giving the posting of the matrix to be created in meters
 %   trac_coord is an exp file containing the coordinates of the tracks (x and y)
 %   trav_values is a vector with the values along the track coordinates
-%   posting is a scalar giving the posting of the matrix in meters
-%   theta is a parameter of the correlation function
+%   theta is a parameter of the correlation function stricly positive
+%   varagin can contain a matrix of data to constrain rhe matrix to be created
+%   it shoud contain indices x and y and the matrix
 %
 %   Usage:
@@ -13,11 +15,17 @@
 %
 %   Example:
-%      [x_f y_f Thickness]=TracksToMatrix(-10^6,!0^6,200,180,1000,'trackcoord.exp',thickness_values),
+%      [x_f y_f Thickness]=TracksToMatrix(-10^6,10^6,200,180,1000,'trackcoord.exp',thickness_values),
+%      [x_f y_f Thickness]=TracksToMatrix(-10^6,10^6,200,180,1000,'trackcoord.exp',thickness_values,x_m,y_m,globalthickness),
 %
 %   See also: CREATEDATABOUNDARIES, CREATEDATAMATRIX
+
+global ISSM_DIR
 
 if nargin~=8 & nargin~=11,
 	error(' TracksToMatrix error message: wrong number of arguments')
 end
+
+%Add path to dace
+addpath([ISSM_DIR '/externalpackages/dace/install'])
 
 %First create the x_m and y_m fot the matrix
@@ -32,5 +40,4 @@
 [Mvalue Mx My]=CreateDataMatrix(x_m,y_m,track_coord,track_values);
 
-MatTracks=Mvalue;
 %Create vector for these coordinates and values
 Svalue=sparse(Mvalue);
@@ -44,4 +51,5 @@
 %Create boundaries for the track if specified
 if nargin==11,
+	disp('      constain the border of matrix with global matrix');
 	%Find out the elements to counstrain the border
 	x_matrix=varargin{1};
@@ -49,13 +57,17 @@
 	datamatrix=varargin{3};
 
-	%Create values on the border
+	%Create values on the border of the smaller map
 	[Xedge,Yedge,EdgeValues]=CreateDataBoundaries(x_m,y_m,x_matrix,y_matrix,datamatrix);
 
+	%Create values on the border of the larger map
+	[Xedge2,Yedge2,EdgeValues2]=CreateDataBoundaries(x_f,y_f,x_matrix,y_matrix,datamatrix);
+
 	%Add these values to the track values
-	Values=[Values;EdgeValues];
-	Coord=[X,Y;Xedge,Yedge];
+	Values=[Values;EdgeValues;EdgeValues2];
+	Coord=[X,Y;Xedge,Yedge;Xedge2,Yedge2];
 end
 
 %Create model for data
+disp('      create the statiscal model of the data');
 [dmodel,perf]=dacefit(Coord,Values,@regpoly1,@corrgauss,theta);
 
@@ -64,6 +76,9 @@
 
 %Compute data on these points
+disp('      predict the values');
 VecData=predictor(Points,dmodel);
 
 %Reshape to get a matrix
 MatData=reshape(VecData,ny,nx);
+
+rmpath([ISSM_DIR '/externalpackages/dace/install']);
