1 | function [ output_args ] = read_aviso( 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 | |
---|
22 | write_u=1; |
---|
23 | |
---|
24 | |
---|
25 | %for plotting |
---|
26 | |
---|
27 | |
---|
28 | %The grid in degrees |
---|
29 | load '../obs_float/meshgrid2.dat'; |
---|
30 | |
---|
31 | GR_long=reshape(meshgrid2(:,1),Nlong,Nlat); %will give a Nlong by Nlat matrix |
---|
32 | %containing the long of the points |
---|
33 | |
---|
34 | GR_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 | |
---|
52 | U1=ncread(strcat('../obs_aviso/',aviso_netcdf_file_bck,'.nc'),'Grid_0001'); |
---|
53 | uaviso1=U1(1:58,end-86:end)./100; %choose the eatern med and make it in m/s |
---|
54 | |
---|
55 | V1=ncread(strcat('../obs_aviso/',aviso_netcdf_file_bck,'.nc'),'Grid_0002'); |
---|
56 | vaviso1=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 | |
---|
62 | U2=ncread(strcat('../obs_aviso/',aviso_netcdf_file_next,'.nc'),'Grid_0001'); |
---|
63 | uaviso2=U2(1:58,end-86:end)./100; |
---|
64 | |
---|
65 | V2=ncread(strcat('../obs_aviso/',aviso_netcdf_file_next,'.nc'),'Grid_0002'); |
---|
66 | vaviso2=V2(1:58,end-86:end)./100; |
---|
67 | |
---|
68 | |
---|
69 | %do the mask manually: |
---|
70 | II1=find(isfinite(uaviso1)==0); |
---|
71 | uaviso1(II1)=0; |
---|
72 | II2=find(isfinite(uaviso2)==0); |
---|
73 | uaviso2(II2)=0; |
---|
74 | |
---|
75 | JJ1=find(isfinite(vaviso1)==0); |
---|
76 | vaviso1(JJ1)=0; |
---|
77 | JJ2=find(isfinite(vaviso2)==0); |
---|
78 | vaviso2(JJ2)=0; |
---|
79 | |
---|
80 | |
---|
81 | %interpolate to get the field every 2 h during the first week, in case need velocity in between: |
---|
82 | Nt=nbofdays*24/2; %one week in units of delta t |
---|
83 | for 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); |
---|
86 | end |
---|
87 | |
---|
88 | |
---|
89 | |
---|
90 | |
---|
91 | |
---|
92 | |
---|
93 | %change grid from degrees to uniteless |
---|
94 | |
---|
95 | R_earth=6371229; %in meters |
---|
96 | delta_x=zeros(Nlong,Nlat); |
---|
97 | delta_y=zeros(Nlong,Nlat); |
---|
98 | |
---|
99 | for 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 | |
---|
107 | end |
---|
108 | end |
---|
109 | |
---|
110 | |
---|
111 | |
---|
112 | delta_x(Nlong,1:Nlat)=delta_x(Nlong-1,1:Nlat); |
---|
113 | delta_y(Nlong,1:Nlat)=delta_y(Nlong-1,1:Nlat); |
---|
114 | |
---|
115 | |
---|
116 | delta_x(1:Nlong,Nlat)=delta_x(1:Nlong,Nlat-1); |
---|
117 | delta_y(1:Nlong,Nlat)=delta_y(1:Nlong,Nlat-1); |
---|
118 | |
---|
119 | |
---|
120 | |
---|
121 | %choose UTRUE=Ufirst week |
---|
122 | |
---|
123 | uu=umod(:,:,1)./delta_x.'; %u has units of pers second |
---|
124 | vv=vmod(:,:,1)./delta_y.'; |
---|
125 | |
---|
126 | %Choose Uback=Uafter 3days |
---|
127 | |
---|
128 | uu_pert=umod(:,:,35)./delta_x.'; |
---|
129 | vv_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 |
---|
137 | u_yao1=reshape(uu, Nlong*Nlat,1); |
---|
138 | v_yao1=reshape(vv, Nlong*Nlat,1); |
---|
139 | |
---|
140 | up_yao1=reshape(uu_pert, Nlong*Nlat,1); |
---|
141 | vp_yao1=reshape(vv_pert, Nlong*Nlat,1); |
---|
142 | %create the vectors rehsaped |
---|
143 | cd1=[]; for k=1:Nlong; cd1=[cd1; k*ones(Nlat,1)]; end |
---|
144 | cd2=repmat([1:1:Nlat].',Nlong,1); |
---|
145 | |
---|
146 | Yao_u=[ ones(Nlong*Nlat,1) cd1 cd2 u_yao1]; |
---|
147 | Yao_v=[ ones(Nlong*Nlat,1) cd1 cd2 v_yao1]; |
---|
148 | |
---|
149 | Yao_up=[ ones(Nlong*Nlat,1) cd1 cd2 up_yao1]; |
---|
150 | Yao_vp=[ ones(Nlong*Nlat,1) cd1 cd2 vp_yao1]; |
---|
151 | |
---|
152 | if (write_u==1) |
---|
153 | |
---|
154 | dlmwrite('../obs_float/uzero.dat',Yao_u,'\t'); |
---|
155 | dlmwrite('../obs_float/vzero.dat',Yao_v,'\t'); |
---|
156 | %save UV_0.mat uu vv; |
---|
157 | dlmwrite('../obs_float/unext3d.dat',Yao_up,'\t'); |
---|
158 | dlmwrite('../obs_float/vnext3d.dat',Yao_vp,'\t'); |
---|
159 | %save UVnext3d.mat uu_pert vv_pert cc1 cc2; |
---|
160 | end; |
---|
161 | |
---|
162 | |
---|
163 | end |
---|
164 | |
---|