1 | |
---|
2 | clear all; |
---|
3 | |
---|
4 | %------------GRID-------------------------------------------------------% |
---|
5 | Nlat=58; %Phi |
---|
6 | Nlong=87; %Lambda |
---|
7 | %The grid in degrees |
---|
8 | load 'meshgrid2.dat'; |
---|
9 | |
---|
10 | GR_long=reshape(meshgrid2(:,1),Nlong,Nlat); %will give a Nlong by Nlat matrix |
---|
11 | %containing the long of the points |
---|
12 | |
---|
13 | GR_lat=reshape(meshgrid2(:,2),Nlong,Nlat); %will give a Nlong by Nlat matrix |
---|
14 | %containing the lat of the points |
---|
15 | |
---|
16 | |
---|
17 | %--------------------TIME-------------------------------------------------% |
---|
18 | dt=2*3600; %in seconds small delta t corresponding to Nume Scheme for advection |
---|
19 | |
---|
20 | %---------------------U---------------------------------------------------% |
---|
21 | load 'velbck.dat'; |
---|
22 | u=reshape(velbck(:,1),Nlong,Nlat,[]); |
---|
23 | v=reshape(velbck(:,2),Nlong,Nlat,[]); |
---|
24 | u1=u(:,:,1); |
---|
25 | v1=v(:,:,1); |
---|
26 | |
---|
27 | |
---|
28 | R_earth=6371229; %in meters |
---|
29 | delta_x=zeros(Nlong,Nlat); |
---|
30 | delta_y=zeros(Nlong,Nlat); |
---|
31 | |
---|
32 | for ilon=1:Nlong-1; |
---|
33 | for jlat=1:Nlat-1; |
---|
34 | |
---|
35 | delta_x(ilon,jlat)=R_earth*(2*pi/360)*(GR_long(ilon+1,jlat)-GR_long(ilon,jlat))... |
---|
36 | .*cos(2*pi*GR_lat(ilon,jlat)/360); |
---|
37 | delta_y(ilon,jlat)=R_earth*(2*pi/360)*(GR_lat(ilon,jlat+1)-GR_lat(ilon,jlat)); |
---|
38 | |
---|
39 | |
---|
40 | end |
---|
41 | end |
---|
42 | |
---|
43 | |
---|
44 | |
---|
45 | delta_x(Nlong,1:Nlat)=delta_x(Nlong-1,1:Nlat); |
---|
46 | delta_y(Nlong,1:Nlat)=delta_y(Nlong-1,1:Nlat); |
---|
47 | |
---|
48 | |
---|
49 | delta_x(1:Nlong,Nlat)=delta_x(1:Nlong,Nlat-1); |
---|
50 | delta_y(1:Nlong,Nlat)=delta_y(1:Nlong,Nlat-1); |
---|
51 | |
---|
52 | |
---|
53 | |
---|
54 | |
---|
55 | u_pers=u1./delta_x; %u pers second |
---|
56 | v_pers=v1./delta_y; |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | %note in fortran he does the nonuniform grid: |
---|
61 | |
---|
62 | %rad = 2. * asin( 1. ) / 180. this is pi/180=2*pi/360 |
---|
63 | % rae = 6371229. |
---|
64 | % DO jj = 1, jpj-1 |
---|
65 | % DO ji = 1, jpi-1 |
---|
66 | % e1t(ji,jj) = rae*rad*cos(rad*phi(ji,jj))*(lam(ji+1,jj)-lam(ji,jj)) |
---|
67 | % e2t(ji,jj) = rae*rad *(phi(ji,jj+1)-phi(ji,jj)) |
---|
68 | % END DO |
---|
69 | % END DO |
---|
70 | |
---|
71 | |
---|
72 | |
---|
73 | |
---|
74 | uu=u_pers.'; |
---|
75 | vv=v_pers.'; |
---|
76 | |
---|
77 | %-----------------PUT U in YAO format-------------------------------------% |
---|
78 | |
---|
79 | %create a Nlat*Nlong by 5 matrix first |
---|
80 | u_yao1=reshape(uu, Nlong*Nlat,1); |
---|
81 | v_yao1=reshape(vv, Nlong*Nlat,1); |
---|
82 | %create the vectors rehsaped |
---|
83 | c1=[]; for k=1:Nlong; c1=[c1; k*ones(Nlat,1)]; end |
---|
84 | c2=repmat([1:1:Nlat].',Nlong,1); |
---|
85 | |
---|
86 | %Yao_u=[ones(Nlong*Nlat,1) ones(Nlong*Nlat,1) c1 c2 u_yao1]; |
---|
87 | %Yao_v=[ones(Nlong*Nlat,1) ones(Nlong*Nlat,1) c1 c2 v_yao1]; |
---|
88 | Yao_u=[ ones(Nlong*Nlat,1) c1 c2 u_yao1]; |
---|
89 | Yao_v=[ ones(Nlong*Nlat,1) c1 c2 v_yao1]; |
---|
90 | |
---|
91 | %dlmwrite('../obs_float/uzero.dat',Yao_u,'\t'); |
---|
92 | %dlmwrite('../obs_float/vzero.dat',Yao_v,'\t'); |
---|
93 | |
---|
94 | |
---|
95 | |
---|
96 | % xx=R_earth*(2*pi/360)*GR_long.*cos(0.5*(lat_min+lat_max)); % this is an approximation |
---|
97 | % %that gives a "uniform" rectangular grid but at these scales, |
---|
98 | % %this approximation is not so good! see fig 1 |
---|
99 | % |
---|
100 | % xx1=R_earth*(2*pi/360)*GR_long.*cos(2*pi*GR_lat/360); %this gives |
---|
101 | % %the non uniform grid that is not a rectangle |
---|
102 | % |
---|
103 | % yy=R_earth*(2*pi/360)*GR_lat; |
---|
104 | |
---|
105 | |
---|