1 |
function []=insitu_cost(dirData,doComp,varargin); |
function []=insitu_cost(doComp,varargin); |
|
%[]=insitu_cost(dirData,listData,listVar,varargin); |
|
2 |
%object: computes or displays cost function statistics |
%object: computes or displays cost function statistics |
3 |
%input: dirData is the data main directory name |
%input: doComp states whether to compute & save (1) or load & display (0) |
|
% doComp states whether to compute & save (1) or load & display (0) |
|
4 |
%optional must take the following form {'name',param1,param2,...} Active ones are |
%optional must take the following form {'name',param1,param2,...} Active ones are |
5 |
% {'subdirData',subdirData} is the data subdirectory name ('profiles/output/' by default) |
% {'dirData',dirData} is the data subdirectory name ('profiles/output/' by default) |
6 |
% {'listData',data1,data2,...} where data1 e.g. is 'argo_indian.nc' |
% {'listData',data1,data2,...} where data1 e.g. is 'argo_indian.nc' |
7 |
% {'listVar',var1,var2} where var1 and var2 are 'T' and 'S' |
% {'listVar',var1,var2} where var1 and var2 are 'T' and 'S' |
8 |
% {'years',year0,year1} to limit computation to [year0 year1] interval |
% {'years',year0,year1} to limit computation to [year0 year1] interval |
9 |
% {'subdirMat',subdirMat} where subdirMat is the output subdirectory ('mat/' by default) |
% {'dirMat',dirMat} where dirMat is the output subdirectory ('mat/' by default) |
10 |
% {'suffMat',suffMat} is the mat file suffix ('all' by default) |
% {'suffMat',suffMat} is the mat file suffix ('all' by default) |
11 |
% {'subdirTex',subdirTex} where subdirTex is the tex directory ('tex/' by default) |
% {'dirTex',dirTex} where dirTex is the tex directory ('tex/' by default) |
12 |
|
% {'nameTex',nameTex} is the tex file name ('myPlots' by default) |
13 |
% {'addToTex',addToTex} states whether (1) or not (0 default) to |
% {'addToTex',addToTex} states whether (1) or not (0 default) to |
14 |
% augment an ongoing tex file (see write2tex.m, subdirTex) |
% augment an ongoing tex file (see write2tex.m, dirTex) |
15 |
% |
% |
16 |
%example: insitu_cost('./',1,{'listData','argo_in*'}); |
%example: insitu_cost('./',1,{'listData','argo_in*'}); |
17 |
|
|
21 |
|
|
22 |
%set more optional paramaters to default values |
%set more optional paramaters to default values |
23 |
global myparms; year0=myparms.yearInAve(1); year1=myparms.yearInAve(2); |
global myparms; year0=myparms.yearInAve(1); year1=myparms.yearInAve(2); |
24 |
%year0=1992; year1=2008; |
listData={'argo_june2012_1992_to_2007*','argo_june2012_2008_to_2010*',... |
25 |
listData={'WOD09_XBT*','WOD09_CTD*','argo_in*','argo_at*','argo_pa*','seals*'}; |
'argo_june2012_2011_to_2012*','climode_june2012*',... |
26 |
|
'ctd_june2012*','itp_june2012*','seals_june2012*','xbt_june2012*'}; |
27 |
listVar={'T','S'}; |
listVar={'T','S'}; |
28 |
%shorter test case: listData={'argo_in*'}; listVar={'T'}; |
%shorter test case: listData={'argo_in*'}; listVar={'T'}; |
29 |
subdirData='/profiles/output/'; |
dirData='/profiles/output/'; |
30 |
subdirMat='mat/'; suffMat='_all'; |
dirMat='mat/'; suffMat='_all'; |
31 |
subdirTex='tex/'; addToTex=0; |
dirTex='tex/'; addToTex=0; nameTex='myPlots'; |
32 |
%set more optional paramaters to user defined values |
%set more optional paramaters to user defined values |
33 |
for ii=1:nargin-2; |
for ii=1:nargin-1; |
34 |
if strcmp(varargin{ii}{1},'listData'); listData={varargin{ii}{2:end}}; |
if strcmp(varargin{ii}{1},'listData'); listData={varargin{ii}{2:end}}; |
35 |
elseif strcmp(varargin{ii}{1},'listVar'); listVar={varargin{ii}{2:end}}; |
elseif strcmp(varargin{ii}{1},'listVar'); listVar={varargin{ii}{2:end}}; |
36 |
elseif strcmp(varargin{ii}{1},'years'); year0=varargin{ii}{2}; year1=varargin{ii}{3}; |
elseif strcmp(varargin{ii}{1},'years'); year0=varargin{ii}{2}; year1=varargin{ii}{3}; |
37 |
elseif strcmp(varargin{ii}{1},'subdirMat'); subdirMat=varargin{ii}{2}; |
elseif strcmp(varargin{ii}{1},'dirMat'); dirMat=varargin{ii}{2}; |
38 |
elseif strcmp(varargin{ii}{1},'suffMat'); suffMat=['_' varargin{ii}{2}]; |
elseif strcmp(varargin{ii}{1},'suffMat'); suffMat=['_' varargin{ii}{2}]; |
39 |
elseif strcmp(varargin{ii}{1},'subdirTex'); subdirTex=varargin{ii}{2}; |
elseif strcmp(varargin{ii}{1},'dirTex'); dirTex=varargin{ii}{2}; |
40 |
elseif strcmp(varargin{ii}{1},'addToTex'); addToTex=varargin{ii}{2}; |
elseif strcmp(varargin{ii}{1},'addToTex'); addToTex=varargin{ii}{2}; |
41 |
elseif strcmp(varargin{ii}{1},'subdirData'); subdirData=varargin{ii}{2}; |
elseif strcmp(varargin{ii}{1},'nameTex'); nameTex=varargin{ii}{2}; |
42 |
|
elseif strcmp(varargin{ii}{1},'dirData'); dirData=varargin{ii}{2}; |
43 |
else; |
else; |
44 |
warning('inputCheck:insitu_cost',... |
warning('inputCheck:insitu_cost',... |
45 |
['unknown option ''' varargin{ii}{1} ''' was ignored']); |
['unknown option ''' varargin{ii}{1} ''' was ignored']); |
55 |
varCur=listVar{vv}; |
varCur=listVar{vv}; |
56 |
|
|
57 |
%get the cost square root: |
%get the cost square root: |
58 |
[MITprof]=MITprof_stats_load([dirData '/' subdirData],listData,varCur); |
[MITprof]=MITprof_stats_load([dirData],listData,varCur); |
59 |
|
|
60 |
%mask out values that are not in year range: |
%mask out values that are not in year range: |
61 |
ii=find(MITprof.prof_date<date0|MITprof.prof_date>date1); |
ii=find(MITprof.prof_date<date0|MITprof.prof_date>date1); |
84 |
|
|
85 |
end; |
end; |
86 |
|
|
87 |
eval(['save ' dirData '/' subdirMat 'insitu_cost' suffMat '.mat costAve* misfitDistrib* depthTimeCost* year* listData listVar;']); |
eval(['save ' dirMat 'insitu_cost' suffMat '.mat costAve* misfitDistrib* depthTimeCost* year* listData listVar;']); |
88 |
|
|
89 |
else;%display result |
else;%display result |
90 |
|
|
91 |
eval(['load ' dirData '/' subdirMat 'insitu_cost' suffMat '.mat;']); |
eval(['load ' dirMat 'insitu_cost' suffMat '.mat;']); |
92 |
|
|
93 |
figureL; |
figureL; |
94 |
|
|
116 |
|
|
117 |
myCaption={'Cost function (top) for in situ profiles, as a function of depth and time. ',... |
myCaption={'Cost function (top) for in situ profiles, as a function of depth and time. ',... |
118 |
'Distribution of normalized misfits (bottom) as a function of latitude. For T (left) and S (right).'}; |
'Distribution of normalized misfits (bottom) as a function of latitude. For T (left) and S (right).'}; |
119 |
if addToTex; write2tex([dirData '/' subdirTex '/myPlots.tex'],2,myCaption,gcf); end; |
if addToTex; write2tex([dirTex '/' nameTex '.tex'],2,myCaption,gcf); end; |
120 |
|
|
121 |
end; |
end; |
122 |
|
|