source: Roms_tools/Preprocessing_tools/vinterp_bry.m @ 2

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

import Roms_Agrif

File size: 2.6 KB
Line 
1function vinterp_bry(bryname,grdname,Zbryname,vname,obcndx)
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3%
4%  Vertical interpolation from a Z-grid to a sigma-grid in the
5%  case of boundary (bry) files.
6%
7%  Further Information: 
8%  http://www.brest.ird.fr/Roms_tools/
9
10%  This file is part of ROMSTOOLS
11%
12%  ROMSTOOLS is free software; you can redistribute it and/or modify
13%  it under the terms of the GNU General Public License as published
14%  by the Free Software Foundation; either version 2 of the License,
15%  or (at your option) any later version.
16%
17%  ROMSTOOLS is distributed in the hope that it will be useful, but
18%  WITHOUT ANY WARRANTY; without even the implied warranty of
19%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20%  GNU General Public License for more details.
21%
22%  You should have received a copy of the GNU General Public License
23%  along with this program; if not, write to the Free Software
24%  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25%  MA  02111-1307  USA
26%
27%  Copyright (c) 2005-2006 by Pierrick Penven
28%  e-mail:Pierrick.Penven@ird.fr 
29%
30%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31%
32% open the grid file 
33%
34ng=netcdf(grdname);
35L=length(ng('xi_rho'));
36M=length(ng('eta_rho'));
37if obcndx==1
38  h=ng{'h'}(1,:);
39elseif obcndx==2
40  h=ng{'h'}(:,L);
41elseif obcndx==3
42  h=ng{'h'}(M,:);
43elseif obcndx==4
44  h=ng{'h'}(:,1);
45end
46close(ng);
47%
48% open the boundary file 
49%
50nc=netcdf(bryname,'write');
51theta_s = nc{'theta_s'}(:);
52theta_b =  nc{'theta_b'}(:);
53hc  =  nc{'hc'}(:);
54N =  length(nc('s_rho'));
55%
56% open the oa file 
57%
58noa=netcdf(Zbryname);
59z=-noa{'Z'}(:);
60t=noa{'bry_time'}(:);
61tlen=length(t);
62Nz0=length(z);
63%
64% Get the sigma depths
65%
66zroms=squeeze(zlevs(h,0.*h,theta_s,theta_b,hc,N,'r'));
67zmin=min(min(zroms));
68zmax=max(max(zroms));
69%
70% Check if the min z level is below the min sigma level
71%    (if not add a deep layer)
72%
73addsurf=max(z)<zmax;
74addbot=min(z)>zmin;
75if addsurf
76 z=[100;z];
77end
78if addbot
79 z=[z;-100000];
80end
81Nz=min(find(z<zmin));
82z=z(1:Nz);
83%
84% loop on time
85%
86for l=1:tlen
87%for l=1:1
88%  disp([' Time index: ',num2str(l),' of total: ',num2str(tlen)])
89  var=squeeze(noa{vname}(l,:));
90%  disp(['SIZE VAR=',num2str(size(var))])
91  if addsurf
92    var=cat(1,var(1,:),var);
93  end
94  if addbot
95    var=cat(1,var,var(end,:));
96  end
97  var=var(1:Nz,:);
98  nc{vname}(l,:,:)=ztosigma_1d(flipdim(var,1),zroms,flipud(z));
99end
100close(nc);
101close(noa);
102
103
104%DEBUG
105%
106%size(var)
107%var
108%
109%size(flipdim(var,1))
110%flipdim(var,1)
111%
112%size(z)
113%z
114%
115%size(flipud(z))
116%flipud(z)
117%
118%size(zroms)
119%zroms
120%
121%size(ztosigma_1d(flipdim(var,1),zroms,flipud(z)))
122%
123%
124%%
125return
Note: See TracBrowser for help on using the repository browser.