source: altifloat/matlab_toolbox/make_obs.m @ 160

Last change on this file since 160 was 129, checked in by jbrlod, 10 years ago

last version of Varanth

File size: 4.2 KB
Line 
1function [ 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
6dirnem='../nemed/';
7nemlist=listename;
8format long
9fid=fopen([dirnem nemlist]);
10count=1;
11float_obs=[];
12index=[];
13while 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;
30end
31
32[m,n]=size(float_obs)
33fclose(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';
50format 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 
61load ../obs_float/meshgrid2.dat
62
63Nlat=58; %Phi
64Nlong=87; %Lambda
65GR_long=reshape(meshgrid2(:,1),Nlong,Nlat);
66GR_lat=reshape(meshgrid2(:,2),Nlong,Nlat);
67load ../obs_float/nemed_observations.dat
68I=find(nemed_observations(:,1)==1);
69xi=interp1(GR_long(:,1),1:Nlong,nemed_observations(I,end));
70xi(1:10)
71I=find(nemed_observations(:,1)==2);
72yi=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';
81format 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 
111outfile='../obs_float/oneandfive_final.dat';
112load ../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
131fid=fopen(outfile,'w');
132fprintf(fid,'%d %d %d %f\n',oneandfive(:,1:4)');
133
134
135
136outfile='../obs_float/obs_float_test.dat';
137load ../obs_float/oneandfive_final.dat;
138[d,f]=size(oneandfive_final)
139floater1=zeros(d,f);
140count1=1;
141
142
143for 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   
150end
151
152
153fid=fopen(outfile,'w');
154fprintf(fid,'%d %d %d %f\n',floater(1:timeneeded*4,:)');
155fclose(fid);
156
157outfile='../obs_float/third_observation.dat';
158load ../obs_float/oneandfive_final.dat;
159[d,f]=size(oneandfive_final)
160floater1=zeros(d,f);
161count1=1;
162
163
164for 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   
171end
172
173
174fid=fopen(outfile,'w');
175fprintf(fid,'%d %d %d %f\n',floater(timeneeded*4+1:end,:)');
176fclose(fid);
177
178
179outfile='../obs_float/init.dat';
180load ../obs_float/oneandfive_final.dat;
181[d,f]=size(oneandfive_final)
182floater1=zeros(d,f);
183count1=1;
184
185
186for 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   
193end
194
195
196fid=fopen(outfile,'w');
197fprintf(fid,'%d %d %d %f\n',floater');
198fclose(fid);
199
200
201end
202
Note: See TracBrowser for help on using the repository browser.