source: Roms_tools/Preprocessing_tools/test_clim.m @ 1

Last change on this file since 1 was 1, checked in by cholod, 13 years ago

import Roms_Agrif

File size: 3.2 KB
Line 
1function test_clim(clim_file,grid_file,tracer,l,coastfileplot)
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%
4% Test the climatology and initial files.
5%
6%  Further Information: 
7%  http://www.brest.ird.fr/Roms_tools/
8
9%  This file is part of ROMSTOOLS
10%
11%  ROMSTOOLS is free software; you can redistribute it and/or modify
12%  it under the terms of the GNU General Public License as published
13%  by the Free Software Foundation; either version 2 of the License,
14%  or (at your option) any later version.
15%
16%  ROMSTOOLS is distributed in the hope that it will be useful, but
17%  WITHOUT ANY WARRANTY; without even the implied warranty of
18%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19%  GNU General Public License for more details.
20%
21%  You should have received a copy of the GNU General Public License
22%  along with this program; if not, write to the Free Software
23%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24%  MA  02111-1307  USA
25%
26%  Copyright (c) 2001-2006 by Pierrick Penven
27%  e-mail:Pierrick.Penven@ird.fr 
28%
29%  Updated    1-Sep-2006 by Pierrick Penven
30%
31%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
32
33
34niceplot=1;
35%
36nc=netcdf(clim_file);
37var=squeeze(nc{tracer}(l,:,:,:));
38[N M L]=size(var);
39u=squeeze(nc{'u'}(l,N,:,:));
40v=squeeze(nc{'v'}(l,N,:,:));
41theta_s=nc{'theta_s'}(:);
42if isempty(theta_s)
43  theta_s=nc.theta_s(:);
44  theta_b=nc.theta_b(:);
45  hc=nc.hc(:);
46else
47  theta_b=nc{'theta_b'}(:);
48  hc=nc{'hc'}(:);
49end
50close(nc)
51%
52% Get the grid
53%
54nc=netcdf(grid_file);
55lat=nc{'lat_rho'}(:);
56lon=nc{'lon_rho'}(:);
57pm=nc{'pm'}(:);
58h=nc{'h'}(:);
59angle=nc{'angle'}(:);
60mask=nc{'mask_rho'}(:);
61mask(mask==0)=NaN;
62%
63% plot the sections
64%
65jstep=round((M/3)-1);
66image=0;
67z = zlevs(h,0*h,theta_s,theta_b,hc,N,'r');
68for j=1:jstep:M
69  index=j;
70  image=image+1;
71  subplot(2,2,image)
72  field=squeeze(var(:,j,:));
73  topo=squeeze(h(j,:));
74  mask_vert=squeeze(mask(j,:));
75  dx=1./squeeze(pm(j,:));
76  xrad(1)=0;
77  for i=2:L
78    xrad(i)=xrad(i-1)+0.5*(dx(i)+dx(i-1));
79  end
80  x=zeros(N,L);
81  masksection=zeros(N,L);
82  for i=1:L
83    for k=1:N
84      x(k,i)=xrad(i);
85      masksection(k,i)=mask_vert(i);
86    end
87  end
88  xrad=xrad/1000;
89  x=x/1000;
90  field=masksection.*field;
91% $$$   x
92% $$$   squeeze(z(:,j,:))
93% $$$   field
94 
95  pcolor(x,squeeze(z(:,j,:)),field)
96  drawnow
97  colorbar
98  shading interp
99  hold on
100  plot(xrad,-topo,'k')
101  hold off
102  title([tracer,', time index=',num2str(l),' - j=',num2str(j)])
103end
104%
105% Surface plot
106%
107figure
108field=squeeze(var(N,:,:));
109[ured,vred,lonred,latred,maskred]=uv_vec2rho(u,v,lon,lat,angle,mask,3,[0 0 0 0]);
110spd=sqrt(ured.^2+vred.^2);
111if niceplot==1
112  domaxis=[min(min(lon)) max(max(lon)) min(min(lat)) max(max(lat))];
113  m_proj('mercator',...
114     'lon',[domaxis(1) domaxis(2)],...
115     'lat',[domaxis(3) domaxis(4)]);
116  m_pcolor(lon,lat,mask.*field);
117  shading flat
118  colorbar
119  hold on
120  m_quiver(lonred,latred,ured,vred,'k');
121  if ~isempty(coastfileplot)
122    m_usercoast(coastfileplot,'patch',[.9 .9 .9]);
123  end
124  hold off
125  title([tracer,', max speed=',num2str(100*max(max(spd)),2),....
126         ' cm/s, time index=',num2str(l)])
127  m_grid('box','fancy',...
128         'xtick',5,'ytick',5,'tickdir','out',...
129         'fontsize',7);
130else
131  imagesc(mask.*field)
132  colorbar
133  title([tracer, ', time index=',num2str(l)])
134end
135
136
Note: See TracBrowser for help on using the repository browser.