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 Nlat by Nlong matrix |
---|
11 | %containing the long of the points |
---|
12 | |
---|
13 | GR_lat=reshape(meshgrid2(:,2),Nlong,Nlat).'; %will give a Nlat by Nlong matrix |
---|
14 | %containing the lat of the points |
---|
15 | |
---|
16 | |
---|
17 | lat_min=2*pi*min(min(GR_lat))/360; |
---|
18 | lat_max=2*pi*max(max(GR_lat))/360; |
---|
19 | |
---|
20 | %transforming from degrees to metres with an approximation of avergaging the |
---|
21 | %cosine since latitude doesnt seem to change much in region of interest |
---|
22 | |
---|
23 | R_earth=6371229; %in meters |
---|
24 | |
---|
25 | xx=R_earth*(2*pi/360)*GR_long.*cos(0.5*(lat_min+lat_max)); % this is an approximation |
---|
26 | %that gives a "uniform" rectangular grid but at these scales, |
---|
27 | %this approximation is not so good! see fig 1 |
---|
28 | |
---|
29 | xx1=R_earth*(2*pi/360)*GR_long.*cos(2*pi*GR_lat/360); %this gives |
---|
30 | %the non uniform grid that is not a rectangle |
---|
31 | |
---|
32 | yy=R_earth*(2*pi/360)*GR_lat; |
---|
33 | |
---|
34 | figure(1); |
---|
35 | plot(xx,yy,'ro') |
---|
36 | hold on |
---|
37 | plot(xx1,yy,'k+') |
---|
38 | |
---|
39 | %note in fortran he does the nonuniform grid: |
---|
40 | |
---|
41 | %rad = 2. * asin( 1. ) / 180. this is pi/180=2*pi/360 |
---|
42 | % rae = 6371229. |
---|
43 | % DO jj = 1, jpj-1 |
---|
44 | % DO ji = 1, jpi-1 |
---|
45 | % e1t(ji,jj) = rae*rad*cos(rad*phi(ji,jj))*(lam(ji+1,jj)-lam(ji,jj)) |
---|
46 | % e2t(ji,jj) = rae*rad *(phi(ji,jj+1)-phi(ji,jj)) |
---|
47 | % END DO |
---|
48 | % END DO |
---|
49 | |
---|
50 | |
---|
51 | dx=xx(1,2)-xx(1,1) |
---|
52 | dy=yy(2,1)-yy(1,1) |
---|
53 | |
---|
54 | |
---|
55 | %--------------------TIME-------------------------------------------------% |
---|
56 | dt=2*3600; %in seconds small delta t corresponding to Nume Scheme for advection |
---|
57 | |
---|
58 | |
---|
59 | %---------------------U---------------------------------------------------% |
---|
60 | load 'velbck.dat'; |
---|
61 | u=reshape(velbck(:,1),Nlong,Nlat,[]); |
---|
62 | v=reshape(velbck(:,2),Nlong,Nlat,[]); |
---|
63 | |
---|
64 | |
---|
65 | u1=u(:,:,1).'.*dt/dx; |
---|
66 | v1=v(:,:,1).'.*dt/dx; |
---|
67 | |
---|
68 | %-----------------PUT U in YAO format-------------------------------------% |
---|
69 | |
---|
70 | %create a Nlat*Nlong by 5 matrix first |
---|
71 | u_yao1=reshape(u1, Nlong*Nlat,1); |
---|
72 | v_yao1=reshape(v1, Nlong*Nlat,1); |
---|
73 | %create the vectors rehsaped |
---|
74 | c1=[]; for k=1:Nlong; c1=[c1; k*ones(Nlat,1)]; end |
---|
75 | c2=repmat([1:1:Nlat].',Nlong,1); |
---|
76 | |
---|
77 | %Yao_u=[ones(Nlong*Nlat,1) ones(Nlong*Nlat,1) c1 c2 u_yao1]; |
---|
78 | %Yao_v=[ones(Nlong*Nlat,1) ones(Nlong*Nlat,1) c1 c2 v_yao1]; |
---|
79 | Yao_u=[ ones(Nlong*Nlat,1) c1 c2 u_yao1]; |
---|
80 | Yao_v=[ ones(Nlong*Nlat,1) c1 c2 v_yao1]; |
---|
81 | |
---|
82 | %dlmwrite('../obs_float/uzero.dat',Yao_u,'\t'); |
---|
83 | %dlmwrite('../obs_float/vzero.dat',Yao_v,'\t'); |
---|
84 | |
---|
85 | |
---|
86 | |
---|
87 | |
---|
88 | |
---|
89 | |
---|