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

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

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


Revision 1.6 - (hide annotations) (download)
Tue Apr 2 22:51:57 2013 UTC (12 years, 3 months ago) by gforget
Branch: MAIN
Changes since 1.5: +1 -1 lines
cost_altimeter.m :
- update to latest ecco v4 inputs.
- set listRecs automatically.
- set maxLatObs to 90 to incl. full Arctic and SO.
cost_altimeter_disp.m : avoid raid4 / gforget reference.
cost_xx.m : avoid raid3 / gforget reference.
v4_basin.m : avoid raid3 / gforget reference.

1 gforget 1.5 function []=cost_xx(dirModel,dirMat,doComp,dirTex,nameTex);
2 gforget 1.1 %object: compute cost function term for atmospheric controls
3     %inputs: dirModel is the model directory
4 gforget 1.3 % 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.3 %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.5 % nameTex is the tex file name (default : 'myPlots')
10 gforget 1.1
11 gforget 1.3 if isempty(dirMat); dirMat=[dirModel 'mat/']; else; dirMat=[dirMat '/']; end;
12 gforget 1.4 if isempty(dir(dirMat)); eval(['!mkdir ' dirMat ';']); end;
13 gforget 1.3
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.5 addToTex=1;
21     if isempty(who('nameTex')); nameTex='myPlots'; end;
22     fileTex=[dirTex nameTex '.tex'];
23 gforget 1.3 end;
24 gforget 1.1
25     for ii=1:6;
26     switch ii;
27     case 1; xxName='atemp'; sigName='cap_sigma_tmp2m_degC_eccollc.bin'; cc=2; uni='K';
28     case 2; xxName='aqh'; sigName='cap_sigma_spfh2m_eccollc.bin'; cc=2; uni='g/kg';
29     case 3; xxName='tauu'; sigName='cap_sigma_ustr_eccollc.bin'; cc=0.04; uni='N/m2';
30     case 4; xxName='tauv'; sigName='cap_sigma_vstr_eccollc.bin'; cc=0.04; uni='N/m2';
31     case 5; xxName='lwdown'; sigName='cap_sigma_dlw_eccollc.bin'; cc=20; uni='W/m2';
32     case 6; xxName='swdown'; sigName='cap_sigma_dsw_eccollc.bin'; cc=40; uni='W/m2';
33     end;
34    
35     if doComp;
36    
37     %load grid
38 gforget 1.2 gcmfaces_global;
39     if ~isfield(mygrid,'XC'); grid_load('./GRID/',5,'compact'); end;
40     if ~isfield(mygrid,'LATS_MASKS'); gcmfaces_lines_zonal; end;
41    
42 gforget 1.6 dirSig='/net/nares/raid11/ecco-shared/ecco-version-4/input/input_all_from_pleiades/';
43 gforget 1.1
44     %read model cost output
45 gforget 1.4 tmp1=dir([dirModel 'ADXXfiles/xx_' xxName '.effective.*data']);
46     tmp2=size(convert2gcmfaces(mygrid.XC));
47     fld_xx=read2memory([dirModel 'ADXXfiles/' tmp1.name],[tmp2 tmp1.bytes/tmp2(1)/tmp2(2)/4]);
48     fld_xx=convert2gcmfaces(fld_xx);
49     %does not work when adjoint overwrites xx*effective*meta fld_xx=rdmds2gcmfaces([dirModel 'ADXXfiles/xx_' xxName '.effective.*']);
50    
51 gforget 1.1 fld_sig=v4_read_bin([dirSig sigName],1,0);
52     if strcmp(xxName,'aqh'); fld_xx=fld_xx*1000; fld_sig=fld_sig*1000; end;
53    
54     %compute xx stats
55     fld_rms=sqrt(mean(fld_xx.^2,3));
56     fld_mean=mean(fld_xx,3);
57     fld_std=std(fld_xx,[],3);
58    
59     %mask
60     fld_rms=fld_rms.*mygrid.mskC(:,:,1);
61     fld_sig=fld_sig.*mygrid.mskC(:,:,1);
62     fld_mean=fld_mean.*mygrid.mskC(:,:,1);
63     fld_std=fld_std.*mygrid.mskC(:,:,1);
64    
65     clear fld_xx;
66    
67 gforget 1.3 eval(['save ' dirMat '/cost_xx_' xxName '.mat fld_* cc uni;']);
68 gforget 1.1
69     else;%display previously computed results
70    
71     global mygrid;
72    
73 gforget 1.3 eval(['load ' dirMat '/cost_xx_' xxName '.mat;']);
74 gforget 1.1
75     figure;
76     m_map_gcmfaces(fld_sig,0,{'myCaxis',[0:0.05:0.5 0.6:0.1:1 1.25]*cc});
77     myCaption={['prior uncertainty -- ' xxName ' (' uni ')']};
78 gforget 1.3 if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
79 gforget 1.1
80     figure;
81     m_map_gcmfaces(fld_rms,0,{'myCaxis',[0:0.05:0.5 0.6:0.1:1 1.25]*cc});
82     myCaption={['rms adjustment -- ' xxName ' (' uni ')']};
83 gforget 1.3 if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
84 gforget 1.1
85     figure;
86     m_map_gcmfaces(fld_std,0,{'myCaxis',[0:0.05:0.5 0.6:0.1:1 1.25]*cc});
87     myCaption={['std adjustment -- ' xxName ' (' uni ')']};
88 gforget 1.3 if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
89 gforget 1.1
90     figure;
91     m_map_gcmfaces(fld_mean,0,{'myCaxis',[-0.5:0.05:0.5]*cc});
92     myCaption={['mean adjustment -- ' xxName ' (' uni ')']};
93 gforget 1.3 if addToTex; write2tex(fileTex,2,myCaption,gcf); end;
94 gforget 1.1
95     end;
96    
97     end;%for ii=1:6;
98    

  ViewVC Help
Powered by ViewVC 1.1.22