%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Make plot from the results of the SANDBAR test case % % Further Information: % http://www.crocoagrif.org/ % % This file is part of CROCOTOOLS % % CROCOTOOLS is free software; you can redistribute it and/or modify % it under the terms of the GNU General Public License as published % by the Free Software Foundation; either version 2 of the License, % or (at your option) any later version. % % CROCOTOOLS is distributed in the hope that it will be useful, but % WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License % along with this program; if not, write to the Free Software % Foundation, Inc., 59 Temple Place, Suite 330, Boston, % MA 02111-1307 USA % % Ref: Penven, P., L. Debreu, P. Marchesiello and J.C. McWilliams, % Application of the ROMS embedding procedure for the Central % California Upwelling System, Ocean Modelling, 2006. % % Patrick Marchesiello, IRD 2017,2020 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% clear all close all %================== User defined parameters =========================== % % --- LIP experiment --- % prompt = 'Erosion (1B) or Accretion (1C) LIP experiment? [1B]: '; mycase = input(prompt,'s'); if isempty(mycase) mycase = '1B'; end % % --- model params --- % fname = 'sandbar_avg.nc'; dianame = 'sandbar_diags_eddy_avg.nc'; hname = 'sandbar_his.nc'; if mycase == '1B', morph_fac = 4*18; % morphological factor (from sediment.in) else morph_fac = 4*13; end read_data = 1; morph_cpl = 1; % feedback to currents sedim = 1; makepdf = 0; % make pdf file % %====================================================================== % % --------------------------------------------------------------------- % --- get grid from numerical model --- % --------------------------------------------------------------------- % yindex = 2; % Mm=1 with NS no-slip conditions % nc=netcdf(fname,'r'); tindex=length(nc{'scrum_time'}(:)); % reads last record %tindex=3; % time=morph_fac*nc{'scrum_time'}(:)/3600; % time in hours if mycase == '1B', [d,tindex0]=min(abs(time-8)); % 8h (1B) else [d,tindex0]=min(abs(time-7)); % 7h (1C) end %tindex0=4; % % horizontal grid nch=netcdf(hname,'r'); hr=squeeze(nch{'h'}(yindex,:)); xr=squeeze(nc{'x_rho'}(yindex,:)); xu=0.5*(xr(1:end-1)+xr(2:end)); L=length(hr); % % new bathy from last record if morph_cpl, hnew=squeeze(nc{'hmorph'}(tindex,yindex,:)); h=hnew; h0=squeeze(nc{'hmorph'}(tindex0,yindex,:)); if isempty(hnew), h=hr; hnew=hr; h0=hr; end else h=hr; hnew=hr; h0=hr; end % % vertical grid N=length(nc('s_rho')); theta_s=nc.theta_s(:); theta_b=nc.theta_b(:); hc=nc.hc(:); zeta=squeeze(nc{'zeta'}(tindex,yindex,:)); Dcrit=nc{'Dcrit'}(:)*1.0; zeta(h xu,zu u=squeeze(nc{'u'}(tindex,:,yindex,:)); % ... vertical velocity ... ---> xr,zw w=squeeze(nc{'w'}(tindex,:,yindex,:)); % ... total viscosity Akv=squeeze(nc{'AKv'}(tindex,:,yindex,:)); if sedim, % ... sediment concentration ... ---> xr,zr C=2*squeeze(nc{'sand_01'}(tindex,:,yindex,:)); end % --------------------------------------------------------------------- % --- read/compute bottom model fields (tindex0) --- % -------------------------------------------------------------------- % ... wave setup ... sup=squeeze(nc{'zeta'}(tindex0,yindex,:)); % mid exp time z0=sup; z0(h0zref)); if isempty(nn), nn=N; end ubot(ix)=squeeze(u0(nn,ix)); end %ubot=u0(3,:); % ... sediment concentration ... if sedim C0=2*squeeze(nc{'sand_01'}(tindex0,:,yindex,:)); zref=0.01; L=length(h); h2d=repmat(h0,[N 1]); zz=h2d+zr0; for ix=1:L nn=min(find(zz(:,ix)>zref)); if isempty(nn), nn=N; end Cbot(ix)=squeeze(C0(nn,ix)); end end %Cbot=C0(1,:); close(nc) close(nch) % ... Hrms ... nc=netcdf(dianame,'r'); time_eddy=morph_fac*nc{'scrum_time'}(:)/3600; % time in hours if mycase == '1B', [d,tindex_eddy]=min(abs(time_eddy-8)); % 8h (1B) else [d,tindex_eddy]=min(abs(time_eddy-7)); % 7h (1C) end zz=squeeze(nc{'zz'}(tindex_eddy,yindex,:)); hrms=4*sqrt(zz-z0.^2)/sqrt(2); close(nc) zeta(D