source: altifloat/matlab_toolbox/read_aviso_file.m @ 199

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

last version of Varanth

File size: 4.4 KB
Line 
1function [ output_args ] = read_aviso_file( aviso_netcdf_file_bck, aviso_netcdf_file_next, Nlat, Nlong, nbofdays )
2%%%%%%%%%% This function is to read the AVISO netcdf files that are
3%%%%%%%%%% downloaded from the Aviso website (aviso_netcdf_file).
4%%%%%%%%%% The user should enter the name of the file of AVISO at the date
5%%%%%%%%%% needed (aviso_netcdf_file_bck) and the name of the file of
6%%%%%%%%%% Aviso a week later of the date (aviso_netcdf_file_next).
7%%%%%%%%%% Note that you should not add the extension while entering the
8%%%%%%%%%% name of the file;
9%%%%%%%%%% The user should also specify the dimention of the grid that 
10%%%%%%%%%%  he wants (Nlat is for the latitude and Nlong is for the
11%%%%%%%%%% longitude). It then extracts the
12%%%%%%%%%% horizontal u and vertical v terms of the velocity fields in the
13%%%%%%%%%% dimentions needed and stores them in an output file that could
14%%%%%%%%%% be read by the YAO software. This code gives you the velocity
15%%%%%%%%%% fields at the 2 dates: the date needed and a week later.
16%%%%%%%%%% The nbof dqys is the number of days between the 2 AVISO datas.
17
18%%%%%%%%%% Usually use:
19%%%%%%%%%% Nlat=58; %Phi
20%%%%%%%%%% Nlong=87; %Lambda
21
22write_u=1;
23
24 
25%for plotting
26
27
28%The grid in degrees
29load 'obs_float/meshgrid2.dat';
30
31GR_long=reshape(meshgrid2(:,1),Nlong,Nlat); %will give a Nlong by Nlat matrix
32%containing the long of the points
33
34GR_lat=reshape(meshgrid2(:,2),Nlong,Nlat); %will give a Nlong by Nlat matrix
35%containing the lat of the points
36
37
38
39
40
41
42%-----------The velocities U and V---------------------------------------%
43
44
45
46%Load directly from AVISO folder where the u s for the whole mediterranean:
47
48
49
50%UTRUE=the first week
51
52U1=ncread(strcat('obs_aviso/',aviso_netcdf_file_bck,'.nc'),'Grid_0001');
53uaviso1=U1(1:58,end-86:end)./100; %choose the eatern med and make it in m/s
54
55V1=ncread(strcat('obs_aviso/',aviso_netcdf_file_bck,'.nc'),'Grid_0002');
56vaviso1=V1(1:58,end-86:end)./100; %choose the eatern med and make it in m/s
57
58
59
60%U the second week
61
62U2=ncread(strcat('obs_aviso/',aviso_netcdf_file_next,'.nc'),'Grid_0001');
63uaviso2=U2(1:58,end-86:end)./100;
64
65V2=ncread(strcat('obs_aviso/',aviso_netcdf_file_next,'.nc'),'Grid_0002');
66vaviso2=V2(1:58,end-86:end)./100;
67
68
69%do the mask manually:
70II1=find(isfinite(uaviso1)==0);
71uaviso1(II1)=0;
72II2=find(isfinite(uaviso2)==0);
73uaviso2(II2)=0;
74
75JJ1=find(isfinite(vaviso1)==0);
76vaviso1(JJ1)=0;
77JJ2=find(isfinite(vaviso2)==0);
78vaviso2(JJ2)=0;
79
80
81%interpolate to get the field every 2 h during the first week, in case need velocity in between:
82Nt=nbofdays*24/2; %one week in units of delta t
83for jt=1:Nt+1
84    umod(:,:,jt)=(uaviso1*(Nt+1-jt)./Nt)+ (uaviso2*(jt-1)/Nt);
85    vmod(:,:,jt)=(vaviso1*(Nt+1-jt)./Nt)+ (vaviso2*(jt-1)/Nt);
86end
87   
88
89
90
91
92
93%change grid from degrees to uniteless
94
95R_earth=6371229; %in meters
96delta_x=zeros(Nlong,Nlat);
97delta_y=zeros(Nlong,Nlat);
98
99for ilon=1:Nlong-1;
100    for jlat=1:Nlat-1;
101       
102    delta_x(ilon,jlat)=R_earth*(2*pi/360)*(GR_long(ilon+1,jlat)-GR_long(ilon,jlat))...
103        .*cos(2*pi*GR_lat(ilon,jlat)/360);
104    delta_y(ilon,jlat)=R_earth*(2*pi/360)*(GR_lat(ilon,jlat+1)-GR_lat(ilon,jlat)); 
105   
106   
107end
108end
109
110
111
112delta_x(Nlong,1:Nlat)=delta_x(Nlong-1,1:Nlat);
113delta_y(Nlong,1:Nlat)=delta_y(Nlong-1,1:Nlat);
114
115
116delta_x(1:Nlong,Nlat)=delta_x(1:Nlong,Nlat-1);
117delta_y(1:Nlong,Nlat)=delta_y(1:Nlong,Nlat-1);
118
119
120
121%choose UTRUE=Ufirst week
122
123uu=umod(:,:,1)./delta_x.'; %u has units of pers second
124vv=vmod(:,:,1)./delta_y.';
125
126%Choose Uback=Uafter 3days
127
128uu_pert=umod(:,:,35)./delta_x.';
129vv_pert=vmod(:,:,35)./delta_y.';
130
131%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
132
133
134%%%%%%%%%%%%%%%%%%%PUT U in YAO format%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135
136%create a Nlat*Nlong by 5 matrix first
137u_yao1=reshape(uu, Nlong*Nlat,1);
138v_yao1=reshape(vv, Nlong*Nlat,1);
139
140up_yao1=reshape(uu_pert, Nlong*Nlat,1);
141vp_yao1=reshape(vv_pert, Nlong*Nlat,1);
142%create the vectors rehsaped
143cd1=[]; for k=1:Nlong; cd1=[cd1; k*ones(Nlat,1)]; end
144cd2=repmat([1:1:Nlat].',Nlong,1);
145
146Yao_u=[ ones(Nlong*Nlat,1)  cd1 cd2 u_yao1];
147Yao_v=[ ones(Nlong*Nlat,1)  cd1 cd2 v_yao1];
148
149Yao_up=[ ones(Nlong*Nlat,1)  cd1 cd2 up_yao1];
150Yao_vp=[ ones(Nlong*Nlat,1)  cd1 cd2 vp_yao1];
151
152if (write_u==1)
153
154dlmwrite('obs_float/uzero.dat',Yao_u,'\t');
155dlmwrite('obs_float/vzero.dat',Yao_v,'\t');
156%save UV_0.mat uu vv;
157dlmwrite('obs_float/unext3d.dat',Yao_up,'\t');
158dlmwrite('obs_float/vnext3d.dat',Yao_vp,'\t');
159%save UVnext3d.mat uu_pert vv_pert cc1 cc2;
160end;
161
162
163end
164
Note: See TracBrowser for help on using the repository browser.