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

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

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


Revision 1.3 - (hide annotations) (download)
Fri Jul 1 16:07:26 2011 UTC (14 years ago) by gforget
Branch: MAIN
Changes since 1.2: +27 -16 lines
ecco_v4/basic_diags_ecco.m
        make a function of dirModel,lChunk,iChunkm[,reLoadGrid]
        break records loop in chunks, and read nChnunk records at once
        write output to dirModel/mat/sic_diags_ecco_*.mat
        get grid from GRID/ if needed or as specified by reLoadGrid
ecco_v4/basic_diags_ecco_disp.m
        now a function of dirModel,addToTex
        dont reload grid
        m_map_gcmfaces updates
        added write2tex calls
ecco_v4/cost_altimeter.m
        function of dirModel
        added doDifObsOrMod loop
        get grid from GRID/ if needed
        the display part is kept for now, but the it will be
                replaced with new cost_altimeter_disp.m
        include faster cost_altimeter_read
        write output to dirModel/mat/cost_altimeter_*.mat
added functions
        ecco_v4/cost_altimeter_disp.m
        ecco_v4/cost_bp.m
        ecco_v4/cost_sst.m
        ecco_v4/plot_driver.m

1 gforget 1.3 function [alldiag,alldiag_anom]=alldiag_load(dirMat,nameMat,timeStep);
2     %object: load single record files off basic_diags_ecco, and assemble time records
3     %inputs: dirMat is the model run sub-directory where the matlab files are (e.g. 'mat/')
4     % nameMat is the mat files name (e.g. 'basic_diags_ecco_A_*.mat')
5     % timeStep is the model time step
6 gforget 1.1
7     %get list of files
8 gforget 1.3 listFiles=dir([dirMat '/' nameMat]);
9 gforget 1.1 %get time steps and sort listFiles
10 gforget 1.3 listSteps=[]; for tt=1:length(listFiles);
11     nn=listFiles(tt).name; ii=strfind(nn,'_'); ii=ii(end); listSteps=[listSteps;str2num(nn(ii+1:end-4))]; end;
12 gforget 1.1 [listSteps,ii]=sort(listSteps);
13     listFiles=listFiles(ii);
14     %compute actual times
15     nTimes=length(listSteps);
16     listTimes=listSteps*timeStep/86400;
17     %initialize alldiag
18 gforget 1.3 alldiag=open([dirMat listFiles(1).name]);
19 gforget 1.1 listDiags=fieldnames(alldiag);
20     %loop and concatenate
21     for tt=2:length(listSteps);
22 gforget 1.3 tmpdiag=open([dirMat listFiles(tt).name]);
23 gforget 1.1 for ii=1:length(listDiags);
24     %get data:
25     eval(['tmp1=tmpdiag.' listDiags{ii} '; tmp2=alldiag.' listDiags{ii} ';']);
26     %determine the time dimension:
27     if strcmp(class(tmp1),'gcmfaces'); nDim=size(tmp1{1}); else; nDim=size(tmp1); end;
28     if ~isempty(find(nDim==0)); nDim=0;
29     elseif nDim(end)==1; nDim=length(nDim)-1;
30     else; nDim=length(nDim);
31     end;
32     %concatenate along the time dimension:
33     if nDim>0; tmp2=cat(nDim+1,tmp2,tmp1); eval(['alldiag.' listDiags{ii} '=tmp2;']); end;
34     end;
35     end;
36     %clean empty diags up
37     for ii=1:length(listDiags);
38     eval(['tmp1=isempty(alldiag.' listDiags{ii} ');']);
39     if tmp1; alldiag=rmfield(alldiag,listDiags{ii}); end;
40     end;
41     %complement alldiag
42     listDiags=fieldnames(alldiag);
43     alldiag.listSteps=listSteps;
44     alldiag.listTimes=listTimes;
45     alldiag.listDiags=listDiags;
46 gforget 1.2 %subtract monthly climatology:
47 gforget 1.3 if length(listSteps)>36;
48     alldiag_anom=alldiag;
49     mm=mod([1:length(listSteps)],12); mm(mm==0)=12;
50     for ii=1:length(listDiags);
51     tmp1=getfield(alldiag,listDiags{ii});
52     if strcmp(class(tmp1),'gcmfaces'); nDim=size(tmp1{1}); else; nDim=size(tmp1); end;
53     nDim=length(nDim); tt=''; for jj=1:nDim-1; tt=[tt ':,']; end;
54     eval(['tmp2=tmp1(' tt '1:12);']);
55     for jj=1:12;
56     JJ=find(mm==jj); eval(['tmp2(' tt 'jj)=mean(tmp1(' tt 'JJ),nDim);']);
57     end;
58     eval(['tmp1=tmp1-tmp2(' tt 'mm);']);
59     eval(['alldiag_anom.' listDiags{ii} '=tmp1;']);
60 gforget 1.2 end;
61 gforget 1.3 else;
62     for ii=1:length(listDiags); eval(['alldiag_anom.' listDiags{ii} '=alldiag.' listDiags{ii} ';']); end;
63 gforget 1.2 end;
64    
65 gforget 1.1
66 gforget 1.3
67    

  ViewVC Help
Powered by ViewVC 1.1.22