/[MITgcm]/MITgcm_contrib/gael/matlab_class/ecco_v4/cost_seaicearea.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/ecco_v4/cost_seaicearea.m

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


Revision 1.8 - (hide annotations) (download)
Wed Apr 3 14:04:32 2013 UTC (12 years, 3 months ago) by gforget
Branch: MAIN
Changes since 1.7: +81 -14 lines
- cost_seaicearea.m : add obs_std, mod_std computations and maps;
  add march and sept clim maps; add march and sept time series.
- cost_sst.m : add maps of ECCO-REMSS misfits; add zonal mean
  anomaly plots.

1 gforget 1.2 function []=cost_seaicearea(dirModel,dirMat,doComp,dirTex,nameTex);
2 heimbach 1.1 %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 gforget 1.2 % nameTex is the tex file name (default : 'myPlots')
10 heimbach 1.1
11     if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end;
12     if isempty(dir(dirMat)); eval(['!mkdir ' dirMat ';']); end;
13    
14     %determine if and where to create tex and figures files
15     dirMat=[dirMat '/'];
16     if isempty(who('dirTex'));
17     addToTex=0;
18     else;
19     if ~ischar(dirTex); error('mis-specified dirTex'); end;
20 gforget 1.2 addToTex=1;
21     if isempty(who('nameTex')); nameTex='myPlots'; end;
22     fileTex=[dirTex nameTex '.tex'];
23 heimbach 1.1 end;
24    
25 gforget 1.5 %grid, params and inputs
26     gcmfaces_global; global myparms;
27 heimbach 1.1 if ~isfield(mygrid,'XC'); grid_load('./GRID/',5,'compact'); end;
28     if ~isfield(mygrid,'LATS_MASKS'); gcmfaces_lines_zonal; end;
29 gforget 1.5 if isfield(myparms,'yearsta'); yearsta=myparms.yearsta; yearend=myparms.yearend;
30     else; yearsta=1992; yearend=2011;
31     end;
32 heimbach 1.1
33 gforget 1.8 [lonPairs,latPairs,names] = line_greatC_TUV_MASKS_core2_antarctic;
34     lonLims=[lonPairs(1:5,1);lonPairs(1,1)];
35    
36     if doComp;
37     %grid, params and inputs
38 heimbach 1.1 fld_err=ones(90,1170);
39     fld_err=convert2gcmfaces(fld_err);
40     fld_w=fld_err.^-2;
41    
42 heimbach 1.3 dirData='/net/nares/raid11/ecco-shared/ecco-version-4/input/';
43 heimbach 1.1
44     fileModel=dir([dirModel 'barfiles/gbar_area*data']);
45     fileModel=['barfiles/' fileModel.name];
46    
47 heimbach 1.3 nyears=yearend-yearsta+1;
48     nmonths=12*nyears;
49    
50 gforget 1.7 %misfits :
51 heimbach 1.3 fld_dif=convert2gcmfaces(NaN*ones(90,90*13,nmonths));
52 gforget 1.8 fld_nsidc=convert2gcmfaces(NaN*ones(90,90*13,nmonths));
53 heimbach 1.3
54 gforget 1.7 %monthly mean climatology :
55     climMod=convert2gcmfaces(zeros(90,90*13,12));
56     climObs=convert2gcmfaces(zeros(90,90*13,12));
57     climMsk=convert2gcmfaces(zeros(90,90*13,12));
58     climNb=convert2gcmfaces(zeros(90,90*13,12));
59    
60     %monthly integrals :
61 gforget 1.4 IceAreaNorthMod=NaN*zeros(1,nmonths);
62     IceAreaNorthObs=NaN*zeros(1,nmonths);
63    
64     IceAreaSouthMod=NaN*zeros(6,nmonths);
65     IceAreaSouthObs=NaN*zeros(6,nmonths);
66 heimbach 1.3
67 gforget 1.7 %computational loop :
68 heimbach 1.3 for ycur=yearsta:yearend;
69 heimbach 1.1 tic;
70     for mcur=1:12;
71 heimbach 1.3 mm=(ycur-yearsta)*12+mcur;
72    
73 gforget 1.7 fld_dat=v4_read_bin([dirData 'input_nsidc_all/nsidc79_monthly_' num2str(ycur)],mcur,0);
74 heimbach 1.1
75 gforget 1.6 fld_dat=fld_dat.*mygrid.mskC(:,:,1);%land mask
76     fld_dat(find(fld_dat<-99))=NaN;%missing data
77     msk=1+0*fld_dat;%combined mask
78 heimbach 1.1
79 gforget 1.6 fld_mod=v4_read_bin([dirModel fileModel],mm,0);
80     fld_mod=fld_mod.*msk;%mask consistent with fld_dat
81 gforget 1.7
82     %misfits :
83 heimbach 1.1 fld_dif(:,:,mm)=fld_mod-fld_dat;
84 gforget 1.8 fld_nsidc(:,:,mm)=fld_dat;
85 heimbach 1.1
86 gforget 1.7 %climatology :
87     tmp1=msk; tmp1(isnan(tmp1))=0; climMsk(:,:,mcur)=climMsk(:,:,mcur)+tmp1;
88     tmp1=fld_mod; tmp1(isnan(tmp1))=0; climMod(:,:,mcur)=climMod(:,:,mcur)+tmp1;
89     tmp1=fld_dat; tmp1(isnan(tmp1))=0; climObs(:,:,mcur)=climObs(:,:,mcur)+tmp1;
90    
91     %integrals :
92 heimbach 1.1 fld=fld_mod.*mygrid.RAC.*(mygrid.YC>0); IceAreaNorthMod(mm)=nansum(fld);
93     fld=fld_dat.*mygrid.RAC.*(mygrid.YC>0); IceAreaNorthObs(mm)=nansum(fld);
94 gforget 1.5
95     fld=fld_mod.*mygrid.RAC.*(mygrid.YC<0); IceAreaSouthMod(1,mm)=nansum(fld);
96     fld=fld_dat.*mygrid.RAC.*(mygrid.YC<0); IceAreaSouthObs(1,mm)=nansum(fld);
97 heimbach 1.3
98     for kk=1:5;
99     tmpmsk=0.*mygrid.XC;
100 gforget 1.5 if lonLims(kk+1) > lonLims(kk)
101     tmpmsk(find(mygrid.XC >= lonLims(kk) & mygrid.XC < lonLims(kk+1)))=1.;
102 heimbach 1.3 else
103 gforget 1.5 tmpmsk(find(mygrid.XC >= lonLims(kk) & mygrid.XC <= 180.))=1.;
104     tmpmsk(find(mygrid.XC >= -180. & mygrid.XC < lonLims(kk+1)))=1.;
105 heimbach 1.3 end
106     tmpmsk=tmpmsk.*(mygrid.YC<0);
107     %
108     fld=fld_mod.*mygrid.RAC.*tmpmsk;
109 gforget 1.5 IceAreaSouthMod(kk+1,mm)=nansum(fld);
110 heimbach 1.3 %
111     fld=fld_dat.*mygrid.RAC.*tmpmsk;
112 gforget 1.5 IceAreaSouthObs(kk+1,mm)=nansum(fld);
113 heimbach 1.3 end
114 heimbach 1.1
115     end;
116     toc;
117     end;
118    
119 gforget 1.7 %misfits :
120 gforget 1.8 mis_rms=sqrt(nanmean(fld_dif.^2,3));
121     obs_std=nanstd(fld_nsidc,[],3);
122     mod_std=nanstd(fld_nsidc+fld_dif,[],3);
123 heimbach 1.1
124 gforget 1.7 %climatology :
125     for mcur=1:12;
126     tmp1=climMsk(:,:,mcur); tmp1(tmp1==0)=NaN;
127     climNb(:,:,mcur)=tmp1;
128     climMod(:,:,mcur)=climMod(:,:,mcur)./tmp1;
129     climObs(:,:,mcur)=climObs(:,:,mcur)./tmp1;
130     end;
131     clear climMsk;
132    
133 gforget 1.8 eval(['save ' dirMat '/cost_seaicearea.mat fld_err mis_rms obs_std mod_std IceArea* clim*;']);
134 heimbach 1.1
135     else;%display previously computed results
136    
137 gforget 1.8 eval(['load ' dirMat '/cost_seaicearea.mat;']);
138    
139     %variance maps:
140     figure; m_map_gcmfaces(mis_rms,0,{'myCaxis',[0:0.1:1.]});
141     myCaption={'modeled-observed rms -- sea ice concentration'};
142     if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
143    
144     figure; m_map_gcmfaces(obs_std,0,{'myCaxis',[0:0.1:1.]});
145     myCaption={'observed std -- sea ice concentration'};
146     if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
147    
148     figure; m_map_gcmfaces(mod_std,0,{'myCaxis',[0:0.1:1.]});
149     myCaption={'modelled std -- sea ice concentration'};
150     if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
151 heimbach 1.1
152 gforget 1.8 %arctic maps
153     figureL;
154     subplot(2,2,1); m_map_gcmfaces(climMod(:,:,3),2,{'myCaxis',[0:0.1:1.]});
155     subplot(2,2,2); m_map_gcmfaces(climObs(:,:,3),2,{'myCaxis',[0:0.1:1.]});
156     subplot(2,2,3); m_map_gcmfaces(climMod(:,:,9),2,{'myCaxis',[0:0.1:1.]});
157     subplot(2,2,4); m_map_gcmfaces(climObs(:,:,9),2,{'myCaxis',[0:0.1:1.]});
158     myCaption={'ECCO (left) and NSIDC (right) ice concentration in March (top) and September (bottom).'};
159     if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
160 heimbach 1.1
161 gforget 1.8 %southern ocean maps
162     figureL;
163     subplot(2,2,1); m_map_gcmfaces(climMod(:,:,3),3,{'myCaxis',[0:0.1:1.]});
164     subplot(2,2,2); m_map_gcmfaces(climObs(:,:,3),3,{'myCaxis',[0:0.1:1.]});
165     subplot(2,2,3); m_map_gcmfaces(climMod(:,:,9),3,{'myCaxis',[0:0.1:1.]});
166     subplot(2,2,4); m_map_gcmfaces(climObs(:,:,9),3,{'myCaxis',[0:0.1:1.]});
167     myCaption={'ECCO (left) and NSIDC (right) ice concentration in March (top) and September (bottom).'};
168     if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
169 heimbach 1.1
170 gforget 1.8 %northern/southern integrals
171     ny=length(IceAreaNorthMod)/12;
172     yy=yearsta+[0:ny-1];
173    
174     figureL;
175     subplot(1,2,1);
176     plot(yy,IceAreaNorthMod(3:12:end),'LineWidth',2); hold on;
177     plot(yy,IceAreaNorthObs(3:12:end),'r','LineWidth',2);
178     plot(yy,IceAreaNorthMod(9:12:end),'LineWidth',2);
179     plot(yy,IceAreaNorthObs(9:12:end),'r','LineWidth',2);
180     axis([yearsta yearsta+ny-1 0 20e12]);
181     ylabel('m^2'); title('Northern Hemisphere');
182     subplot(1,2,2);
183     plot(yy,IceAreaSouthMod(1,3:12:end),'LineWidth',2); hold on;
184     plot(yy,IceAreaSouthObs(1,3:12:end),'r','LineWidth',2);
185     plot(yy,IceAreaSouthMod(1,9:12:end),'LineWidth',2);
186     plot(yy,IceAreaSouthObs(1,9:12:end),'r','LineWidth',2);
187     axis([yearsta yearsta+ny-1 0 20e12]);
188     ylabel('m^2'); title('Southern Hemisphere');
189 heimbach 1.1
190 gforget 1.8 myCaption={'ECCO (blue) and NSIDC (red) ice concentration in March and September',...
191     'in Northern Hemisphere (left) and Southern Hemisphere (right)'};
192 heimbach 1.1 if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
193    
194 gforget 1.8 %southern basin integrals
195    
196     for mm=[3 9];
197     figureL;
198     for ii=1:6;
199     subplot(3,2,ii);
200     if ii==1; iiTxt='Entire Southern Ocean';
201     else; iiTxt=sprintf('%dE to %dE',lonLims(ii-1),lonLims(ii));
202     end;
203     plot(yy,IceAreaSouthMod(ii,mm:12:end),'LineWidth',2); hold on;
204     plot(yy,IceAreaSouthObs(ii,mm:12:end),'r','LineWidth',2);
205     aa=axis; aa(1:2)=[yearsta yearsta+ny-1]; axis(aa);
206     ylabel('m^2'); title(iiTxt);
207     end;
208     if mm==3; mmTxt='March'; elseif mm==9; mmTxt='September'; else; '???'; end;
209     myCaption={'ECCO (blue) and NSIDC (red) ice concentration in ',mmTxt,' per Southern Ocean sector'};
210     if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
211     end;
212    
213 heimbach 1.1 end;
214    
215    

  ViewVC Help
Powered by ViewVC 1.1.22