function []=MITprof_stats_cost(dirData,listData,listVar,varargin); %[]=MITprof_stats_cost(dirData,listData,listVar,varargin); %object: computes and displays cost function statistics %input: dirData is the data directory name % listData is the data file list (e.g. {'argo_in*'} or {'argo_in*','argo_at*'} ) % listVar is the variable list varCur (e.g. {'T'} or {'T','S'} ) % year0,year1 (optional) is the first,last year pair %output: (none -- figures only) % %for example: % dirData='./'; % listData={'argo_in*'}; listVar={'T','S'}; % MITprof_stats_cost(dirData,listData,listVar); %load paths and grid: %-------------------- gcmfaces_path; global mygrid; mygrid=[]; grid_load([gcmfaces_dir '/sample_input/GRIDv4/'],5,'compact'); %time limits: if nargin>3; year0=varargin{1}; year1=varargin{2}; date0=datenum(year0,1,1); date1=datenum(year1,12,31); else; year0=1992; year1=2008; date0=datenum(year0,1,1); date1=datenum(year1,12,31); end; figureL; for vv=1:length(listVar); varCur=listVar{vv}; %get the cost square root: [MITprof]=MITprof_stats_load(dirData,listData,varCur); %mask out values that are not in year range: ii=find(MITprof.prof_datedate1); MITprof.prof(ii,:)=NaN; %mean and median: costCur=[nanmean(MITprof.prof(:).^2) nanmedian(MITprof.prof(:).^2)]; fprintf('mean cost for %s: %0.3g (median: %0.3g) \n',varCur,costCur); %depth/time mean cost: tmp_date=(MITprof.prof_date-date0)/365; [x,y,z,n]=MITprof_stats(MITprof.prof_depth,MITprof.prof_depth,... tmp_date,[0:1/4:1+(year1-year0)],'mean',MITprof.prof.^2); z(n<1e2)=NaN; subplot(2,length(listVar),vv); depthStretchPlot('pcolor',{y,x,z}); caxis([0 8]); shading flat; colorbar; ylabel('depth (in m)'); xlabel(['date (in years since ' num2str(year0) ')']); title(sprintf('mean cost for %s: %0.3g (median: %0.3g)',varCur,costCur)); %latitudinal distribution: [x,y,z,n]=MITprof_stats(MITprof.prof_lat,[-90:5:90],MITprof.prof,[-5:0.25:5]); tmp1=(nansum(n,2)>1e4)*ones(1,size(n,2)); z(tmp1==0)=NaN; subplot(2,length(listVar),vv+length(listVar)); contourf(x,y,z,[0:0.05:0.5]); grid on; caxis([0 0.5]); colorbar; ylabel('normalized misfit'); xlabel('latitude'); title('pdf'); end;