-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathdeformat_variogram.m
137 lines (118 loc) · 2.82 KB
/
deformat_variogram.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
% deformat_variogram : convert gstat variogram line into matlab structure
%
% Call:
% V=deformat_variogram(txt);
%
% Example:
% V=deformat_variogram('1 Sph(2)')
%
%V =
%
% par1: 1
% par2: 2
% type: 'Sph'
% itype: 1
%
%
% See also : format_variogram
%
% TMH /2004
%
function V=deformat_variogram(txt);
txt=regexprep(txt,'\<;','');
% find position of '+' separating multiple models
fp=regexp(txt,'\+');
% makse sure 'e+' does not count as seperators
fp_use=fp;
for ip=1:length(fp);
if strcmp(txt(fp(ip)-1),'e');
% fp(ip) is not the locaton of a seprator
fp_use=setxor(fp_use,fp(ip));
end
end
fp=fp_use;
nvar=length(fp)+1;
% disp(sprintf('Found %d variograms',nvar))
if nvar==1,
ifp_array=[0];
else
ifp_array=[0 fp];
end
ivar=0;
for ifp=1:length(ifp_array);
ivar=ivar+1;
if nvar==1,
vartxt=txt;
else
if ifp_array(ifp)==0,
vartxt=txt(1:fp(1)-1);
elseif ifp_array(ifp)==max(fp)
vartxt=txt(ifp_array(ifp)+1:length(txt));
else
ind1=ifp_array(ifp)+1;
ind2=ifp_array(ifp+1)-1;
vartxt=txt(ind1:ind2);
% else
% keyboard
% mgstat_verbose('MORE THAN TWO VARIOGRAMS NOT IMPLEMENTED YET',0)
end
end
vartxt=strip_space(vartxt);
%disp(sprintf('ivar=%d ifp=%d --%s--',ivar,ifp,vartxt))
sp=find(vartxt==' ');
lb=find(vartxt=='(');
rb=find(vartxt==')');
par1=vartxt(1:sp-1);
par2=vartxt(lb+1:rb-1);
type=strip_space(vartxt(sp+1:lb-1));
if ~isempty(str2num(par1)), par1=str2num(par1); end
if ~isempty(str2num(par2)), par2=str2num(par2); end
if isempty(par2), par2=[];end
if (strcmp(type,'Nug'))
itype=0;
elseif (strcmp(type,'iNug')),
itype=14;
elseif (strcmp(type,'Sph')),
itype=1;
elseif (strcmp(type,'Gau'))
itype=3;
elseif (strcmp(type,'Exp'))
itype=2;
elseif (strcmp(type,'Log'))
itype=15;
elseif (strcmp(type,'Lin'))
itype=6;
elseif (strcmp(type,'Pow'))
itype=4;
elseif (strcmp(type,'Hole'))
itype=5;
elseif (strcmp(type,'Bal'))
itype=10;
elseif (strcmp(type,'Thi'))
itype=11;
elseif (strcmp(type,'Mat'))
itype=12;
elseif (isempty(type))
itype=-1;
else
disp(sprintf('%s : Unknown semivariogram type : %s ',mfilename,type))
itype=8;
end
% disp(sprintf('par1=%5.1f par2=%5.1f type=%4s itype=%d',par1,par2,type,itype))
if length(par2)==2,
V(ivar).nu=par2(2);
par2=par2(1);
end
if length(par2)==4,
V(ivar).nu=par2(4);
par2=par2(1:3);
end
if length(par2)==7,
V(ivar).nu=par2(7);
par2=par2(1:6);
end
V(ivar).par1=par1;
V(ivar).par2=par2;
V(ivar).type=type;
V(ivar).itype=itype;
end