source: altifloat/obs_external/read_davane.m @ 88

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

uniform grid??

File size: 2.4 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 Nlat by Nlong matrix
11%containing the long of the points
12
13GR_lat=reshape(meshgrid2(:,2),Nlong,Nlat).'; %will give a Nlat by Nlong matrix
14%containing the lat of the points
15
16
17lat_min=2*pi*min(min(GR_lat))/360;
18lat_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
23R_earth=6371229; %in meters
24
25xx=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
29xx1=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
32yy=R_earth*(2*pi/360)*GR_lat;
33
34figure(1);
35plot(xx,yy,'ro')
36hold on
37plot(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
51dx=xx(1,2)-xx(1,1)
52dy=yy(2,1)-yy(1,1)
53
54
55%--------------------TIME-------------------------------------------------%
56dt=2*3600; %in seconds small delta t corresponding to Nume Scheme for advection
57
58
59%---------------------U---------------------------------------------------%
60load 'velbck.dat';
61u=reshape(velbck(:,1),Nlong,Nlat,[]);
62v=reshape(velbck(:,2),Nlong,Nlat,[]);
63
64
65u1=u(:,:,1).'.*dt/dx;
66v1=v(:,:,1).'.*dt/dx;
67
68%-----------------PUT U in YAO format-------------------------------------%
69
70%create a Nlat*Nlong by 5 matrix first
71u_yao1=reshape(u1, Nlong*Nlat,1);
72v_yao1=reshape(v1, Nlong*Nlat,1);
73%create the vectors rehsaped
74c1=[]; for k=1:Nlong; c1=[c1; k*ones(Nlat,1)]; end
75c2=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];
79Yao_u=[ ones(Nlong*Nlat,1)  c1 c2 u_yao1];
80Yao_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 
Note: See TracBrowser for help on using the repository browser.