/[MITgcm]/MITgcm_contrib/timour_matlab/mscripts/meanpv.m
ViewVC logotype

Annotation of /MITgcm_contrib/timour_matlab/mscripts/meanpv.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download)
Wed Sep 3 21:22:22 2003 UTC (21 years, 10 months ago) by edhill
Branch: MAIN
CVS Tags: HEAD
initial checkin of Timour's MatLAB scripts

1 edhill 1.1 function pvmean( iter )
2     clear
3     clear path
4    
5     global Nx Ny Nz
6     global lat long dz dm mdep
7     global delt_su su_its t_su delt
8     global descriptor this_path
9     global f deltaf Q beta r_expt r_heat H
10     global time rots it
11     global g Cp rho_bar alpha
12     global u v t w
13     global iterations
14    
15    
16     param_file_name = ...
17     input(' Please enter the name of the m-file with the parameters for this run : ','s') ;
18     feval(param_file_name) ;
19    
20     iterations
21    
22     itstart = input(' Please enter start iteration : ','s')
23     itend = input(' Please enter end iteration : ','s')
24    
25    
26     sizeit=size(iterations);
27     for i=1:sizeit(1)
28     iter(i)=eval(iterations(i,1:10));
29     end
30     nitstart=find(iter==eval(itstart))
31     nitend=find(iter==eval(itend))
32    
33     path = this_path
34     cmdstr=['cd ' path ];
35     eval(cmdstr);
36     path=pwd
37    
38     sumtheta=zeros(Nx,Ny,Nz);
39     sumu=zeros(Nx,Ny,Nz);
40     sumv=zeros(Nx,Ny,Nz);
41     counter=0;
42    
43     for i=nitstart:nitend
44     tfilename=(['T.' iterations((i),1:10) ]) ;
45     t=rdmds(tfilename,'b');
46     ufilename=(['U.' iterations((i),1:10) ]) ;
47     u=rdmds(ufilename,'b');
48     vfilename=(['V.' iterations((i),1:10) ]) ;
49     v=rdmds(vfilename,'b');
50     sumtheta=sumtheta+t;
51     sumu=sumu+u;
52     sumv=sumv+v;
53     counter=counter+1;
54     end
55     meantheta=sumtheta/counter;
56     meanu=sumu/counter;
57     meanv=sumv/counter;
58    
59    
60     pv=zeros(Nx,Ny,Nz);
61     ff=zeros(Nx,Ny,Nz);
62     dx=dm;
63     dy=dm;
64    
65     for j=1:Ny
66     ff(:,j,:)=f+(j-1)*dy*beta;
67     end
68    
69     pv(1:Nx-1,1:Ny-1,1:Nz-1)=(meanv(2:Nx,1:Ny-1,1:Nz-1)/dx -meanv(1:Nx-1,1:Ny-1,1:Nz-1)/dx ...
70     -meanu(1:Nx-1,2:Ny,1:Nz-1)/dy +meanu(1:Nx-1,1:Ny-1,1:Nz-1)/dy ...
71     +ff(1:Nx-1,1:Ny-1,1:Nz-1)) ...
72     .*(meantheta(1:Nx-1,1:Ny-1,1:Nz-1)-meantheta(1:Nx-1,1:Ny-1,2:Nz))/dz;
73    
74     t0=input('Enter temperature : ')
75    
76     % Interpolate PV on T=T0 surface
77    
78     h=zeros(Nx,Ny);
79     pvh=zeros(Nx,Ny);
80    
81     meantheta(:,:,Nz)=0.;
82     for i=1:Nx
83     for j=1:Ny
84     kk=find(meantheta(i,j,:)<t0);
85    
86     if kk(1)>1
87     h(i,j)=(kk(1)-1)*dz+dz*(meantheta(i,j,kk(1)-1)-t0)/(meantheta(i,j,kk(1)-1)-meantheta(i,j,kk(1)));
88    
89     pvh(i,j)=pv(i,j,kk(1)-1) ...
90     +(pv(i,j,kk(1))-pv(i,j,kk(1)-1)) ...
91     *(meantheta(i,j,kk(1)-1)-t0)/(meantheta(i,j,kk(1)-1)-meantheta(i,j,kk(1)));
92     else
93     h(i,j)=0;
94     pvh(i,j)=0;
95     end
96    
97     end
98     end
99    
100     hmax=max(max(h))
101    
102    
103     pcolor(pvh.');shading flat; colorbar; axis square
104     title(['mean PV from ' num2str(eval(itstart)) ' to 'num2str(eval(itend)) ' level of t=' num2str(t0) ]);
105     drawnow
106    
107     figure
108    
109     pcolor(squeeze(ff(:,:,2)).');shading flat; colorbar; axis square
110     drawnow
111    
112     pcolor(h.');shading flat; colorbar; axis square
113     %pcolor(flipud(h.'));shading flat; colorbar; axis square
114     title(['mean H from ' num2str(eval(itstart)) ' to 'num2str(eval(itend)) ' level of t=' num2str(t0) ]);
115     drawnow
116    
117     return

  ViewVC Help
Powered by ViewVC 1.1.22