function plot_swan(swan,tidx) % plot_swan - plot swan results at a particular time step % Usage: plot_swan(swan,tidx); % % Inputs: swan = structure containing: % swan.input = name of swan INPUT file % swan.var = cell array of variable names % swan.file = cell array of mat file names corresponding % to variable name % Note: recognized variable names: % {'depth','dissip','hsig','qb','rtp','setup','tmbot',... % 'ubot','vel','wdir','wind','wlen','xp','yp'} % tidx = time index for plots (e.g. 1 = 1st time step) % Outputs: plots for each variable (except 'xp' and 'yp') % % Example: % swan.input='INPUT'; % swan.var ={'depth', 'xp', 'yp', 'hsig', 'ubot'} % swan.file={'depth.mat','xp.mat','yp.mat','hsig.mat','ubot.mat'} % plot_swan(swan,1) % makes plots of variables at 1st time step nc=netcdf('xp.nc'); if isempty(nc), disp('Error: File xp.nc not found'),return, end xp=nc{'xp'}(:); close(nc); nc=netcdf('yp.nc'); if isempty(nc), disp('Error: File yp.nc not found'),return, end yp=nc{'yp'}(:); close(nc); for i=1:length(swan.var); switch swan.var{i} case 'depth' figure; fname=[swan.var{i} '.nc']; nc=netcdf(fname); u=squeeze(nc{'swan_depth'}(tidx,:,:)); jdmat=nc{'wave_time'}+datenum(1968,5,23,0,0,0); u(u==0)=NaN; pcolorjw(xp,yp,u); colorbar; title(fprintf('SWAN: depth at %s',datestr(jdmat(tidx)))); close(nc); case 'dissip' figure; fname=[swan.var{i} '.nc']; jdmat=cf_time(fname,'Wave_dissip'); nc=netcdf(fname); u=squeeze(nc{'Wave_dissip'}(tidx,:,:)); figure; u(u==0)=NaN; pcolorjw(xp,yp,u); colorbar; title(sprintf('SWAN: Wave_dissip at %s',datestr(jdmat(tidx)))); close(nc); case 'force' figure subplot(121) % vel(find(vel == 0)) = NaN; pcolor(xp,yp,squeeze(velx(:,:))); shading interp; colorbar; title('velx Output of Swan'); subplot(122) % vel(find(vel == 0)) = NaN; pcolor(xp,yp,squeeze(vely(:,:))); shading interp; colorbar; title('vely Output of Swan'); case 'hsig' figure; fname=[swan.var{i} '.nc']; nc=netcdf(fname); jdmat=nc{'wave_time'}+datenum(1968,5,23,0,0,0); u=squeeze(nc{'Hwave'}(tidx,:,:)); u(u==0)=NaN; pcolorjw(xp,yp,u); colorbar; title(sprintf('SWAN: Hwave at %s',datestr(jdmat(tidx)))); close(nc); case 'qb' figure; fname=[swan.var{i} '.nc']; nc=netcdf(fname); jdmat=nc{'wave_time'}+datenum(1968,5,23,0,0,0); u=squeeze(nc{'Wave_break'}(tidx,:,:)); u(u==0)=NaN; pcolorjw(xp,yp,u); colorbar; title(sprintf('SWAN: Wave_break at %s',datestr(jdmat(tidx)))); close(nc); case 'rtp' figure; fname=[swan.var{i} '.nc']; nc=netcdf(fname); jdmat=nc{'wave_time'}+datenum(1968,5,23,0,0,0); u=squeeze(nc{'Hwave'}(tidx,:,:)); u(u==0)=NaN; pcolorjw(xp,yp,u); colorbar; title(sprintf('SWAN: Hwave at %s',datestr(jdmat(tidx)))); close(nc); case 'setup' figure; fname=[swan.var{i} '.nc']; nc=netcdf(fname); jdmat=nc{'wave_time'}+datenum(1968,5,23,0,0,0); u=squeeze(nc{'Hwave'}(tidx,:,:)); u(u==0)=NaN; pcolorjw(xp,yp,u); colorbar; title(sprintf('SWAN: Hwave at %s',datestr(jdmat(tidx)))); close(nc); case 'tmbot' Pwave_bot(find(Pwave_bot == 9999)) = NaN; pcolor(xp,yp,squeeze(Pwave_bot(:,:))); shading interp; title('Pwave_bot Output of Swan'); caxis([2 15]);colorbar case 'ubot' case 'vel' case 'wdir' case 'wind' figure subplot(121) % vel(find(vel == 0)) = NaN; pcolor(xp,yp,squeeze(Windx(:,:))); shading interp; colorbar; title('wind x Output of Swan'); subplot(122) % vel(find(vel == 0)) = NaN; pcolor(xp,yp,squeeze(Windy(:,:))); shading interp; colorbar; title('wind y Output of Swan'); case 'wlen' case 'xp' case 'yp' otherwise disp(['Unrecognized variable ' swan.var{i} ' in swan.var']); end end return forcex=squeeze(nc{'Wave_forcex'}(tidx,:,:)); forcey=squeeze(nc{'Wave_forcey'}(tidx,:,:)); Hwave=squeeze(nc{'Hwave'}(tidx,:,:)); setup=squeeze(nc{'Wave_setup'}(tidx,:,:)); Pwave_top=squeeze(nc{'Pwave_top'}(tidx,:,:)); Pwave_bot=squeeze(nc{'Pwave_bot'}(tidx,:,:)); Ub_swan=squeeze(nc{'Ub_swan'}(tidx,:,:)); velx=squeeze(nc{'velx'}(tidx,:,:)); vely=squeeze(nc{'vely'}(tidx,:,:)); Dwave=squeeze(nc{'Dwave'}(tidx,:,:)); Lwave=squeeze(nc{'Lwave'}(tidx,:,:)); windx=squeeze(nc{'Windx'}(tidx,:,:)); windy=squeeze(nc{'Windy'}(tidx,:,:)); xp=nc{'xp'}(:); yp=nc{'yp'}(:); end