source: altifloat/obs_external/read_davane.m

Last change on this file was 108, checked in by leila_ocean, 11 years ago

with filter

File size: 2.7 KB
Line 
1
2clear all;
3
4%------------GRID-------------------------------------------------------%
5Nlat=58; %Phi
6Nlong=87; %Lambda
7%The grid in degrees
8load 'meshgrid2.dat';
9
10GR_long=reshape(meshgrid2(:,1),Nlong,Nlat); %will give a Nlong by Nlat matrix
11%containing the long of the points
12
13GR_lat=reshape(meshgrid2(:,2),Nlong,Nlat); %will give a Nlong by Nlat matrix
14%containing the lat of the points
15
16
17%--------------------TIME-------------------------------------------------%
18dt=2*3600; %in seconds small delta t corresponding to Nume Scheme for advection
19
20%---------------------U---------------------------------------------------%
21load 'velbck.dat';
22u=reshape(velbck(:,1),Nlong,Nlat,[]);
23v=reshape(velbck(:,2),Nlong,Nlat,[]);
24u1=u(:,:,1);
25v1=v(:,:,1);
26
27
28R_earth=6371229; %in meters
29delta_x=zeros(Nlong,Nlat);
30delta_y=zeros(Nlong,Nlat);
31
32for 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   
40end
41end
42
43
44
45delta_x(Nlong,1:Nlat)=delta_x(Nlong-1,1:Nlat);
46delta_y(Nlong,1:Nlat)=delta_y(Nlong-1,1:Nlat);
47
48
49delta_x(1:Nlong,Nlat)=delta_x(1:Nlong,Nlat-1);
50delta_y(1:Nlong,Nlat)=delta_y(1:Nlong,Nlat-1);
51
52
53
54
55u_pers=u1./delta_x; %u pers second
56v_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
74uu=u_pers.';
75vv=v_pers.';
76
77%-----------------PUT U in YAO format-------------------------------------%
78
79%create a Nlat*Nlong by 5 matrix first
80u_yao1=reshape(uu, Nlong*Nlat,1);
81v_yao1=reshape(vv, Nlong*Nlat,1);
82%create the vectors rehsaped
83c1=[]; for k=1:Nlong; c1=[c1; k*ones(Nlat,1)]; end
84c2=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];
88Yao_u=[ ones(Nlong*Nlat,1)  c1 c2 u_yao1];
89Yao_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 
Note: See TracBrowser for help on using the repository browser.