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

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

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


Revision 1.6 - (hide annotations) (download)
Sun Dec 30 00:28:39 2012 UTC (12 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.5: +5 -2 lines
- add nameTex optional input parameter in all cost routines.
- cost_altimeter_disp.m : backward compatibility and help fix.

1 gforget 1.6 function []=cost_sst(dirModel,dirMat,doComp,dirTex,nameTex);
2 gforget 1.1 %object: compute cost function term for sst data
3     %inputs: dimodel is the model directory
4 gforget 1.4 % dirMat is the directory where diagnozed .mat files will be saved
5     % -> set it to '' to use the default [dirModel 'mat/']
6 gforget 1.1 % doComp is a switch (1->compute; 0->display)
7 gforget 1.4 %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.6 % nameTex is the tex file name (default : 'myPlots')
10 gforget 1.1
11 gforget 1.4 if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end;
12 gforget 1.5 if isempty(dir(dirMat)); eval(['!mkdir ' dirMat ';']); end;
13 gforget 1.4
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.6 addToTex=1;
21     if isempty(who('nameTex')); nameTex='myPlots'; end;
22     fileTex=[dirTex nameTex '.tex'];
23 gforget 1.4 end;
24 gforget 1.1
25     if doComp;
26    
27     %load grid
28 gforget 1.3 gcmfaces_global;
29     if ~isfield(mygrid,'XC'); grid_load('./GRID/',5,'compact'); end;
30     if ~isfield(mygrid,'LATS_MASKS'); gcmfaces_lines_zonal; end;
31 gforget 1.1
32     %
33     choiceWeights=2;
34     choiceData=1;
35    
36     if choiceWeights==1;
37     fld_err=read2memory('/net/weddell/raid3/gforget/ecco_v4/input_files/sigma_SST_eccollc.bin',[90 1170]);
38     fld_err(find(fld_err==0))=NaN;
39     fld_err(find(fld_err<0.5))=0.5;
40     fprintf('I need to fix the error field...\n');
41     elseif choiceWeights==2;
42     fld_err=read2memory('/net/weddell/raid3/gforget/ecco_v4/input_files/sigma_half.bin',[90 1170]);
43     end;
44    
45     fld_err=convert2gcmfaces(fld_err);
46     fld_w=fld_err.^-2;
47    
48     dirData='/net/weddell/raid3/gforget/ecco_v4/input_files/';
49     fileModel=dir([dirModel 'barfiles/tbar*data']); fileModel=['barfiles/' fileModel.name];
50    
51     fld_dif=convert2gcmfaces(NaN*ones(90,1170,12*17));
52     for ycur=1992:2007;
53     for mcur=1:12;
54     if choiceData==1;
55     fld_dat=v4_read_bin([dirData 'gael_quick_interp/g_SST_monthly_r2_' num2str(ycur)],mcur,0);
56     else;
57     fld_dat=v4_read_bin([dirData 'SST_REYNOLDS/REYNOLDS_gael_' num2str(ycur)],mcur,0);
58     end;
59     fld_dat(find(fld_dat==0))=NaN;
60     fld_dat(find(fld_dat<-99))=NaN;
61    
62     mm=(ycur-1992)*12+mcur;
63     fld_mod=v4_read_bin([dirModel fileModel],mm,1).*mygrid.mskC(:,:,1);
64    
65     fld_dif(:,:,mm)=fld_mod-fld_dat;
66     end;
67     end;
68    
69     fld_rms=sqrt(nanmean(fld_dif.^2,3));
70     fld_cost=fld_rms.^2.*fld_w;
71    
72 gforget 1.4 eval(['save ' dirMat '/cost_sst.mat fld_err fld_rms fld_cost;']);
73 gforget 1.1
74     else;%display previously computed results
75    
76     global mygrid;
77    
78 gforget 1.4 eval(['load ' dirMat '/cost_sst.mat;']);
79 gforget 1.1
80     %figure; m_map_gcmfaces(fld_cost,0,{'myCaxis',[0:0.2:1.2 1.5:0.5:3 4:1:6 8 10]});
81     %figure; m_map_gcmfaces(fld_err,0,{'myCaxis',[0:0.2:1.2 1.5:0.5:3 4:1:6 8 10]/2});
82    
83     figure; m_map_gcmfaces(fld_rms,0,{'myCaxis',[0:0.2:1.2 1.5:0.5:3 4:1:6 8 10]/2});
84 gforget 1.2 myCaption={'modeled-observed rms -- sea surface temperature (K)'};
85 gforget 1.4 if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
86 gforget 1.1
87     end;
88    
89    

  ViewVC Help
Powered by ViewVC 1.1.22