forked from cultpenguin/mGstat
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Kriging algorithms now suports 2D anisotropy, and ND is range covaria…
…nce models. (Nd kriging without rotation is now OK)
- Loading branch information
cultpenguin
committed
May 13, 2009
1 parent
5f11d6c
commit 3235897
Showing
6 changed files
with
102 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,80 @@ | ||
% edist : Euclidean distance | ||
% | ||
% Call : | ||
% Call : | ||
% D=edist(p1,p2,transform,isorange) | ||
% | ||
% | ||
% p1,p2 : vectors | ||
% | ||
% transform : GSTAT anisotropy and/or range information | ||
% transform : GSTAT anisotropy and/or range information | ||
% | ||
% isorange : [0] (default), transform is the usual GSTAT-anisotropy setting | ||
% isorange : [0] (default), transform is the usual GSTAT-anisotropy setting | ||
% isorange : [1] means that transform simply lists the range in | ||
% each dimensions, and that no rotation is performed | ||
% each dimensions, and that no rotation is performed | ||
|
||
function D=edist(p1,p2,transform,isorange) | ||
|
||
|
||
|
||
if nargin<4 | ||
|
||
if nargin<4 | ||
isorange=0; | ||
end | ||
if nargin==1; | ||
end | ||
|
||
if nargin==1; | ||
p2=0.*p1; | ||
end | ||
|
||
n_dim=size(p1,2); | ||
|
||
if size(p1,1)==1 | ||
dp=(p1-p2)'; | ||
else | ||
dp=(p1-p2); | ||
end | ||
|
||
if isorange==1 | ||
end | ||
|
||
n_dim=size(p1,2); | ||
|
||
dp=(p1-p2); | ||
|
||
if isorange==1 | ||
%mgstat_verbose(sprintf('%s : isorange',mfilename)) | ||
% ONLY SACLING, no transformation | ||
|
||
%rescale=transform | ||
%RescaleMat=eye(length(rescale)); | ||
%for i=1:length(rescale) | ||
% RescaleMat(i,i)=rescale(i); | ||
%end | ||
%dp=RescaleMat*dp; | ||
if length(transform)==1; | ||
transform=ones(1,n_dim).*transform; | ||
end | ||
|
||
if transform==0 | ||
% Do not transfrom since this is likely a nugget | ||
% Do not transfrom since this is likely a nugget | ||
else | ||
dp=transform(1).*dp./transform(:); | ||
for j=1:n_dim; | ||
dp(:,j)=dp(:,j)./transform(j); | ||
end | ||
dp=transform(1).*dp; | ||
end | ||
D=sqrt(dp'*dp); | ||
return | ||
end | ||
|
||
|
||
else | ||
|
||
|
||
% 2D COORDINATE TRANSFORMATION | ||
if (nargin>2)&(length(p1)==2); | ||
|
||
if length(transform)>1 | ||
|
||
rescale=transform(1:2); | ||
rotate=transform(3); | ||
|
||
|
||
RotMat=[cos(rotate) -sin(rotate);sin(rotate) cos(rotate)]; | ||
dp=RotMat*dp; | ||
|
||
RescaleMat=eye(length(rescale)); | ||
for i=1:length(rescale) | ||
RescaleMat(i,i)=rescale(i); | ||
end | ||
dp=RescaleMat*dp; | ||
end | ||
end | ||
% 2D COORDINATE TRANSFORMATION | ||
if (nargin>2)&(n_dim==2); | ||
mgstat_verbose(sprintf('%s : 2D coordinate transform'),0); | ||
if length(transform)>1 | ||
rescale=transform(1:2); | ||
rotate=transform(3)*pi/180; | ||
|
||
% 3D COORDINATE TRANSFORMATION | ||
if (nargin>2)&(length(p1)==3); | ||
% NOT YET IMPLEMENTED, SEE GSLIB BOOK | ||
end | ||
dp=dp'; | ||
|
||
RotMat=[cos(rotate) -sin(rotate);sin(rotate) cos(rotate)]; | ||
RescaleMat=eye(length(rescale)); | ||
RescaleMat(1,1)=1; | ||
RescaleMat(2,2)=rescale(2); | ||
|
||
%dp=RotMat*dp;%dp=RescaleMat*dp; | ||
dp=RescaleMat*RotMat*dp; | ||
dp=dp./rescale(2); | ||
|
||
dp=dp'; | ||
end | ||
end | ||
|
||
% 3D COORDINATE TRANSFORMATION | ||
if (nargin>2)&(n_dim==3); | ||
mgstat_verbose(sprintf('%s : 3D anisotropy not yet implemented',mfilename),-1) | ||
% NOT YET IMPLEMENTED, SEE GSLIB BOOK | ||
end | ||
end | ||
|
||
if n_dim==1 | ||
D=sqrt(dp.^2+dp.^2); | ||
elseif size(p1,1)==2 | ||
D=sqrt(dp(1,:).^2+dp(2,:).^2); | ||
% elseif size(p1,1)==3 | ||
% D=sqrt(dp(1,:).^2+dp(2,:).^2+dp(3,:).^2); | ||
else | ||
D=sqrt(dp'*dp); | ||
end | ||
if n_dim==1 | ||
D=sqrt(dp.^2+dp.^2); | ||
else | ||
D=transpose(sqrt(sum(transpose(dp.^2)))); | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.