/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_calc/disp_transport.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_calc/disp_transport.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.4 - (hide annotations) (download)
Mon Sep 10 18:58:02 2012 UTC (12 years, 10 months ago) by gforget
Branch: MAIN
Changes since 1.3: +1 -0 lines
- fix case of only 1 record (e.g. for results of extract_mean.m).

1 gforget 1.1 function [myplot]=disp_transport(myTransports,myTimes,myTitle,varargin);
2     %object: display transport time series and/or time mean
3     %inputs: myTransports contains the transports as a function of depth and time
4     % myTitle is the transport name to be displayed
5     % myTimes is the time vector
6     %optional: must take the following form {'name',param1,param2,...} where name may be
7     % nmean is a running mean window length (0 by default)
8     % ylim is the y axis range for plotting
9     % choicePlot is the type of plot (1 by default)
10     % 1) time series of vertical integral
11     % 2) time series of overturning magnitude (>0)
12     % 3) time mean profile of transport per grid point
13     % 4) time mean profile of bottom-to-top cumulated transport
14    
15     global mygrid;
16    
17    
18     %set more optional paramaters to default values
19     ylim=[]; nmean=0; choicePlot=1;
20     %set more optional paramaters to user defined values
21     for ii=1:nargin-3;
22     if ~iscell(varargin{ii});
23     warning(inputCheck:disp_transport_1',...
24     ['disp_transport optional parameters must be spc. as cell arrays. \n'...
25     ' Argument no. ' num2str(ii+1) ' was ignored \n'...
26     ' Type ''help disp_transport'' for details.']);
27     elseif ~ischar(varargin{ii}{1});
28     warning('inputCheck:disp_transport_2',...
29     ['disp_transport opt. param. cells must start with a char. string. \n'...
30     ' Argument no. ' num2str(ii+1) ' was ignored \n'...
31     ' Type ''help disp_transport'' for details.']);
32     else;
33     if strcmp(varargin{ii}{1},'nmean')|...
34     strcmp(varargin{ii}{1},'ylim')|...
35     strcmp(varargin{ii}{1},'choicePlot');
36     eval([varargin{ii}{1} '=varargin{ii}{2};']);
37     else;
38     warning('inputCheck:disp_transport_3',...
39     ['unknown option ''' varargin{ii}{1} ''' was ignored']);
40     end;
41     end;
42     end;
43    
44     nt=length(myTimes);
45 gforget 1.4 if nt==1&size(myTransports,1)==1; myTransports=myTransports'; end;
46 gforget 1.1
47     if choicePlot==2|choicePlot==4;%compute cumulative sum from bottom
48 gforget 1.2 if size(myTransports,1)>1;
49     fld=[flipdim(cumsum(flipdim(myTransports,1)),1);zeros(1,nt)];
50     else;
51     fld=[flipdim(cumsum(flipdim(myTransports',1)),1);zeros(1,nt)];
52     end;
53 gforget 1.1 else;
54     fld=myTransports;
55     end;
56    
57     if choicePlot==1; fld=nansum(fld,1); end;
58     if choicePlot==2; fld=nanmax(abs(fld),[],1); end;
59     if choicePlot==3; fld=nanmean(fld,2); z=squeeze(mygrid.RC); end;
60     if choicePlot==4; fld=[nanmean(fld,2);0]; z=squeeze(mygrid.RF); end;
61    
62     if choicePlot==1|choicePlot==2;%time series
63     fldmean=1e-2*round(mean(fld)*1e2);
64     if nt>1;
65     %myTitle=[myTitle ' mean=' num2str(fldmean) 'Sv'];
66 gforget 1.3 if nmean>0; plot(myTimes,fld); hold on; end;
67 gforget 1.1 fld=runmean(fld,nmean,2);
68     myplot=plot(myTimes,fld,'LineWidth',2); title(myTitle); set(gca,'FontSize',14); grid on;
69     if ~isempty(ylim); aa=[min(myTimes) max(myTimes) ylim]; axis(aa); end;
70     aa=axis; xx=aa(1)+(aa(2)-aa(1))/20; yy=aa(4)-(aa(4)-aa(3))/5;
71     cc=text(xx,yy,['(mean=' num2str(fldmean) 'Sv)']);
72     else;
73     fprintf([myTitle '-- mean: ' num2str(fldmean) 'Sv\n']);
74     end;
75     elseif choicePlot==3|choicePlot==4;%time mean profile
76     nr=length(z);
77     kk=find(fld==0); if length(kk)>0; kk=[1:min(min(kk)+2,nr)]; else; kk=[1:nr]; end;
78     myplot=plot(fld(kk),z(kk),'LineWidth',2); title(myTitle); set(gca,'FontSize',14); grid on;
79     aa=axis; tmp1=max(abs(aa(1:2))); aa(1:2)=tmp1*[-1 1]; axis(aa);
80     end;
81    

  ViewVC Help
Powered by ViewVC 1.1.22