
%VENICE_FUNCS uses the Venice coordinate data to construct spatial 
%models of 'draw-down'functions.

%NOTE: Requires that 'venice.txt' be loaded in the workspace.

clear('X0','L0','X1','L1');

clear('V','x','y','x1','y1','x2','y2','z','L','X','XX','U') ;


V = venice ;
z = V(:,3); %1973 data

%Transform Sample Locations

x = V(:,1);
y = V(:,2);

L = V(:,1:2);

%Industry-centered coordinates

x1 = .01*(.873*(x - 418) - .488*(y - 458));
y1 = .01*(.488*(x - 418) + .873*(y - 458));

%Approximation of Elevation Effects

X(:,1) = exp(-x1);

%Industry draw-down function

X(:,2) = exp(-((1.5)*(x1.^2) + (y1.^2)));

%Venice Island draw-down function

x2 = (x - 560) ;
y2 = (y - 390) ;

z2 = sqrt(x2.^2 + y2.^2) ;

X(:,3) = exp(-((z2/35).^8));

%SAMPLE DATA

X0 = X ;
L0 = L ;

XX0(:,1) = ones(length(X0),1);
XX0(:,2:4) = X0 ;

b = XX0\z;

%Now form grid locations

clear('x','y','X','U','x1','y1','x2','y2','z2','s1','u1','U1',...
      's2','u2','U2','S'); 
   
   Xmin = 150;
   Xmax = 900;
   Xcell = 25;
   Ymin = 200;
   Ymax = 650;
   Ycell = 25;
   
G = grid_form(Xmin,Xmax,Xcell,Ymin,Ymax,Ycell);
   
x = G(:,1) ;
y = G(:,2) ;

%Industry-centered coordinates

x1 = .01*(.873*(x - 418) - .488*(y - 458));
y1 = .01*(.488*(x - 418) + .873*(y - 458));

%Approximation of Elevation Effects

X(:,1) = exp(-x1);

%Industry draw-down function

X(:,2) = exp(-((1.5)*(x1.^2) + (y1.^2)));

%Venice Island draw-down function

x2 = (x - 560) ;
y2 = (y - 390) ;

z2 = sqrt(x2.^2 + y2.^2) ;

X(:,3) = exp(-((z2/35).^8));



%GRID DATA

X1 = X ;
L1 = G ;




