Back to home page

MITgcm

 
 

    


Warning, /verification/tutorial_global_oce_latlon/diags_matlab/mit_plotmeandrift.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
051ee7f715 Jean*0001 % m-file: mit_plotmeandrift.m
                0002 % mean temperature and salinity drift
                0003 
                0004 if ~isempty(msg_spinup)
                0005   % extracted from the monitor output with a script by jmc
                0006   global_mt = load('spinup.t_A');
                0007   global_ms = load('spinup.s_A');
                0008   global_mt(itim) = [];
                0009   global_ms(itim) = [];
                0010 else
                0011   % or computed `on the fly'
                0012   global_mt = zeros(size(kt));
                0013   global_ms = zeros(size(kt));
                0014   for k=kt;
                0015     if meanfields
                0016       % read the snapshots
                0017       tk=rdmds('T',timesteps(k));
                0018       sk=rdmds('S',timesteps(k));
                0019       if strcmp(grd.buoyancy,'OCEANICP')
                0020         % turn fields upside down
                0021         tk=tk(:,:,end:-1:1).*grd.cmask;
                0022         sk=sk(:,:,end:-1:1).*grd.cmask;
                0023       end
                0024     else
                0025       % snapshots are already available
                0026       if iscell(t)
                0027         tk = t{k};
                0028       else
                0029         tk = t(:,:,:,k);
                0030       end
                0031       if iscell(s)
                0032         sk = s{k};
                0033       else
                0034         sk = s(:,:,:,k);
                0035       end
                0036     end
                0037     global_mt(k)= nansum(tk(:).*grd.volc(:))/nansum(grd.volc(:));
                0038     global_ms(k)= nansum(sk(:).*grd.volc(:))/nansum(grd.volc(:));
                0039   end
                0040 end
                0041 figure
                0042 subplot(2,1,1);
                0043 plot(tim,global_mt)
                0044 title('Drift of Mean Temperature'); xlabel(['Time [' timeunit ']']); ylabel('T [degC]')
                0045 subplot(2,1,2);
                0046 plot(tim,global_ms)
                0047 title('Drift of Mean Salinity'); xlabel(['Time [' timeunit ']']); ylabel('S [PSU]')
                0048 suptitle(['experiment ' dname])
                0049