1 |
heimbach |
1.1 |
function []=cost_seaicearea(dirModel,dirMat,doComp,dirTex); |
2 |
|
|
%object: compute cost function term for sea ice data |
3 |
|
|
%inputs: dimodel is the model directory |
4 |
|
|
% dirMat is the directory where diagnozed .mat files will be saved |
5 |
|
|
% -> set it to '' to use the default [dirModel 'mat/'] |
6 |
|
|
% doComp is a switch (1->compute; 0->display) |
7 |
|
|
%optional: dirTex is the directory where tex and figures files are created |
8 |
|
|
% (if not specified then display all results to screen instead) |
9 |
|
|
|
10 |
|
|
if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end; |
11 |
|
|
if isempty(dir(dirMat)); eval(['!mkdir ' dirMat ';']); end; |
12 |
|
|
|
13 |
|
|
%determine if and where to create tex and figures files |
14 |
|
|
dirMat=[dirMat '/']; |
15 |
|
|
if isempty(who('dirTex')); |
16 |
|
|
addToTex=0; |
17 |
|
|
else; |
18 |
|
|
if ~ischar(dirTex); error('mis-specified dirTex'); end; |
19 |
|
|
addToTex=1; fileTex=[dirTex 'myPlots.tex']; |
20 |
|
|
end; |
21 |
|
|
|
22 |
|
|
if doComp; |
23 |
|
|
|
24 |
|
|
%load grid |
25 |
|
|
gcmfaces_global; |
26 |
|
|
if ~isfield(mygrid,'XC'); grid_load('./GRID/',5,'compact'); end; |
27 |
|
|
if ~isfield(mygrid,'LATS_MASKS'); gcmfaces_lines_zonal; end; |
28 |
|
|
|
29 |
|
|
fld_err=ones(90,1170); |
30 |
|
|
fld_err=convert2gcmfaces(fld_err); |
31 |
|
|
fld_w=fld_err.^-2; |
32 |
|
|
|
33 |
|
|
%%%dirData='/net/weddell/raid3/gforget/ecco_v4/input_files/'; |
34 |
|
|
dirData='/net/nares/raid11/ecco-shared/ecco-version-4/input//'; |
35 |
|
|
|
36 |
|
|
fileModel=dir([dirModel 'barfiles/gbar_area*data']); |
37 |
|
|
fileModel=['barfiles/' fileModel.name]; |
38 |
|
|
|
39 |
|
|
fld_dif=convert2gcmfaces(NaN*ones(90,1170,12*19)); |
40 |
|
|
|
41 |
|
|
IceAreaNorthMod=zeros(1,228); |
42 |
|
|
IceAreaSouthMod=zeros(1,228); |
43 |
|
|
IceAreaNorthObs=zeros(1,228); |
44 |
|
|
IceAreaSouthObs=zeros(1,228); |
45 |
|
|
|
46 |
|
|
for ycur=1992:2010; |
47 |
|
|
tic; |
48 |
|
|
for mcur=1:12; |
49 |
|
|
%%% fld_dat=v4_read_bin([dirData 'gael_quick_interp/g_SST_monthly_r2_' num2str(ycur)],mcur,0); |
50 |
|
|
%%% fld_dat=v4_read_bin([dirData 'input_nsidc_postproc/NSIDC0079_v4_gael_' num2str(ycur)],mcur,0); |
51 |
|
|
fld_dat=v4_read_bin([dirData 'input_nsidc_all/nsidc79_monthly_' num2str(ycur)],mcur,0); |
52 |
|
|
|
53 |
|
|
fld_dat(find(fld_dat==0))=NaN; |
54 |
|
|
fld_dat(find(fld_dat<-99))=NaN; |
55 |
|
|
|
56 |
|
|
mm=(ycur-1992)*12+mcur; |
57 |
|
|
fld_mod=v4_read_bin([dirModel fileModel],mm,1).*mygrid.mskC(:,:,1); |
58 |
|
|
|
59 |
|
|
fld_dif(:,:,mm)=fld_mod-fld_dat; |
60 |
|
|
|
61 |
|
|
fld=fld_mod.*mygrid.RAC.*(mygrid.YC>0); IceAreaNorthMod(mm)=nansum(fld); |
62 |
|
|
fld=fld_mod.*mygrid.RAC.*(mygrid.YC<0); IceAreaSouthMod(mm)=nansum(fld); |
63 |
|
|
fld=fld_dat.*mygrid.RAC.*(mygrid.YC>0); IceAreaNorthObs(mm)=nansum(fld); |
64 |
|
|
fld=fld_dat.*mygrid.RAC.*(mygrid.YC<0); IceAreaSouthObs(mm)=nansum(fld); |
65 |
|
|
|
66 |
|
|
end; |
67 |
|
|
toc; |
68 |
|
|
end; |
69 |
|
|
|
70 |
|
|
fld_rms=sqrt(nanmean(fld_dif.^2,3)); |
71 |
|
|
fld_cost=fld_rms.^2.*fld_w; |
72 |
|
|
|
73 |
|
|
eval(['save ' dirMat '/cost_seaicearea.mat fld_err fld_rms fld_cost IceAreaNorthMod IceAreaSouthMod IceAreaNorthObs IceAreaSouthObs;']); |
74 |
|
|
|
75 |
|
|
else;%display previously computed results |
76 |
|
|
|
77 |
|
|
global mygrid; |
78 |
|
|
|
79 |
|
|
eval(['load ' dirMat '/cost_seaicearea.mat;']); |
80 |
|
|
|
81 |
|
|
%figure; m_map_gcmfaces(fld_cost,0,{'myCaxis',[0:0.2:1.2 1.5:0.5:3 4:1:6 8 10]}); |
82 |
|
|
%figure; m_map_gcmfaces(fld_err,0,{'myCaxis',[0:0.2:1.2 1.5:0.5:3 4:1:6 8 10]/2}); |
83 |
|
|
|
84 |
|
|
figure; m_map_gcmfaces(fld_rms,0,{'myCaxis',[0:0.1:1.]}); |
85 |
|
|
myCaption={'modeled-observed rms -- sea ice area (K)'}; |
86 |
|
|
|
87 |
|
|
if addToTex; write2tex(fileTex,2,myCaption,gcf); end; |
88 |
|
|
|
89 |
|
|
end; |
90 |
|
|
|
91 |
|
|
|