1 | function [ output_args ] = make_obs( listename, timeneeded ) |
---|
2 | |
---|
3 | %%%%%%%%% This function takes the name of the floater from the list and |
---|
4 | %%%%%%%%% changes it's format so it is YAO compatible. |
---|
5 | |
---|
6 | dirnem='../nemed/'; |
---|
7 | nemlist=listename; |
---|
8 | format long |
---|
9 | fid=fopen([dirnem nemlist]); |
---|
10 | count=1; |
---|
11 | float_obs=[]; |
---|
12 | index=[]; |
---|
13 | while 1 |
---|
14 | tline = fgetl(fid); |
---|
15 | disp(tline) |
---|
16 | if ~ischar(tline), break, end |
---|
17 | lon=ncread([dirnem tline],'longitudes'); |
---|
18 | lat=ncread([dirnem tline],'latitudes'); |
---|
19 | pdt=ncread([dirnem tline],'time'); |
---|
20 | |
---|
21 | M=zeros(size(lat,1),4); |
---|
22 | M(:,1)=count; |
---|
23 | M(:,2)=pdt/365.25; |
---|
24 | M(:,3)=lon; |
---|
25 | M(:,4)=lat; |
---|
26 | [m1,n1]=size(M); |
---|
27 | index=[index;m1] |
---|
28 | float_obs=[float_obs;M]; |
---|
29 | count=count+1; |
---|
30 | end |
---|
31 | |
---|
32 | [m,n]=size(float_obs) |
---|
33 | fclose(fid); |
---|
34 | |
---|
35 | |
---|
36 | firstcol=ones(m,1); |
---|
37 | |
---|
38 | float_obs(:,5)=float_obs(:,1); |
---|
39 | float_obs(:,1)=ones(m,1); |
---|
40 | float_obs(:,6)=float_obs(:,3); |
---|
41 | float_obs(:,3)=float_obs(:,5); |
---|
42 | float_obs(:,7)=float_obs(:,4); |
---|
43 | float_obs(:,4)=float_obs(:,6); |
---|
44 | |
---|
45 | |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | outfile='../obs_float/nemed_observations.dat'; |
---|
50 | format long |
---|
51 | files=fopen(outfile,'w'); |
---|
52 | fprintf(files,'%d %d %d %f\n',float_obs(:,1:4)'); |
---|
53 | |
---|
54 | float_obs(:,1)=firstcol+1; |
---|
55 | |
---|
56 | fprintf(files,'%d %d %d %f\n',float_obs(:,[1,2,3,7])'); |
---|
57 | |
---|
58 | fclose(files); |
---|
59 | |
---|
60 | |
---|
61 | load ../obs_float/meshgrid2.dat |
---|
62 | |
---|
63 | Nlat=58; %Phi |
---|
64 | Nlong=87; %Lambda |
---|
65 | GR_long=reshape(meshgrid2(:,1),Nlong,Nlat); |
---|
66 | GR_lat=reshape(meshgrid2(:,2),Nlong,Nlat); |
---|
67 | load ../obs_float/nemed_observations.dat |
---|
68 | I=find(nemed_observations(:,1)==1); |
---|
69 | xi=interp1(GR_long(:,1),1:Nlong,nemed_observations(I,end)); |
---|
70 | xi(1:10) |
---|
71 | I=find(nemed_observations(:,1)==2); |
---|
72 | yi=interp1(GR_lat(1,:),1:Nlat,nemed_observations(I,end)); |
---|
73 | |
---|
74 | float_obs(:,1)=firstcol; |
---|
75 | |
---|
76 | float_obs(:,4)=xi; |
---|
77 | float_obs(:,7)=yi; |
---|
78 | |
---|
79 | |
---|
80 | outfile='../obs_float/nemed_observations_2.dat'; |
---|
81 | format long |
---|
82 | files=fopen(outfile,'w'); |
---|
83 | fprintf(files,'%d %d %d %f\n',float_obs(:,1:4)'); |
---|
84 | |
---|
85 | float_obs(:,1)=firstcol+1; |
---|
86 | |
---|
87 | fprintf(files,'%d %d %d %f\n',float_obs(:,[1,2,3,7])'); |
---|
88 | |
---|
89 | fclose(files); |
---|
90 | |
---|
91 | outfile='../obs_float/oneandfive.dat'; |
---|
92 | load ../obs_float/nemed_observations_2.dat; |
---|
93 | files=fopen(outfile,'w'); |
---|
94 | |
---|
95 | I1=find(nemed_observations_2(:,3)==1); |
---|
96 | I2=find(nemed_observations_2(:,3)==2); |
---|
97 | I3=find(nemed_observations_2(:,3)==3); |
---|
98 | s1=length(I1) |
---|
99 | S1=s1/2; |
---|
100 | s2=length(I2); |
---|
101 | S2=s2/2; |
---|
102 | s3=length(I3); |
---|
103 | S3=s3/2; |
---|
104 | |
---|
105 | I=[I1(1:timeneeded) I2(1:timeneeded) I3(1:timeneeded) I1(S1+1:S1+timeneeded) I2(S2+1:S2+timeneeded) I3(S3+1:S3+timeneeded)]; |
---|
106 | |
---|
107 | fprintf(files,'%d %d %d %f\n',nemed_observations_2(I,[1,2,3,4])'); |
---|
108 | |
---|
109 | fclose(files); |
---|
110 | |
---|
111 | outfile='../obs_float/oneandfive_final.dat'; |
---|
112 | load ../obs_float/oneandfive.dat; |
---|
113 | [m,n]=size(oneandfive) |
---|
114 | |
---|
115 | |
---|
116 | count=1; |
---|
117 | for s=1:m/6 |
---|
118 | oneandfive(s,2)=count; |
---|
119 | oneandfive(s+m/6,2)=count; |
---|
120 | oneandfive(s+2*m/6,2)=count; |
---|
121 | oneandfive(s+3*m/6,2)=count; |
---|
122 | oneandfive(s+4*m/6,2)=count; |
---|
123 | oneandfive(s+5*m/6,2)=count; |
---|
124 | |
---|
125 | |
---|
126 | count=count+3; |
---|
127 | |
---|
128 | |
---|
129 | end |
---|
130 | |
---|
131 | fid=fopen(outfile,'w'); |
---|
132 | fprintf(fid,'%d %d %d %f\n',oneandfive(:,1:4)'); |
---|
133 | |
---|
134 | |
---|
135 | |
---|
136 | outfile='../obs_float/obs_float_test.dat'; |
---|
137 | load ../obs_float/oneandfive_final.dat; |
---|
138 | [d,f]=size(oneandfive_final) |
---|
139 | floater1=zeros(d,f); |
---|
140 | count1=1; |
---|
141 | |
---|
142 | |
---|
143 | for i=1:d/2 |
---|
144 | floater(count1,:)=oneandfive_final(i,:); |
---|
145 | floater(count1+1,:)=oneandfive_final(i+d/2,:); |
---|
146 | |
---|
147 | |
---|
148 | count1=count1+2; |
---|
149 | |
---|
150 | end |
---|
151 | |
---|
152 | |
---|
153 | fid=fopen(outfile,'w'); |
---|
154 | fprintf(fid,'%d %d %d %f\n',floater(1:timeneeded*4,:)'); |
---|
155 | fclose(fid); |
---|
156 | |
---|
157 | outfile='../obs_float/third_observation.dat'; |
---|
158 | load ../obs_float/oneandfive_final.dat; |
---|
159 | [d,f]=size(oneandfive_final) |
---|
160 | floater1=zeros(d,f); |
---|
161 | count1=1; |
---|
162 | |
---|
163 | |
---|
164 | for i=1:d/2 |
---|
165 | floater(count1,:)=oneandfive_final(i,:); |
---|
166 | floater(count1+1,:)=oneandfive_final(i+d/2,:); |
---|
167 | |
---|
168 | |
---|
169 | count1=count1+2; |
---|
170 | |
---|
171 | end |
---|
172 | |
---|
173 | |
---|
174 | fid=fopen(outfile,'w'); |
---|
175 | fprintf(fid,'%d %d %d %f\n',floater(timeneeded*4+1:end,:)'); |
---|
176 | fclose(fid); |
---|
177 | |
---|
178 | |
---|
179 | outfile='../obs_float/init.dat'; |
---|
180 | load ../obs_float/oneandfive_final.dat; |
---|
181 | [d,f]=size(oneandfive_final) |
---|
182 | floater1=zeros(d,f); |
---|
183 | count1=1; |
---|
184 | |
---|
185 | |
---|
186 | for i=1:d/2 |
---|
187 | floater(count1,:)=oneandfive_final(i,:); |
---|
188 | floater(count1+1,:)=oneandfive_final(i+d/2,:); |
---|
189 | |
---|
190 | |
---|
191 | count1=count1+2; |
---|
192 | |
---|
193 | end |
---|
194 | |
---|
195 | |
---|
196 | fid=fopen(outfile,'w'); |
---|
197 | fprintf(fid,'%d %d %d %f\n',floater'); |
---|
198 | fclose(fid); |
---|
199 | |
---|
200 | |
---|
201 | end |
---|
202 | |
---|