forked from cultpenguin/mGstat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathread_emm.m
155 lines (126 loc) · 3.22 KB
/
read_emm.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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
% read_emm : read emm output file from em1dinv
%
% CALL :
% [emm]=read_emm(filename);
%
function [emm,line]=read_emm(filename)
if nargin==0
help read_emm
return
end
fid=fopen(filename,'r');
iline=0;
for i=1:43,
iline=iline+1;
line{iline}=fgetl(fid);
end
emm.version=line{2};
emm.date=line{6};
emm.runtimee=str2num(line{8});
emm.ni=str2num(line{10});
emm.nds=str2num(line{12});
emm.nd=str2num(line{14});
emm.dcp_file=line{16};
emm.mod_file=line{18};
emm.nm=str2num(line{20});
emm.nm_par=str2num(line{22});
emm.nm_layers=str2num(line{24});
emm.logspace=sscanf(line{26},'%d');
% Model parameters
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.MPar.nm=d(1);
emm.MPar.ni=d(2);
for i=1:emm.MPar.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.MPar.data(i,:)=d(:)';
end
% Forward
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.Forward.nm=d(1);
emm.Forward.ni=d(2);
for i=1:emm.Forward.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.Forward.data(i,:)=d(:)';
end
% G
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.G.nm=d(1);
emm.G.ni=d(2);
for i=1:emm.G.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.G.data(i,:)=d(:)';
end
% Mres
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.Mres.nm=d(1);
emm.Mres.ni=d(2);
for i=1:emm.Mres.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.Mres.data(i,:)=d(:)';
end
% MCovC
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.MCovC.nm=d(1);
emm.MCovC.ni=d(2);
for i=1:emm.MCovC.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.MCovC.data(i,:)=d(:)';
end
% MCovCn
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.MCovCn.nm=d(1);
emm.MCovCn.ni=d(2);
for i=1:emm.MCovCn.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.MCovCn.data(i,:)=d(:)';
end
% MCovUC
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.MCovUC.nm=d(1);
emm.MCovUC.ni=d(2);
for i=1:emm.MCovUC.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.MCovUC.data(i,:)=d(:)';
end
% AnaC
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.AnaC.nm=d(1);
emm.AnaC.ni=d(2);
for i=1:emm.AnaC.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.AnaC.data(i,:)=d(:)';
end
% AnaUC
fgetl(fid);
iline=iline+1; line{iline}=fgetl(fid);
d=sscanf(line{iline},'%d');
emm.AnaUC.nm=d(1);
emm.AnaUC.ni=d(2);
for i=1:emm.AnaUC.nm
l=fgetl(fid);
d=sscanf(l,'%f');
emm.AnaUC.data(i,:)=d(:)';
end