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

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

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


Revision 1.2 - (hide annotations) (download)
Mon Jul 28 20:54:10 2014 UTC (11 years ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65r, checkpoint65p, checkpoint65q
Changes since 1.1: +1 -1 lines
- fix windows PC compatibility (contributed by D.Spiegel).

1 gforget 1.1 function []=extend_xx(dirIn,dirOut,ndayIn,nyearOut);
2     %object: extend atmospheric controls to additional years
3     %inputs: dirIn is the input directory
4     % dirOut is the output directory
5     % ndayIn is the control vector frecuency, in days
6     % nyearOut is the extended number of years
7     %
8     %note: we will take the time mean seasonal cycle, and transition
9     % to it linearly over the last year that was already covered
10    
11     %example:
12     %dirIn='/net/weddell/raid3/gforget/ecco_v4/output_files2/apr1alpha_it9/';
13     %dirOut='/net/weddell/raid3/gforget/ecco_v4/input_files2/apr1alpha_it9_extended_xx/';
14     %extend_xx(dirIn,dirOut,14,20);
15    
16     gcmfaces_global;
17    
18     %first copy time independent controls
19     listCp={'diffkr','kapgm','kapredi','salt','theta'};
20     for ii=1:length(listCp);
21     fileIn=dir([dirIn 'ADXXfiles/xx_' listCp{ii} '.00*data']);
22 gforget 1.2 copyfile([dirIn 'ADXXfiles/' fileIn.name] , [dirOut fileIn.name]);
23 gforget 1.1 end;
24    
25     %then extend the time dependent ones
26     for ii=1:7;
27     switch ii;
28     case 1; xxName='atemp';
29     case 2; xxName='aqh';
30     case 3; xxName='tauu';
31     case 4; xxName='tauv';
32     case 5; xxName='lwdown';
33     case 6; xxName='swdown';
34     case 7; xxName='precip';
35     end;
36    
37     %read model cost output
38     fld_xx=rdmds2gcmfaces([dirIn 'ADXXfiles/xx_' xxName '.00*']);
39    
40     %determine already covered time period
41     nrec=size(fld_xx{1},3);
42     nyearIn=nrec*ndayIn/365;
43     nrecInOneYear=round(365/ndayIn);
44     nrecOut=nrecInOneYear*nyearOut+1;
45    
46     %determine seasonal cycle
47     season_xx=0*fld_xx(:,:,1:nrecInOneYear);
48     for tt=1:nrecInOneYear;
49     season_xx(:,:,tt)=mean(fld_xx(:,:,tt:nrecInOneYear:nrec),3);
50     end;
51    
52     %determine transition factor (fld_xx -> season_xx)
53     nrec0=nrecInOneYear*(floor(nyearIn)-1);
54     fac=([1:nrecOut]-nrec0)/(nrec-nrec0);
55     fac=max(min(fac,1),0);
56    
57     %build extended time series
58     more_xx=zeros(fld_xx(:,:,1),nrecOut);
59     more_xx(:,:,1:nrec0)=fld_xx(:,:,1:nrec0);
60     for tt=nrec0+1:nrecOut;
61     ttt=mod(tt,nrecInOneYear);
62     if ttt==0; ttt=nrecInOneYear; end;
63     if tt<nrec;
64     more_xx(:,:,tt)=fac(tt)*season_xx(:,:,ttt)+(1-fac(tt))*fld_xx(:,:,tt);
65     else;
66     more_xx(:,:,tt)=season_xx(:,:,ttt);
67     end;
68     end;
69    
70     %to check the transition:
71     tmp1=convert2array(fld_xx); tmp11=squeeze(mean(tmp1,1));
72     tmp2=convert2array(more_xx); tmp22=squeeze(mean(tmp2,1));
73    
74     %save to file
75     more_xx=convert2gcmfaces(more_xx);
76     fileIn=dir([dirIn 'ADXXfiles/xx_' xxName '.00*data']);
77     write2file([dirOut fileIn.name],more_xx);
78    
79     end;%for ii=1:6;
80    

  ViewVC Help
Powered by ViewVC 1.1.22