[21726] | 1 | Index: ../trunk-jpl/externalpackages/pcatool/install.sh
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/externalpackages/pcatool/install.sh (revision 0)
|
---|
| 4 | +++ ../trunk-jpl/externalpackages/pcatool/install.sh (revision 21589)
|
---|
| 5 | @@ -0,0 +1,12 @@
|
---|
| 6 | +#!/bin/bash
|
---|
| 7 | +
|
---|
| 8 | +#Some cleanup
|
---|
| 9 | +rm -rf install pcatool
|
---|
| 10 | +mkdir install
|
---|
| 11 | +
|
---|
| 12 | +#Download from ISSM server
|
---|
| 13 | +$ISSM_DIR/scripts/DownloadExternalPackage.py 'http://issm.jpl.nasa.gov/files/externalpackages/pcatool.tar.gz' 'pcatool.tar.gz'
|
---|
| 14 | +
|
---|
| 15 | +#Untar into install
|
---|
| 16 | +cd install
|
---|
| 17 | +tar -zxvf ../pcatool.tar.gz
|
---|
| 18 |
|
---|
| 19 | Property changes on: ../trunk-jpl/externalpackages/pcatool/install.sh
|
---|
| 20 | ___________________________________________________________________
|
---|
| 21 | Added: svn:executable
|
---|
| 22 | + *
|
---|
| 23 |
|
---|
| 24 | Index: ../trunk-jpl/externalpackages/pcatool/pcatool.tar.gz
|
---|
| 25 | ===================================================================
|
---|
| 26 | Cannot display: file marked as a binary type.
|
---|
| 27 | svn:mime-type = application/octet-stream
|
---|
| 28 |
|
---|
| 29 | Property changes on: ../trunk-jpl/externalpackages/pcatool/pcatool.tar.gz
|
---|
| 30 | ___________________________________________________________________
|
---|
| 31 | Added: svn:mime-type
|
---|
| 32 | + application/octet-stream
|
---|
| 33 |
|
---|
| 34 | Index: ../trunk-jpl/externalpackages/pcatool/install/license.txt
|
---|
| 35 | ===================================================================
|
---|
| 36 | --- ../trunk-jpl/externalpackages/pcatool/install/license.txt (revision 0)
|
---|
| 37 | +++ ../trunk-jpl/externalpackages/pcatool/install/license.txt (revision 21589)
|
---|
| 38 | @@ -0,0 +1,24 @@
|
---|
| 39 | +Copyright (c) 2008, Guillaume MAZE
|
---|
| 40 | +All rights reserved.
|
---|
| 41 | +
|
---|
| 42 | +Redistribution and use in source and binary forms, with or without
|
---|
| 43 | +modification, are permitted provided that the following conditions are
|
---|
| 44 | +met:
|
---|
| 45 | +
|
---|
| 46 | + * Redistributions of source code must retain the above copyright
|
---|
| 47 | + notice, this list of conditions and the following disclaimer.
|
---|
| 48 | + * Redistributions in binary form must reproduce the above copyright
|
---|
| 49 | + notice, this list of conditions and the following disclaimer in
|
---|
| 50 | + the documentation and/or other materials provided with the distribution
|
---|
| 51 | +
|
---|
| 52 | +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
---|
| 53 | +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
---|
| 54 | +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
---|
| 55 | +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
---|
| 56 | +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
---|
| 57 | +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
---|
| 58 | +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
---|
| 59 | +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
---|
| 60 | +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
---|
| 61 | +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
---|
| 62 | +POSSIBILITY OF SUCH DAMAGE.
|
---|
| 63 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispEEOF_v2.m
|
---|
| 64 | ===================================================================
|
---|
| 65 | --- ../trunk-jpl/externalpackages/pcatool/install/dispEEOF_v2.m (revision 0)
|
---|
| 66 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispEEOF_v2.m (revision 21589)
|
---|
| 67 | @@ -0,0 +1,76 @@
|
---|
| 68 | +% dispEEOF_v2(CHP,PC,EXPVAR,DT,NLAG,MOD) Display few EEOFs with their
|
---|
| 69 | +% PC time evolution
|
---|
| 70 | +%
|
---|
| 71 | +% => DISPLAY FEW EEOFs with their PC time evolution.
|
---|
| 72 | +% CHP contains all the EEOFs as EOF*LAG*X*Y.
|
---|
| 73 | +% PC contains all the PCs.
|
---|
| 74 | +% EXPVAR is a matrix with the explained variance of each
|
---|
| 75 | +% EEOFs in %. This is just for title.
|
---|
| 76 | +% DT is time step between maps.
|
---|
| 77 | +% NLAG is the number of LAG to display.
|
---|
| 78 | +% MOD contains explicitly the EEOFs to display.
|
---|
| 79 | +%
|
---|
| 80 | +% Rq: it's using the plotm function
|
---|
| 81 | +% See also: dispEEOF
|
---|
| 82 | +%
|
---|
| 83 | +%================================================================
|
---|
| 84 | +
|
---|
| 85 | +% Guillaume MAZE - LPO/LMD - June 2004
|
---|
| 86 | +% gmaze@univ-brest.fr
|
---|
| 87 | +
|
---|
| 88 | +function [] = dispEEOF(CHP,PC,EXPVAR,DT,NLAG,MOD)
|
---|
| 89 | +
|
---|
| 90 | +% Number of EEOF to display
|
---|
| 91 | +NMOD = length(MOD);
|
---|
| 92 | +
|
---|
| 93 | +% Open figure and first guest
|
---|
| 94 | +figur;
|
---|
| 95 | +clf;hold on
|
---|
| 96 | +typg=8;
|
---|
| 97 | +width = .9/NMOD;
|
---|
| 98 | +height = .9/(NLAG+1);
|
---|
| 99 | +dleft = (.95-width*NMOD)/4;
|
---|
| 100 | +left = dleft;
|
---|
| 101 | +load mapanom
|
---|
| 102 | +
|
---|
| 103 | +% Let'go :
|
---|
| 104 | +
|
---|
| 105 | +% We choose an EEOF
|
---|
| 106 | +for imod = 1 : NMOD
|
---|
| 107 | + mod = MOD(imod);
|
---|
| 108 | +
|
---|
| 109 | + % and plot maps
|
---|
| 110 | + for iplot=1:NLAG+1
|
---|
| 111 | + bottom = .95-height*iplot;
|
---|
| 112 | + subplot('Position',[left bottom width height]);
|
---|
| 113 | + if iplot==1 % Plot the pc's time serie
|
---|
| 114 | + plot(PC(imod,:));
|
---|
| 115 | + grid on;box on;
|
---|
| 116 | + set(gca,'XAxisLocation','top');axis tight;
|
---|
| 117 | + titre=strcat('EEOF',num2str(mod),'(',num2str(EXPVAR(mod)),'%)');
|
---|
| 118 | + titre=strcat(titre,'; DT=',num2str(DT),' ');
|
---|
| 119 | + title(titre);
|
---|
| 120 | + if (imod==1),ax1=get(gca,'YLim');else,set(gca,'YLim',ax1);end
|
---|
| 121 | + else % Plot the lag maps
|
---|
| 122 | + lag=iplot-1;
|
---|
| 123 | + C = squeeze(real(CHP(mod,lag,:,:)));
|
---|
| 124 | +% C = C./xtrm(C); % Eventually normalise field
|
---|
| 125 | + plotm(C,typg);
|
---|
| 126 | + if(lag==1),caxis([-abs(xtrm(C)) abs(xtrm(C))]);cx=caxis;end;
|
---|
| 127 | + caxis(cx);
|
---|
| 128 | + colormap(mapanom);
|
---|
| 129 | + %ylabel(strcat('{\bf',num2str((lag-1)*DT),'}'))
|
---|
| 130 | + m_text(10,-70,strcat('{\bf',num2str((lag-1)*DT),'}'));
|
---|
| 131 | + end %if
|
---|
| 132 | +
|
---|
| 133 | + end
|
---|
| 134 | + left = left + width + dleft;
|
---|
| 135 | +
|
---|
| 136 | + % Adjust plot width via the plot Aspect ratio
|
---|
| 137 | + ch=get(gcf,'Children');
|
---|
| 138 | + posiPC=get(ch(iplot),'PlotBoxAspectRatio');
|
---|
| 139 | + posiMAP=get(ch(iplot-1),'PlotBoxAspectRatio');
|
---|
| 140 | + set(ch(iplot),'PlotBoxAspectRatio',posiMAP);
|
---|
| 141 | +
|
---|
| 142 | +end
|
---|
| 143 | +
|
---|
| 144 | Index: ../trunk-jpl/externalpackages/pcatool/install/confexpvar.m
|
---|
| 145 | ===================================================================
|
---|
| 146 | --- ../trunk-jpl/externalpackages/pcatool/install/confexpvar.m (revision 0)
|
---|
| 147 | +++ ../trunk-jpl/externalpackages/pcatool/install/confexpvar.m (revision 21589)
|
---|
| 148 | @@ -0,0 +1,67 @@
|
---|
| 149 | +% [CONF,CONFLEVEL] = CONFEXPVAR(A,B,nsamples,N)
|
---|
| 150 | +%
|
---|
| 151 | +% A(Ntime,MmapA), B(Ntime,MmapB) are time-synchronised
|
---|
| 152 | +% and time-constant sampled data sets.
|
---|
| 153 | +% MmapA and MmapB are not required to be identic.
|
---|
| 154 | +% nsamples is what it is (given at least a 100 factor
|
---|
| 155 | +% will be nice to provide a trustable result).
|
---|
| 156 | +% N is the max number of eigen vectors to be computed.
|
---|
| 157 | +%
|
---|
| 158 | +% CONFEXPVAR Compute the confidence limits for significant
|
---|
| 159 | +% eigenvalues in a SVD decomposition of data sets A and B.
|
---|
| 160 | +% This generates nsamples random-in-time data set of B
|
---|
| 161 | +% and finds percent variance of N SVD modes computed
|
---|
| 162 | +% with data set A.
|
---|
| 163 | +% This is exactly the monte-carlo method but based on
|
---|
| 164 | +% a random-in-time only data set. This considerably
|
---|
| 165 | +% decrease the cputime.
|
---|
| 166 | +%
|
---|
| 167 | +% 2005/11. Guillaume Maze
|
---|
| 168 | +% gmaze@univ-brest.fr
|
---|
| 169 | +
|
---|
| 170 | +function [conf,lev,dsumCF] = confexpvar(A,B,nsamples,N)
|
---|
| 171 | +
|
---|
| 172 | +% We try to find the p confidence levels of expvar.
|
---|
| 173 | +% Keeping as it is the first field, we determine SVDs with the
|
---|
| 174 | +% second field arbitrary sorted in time.
|
---|
| 175 | +% 1st field : A
|
---|
| 176 | +% 2nd field : B
|
---|
| 177 | +
|
---|
| 178 | +n = size(A,1);
|
---|
| 179 | +if size(B,1)~=n
|
---|
| 180 | + disp('Error, A and B required to be of the same time length !');
|
---|
| 181 | + disp('See help confexpvar');
|
---|
| 182 | + stop
|
---|
| 183 | +end
|
---|
| 184 | +
|
---|
| 185 | +timer = cputime;
|
---|
| 186 | +disp('Compute confidence levels of explained variance...');
|
---|
| 187 | +for iR=1:nsamples
|
---|
| 188 | + if iR==fix(nsamples/2)
|
---|
| 189 | + disp(strcat(num2str(iR),'/',num2str(nsamples)));
|
---|
| 190 | + disp(['Please, still wait a little time ... around '...
|
---|
| 191 | + num2str(cputime-timer) ' cpu seconds']);
|
---|
| 192 | + end
|
---|
| 193 | +
|
---|
| 194 | + % Generate a random new time index:
|
---|
| 195 | + t=randperm(n);
|
---|
| 196 | + % and sort the 2nd field with it:
|
---|
| 197 | + Br=B(t,:);
|
---|
| 198 | +
|
---|
| 199 | + % Now we compute SVD and expvar:
|
---|
| 200 | + C=A'*Br;
|
---|
| 201 | + [U,Lambda,V] = svds(C,N);
|
---|
| 202 | + L2 = Lambda.^2; dsum = diag(L2)/trace(L2);
|
---|
| 203 | + L = Lambda; dsum = diag(L)/trace(L);
|
---|
| 204 | + dsumCF(iR,:) = dsum';
|
---|
| 205 | +
|
---|
| 206 | +end %for iR
|
---|
| 207 | +disp(['OK, this took ' num2str(cputime-timer) ' cpu seconds'])
|
---|
| 208 | +
|
---|
| 209 | +% CF(nsamples,N) contains expvar of the nsamples realisations:
|
---|
| 210 | +CF=sort(dsumCF,1);
|
---|
| 211 | +
|
---|
| 212 | +% Now we just take the decadal significant levels:
|
---|
| 213 | +lev=fix([nsamples/10:nsamples/10:nsamples]);
|
---|
| 214 | +conf = CF(lev,:) ;
|
---|
| 215 | +lev=(lev./max(lev))*100;
|
---|
| 216 | Index: ../trunk-jpl/externalpackages/pcatool/install/calsvd.m
|
---|
| 217 | ===================================================================
|
---|
| 218 | --- ../trunk-jpl/externalpackages/pcatool/install/calsvd.m (revision 0)
|
---|
| 219 | +++ ../trunk-jpl/externalpackages/pcatool/install/calsvd.m (revision 21589)
|
---|
| 220 | @@ -0,0 +1,54 @@
|
---|
| 221 | +% [SVD1,SVD2,PC1,PC2,EXPVAR,Lambda] = CALSVD(A,B,N) Compute SVDs
|
---|
| 222 | +%
|
---|
| 223 | +% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
|
---|
| 224 | +% Analyses of climatic Data" 1997
|
---|
| 225 | +%================================================================
|
---|
| 226 | +%
|
---|
| 227 | +% Guillaume MAZE - LPO/LMD - March 2004
|
---|
| 228 | +% gmaze@univ-brest.fr
|
---|
| 229 | +
|
---|
| 230 | +
|
---|
| 231 | + function [e1,e2,pc1,pc2,expvar,Lambda] = calsvd(A,B,N);
|
---|
| 232 | +
|
---|
| 233 | +
|
---|
| 234 | +disp('====> Let''go for SVDs and pc computing...')
|
---|
| 235 | +
|
---|
| 236 | +% Assume that A is (time*map) matrix
|
---|
| 237 | +[n p]=size(A);
|
---|
| 238 | +
|
---|
| 239 | +% Remove the mean of each column (ie the time mean in each station records)
|
---|
| 240 | +S=detrend(A,'constant');
|
---|
| 241 | +P=detrend(B,'constant');
|
---|
| 242 | +
|
---|
| 243 | +% Form the covariance matrix:
|
---|
| 244 | +C = S'*P;
|
---|
| 245 | +
|
---|
| 246 | +% Find eigenvectors and singular values
|
---|
| 247 | +[U,Lambda,V] = svds(C,N);
|
---|
| 248 | +
|
---|
| 249 | +% PC
|
---|
| 250 | +a = S*U;
|
---|
| 251 | +b = P*V;
|
---|
| 252 | +
|
---|
| 253 | +% Make them clear for output
|
---|
| 254 | +for iN=1:N
|
---|
| 255 | + e1(iN,:) = squeeze( U(:,iN) )';
|
---|
| 256 | + pc1(iN,:) = squeeze( a(:,iN) )';
|
---|
| 257 | + e2(iN,:) = squeeze( V(:,iN) )';
|
---|
| 258 | + pc2(iN,:) = squeeze( b(:,iN) )';
|
---|
| 259 | +end
|
---|
| 260 | +
|
---|
| 261 | +% Amount of variance explained a 0.1 pres et en %
|
---|
| 262 | +L2=Lambda.^2;
|
---|
| 263 | +dsum=diag(L2)/trace(L2);
|
---|
| 264 | +
|
---|
| 265 | +for iN=1:N
|
---|
| 266 | + expvar(iN)=fix( ( dsum(iN)*100/sum(dsum) )*10 ) /10;
|
---|
| 267 | +end
|
---|
| 268 | +
|
---|
| 269 | +
|
---|
| 270 | +disp('====> Finished !')
|
---|
| 271 | +
|
---|
| 272 | +
|
---|
| 273 | +
|
---|
| 274 | +
|
---|
| 275 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispSVD.m
|
---|
| 276 | ===================================================================
|
---|
| 277 | --- ../trunk-jpl/externalpackages/pcatool/install/dispSVD.m (revision 0)
|
---|
| 278 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispSVD.m (revision 21589)
|
---|
| 279 | @@ -0,0 +1,86 @@
|
---|
| 280 | +% dispSVD(typg,CHP1,CHP2,N,expvar) Display SVDs
|
---|
| 281 | +%
|
---|
| 282 | +% => Display SVDs
|
---|
| 283 | +% typg is plot type you want (see plotm.m).
|
---|
| 284 | +% CHP contains SVDs and is of the form: CHP(iSVD,X,Y)
|
---|
| 285 | +% N is number of SVD to display
|
---|
| 286 | +% expvar contained the explained variance of SVDs
|
---|
| 287 | +%
|
---|
| 288 | +% Rq: it''s using the plotm function
|
---|
| 289 | +%
|
---|
| 290 | +%================================================================
|
---|
| 291 | +
|
---|
| 292 | +% Guillaume MAZE - LPO/LMD - December 2004
|
---|
| 293 | +% gmaze@univ-brest.fr
|
---|
| 294 | +
|
---|
| 295 | +function [] = dispSVD(typg,CHP1,CHP2,N,expvar)
|
---|
| 296 | +
|
---|
| 297 | +load mapanom2
|
---|
| 298 | +global ffile1 ffile2
|
---|
| 299 | +
|
---|
| 300 | +if length(N)>1
|
---|
| 301 | + mod=N;
|
---|
| 302 | +else
|
---|
| 303 | + mod=[1:N];
|
---|
| 304 | +end
|
---|
| 305 | +Nx=length(mod);
|
---|
| 306 | +% --------------------------------------------------
|
---|
| 307 | +% AFFICHAGE
|
---|
| 308 | +% --------------------------------------------------
|
---|
| 309 | +if (typg~=1)&(typg~=7)&(typg~=3)&(typg~=6)
|
---|
| 310 | + CBAROR='horiz';
|
---|
| 311 | + iw=Nx;jw=2;
|
---|
| 312 | +else
|
---|
| 313 | + CBAROR='vert';
|
---|
| 314 | + iw=Nx;jw=2;
|
---|
| 315 | +end
|
---|
| 316 | +
|
---|
| 317 | +
|
---|
| 318 | +f1=figur;clf; hold on
|
---|
| 319 | +for iN=1:Nx
|
---|
| 320 | + subplot(iw,jw,2*iN-1)
|
---|
| 321 | +C = squeeze(real(CHP1(mod(iN),:,:)));
|
---|
| 322 | +%plotm(C./xtrm(C),typg);caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 323 | +plotm(C,typg);
|
---|
| 324 | +caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 325 | +%if(iN==1);cx=caxis;end;caxis(cx);
|
---|
| 326 | +colormap(mycolormap(mapanom,21));
|
---|
| 327 | +c=colorbar(CBAROR);
|
---|
| 328 | +titre1=strcat('SVD',num2str(mod(iN)),':',blanks(1),ffile1);
|
---|
| 329 | +titre2=strcat(' (',num2str(expvar(mod(iN))),'%)');
|
---|
| 330 | +tt=title(strvcat(strcat(titre1,titre2),char(1)));
|
---|
| 331 | +set(tt,'fontweight','bold')
|
---|
| 332 | +
|
---|
| 333 | + subplot(iw,jw,2*iN)
|
---|
| 334 | +C = squeeze(real(CHP2(mod(iN),:,:)));
|
---|
| 335 | +%plotm(C./xtrm(C),typg);caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 336 | +plotm(C,typg);
|
---|
| 337 | +caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 338 | +%if(iN==1);cx=caxis;end;caxis(cx);
|
---|
| 339 | +colormap(mycolormap(mapanom,21));
|
---|
| 340 | +c=colorbar(CBAROR);
|
---|
| 341 | +titre1=strcat('SVD',num2str(mod(iN)),':',blanks(1),ffile2);
|
---|
| 342 | +titre2=strcat(' (',num2str(expvar(mod(iN))),'%)');
|
---|
| 343 | +tt=title(strvcat(strcat(titre1,titre2),char(1)));
|
---|
| 344 | +set(tt,'fontweight','bold')
|
---|
| 345 | +
|
---|
| 346 | +end %for iN
|
---|
| 347 | +
|
---|
| 348 | +
|
---|
| 349 | +% $$$ for iN=1:2*N
|
---|
| 350 | +% $$$ figure(f1);
|
---|
| 351 | +% $$$ subplot(iw,jw,iN);
|
---|
| 352 | +% $$$ % colorbar(CBAROR);
|
---|
| 353 | +% $$$ end
|
---|
| 354 | +% $$$ refresh
|
---|
| 355 | +
|
---|
| 356 | +
|
---|
| 357 | +%titre1=strcat(num2str(lat(il1)),'/',num2str(lat(il2)));
|
---|
| 358 | +titre2=strcat(' Total explained variance:',num2str(sum(expvar(mod))),'%');
|
---|
| 359 | +%titre3=strcat('(Analysed files: ',ffile1,' vs ',ffile2,')');
|
---|
| 360 | +%titre=strvcat(titre2,titre3);
|
---|
| 361 | +suptitle(titre2);
|
---|
| 362 | +
|
---|
| 363 | +set(f1,'Position',[378 39 313 647]); % Laptop screen
|
---|
| 364 | +%set(f1,'Position',[369 55 316 899]); % Desktop screen
|
---|
| 365 | +%set(f1,'Name',strcat(ffile,'<>',titre1,'<> REAL PART'));
|
---|
| 366 | Index: ../trunk-jpl/externalpackages/pcatool/install/caleof.m
|
---|
| 367 | ===================================================================
|
---|
| 368 | --- ../trunk-jpl/externalpackages/pcatool/install/caleof.m (revision 0)
|
---|
| 369 | +++ ../trunk-jpl/externalpackages/pcatool/install/caleof.m (revision 21589)
|
---|
| 370 | @@ -0,0 +1,234 @@
|
---|
| 371 | +% [EOFs,PC,EXPVAR] = CALEOF(M,N,METHOD) Compute EOF
|
---|
| 372 | +%
|
---|
| 373 | +% => Compute the Nth first EOFs of matrix M(TIME,MAP).
|
---|
| 374 | +% EOFs is a matrix of the form EOFs(N,MAP), PC is the principal
|
---|
| 375 | +% components matrix ie it has the form PC(N,TIME) and EXPVAR is
|
---|
| 376 | +% the fraction of total variance "explained" by each EOF ie it has
|
---|
| 377 | +% the form EXPVAR(N).
|
---|
| 378 | +% Differents method can be used:
|
---|
| 379 | +% 1 - The "classic" one, ie we compute eigenvectors of the
|
---|
| 380 | +% temporal covariance matrix with the eig Matlab function.
|
---|
| 381 | +% 2 - A faster "classic" one, same as method 1 but we use the
|
---|
| 382 | +% eigs Matlab function.
|
---|
| 383 | +% 3 - We compute eigenvectors by the singular value decomposition,
|
---|
| 384 | +% by used of the svd Matlab function.
|
---|
| 385 | +% 4 - Same as method 3 but faster by used of the svds Matlab function
|
---|
| 386 | +%
|
---|
| 387 | +% See also EIG, EIGS, SVD, SVDS
|
---|
| 388 | +%
|
---|
| 389 | +% Ref: L. Hartmann: "Objective Analysis" 2002
|
---|
| 390 | +% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
|
---|
| 391 | +% Analyses of climatic Data" 1997
|
---|
| 392 | +%================================================================
|
---|
| 393 | +
|
---|
| 394 | +% Guillaume MAZE - LPO/LMD - March 2004
|
---|
| 395 | +% Revised July 2006
|
---|
| 396 | +% gmaze@univ-brest.fr
|
---|
| 397 | +
|
---|
| 398 | +
|
---|
| 399 | +function [e,pc,expvar,L] = caleof(M,N,method);
|
---|
| 400 | +
|
---|
| 401 | +% Get dimensions
|
---|
| 402 | +[n p]=size(M);
|
---|
| 403 | +
|
---|
| 404 | +% Temporal covariance is p*p matrix, that why max EOF computable is p,
|
---|
| 405 | +% so we perform a test on parameter N:
|
---|
| 406 | +if(N>p)
|
---|
| 407 | + disp('Warning: N is larger than possible so it''s modified to perform')
|
---|
| 408 | + disp(' EOFs computing...');
|
---|
| 409 | + N = p;
|
---|
| 410 | +end
|
---|
| 411 | +
|
---|
| 412 | +
|
---|
| 413 | +% Eventualy time filtering of data
|
---|
| 414 | +if 0==1
|
---|
| 415 | + disp('====> Time filtering...')
|
---|
| 416 | + Fc = 1/20; Fc2 = 1/1;
|
---|
| 417 | + Fc = 1/7 ; Fc2 = 1/3;
|
---|
| 418 | + SIGNAL = M(:,1);
|
---|
| 419 | + nj = fix(length(SIGNAL)/10); % Nombre de points du filtre
|
---|
| 420 | + for ipt = 1 : p
|
---|
| 421 | + SIGNAL = M(:,ipt);
|
---|
| 422 | + SIGNALF = lanczos(SIGNAL,Fc2,nj);
|
---|
| 423 | + SIGNALF = SIGNALF - lanczos(SIGNALF,Fc,nj);
|
---|
| 424 | + Y(:,ipt) = SIGNALF;
|
---|
| 425 | + end
|
---|
| 426 | + M = Y;
|
---|
| 427 | +end
|
---|
| 428 | +
|
---|
| 429 | +
|
---|
| 430 | +disp('====> Let''go for EOFs and pc computing...')
|
---|
| 431 | +switch method
|
---|
| 432 | + case 1 % CLASSIC METHOD
|
---|
| 433 | +%================================================================
|
---|
| 434 | +% Transform the data matrix in the correct form (map*time) for eig
|
---|
| 435 | +M = M';
|
---|
| 436 | +
|
---|
| 437 | +% Remove the time mean (ie the mean of each rows of M)
|
---|
| 438 | +% Rq: detrend remove the mean of columns ie we take M'.
|
---|
| 439 | +F = detrend(M','constant')';
|
---|
| 440 | +
|
---|
| 441 | +% Covariance Matrix (inner product over space = covariance in time)
|
---|
| 442 | +R = F * F';
|
---|
| 443 | +
|
---|
| 444 | +% Eigenanalysis of the covariance matrix R
|
---|
| 445 | +[E,L] = eig(R);
|
---|
| 446 | +
|
---|
| 447 | +% Get PC by projecting eigenvectors on original data
|
---|
| 448 | +Z = E'*F;
|
---|
| 449 | +
|
---|
| 450 | +% Make them clear for output
|
---|
| 451 | +for iN=1:N
|
---|
| 452 | + e(iN,:) = squeeze( E(:,p-(iN-1)) )';
|
---|
| 453 | + pc(iN,:) = squeeze( Z(p-(iN-1),:) );
|
---|
| 454 | +end
|
---|
| 455 | +
|
---|
| 456 | +% Amount of explained variance (at 0.1%)
|
---|
| 457 | +dsum = diag(L)./trace(L);
|
---|
| 458 | +for iN=1:N
|
---|
| 459 | + expvar(iN)=fix((dsum(p-(iN-1))*100/sum(dsum))*10)/10;
|
---|
| 460 | +end
|
---|
| 461 | +
|
---|
| 462 | +% Plots Original field and reconstructed one
|
---|
| 463 | +if 0==1
|
---|
| 464 | +figure;
|
---|
| 465 | +subplot(1,2,1);imagesc(abs(M));title('ORIGINAL');cx=caxis;
|
---|
| 466 | +%subplot(1,2,2);imagesc((E*Z));title('RECONSTRUCTED')
|
---|
| 467 | +subplot(1,2,2);imagesc(abs(e'*pc));title('RECONSTRUCTED');caxis(cx);
|
---|
| 468 | +end
|
---|
| 469 | +
|
---|
| 470 | + case 2 % RAPID CLASSIC METHOD
|
---|
| 471 | +%================================================================
|
---|
| 472 | +% Remove the time mean of each column
|
---|
| 473 | +F = detrend(M,'constant');
|
---|
| 474 | +
|
---|
| 475 | +% Covariance Matrix
|
---|
| 476 | +if n >= p
|
---|
| 477 | + R = F' * F;
|
---|
| 478 | +else
|
---|
| 479 | + R = F * F';
|
---|
| 480 | +end
|
---|
| 481 | +
|
---|
| 482 | +% Eigen analysis of the square covariance matrix
|
---|
| 483 | +[E,L] = eigs(R,N);
|
---|
| 484 | +if n < p
|
---|
| 485 | + E = F' * E;
|
---|
| 486 | + sq = [sqrt(diag(L))+eps]';
|
---|
| 487 | + sq = sq(ones(1,p),:);
|
---|
| 488 | + E = E ./ sq;
|
---|
| 489 | +end
|
---|
| 490 | +
|
---|
| 491 | +% Get PC by projecting eigenvectors on original data
|
---|
| 492 | +if n >= p
|
---|
| 493 | + Z = (F*E)';
|
---|
| 494 | +else
|
---|
| 495 | + Z = E'*F';
|
---|
| 496 | +end
|
---|
| 497 | +
|
---|
| 498 | +
|
---|
| 499 | +% Make them clear for output
|
---|
| 500 | +for iN=1:N
|
---|
| 501 | + e(iN,:) = squeeze( E(:,iN) )';
|
---|
| 502 | + pc(iN,:) = squeeze( Z(iN,:) );
|
---|
| 503 | +end
|
---|
| 504 | +
|
---|
| 505 | +% Amount of variance explained a 0.1 pres et en %
|
---|
| 506 | +dsum=diag(L)./trace(L);
|
---|
| 507 | +for iN=1:N
|
---|
| 508 | + expvar(iN)=fix((dsum(iN)*100/sum(dsum))*10)/10;
|
---|
| 509 | +end
|
---|
| 510 | +
|
---|
| 511 | +
|
---|
| 512 | + case 3 % SVD METHOD
|
---|
| 513 | +%================================================================
|
---|
| 514 | +% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
|
---|
| 515 | +% Analyses of climatic Data" 1997 => p18
|
---|
| 516 | +
|
---|
| 517 | +% Assume that M is (time*map) matrix
|
---|
| 518 | +[n p]=size(M);
|
---|
| 519 | +
|
---|
| 520 | +% Remove the mean of each column (ie the time mean in each station records)
|
---|
| 521 | +F=detrend(M,'constant');
|
---|
| 522 | +
|
---|
| 523 | +% Form the covariance matrix:
|
---|
| 524 | +R = F'*F;
|
---|
| 525 | +
|
---|
| 526 | +% Find eigenvectors and singular values
|
---|
| 527 | +[C,L,CC] = svd(R);
|
---|
| 528 | +% Eigenvectors are in CC and the squared diagonal values of L
|
---|
| 529 | +% are the eigenvalues of the temporal covariance matrix R=F'*F
|
---|
| 530 | +
|
---|
| 531 | +% find the PC corresponding to eigenvalue
|
---|
| 532 | +PC = F*CC;
|
---|
| 533 | +
|
---|
| 534 | +% Make them clear for output
|
---|
| 535 | +for iN=1:N
|
---|
| 536 | + e(iN,:) = squeeze( CC(:,iN) )';
|
---|
| 537 | + pc(iN,:) = squeeze( PC(:,iN) )';
|
---|
| 538 | +end
|
---|
| 539 | +
|
---|
| 540 | +if 0
|
---|
| 541 | +figure;
|
---|
| 542 | +subplot(1,2,1);imagesc(F);title('ORIGINAL');cx=caxis;
|
---|
| 543 | +subplot(1,2,2);imagesc(C*L*CC');title('RECONSTRUCTED');caxis(cx);
|
---|
| 544 | +end
|
---|
| 545 | +
|
---|
| 546 | +% Amount of variance explained at 0.1%
|
---|
| 547 | +dsum=diag(L)./trace(L);
|
---|
| 548 | +if length(dsum)<N % L was not squared
|
---|
| 549 | + dsum = [dsum ;zeros(N-length(dsum),1)];
|
---|
| 550 | +end
|
---|
| 551 | +for iN = 1 : N
|
---|
| 552 | + expvar(iN)=fix( ( dsum(iN)*100/sum(dsum) )*10 ) /10;
|
---|
| 553 | +end
|
---|
| 554 | +
|
---|
| 555 | +
|
---|
| 556 | + case 4 % FAST SVD METHOD
|
---|
| 557 | +%================================================================
|
---|
| 558 | +% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
|
---|
| 559 | +% Analyses of climatic Data" 1997 => p18
|
---|
| 560 | +
|
---|
| 561 | +% Assume that M is (time*map) matrix
|
---|
| 562 | +[n p]=size(M);
|
---|
| 563 | +
|
---|
| 564 | +% Remove the mean of each column (ie the time mean in each station records)
|
---|
| 565 | +F=detrend(M,'constant');
|
---|
| 566 | +
|
---|
| 567 | +% Form the covariance matrix:
|
---|
| 568 | +R = F' * F;
|
---|
| 569 | +
|
---|
| 570 | +% Find eigenvectors and singular values
|
---|
| 571 | +[C,L,CC,flag] = svds(R,N);
|
---|
| 572 | +% Eigenvectors are in CC and the squared diagonal values of L
|
---|
| 573 | +% are the eigenvalues of the temporal covariance matrix R=F'*F
|
---|
| 574 | +% (Sometimes, CC stops for nul eigenvector, then we need to fill to reach N)
|
---|
| 575 | +if size(CC,2)<N
|
---|
| 576 | + CC = [CC zeros(size(CC,1),N-size(CC,2)+1)];
|
---|
| 577 | +end
|
---|
| 578 | +
|
---|
| 579 | +% find the PC corresponding to eigenvalue
|
---|
| 580 | +PC = F*CC;
|
---|
| 581 | +% Which is similar to: C*L
|
---|
| 582 | +
|
---|
| 583 | +% Make them clear for output
|
---|
| 584 | +for iN=1:N
|
---|
| 585 | + e(iN,:) = squeeze( CC(:,iN) )';
|
---|
| 586 | + pc(iN,:) = squeeze( PC(:,iN) )';
|
---|
| 587 | +end
|
---|
| 588 | +
|
---|
| 589 | +% Amount of variance explained a 0.1 pres et en %
|
---|
| 590 | +dsum=diag(L)./trace(L);
|
---|
| 591 | +if length(dsum)<N % L was not squared
|
---|
| 592 | + dsum = [dsum ;zeros(N-length(dsum),1)];
|
---|
| 593 | +end
|
---|
| 594 | +for iN=1:N
|
---|
| 595 | + expvar(iN)=fix( ( dsum(iN)*100/sum(dsum) )*10 ) /10;
|
---|
| 596 | +end
|
---|
| 597 | +
|
---|
| 598 | +%figure;
|
---|
| 599 | +%subplot(1,2,1);imagesc(M);title('ORIGINAL');cx=caxis;
|
---|
| 600 | +%subplot(1,2,2);imagesc((e'*pc)');title('RECONSTRUCTED');caxis(cx);
|
---|
| 601 | +
|
---|
| 602 | +
|
---|
| 603 | +end % switch method
|
---|
| 604 | +disp('====> Finished !')
|
---|
| 605 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispEOF.m
|
---|
| 606 | ===================================================================
|
---|
| 607 | --- ../trunk-jpl/externalpackages/pcatool/install/dispEOF.m (revision 0)
|
---|
| 608 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispEOF.m (revision 21589)
|
---|
| 609 | @@ -0,0 +1,130 @@
|
---|
| 610 | +% dispEOF(typg,CHP,N,expvar) Display EOFs
|
---|
| 611 | +%
|
---|
| 612 | +% => Display EOFs
|
---|
| 613 | +% typg is plot type you want (see plotm.m).
|
---|
| 614 | +% CHP contains EOFs and is of the form: CHP(EOF,X,Y)
|
---|
| 615 | +% N is number of EOF to display
|
---|
| 616 | +% expvar contained the explained variance of EOFs
|
---|
| 617 | +%
|
---|
| 618 | +% Rq: it''s using the plotm function
|
---|
| 619 | +%
|
---|
| 620 | +%================================================================
|
---|
| 621 | +
|
---|
| 622 | +% Guillaume MAZE - LPO/LMD - March 2004
|
---|
| 623 | +% gmaze@univ-brest.fr
|
---|
| 624 | +
|
---|
| 625 | +function [] = dispEOF(typg,CHP,N,expvar)
|
---|
| 626 | +
|
---|
| 627 | +load mapanom2
|
---|
| 628 | +global ffile
|
---|
| 629 | +% --------------------------------------------------
|
---|
| 630 | +% AFFICHAGE
|
---|
| 631 | +% --------------------------------------------------
|
---|
| 632 | +if (typg~=1)&(typg~=7)&(typg~=3)&(typg~=6)
|
---|
| 633 | +
|
---|
| 634 | + CBAROR='horiz';
|
---|
| 635 | +if N>12,NN=12;else,NN=N;end
|
---|
| 636 | +switch NN
|
---|
| 637 | + case 1,tblmagique=[1]; iw=1;jw=1;
|
---|
| 638 | + case 2,tblmagique=[1 2]; iw=2;jw=1;
|
---|
| 639 | + case 3,tblmagique=[1 2 3]; iw=3;jw=1;
|
---|
| 640 | + case 4,tblmagique=[1 2 3 4]; iw=2;jw=2;
|
---|
| 641 | + case 5,tblmagique=[1 2 3 4 5]; iw=3;jw=2;
|
---|
| 642 | + case 6,tblmagique=[1 2 3 4 5 6]; iw=3;jw=2;
|
---|
| 643 | + case 7,tblmagique=[1 2 3 4 5 6 7]; iw=4;jw=2;
|
---|
| 644 | + case 8,tblmagique=[1 2 3 4 5 6 7 8]; iw=4;jw=2;
|
---|
| 645 | + case 9,tblmagique=[1 2 3 4 5 6 7 8 9]; iw=3;jw=3;
|
---|
| 646 | + case 10,tblmagique=[1 2 3 4 5 6 7 8 9 10]; iw=4;jw=3;
|
---|
| 647 | + case 11,tblmagique=[1 2 3 4 5 6 7 8 9 10 11]; iw=4;jw=3;
|
---|
| 648 | + case 12,tblmagique=[1 2 3 4 5 6 7 8 9 10 11 12];iw=4;jw=3;
|
---|
| 649 | +end
|
---|
| 650 | +iw=N;jw=1;
|
---|
| 651 | +
|
---|
| 652 | +else
|
---|
| 653 | +
|
---|
| 654 | + CBAROR='vert';
|
---|
| 655 | +if N>12,NN=12;else,NN=N;end
|
---|
| 656 | +switch NN
|
---|
| 657 | + case 1,tblmagique=[1]; iw=1;jw=1;
|
---|
| 658 | + case 2,tblmagique=[1 2]; iw=2;jw=1;
|
---|
| 659 | + case 3,tblmagique=[1 2 3]; iw=3;jw=1;
|
---|
| 660 | + case 4,tblmagique=[1 2 3 4]; iw=2;jw=2;
|
---|
| 661 | + case 5,tblmagique=[1 2 3 4 5]; iw=3;jw=2;
|
---|
| 662 | + case 6,tblmagique=[1 2 3 4 5 6]; iw=3;jw=2;
|
---|
| 663 | + case 7,tblmagique=[1 2 3 4 5 6 7]; iw=4;jw=2;
|
---|
| 664 | + case 8,tblmagique=[1 2 3 4 5 6 7 8]; iw=4;jw=2;
|
---|
| 665 | + case 9,tblmagique=[1 2 3 4 5 6 7 8 9]; iw=3;jw=3;
|
---|
| 666 | + case 10,tblmagique=[1 2 3 4 5 6 7 8 9 10]; iw=4;jw=3;
|
---|
| 667 | + case 11,tblmagique=[1 2 3 4 5 6 7 8 9 10 11]; iw=4;jw=3;
|
---|
| 668 | + case 12,tblmagique=[1 2 3 4 5 6 7 8 9 10 11 12];iw=4;jw=3;
|
---|
| 669 | +end
|
---|
| 670 | +
|
---|
| 671 | +
|
---|
| 672 | +
|
---|
| 673 | +end %if
|
---|
| 674 | +
|
---|
| 675 | +
|
---|
| 676 | +
|
---|
| 677 | +f1=figur;clf; hold on
|
---|
| 678 | +
|
---|
| 679 | +for iN=1:NN
|
---|
| 680 | + subplot(iw,jw,tblmagique(iN)); hold on
|
---|
| 681 | +C = squeeze(real(CHP(iN,:,:)));
|
---|
| 682 | +%plotm(C./xtrm(C),typg);caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 683 | +plotm(C,typg);caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 684 | +if(iN==1);cx=caxis;end;caxis(cx);
|
---|
| 685 | +colormap(mycolormap(mapanom,21));
|
---|
| 686 | +
|
---|
| 687 | +%c=colorbar(CBAROR);
|
---|
| 688 | +titre1=strcat('EOF',num2str(iN));
|
---|
| 689 | +titre2=strcat(' (',num2str(expvar(iN)),'%)');
|
---|
| 690 | +title(strcat(titre1,titre2));
|
---|
| 691 | +
|
---|
| 692 | +end %for iN
|
---|
| 693 | +
|
---|
| 694 | +%titre1=strcat(num2str(lat(il1)),'/',num2str(lat(il2)));
|
---|
| 695 | +titre2=strcat(' Total explained variance:',num2str(sum(expvar)),'%');
|
---|
| 696 | +%titre3=strcat('(Analysed file: ',ffile,')');
|
---|
| 697 | +%titre=strvcat(titre2,titre3);
|
---|
| 698 | +suptitle(titre2);
|
---|
| 699 | +
|
---|
| 700 | +set(f1,'Position',[378 39 313 647]); % Laptop screen
|
---|
| 701 | +%set(f1,'Position',[369 55 316 899]); % Desktop screen
|
---|
| 702 | +%set(f1,'Name',strcat(ffile,'<>',titre1,'<> REAL PART'));
|
---|
| 703 | +set(f1,'Name','<> REAL PART <>');
|
---|
| 704 | +
|
---|
| 705 | +
|
---|
| 706 | +% -------------------------------------------
|
---|
| 707 | +if isreal(CHP)==0
|
---|
| 708 | +
|
---|
| 709 | +f2=figur;clf; hold on
|
---|
| 710 | +
|
---|
| 711 | +for iN=1:NN
|
---|
| 712 | + subplot(iw,jw,tblmagique(iN)); hold on
|
---|
| 713 | +
|
---|
| 714 | +C = squeeze(imag(CHP(iN,:,:)));
|
---|
| 715 | +plotm(C,typg);caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 716 | +%if(iN==1);cx=caxis;end;
|
---|
| 717 | +caxis(cx);
|
---|
| 718 | +colormap(mycolormap(mapanom,21));
|
---|
| 719 | +
|
---|
| 720 | +c=colorbar(CBAROR);
|
---|
| 721 | +titre1=strcat('EOF',num2str(iN));
|
---|
| 722 | +titre2=strcat(' (',num2str(expvar(iN)),'%)');
|
---|
| 723 | +title(strcat(titre1,titre2));
|
---|
| 724 | +
|
---|
| 725 | +end %for iNN
|
---|
| 726 | +
|
---|
| 727 | +%titre1=strcat(num2str(lat(il1)),'/',num2str(lat(il2)));
|
---|
| 728 | +titre2=strcat(' Total explained variance:',num2str(sum(expvar)),'%');
|
---|
| 729 | +%titre3=strcat('(Analysed file: ',ffile,')');
|
---|
| 730 | +%titre=strvcat(titre2,titre3);
|
---|
| 731 | +suptitle(titre2);
|
---|
| 732 | +
|
---|
| 733 | +set(f2,'Position',[378 39 313 647]); % Laptop screen
|
---|
| 734 | +%set(f2,'Position',[369 55 316 899]); % Desktop screen
|
---|
| 735 | +set(f2,'Name','<> IMAGINARY PART <>');
|
---|
| 736 | +
|
---|
| 737 | +end
|
---|
| 738 | +
|
---|
| 739 | +
|
---|
| 740 | Index: ../trunk-jpl/externalpackages/pcatool/install/plotm.m
|
---|
| 741 | ===================================================================
|
---|
| 742 | --- ../trunk-jpl/externalpackages/pcatool/install/plotm.m (revision 0)
|
---|
| 743 | +++ ../trunk-jpl/externalpackages/pcatool/install/plotm.m (revision 21589)
|
---|
| 744 | @@ -0,0 +1,214 @@
|
---|
| 745 | +%PLOTM Trace un champ de donnee geographique
|
---|
| 746 | +% [CS,H]=PLOTM(C,[ZONE])
|
---|
| 747 | +% Trace le champ C(LONGITUDE,LATITUDE) sur une carte
|
---|
| 748 | +% du monde en projection Mercator par defaut.
|
---|
| 749 | +% Le parametre optionnel ZONE peut prendre les valeurs
|
---|
| 750 | +% ZONE = 1 : Projection Stereographique centree sur le pole sud
|
---|
| 751 | +% ZONE = 2 : Projection Mercator de l'hemisphere sud
|
---|
| 752 | +% ZONE = 3 : Projection Mercator du globe
|
---|
| 753 | +% ZONE = 4 : Pas de projection (imagesc)
|
---|
| 754 | +% ZONE = 5 : Projection Mercator de l'hemisphere sud complet
|
---|
| 755 | +% ZONE = 6 : Projection Mercator du globe complet
|
---|
| 756 | +% ZONE = 7 : Projection Stereographique centree sur le pole nord
|
---|
| 757 | +% ZONE = 8 : Idem 2 mais sans label sur les axes
|
---|
| 758 | +% ZONE = 9 : Projection Mercator de l'hemisphere sud aux limites du Fmask
|
---|
| 759 | +% Returns contour matrix CS as described in CONTOURC and a vector H
|
---|
| 760 | +% of handles to PATCH objects (for use by CLABEL).
|
---|
| 761 | +%
|
---|
| 762 | +% La definition des grilles (longitude,latitude) est celle du
|
---|
| 763 | +% modele par defaut, mais elle peut etre modifiee en passant en
|
---|
| 764 | +% global les nouvelles variables nommees lon et lat.
|
---|
| 765 | +%
|
---|
| 766 | +% NECESSITE LE PACKAGE M_MAP
|
---|
| 767 | +%
|
---|
| 768 | +%
|
---|
| 769 | +% (nov. 2003 -> gmaze@univ-brest.fr)
|
---|
| 770 | +
|
---|
| 771 | +function varargout = plotm(C,varargin)
|
---|
| 772 | +
|
---|
| 773 | +if (nargin>2)|(nargin<1)
|
---|
| 774 | + help plotm.m
|
---|
| 775 | + error('plotm.m : Wrong number or bad parameter(s)')
|
---|
| 776 | + return
|
---|
| 777 | +elseif (nargin==2)
|
---|
| 778 | + arg = varargin{:};
|
---|
| 779 | + if (arg>14)|(arg<1)
|
---|
| 780 | + help plotm.m
|
---|
| 781 | + error('plotm.m : Wrong number or bad parameter(s)')
|
---|
| 782 | + return
|
---|
| 783 | + end
|
---|
| 784 | +end %if
|
---|
| 785 | +
|
---|
| 786 | +%--------------------------------------------------
|
---|
| 787 | +% Variabes
|
---|
| 788 | +%--------------------------------------------------
|
---|
| 789 | +[lx,ly]=size(C);
|
---|
| 790 | +% Si lon et lat ne sont pas definie comme dans le modele
|
---|
| 791 | +% on prend en global n'importe quel definition
|
---|
| 792 | +if ((lx~=64)|(ly~=32))
|
---|
| 793 | + global lon lat
|
---|
| 794 | +else
|
---|
| 795 | + lon= linspace(0.,360.,64);
|
---|
| 796 | + lat= [85.76 80.27 74.74 69.21 63.68 58.14 52.61 47.07 41.53 ...
|
---|
| 797 | + 36.00 30.46 24.92 19.38 13.84 8.31 2.77 -2.77 -8.31 ...
|
---|
| 798 | + -13.84 -19.38 -24.92 -30.46 -36.00 -41.53 -47.07 -52.61 ...
|
---|
| 799 | + -58.14 -63.68 -69.21 -74.74 -80.27 -85.76];
|
---|
| 800 | +end
|
---|
| 801 | +
|
---|
| 802 | +% Le nombre de contour est par defaut a 10, mais on peut le
|
---|
| 803 | +% modifier en declarant nbcont en global
|
---|
| 804 | +global nbcont
|
---|
| 805 | +if isempty(nbcont)==1
|
---|
| 806 | + nbcont=10;
|
---|
| 807 | +end
|
---|
| 808 | +
|
---|
| 809 | +%-----------------------------------------------
|
---|
| 810 | +% Projection
|
---|
| 811 | +%-----------------------------------------------
|
---|
| 812 | +if (nargin==2)
|
---|
| 813 | + arg = varargin{:};
|
---|
| 814 | + switch arg(1)
|
---|
| 815 | + case 1 % Projection stereo
|
---|
| 816 | + m_proj('stereo','lon',0,'lat',-90,'rad',71);
|
---|
| 817 | + case 2 % Projection mercator (HS)
|
---|
| 818 | + m_proj('miller','lon',[0 360],'lat',[-80 -20]);
|
---|
| 819 | + m_proj('miller','lon',[0 360],'lat',[-60 -20]);
|
---|
| 820 | + case 3 % Projection mercator (Tout) -> Defaut
|
---|
| 821 | + m_proj('miller','lon',[0 360],'lat',[-80 80]);
|
---|
| 822 | + case 5 % Projection mercator (HS-complet)
|
---|
| 823 | + m_proj('miller','lon',[0 360],'lat',[-85 -5]);
|
---|
| 824 | + case 6 % Projection mercator (Tout-complet)
|
---|
| 825 | + m_proj('miller','lon',[0 360],'lat',[-85 85]);
|
---|
| 826 | + case 7 % Projection stereo
|
---|
| 827 | + m_proj('stereo','lon',0,'lat',90,'rad',71);
|
---|
| 828 | + case 8 % Projection mercator (HS) sans Label sur les axes
|
---|
| 829 | + m_proj('miller','lon',[0 360],'lat',[-80 -20]);
|
---|
| 830 | + m_proj('miller','lon',[0 360],'lat',[-75 -30]);
|
---|
| 831 | + case 9 % Projection mercator (HS) sans Label sur les axes aux limtes du FMASK
|
---|
| 832 | + m_proj('miller','lon',[0 360],'lat',[-69 -25]);
|
---|
| 833 | + case 10 % Projection stereo recentree sur le pole sud
|
---|
| 834 | + m_proj('stereo','lon',0,'lat',-90,'rad',51);
|
---|
| 835 | + case 11 % Indien
|
---|
| 836 | + m_proj('lambert','long',[11 125],'lat',[-60 -30]);
|
---|
| 837 | + case 12 % Pacifique
|
---|
| 838 | + m_proj('lambert','long',[120 290],'lat',[-60 -30]);
|
---|
| 839 | + case 13 % Atlantique
|
---|
| 840 | + m_proj('lambert','long',[-70 20],'lat',[-60 -30]);
|
---|
| 841 | + case 14 % Centré Atlantique
|
---|
| 842 | + m_proj('lambert','long',[-90 90],'lat',[-70 -20],'rectbox','on');
|
---|
| 843 | + end
|
---|
| 844 | +else
|
---|
| 845 | +% Projection mercator (Tout) -> Defaut
|
---|
| 846 | + m_proj('mercator','lon',[0 360],'lat',[-80 80]);
|
---|
| 847 | +end
|
---|
| 848 | +
|
---|
| 849 | +%------------------------------------------------
|
---|
| 850 | +% Affichage
|
---|
| 851 | +%------------------------------------------------
|
---|
| 852 | +load MODELCOAST
|
---|
| 853 | +if length(lon)==65
|
---|
| 854 | + modelcoast=[modelcoast;modelcoast(1,:)];
|
---|
| 855 | +end
|
---|
| 856 | +
|
---|
| 857 | +hold on
|
---|
| 858 | +if (nargin==2)
|
---|
| 859 | + arg = varargin{:};
|
---|
| 860 | + switch arg(1)
|
---|
| 861 | + case 1 % Projection stereo (Par defaut)
|
---|
| 862 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 863 | +% m_coast('color',[0 0 0]);
|
---|
| 864 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 865 | + m_grid('ytick',[-30 -40 -50 -60 -70],'yticklabels',[],...
|
---|
| 866 | + 'xtick',[0 60 120 180 -120 -60],'XaxisLocation','top')
|
---|
| 867 | + case 2 % Projection mercator (HS)
|
---|
| 868 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 869 | +% m_coast('color',[0 0 0]);
|
---|
| 870 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 871 | + m_grid('ytick',[-80 -70 -60 -50 -40 -30 -20]);
|
---|
| 872 | + case 3 % Projection mercator (Tout)
|
---|
| 873 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 874 | +% m_coast('color',[0 0 0]);
|
---|
| 875 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 876 | + m_grid('ytick',[-80 -60 -40 -20 0 20 40 60 80]);
|
---|
| 877 | + case 4 % Pas de projection
|
---|
| 878 | + pcolor(lon,lat,C');
|
---|
| 879 | + axis tight;box on
|
---|
| 880 | +% axis([lon(1) lon(64) lat(32) lat(1)]);
|
---|
| 881 | +% gc=gca;set(gc,'YDir','reverse');
|
---|
| 882 | + case 5 % Projection mercator (Hs-complet)
|
---|
| 883 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 884 | +% m_coast('color',[0 0 0]);
|
---|
| 885 | + COASTYPE='color';COASTCOLOR=[0 0 0];
|
---|
| 886 | +% COASTYPE='patch';COASTCOLOR=[0 0.5 0.6];
|
---|
| 887 | +% m_coast(COASTYPE,COASTCOLOR);
|
---|
| 888 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 889 | + m_grid('ytick',[-80 -60 -40 -20 0]);
|
---|
| 890 | + case 6 % Projection mercator (Tout-complet)
|
---|
| 891 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 892 | +% m_coast('color',[0 0 0]);
|
---|
| 893 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 894 | + m_grid('ytick',[-80 -60 -40 -20 0 20 40 60 80]);
|
---|
| 895 | + case 7 % Projection stereo
|
---|
| 896 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 897 | +% m_coast('color',[0 0 0]);
|
---|
| 898 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 899 | + m_grid('ytick',[30 40 50 60 70],'yticklabels',[],...
|
---|
| 900 | + 'xtick',[0 60 120 180 -120 -60],'XaxisLocation','top')
|
---|
| 901 | + case 8 % Projection mercator (HS) sans label sur les axes
|
---|
| 902 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 903 | +% m_pcolor(lon,lat,C');shading interp
|
---|
| 904 | +% m_coast('color',[0 0 0]);
|
---|
| 905 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 906 | + m_grid('ytick','','xtick','');
|
---|
| 907 | + case 9 % Projection mercator (HS) sans label sur les axes aux limtes du FMASK
|
---|
| 908 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 909 | +% m_coast('color',[0 0 0]);
|
---|
| 910 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 911 | + m_grid('ytick','','xtick','');
|
---|
| 912 | + case 10 % Projection stereo recentree sur le pole Sud
|
---|
| 913 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 914 | +% m_coast('color',[0 0 0]);
|
---|
| 915 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 916 | + m_grid('ytick',[-40 -50 -60 -70],'yticklabels',[],...
|
---|
| 917 | + 'xtick',[0 60 120 180 -120 -60],'XaxisLocation','top')
|
---|
| 918 | + case 11 % Indien
|
---|
| 919 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 920 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 921 | + m_grid('ytick',[-40 -50 -60 -70],'yticklabels',[],...
|
---|
| 922 | + 'xtick',[30 60 90 120 150 180],'XaxisLocation','top')
|
---|
| 923 | + case 12 % Pacifique
|
---|
| 924 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 925 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 926 | + m_grid('ytick',[-40 -50 -60 -70],'yticklabels',[],...
|
---|
| 927 | + 'xtick',[120 150 180 210 240 270 300],'XaxisLocation','top')
|
---|
| 928 | + case 13 % Atlantique
|
---|
| 929 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 930 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 931 | + m_grid('ytick',[-40 -50 -60 -70],'yticklabels',[],...
|
---|
| 932 | + 'xtick',[-60 -30 0 30 60],'XaxisLocation','top')
|
---|
| 933 | + case 14 % Centré Atlantique
|
---|
| 934 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 935 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 936 | + m_grid('yticklabels',[],'XaxisLocation','top',...
|
---|
| 937 | + 'fontsize',6,...
|
---|
| 938 | + 'xtick',[0 60 120 180 -120 -60],'xticklabels',[180 -120 -60 0 60 120]);
|
---|
| 939 | +
|
---|
| 940 | + end % switch
|
---|
| 941 | +else
|
---|
| 942 | + % Projection Mercator (Par defaut)
|
---|
| 943 | + [cs,h]=m_contourf(lon,lat,C',nbcont);
|
---|
| 944 | +% m_coast('color',[0 0 0]);
|
---|
| 945 | + m_contour(lon,lat,modelcoast',1,'k');
|
---|
| 946 | + m_grid('ytick',[-80 -60 -40 -20 0 20 40 60 80]);
|
---|
| 947 | +end
|
---|
| 948 | +
|
---|
| 949 | +
|
---|
| 950 | +
|
---|
| 951 | +% OUTPUT VARIABLES
|
---|
| 952 | +switch nargout
|
---|
| 953 | + case 1
|
---|
| 954 | + varargout(1) = {cs} ;
|
---|
| 955 | + case 2
|
---|
| 956 | + varargout(1) = {cs} ;
|
---|
| 957 | + varargout(2) = {h};
|
---|
| 958 | +end
|
---|
| 959 | Index: ../trunk-jpl/externalpackages/pcatool/install/calCeof.m
|
---|
| 960 | ===================================================================
|
---|
| 961 | --- ../trunk-jpl/externalpackages/pcatool/install/calCeof.m (revision 0)
|
---|
| 962 | +++ ../trunk-jpl/externalpackages/pcatool/install/calCeof.m (revision 21589)
|
---|
| 963 | @@ -0,0 +1,11 @@
|
---|
| 964 | +% [e,pc,expvar] = calCeof(M,N,METHOD)
|
---|
| 965 | +% Compute Complex EOF
|
---|
| 966 | +
|
---|
| 967 | + function [e,pc,expvar] = calCeof(M,N,METHOD)
|
---|
| 968 | +
|
---|
| 969 | +
|
---|
| 970 | +% Compute Hilbert transform Mh and create M as: M = M + i*Mh
|
---|
| 971 | +M = hilbert(M);
|
---|
| 972 | +
|
---|
| 973 | +% Compute EOFs
|
---|
| 974 | + [e,pc,expvar] = caleof(M,N,METHOD);
|
---|
| 975 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispCEOF.m
|
---|
| 976 | ===================================================================
|
---|
| 977 | --- ../trunk-jpl/externalpackages/pcatool/install/dispCEOF.m (revision 0)
|
---|
| 978 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispCEOF.m (revision 21589)
|
---|
| 979 | @@ -0,0 +1,65 @@
|
---|
| 980 | +% dispCEOF(CEOF,EXPVAR,PHI,MOD) Display few CEOFs.
|
---|
| 981 | +%
|
---|
| 982 | +% => DISPLAY FEW CEOFs.
|
---|
| 983 | +% CEOF contains all the CEOFs as nCEOF*X*Y.
|
---|
| 984 | +% EXPVAR is a matrix with the explained variance of each
|
---|
| 985 | +% CEOFs in %. This is just for title.
|
---|
| 986 | +% PHI is phase when ploting maps.
|
---|
| 987 | +% MOD contains explicitly the CEOFs to display.
|
---|
| 988 | +%
|
---|
| 989 | +% Rq: it's using the plotm function
|
---|
| 990 | +%
|
---|
| 991 | +%================================================================
|
---|
| 992 | +
|
---|
| 993 | +% Guillaume MAZE - LPO/LMD - June 2004
|
---|
| 994 | +% gmaze@univ-brest.fr
|
---|
| 995 | +
|
---|
| 996 | +function [] = dispCEOF(CEOF,EXPVAR,PHI,MOD)
|
---|
| 997 | +
|
---|
| 998 | +% Number of EEOF to display
|
---|
| 999 | +NMOD = length(MOD);
|
---|
| 1000 | +NANG = length(PHI);
|
---|
| 1001 | +
|
---|
| 1002 | +% Open figure and first guest
|
---|
| 1003 | +figur;clf;hold on
|
---|
| 1004 | +typg=8;
|
---|
| 1005 | +width = .9/NMOD;
|
---|
| 1006 | +height = .9/NANG;
|
---|
| 1007 | +dleft = (.95-width*NMOD)/4;
|
---|
| 1008 | +left = dleft;
|
---|
| 1009 | +load mapanom2
|
---|
| 1010 | +
|
---|
| 1011 | +% Let'go :
|
---|
| 1012 | +
|
---|
| 1013 | +% We select a CEOF:
|
---|
| 1014 | +for imod = 1 : NMOD
|
---|
| 1015 | + mod = MOD(imod);
|
---|
| 1016 | + chp=squeeze(CEOF(mod,:,:));
|
---|
| 1017 | + Rchp=real(chp);
|
---|
| 1018 | + Ichp=-imag(chp);
|
---|
| 1019 | +
|
---|
| 1020 | + %
|
---|
| 1021 | + for ang=1:NANG
|
---|
| 1022 | + C = cos(PHI(ang))*Rchp + sin(PHI(ang))*Ichp;
|
---|
| 1023 | + m(ang)=abs(xtrm(C));
|
---|
| 1024 | + end
|
---|
| 1025 | + m=max(m);
|
---|
| 1026 | +
|
---|
| 1027 | + % and plot maps
|
---|
| 1028 | + for ang=1:NANG
|
---|
| 1029 | + C = cos(PHI(ang))*Rchp + sin(PHI(ang))*Ichp;
|
---|
| 1030 | + bottom = .95-height*ang;
|
---|
| 1031 | + subplot('Position',[left bottom width height]);
|
---|
| 1032 | + plotm(C,typg);
|
---|
| 1033 | + m_text(10,-70,strcat('\phi=',num2str(PHI(ang)*180/pi),'^o'));
|
---|
| 1034 | +% ylabel(strcat('\phi=',num2str(PHI(ang)*180/pi),'^o'),'Rotation',0);
|
---|
| 1035 | + caxis([-m m]);
|
---|
| 1036 | + colormap(mapanom);
|
---|
| 1037 | + if(ang==1)
|
---|
| 1038 | + titre=strcat('CEOF',num2str(mod),'(',num2str(EXPVAR(mod)),'%)');
|
---|
| 1039 | + title(titre);
|
---|
| 1040 | + end;
|
---|
| 1041 | + end
|
---|
| 1042 | + left = left + width + dleft;
|
---|
| 1043 | +
|
---|
| 1044 | +end
|
---|
| 1045 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispSVDnb.m
|
---|
| 1046 | ===================================================================
|
---|
| 1047 | --- ../trunk-jpl/externalpackages/pcatool/install/dispSVDnb.m (revision 0)
|
---|
| 1048 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispSVDnb.m (revision 21589)
|
---|
| 1049 | @@ -0,0 +1,63 @@
|
---|
| 1050 | +% dispSVDnb(typg,CHP1,CHP2,N,expvar) Display SVDs
|
---|
| 1051 | +%
|
---|
| 1052 | +% => Display SVDs in white and black
|
---|
| 1053 | +% typg is plot type you want (see plotm.m).
|
---|
| 1054 | +% CHP contains SVDs and is of the form: CHP(iSVD,X,Y)
|
---|
| 1055 | +% N is number of SVD to display
|
---|
| 1056 | +% expvar contained the explained variance of SVDs
|
---|
| 1057 | +%
|
---|
| 1058 | +% Rq: it''s using the plotmNB function
|
---|
| 1059 | +%
|
---|
| 1060 | +%================================================================
|
---|
| 1061 | +
|
---|
| 1062 | +% Guillaume MAZE - LPO/LMD - December 2004
|
---|
| 1063 | +% gmaze@univ-brest.fr
|
---|
| 1064 | +
|
---|
| 1065 | +function [] = dispSVDnb(typg,CHP1,CHP2,N,expvar)
|
---|
| 1066 | +
|
---|
| 1067 | +global ffile1 ffile2
|
---|
| 1068 | +% --------------------------------------------------
|
---|
| 1069 | +% AFFICHAGE
|
---|
| 1070 | +% --------------------------------------------------
|
---|
| 1071 | +if (typg~=1)&(typg~=7)&(typg~=3)&(typg~=6)
|
---|
| 1072 | + CBAROR='horiz';
|
---|
| 1073 | + iw=N;jw=2;
|
---|
| 1074 | +else
|
---|
| 1075 | + CBAROR='vert';
|
---|
| 1076 | + iw=N;jw=2;
|
---|
| 1077 | +end
|
---|
| 1078 | +
|
---|
| 1079 | +
|
---|
| 1080 | +f1=figur;clf; hold on
|
---|
| 1081 | +for iN=1:N
|
---|
| 1082 | + subplot(iw,jw,2*iN-1)
|
---|
| 1083 | +C = squeeze(real(CHP1(iN,:,:)));
|
---|
| 1084 | +%[cs,h]=plotmNB(C,typg); whos cs h
|
---|
| 1085 | +[cs,h]=plotmNB(C,typg);
|
---|
| 1086 | +%clabel(cs,h,'labelspacing',100);
|
---|
| 1087 | +titre1=strcat('SVD',num2str(iN),':',ffile1);
|
---|
| 1088 | +titre2=strcat(' (',num2str(expvar(iN)),'%)');
|
---|
| 1089 | +title(strcat(titre1,titre2));
|
---|
| 1090 | +
|
---|
| 1091 | + subplot(iw,jw,2*iN)
|
---|
| 1092 | +C = squeeze(real(CHP2(iN,:,:)));
|
---|
| 1093 | +[cs,h]=plotmNB(C,typg);
|
---|
| 1094 | +%clabel(cs,h,'labelspacing',100);
|
---|
| 1095 | +titre1=strcat('SVD',num2str(iN),':',ffile2);
|
---|
| 1096 | +titre2=strcat(' (',num2str(expvar(iN)),'%)');
|
---|
| 1097 | +title(strcat(titre1,titre2));
|
---|
| 1098 | +
|
---|
| 1099 | +end %for iN
|
---|
| 1100 | +
|
---|
| 1101 | +
|
---|
| 1102 | +
|
---|
| 1103 | +
|
---|
| 1104 | +%titre1=strcat(num2str(lat(il1)),'/',num2str(lat(il2)));
|
---|
| 1105 | +titre2=strcat(' Total explained variance:',num2str(sum(expvar)),'%');
|
---|
| 1106 | +%titre3=strcat('(Analysed files: ',ffile1,' vs ',ffile2,')');
|
---|
| 1107 | +%titre=strvcat(titre2,titre3);
|
---|
| 1108 | +suptitle(titre2);
|
---|
| 1109 | +
|
---|
| 1110 | +set(f1,'Position',[378 39 313 647]); % Laptop screen
|
---|
| 1111 | +%set(f1,'Position',[369 55 316 899]); % Desktop screen
|
---|
| 1112 | +%set(f1,'Name',strcat(ffile,'<>',titre1,'<> REAL PART'));
|
---|
| 1113 | Index: ../trunk-jpl/externalpackages/pcatool/install/Contents.m
|
---|
| 1114 | ===================================================================
|
---|
| 1115 | --- ../trunk-jpl/externalpackages/pcatool/install/Contents.m (revision 0)
|
---|
| 1116 | +++ ../trunk-jpl/externalpackages/pcatool/install/Contents.m (revision 21589)
|
---|
| 1117 | @@ -0,0 +1,32 @@
|
---|
| 1118 | +% PRINCIPAL COMPONENTS ANALYSIS TOOLBOX
|
---|
| 1119 | +% Last Modified: Dec 2007
|
---|
| 1120 | +%
|
---|
| 1121 | +% This software is provided "as is" without express
|
---|
| 1122 | +% or implied warranty...
|
---|
| 1123 | +%
|
---|
| 1124 | +%
|
---|
| 1125 | +% EOF and SVD
|
---|
| 1126 | +% caleof - Compute EOFs
|
---|
| 1127 | +% calEeof - Compute Extended EOFs
|
---|
| 1128 | +% calCeof - Compute Complex EOFs
|
---|
| 1129 | +% calsvd - Compute SVDs
|
---|
| 1130 | +% confexpvar - Compute statistical confidence of explained variance
|
---|
| 1131 | +%
|
---|
| 1132 | +% VISUALISATION
|
---|
| 1133 | +% dispEOF - Display EOFs
|
---|
| 1134 | +% dispEEOF - Display EEOFs as time sequence map
|
---|
| 1135 | +% dispEEOF_v2 - Display EEOFs as time sequence map with
|
---|
| 1136 | +% the PC time series
|
---|
| 1137 | +% dispCEOF - Display CEOFs
|
---|
| 1138 | +% dispSVD - Display SVDs
|
---|
| 1139 | +% plotm - Plot a 2D geo field
|
---|
| 1140 | +%
|
---|
| 1141 | +% Matrix manipulation
|
---|
| 1142 | +% map2mat - Transform C(TIME,LON,LAT) in D(TIME,PT)
|
---|
| 1143 | +% under a geographic points selection
|
---|
| 1144 | +% mat2map - Invert transform done by map2mat
|
---|
| 1145 | +%
|
---|
| 1146 | +%
|
---|
| 1147 | +%================================================================
|
---|
| 1148 | +% Author: Guillaume MAZE - LPO/LMD - March 2004
|
---|
| 1149 | +% gmaze@univ-brest.fr
|
---|
| 1150 | Index: ../trunk-jpl/externalpackages/pcatool/install/calEeof.m
|
---|
| 1151 | ===================================================================
|
---|
| 1152 | --- ../trunk-jpl/externalpackages/pcatool/install/calEeof.m (revision 0)
|
---|
| 1153 | +++ ../trunk-jpl/externalpackages/pcatool/install/calEeof.m (revision 21589)
|
---|
| 1154 | @@ -0,0 +1,128 @@
|
---|
| 1155 | +% [EOFs,PC,EXPVAR] = calEeof(M,N,METHOD,NLAG,DT) Compute EEOF
|
---|
| 1156 | +%
|
---|
| 1157 | +% => Compute N Extended EOF of a M(TIME*MAP) matrix.
|
---|
| 1158 | +% METHOD is the EOF method computing (see caleof.m)
|
---|
| 1159 | +% NLAG is the number of map you want
|
---|
| 1160 | +% DT is the increment between each map (not the time step
|
---|
| 1161 | +% of your data)
|
---|
| 1162 | +%
|
---|
| 1163 | +% The function can filter datas with a Lanczos band-pass
|
---|
| 1164 | +% filter. Edit the calEeof.m file and change option in it.
|
---|
| 1165 | +%
|
---|
| 1166 | +% See also: CALEOF
|
---|
| 1167 | +%
|
---|
| 1168 | +% Ref: Weare and Nasstrom 1982
|
---|
| 1169 | +%================================================================
|
---|
| 1170 | +
|
---|
| 1171 | +% Guillaume MAZE - LPO/LMD - March 2004
|
---|
| 1172 | +% gmaze@univ-brest.fr
|
---|
| 1173 | +
|
---|
| 1174 | + function varargout = calEeof(M,N,METHOD,NLAG,DT)
|
---|
| 1175 | +
|
---|
| 1176 | +% ---------------------------------
|
---|
| 1177 | +% Divers
|
---|
| 1178 | +tic
|
---|
| 1179 | +LAG = NLAG*DT;
|
---|
| 1180 | +foll = 1; % Turn this value to 0 if you don t want commentary along computing
|
---|
| 1181 | +
|
---|
| 1182 | +% ---------------------------------
|
---|
| 1183 | +% LAG must be >0, LAG=1 correspond to initial position
|
---|
| 1184 | +if LAG<=0
|
---|
| 1185 | + LAG = 1;
|
---|
| 1186 | +end
|
---|
| 1187 | +
|
---|
| 1188 | +% ---------------------------------
|
---|
| 1189 | +% Usely for us, M is a TIME*MAP matrix so:
|
---|
| 1190 | +% We get dimensions
|
---|
| 1191 | + [n p]=size(M);
|
---|
| 1192 | +% and put M in the correct form for computing
|
---|
| 1193 | + M = M';
|
---|
| 1194 | +
|
---|
| 1195 | +% ---------------------------------
|
---|
| 1196 | +% Eventualy time filtering of data
|
---|
| 1197 | +if 0==1
|
---|
| 1198 | + if (foll~=0),disp('==> Time filtering...');end
|
---|
| 1199 | + dt = 1; % Real time step of your data (diff from DT)
|
---|
| 1200 | + Fc = 1/dt/8; % This the low cut off frequency
|
---|
| 1201 | + Fc2 = 1/dt/2; % and this the high cut off frequency
|
---|
| 1202 | + SIGNAL = M(1,:);
|
---|
| 1203 | + nj = fix(length(SIGNAL)/10); % Nb of points of the window
|
---|
| 1204 | +
|
---|
| 1205 | + for ipt = 1 : p
|
---|
| 1206 | + SIGNAL = M(ipt,:)';
|
---|
| 1207 | + SIGNALF = lanczos(SIGNAL,Fc2,nj);
|
---|
| 1208 | + SIGNALF = SIGNALF - lanczos(SIGNALF,Fc,nj);
|
---|
| 1209 | + Y(:,ipt) = SIGNALF;
|
---|
| 1210 | + if mod(ipt,10)==0 % We display a plot of filtered data
|
---|
| 1211 | + clf;
|
---|
| 1212 | + plot((0:n-1),SIGNAL,'k',(0:n-1),SIGNALF,'r');
|
---|
| 1213 | + drawnow;
|
---|
| 1214 | + end
|
---|
| 1215 | + end
|
---|
| 1216 | + M = Y';
|
---|
| 1217 | +end, clear Fc Fc2 SIGNAL nj SIGNALF Y ipt, close
|
---|
| 1218 | +
|
---|
| 1219 | +
|
---|
| 1220 | +% ---------------------------------
|
---|
| 1221 | +% This is the matrix where we concat all submatrices from M.
|
---|
| 1222 | +% Size of each submatrix is : NLAG*p rows vs n-LAG+1 colums
|
---|
| 1223 | +F = zeros(NLAG*p,n-LAG+1);
|
---|
| 1224 | +
|
---|
| 1225 | +% ---------------------------------
|
---|
| 1226 | +% Let's go for F:
|
---|
| 1227 | +if (foll~=0),disp('==> Forming concatenated matrix...');end
|
---|
| 1228 | +if DT==1
|
---|
| 1229 | +% CLASSIC CASE
|
---|
| 1230 | +for ilag = 1 : LAG
|
---|
| 1231 | + % Extract submatrix ilag from M
|
---|
| 1232 | + Msub = M(:,ilag:n-LAG+ilag);
|
---|
| 1233 | + % Concat matrix
|
---|
| 1234 | + F( (ilag-1)*p+1 : ilag*p , : ) = Msub;
|
---|
| 1235 | +end
|
---|
| 1236 | +else
|
---|
| 1237 | +% DT>1
|
---|
| 1238 | +it=0;
|
---|
| 1239 | +for ilag = 1 : DT : LAG
|
---|
| 1240 | + % Extract submatrix ilag from M
|
---|
| 1241 | + Msub = M( : , ilag : n-LAG+ilag);
|
---|
| 1242 | + % Concat matrix
|
---|
| 1243 | + it = it + 1;
|
---|
| 1244 | + F( (it-1)*p+1 : it*p , : ) = Msub;
|
---|
| 1245 | + % imagesc(Msub);pause % for debugging
|
---|
| 1246 | +end
|
---|
| 1247 | +end
|
---|
| 1248 | +
|
---|
| 1249 | +% ---------------------------------
|
---|
| 1250 | +% Compute EOFs by normal way
|
---|
| 1251 | +% (Don't forget that caleof is taking a TIME*MAP argument matrix,
|
---|
| 1252 | +% that's why we have F' !)
|
---|
| 1253 | +if (foll~=0),disp('==> Computing EOFs ...');end
|
---|
| 1254 | +[e,pc,expvar] = caleof(F',N,METHOD);
|
---|
| 1255 | +
|
---|
| 1256 | +% ---------------------------------
|
---|
| 1257 | +% e is the matrix with EOFs inside. We should extract each map
|
---|
| 1258 | +% for different lags from it.
|
---|
| 1259 | +% e is NEOF*(LAG*MAP) and we construct 3D matrix CHP as NEOF*LAG*MAP
|
---|
| 1260 | +if (foll~=0),disp('==> Reshaping vectors ...');end
|
---|
| 1261 | +for ilag = 1 : NLAG
|
---|
| 1262 | + E = e( : , (ilag-1)*p+1 : ilag*p );
|
---|
| 1263 | + CHP(:,ilag,:) = E;
|
---|
| 1264 | +end
|
---|
| 1265 | +
|
---|
| 1266 | +
|
---|
| 1267 | +% ---------------------------------
|
---|
| 1268 | +% OUTPUT VARIABLES
|
---|
| 1269 | +switch nargout
|
---|
| 1270 | + case 1
|
---|
| 1271 | + varargout(1) = {CHP} ;
|
---|
| 1272 | + case 2
|
---|
| 1273 | + varargout(1) = {CHP} ;
|
---|
| 1274 | + varargout(2) = {pc};
|
---|
| 1275 | + case 3
|
---|
| 1276 | + varargout(1) = {CHP} ;
|
---|
| 1277 | + varargout(2) = {pc};
|
---|
| 1278 | + varargout(3) = {expvar};
|
---|
| 1279 | +end
|
---|
| 1280 | +
|
---|
| 1281 | +% ---------------------------------
|
---|
| 1282 | +if (foll~=0),toc,disp('==> That''s all folks !');end
|
---|
| 1283 | Index: ../trunk-jpl/externalpackages/pcatool/install/calsvd2.m
|
---|
| 1284 | ===================================================================
|
---|
| 1285 | --- ../trunk-jpl/externalpackages/pcatool/install/calsvd2.m (revision 0)
|
---|
| 1286 | +++ ../trunk-jpl/externalpackages/pcatool/install/calsvd2.m (revision 21589)
|
---|
| 1287 | @@ -0,0 +1,49 @@
|
---|
| 1288 | +% [SVD1,SVD2,PC1,PC2,EXPVAR,Lambda] = CALSVD2(A,B,N) Compute SVDs
|
---|
| 1289 | +%
|
---|
| 1290 | +% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
|
---|
| 1291 | +% Analyses of climatic Data" 1997
|
---|
| 1292 | +%================================================================
|
---|
| 1293 | +%
|
---|
| 1294 | +% Guillaume MAZE - LPO/LMD - March 2004
|
---|
| 1295 | +% gmaze@univ-brest.fr
|
---|
| 1296 | +
|
---|
| 1297 | +
|
---|
| 1298 | + function [e1,e2,pc1,pc2,expvar,Lambda,dsumCF] = calsvd2(A,B,N);
|
---|
| 1299 | +
|
---|
| 1300 | +
|
---|
| 1301 | +%================================================================
|
---|
| 1302 | +% Ref: H. Bjornson and S.A. Venegas: "A manual for EOF and SVD -
|
---|
| 1303 | +% Analyses of climatic Data" 1997 => p18
|
---|
| 1304 | +
|
---|
| 1305 | +% Assume that A is (time*map) matrix
|
---|
| 1306 | +[n p]=size(A);
|
---|
| 1307 | +
|
---|
| 1308 | +% Remove the mean of each column (ie the time mean in each station records)
|
---|
| 1309 | +S=detrend(A,'constant');
|
---|
| 1310 | +P=detrend(B,'constant');
|
---|
| 1311 | +
|
---|
| 1312 | +% Form the covariance matrix:
|
---|
| 1313 | +C=S'*P;
|
---|
| 1314 | +
|
---|
| 1315 | +% Find eigenvectors and singular values
|
---|
| 1316 | +[U,Lambda,V] = svds(C,N);
|
---|
| 1317 | +
|
---|
| 1318 | +% PC
|
---|
| 1319 | +a=S*U;
|
---|
| 1320 | +b=P*V;
|
---|
| 1321 | +
|
---|
| 1322 | +% Make them clear for output
|
---|
| 1323 | +for iN=1:N
|
---|
| 1324 | + e1(iN,:) = squeeze( U(:,iN) )';
|
---|
| 1325 | + pc1(iN,:) = squeeze( a(:,iN) )';
|
---|
| 1326 | + e2(iN,:) = squeeze( V(:,iN) )';
|
---|
| 1327 | + pc2(iN,:) = squeeze( b(:,iN) )';
|
---|
| 1328 | +end
|
---|
| 1329 | +
|
---|
| 1330 | +% Amount of variance explained a 0.1 pres et en %
|
---|
| 1331 | +L2=Lambda.^2;
|
---|
| 1332 | +dsum=diag(L2)/trace(L2);
|
---|
| 1333 | +for iN=1:N
|
---|
| 1334 | + expvar(iN)=fix( ( dsum(iN)*100/sum(dsum) )*10 ) /10;
|
---|
| 1335 | +end
|
---|
| 1336 | +
|
---|
| 1337 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispEEOF.m
|
---|
| 1338 | ===================================================================
|
---|
| 1339 | --- ../trunk-jpl/externalpackages/pcatool/install/dispEEOF.m (revision 0)
|
---|
| 1340 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispEEOF.m (revision 21589)
|
---|
| 1341 | @@ -0,0 +1,57 @@
|
---|
| 1342 | +% dispEEOF(CHP,EXPVAR,DT,NLAG,MOD) Display few EEOFs.
|
---|
| 1343 | +%
|
---|
| 1344 | +% => DISPLAY FEW EEOFs.
|
---|
| 1345 | +% CHP contains all the EEOFs as EOF*LAG*X*Y.
|
---|
| 1346 | +% EXPVAR is a matrix with the explained variance of each
|
---|
| 1347 | +% EEOFs in %. This is just for title.
|
---|
| 1348 | +% DT is time step between maps.
|
---|
| 1349 | +% NLAG is the number of LAG to display.
|
---|
| 1350 | +% MOD contains explicitly the EEOFs to display.
|
---|
| 1351 | +%
|
---|
| 1352 | +% Rq: it's using the plotm function
|
---|
| 1353 | +%
|
---|
| 1354 | +%================================================================
|
---|
| 1355 | +
|
---|
| 1356 | +% Guillaume MAZE - LPO/LMD - March 2004
|
---|
| 1357 | +% gmaze@univ-brest.fr
|
---|
| 1358 | +
|
---|
| 1359 | +function [] = dispEEOF(CHP,EXPVAR,DT,NLAG,MOD)
|
---|
| 1360 | +
|
---|
| 1361 | +% Number of EEOF to display
|
---|
| 1362 | +NMOD = length(MOD);
|
---|
| 1363 | +
|
---|
| 1364 | +% Open figure and first guest
|
---|
| 1365 | +figur;
|
---|
| 1366 | +clf;hold on
|
---|
| 1367 | +typg=8;
|
---|
| 1368 | +width = .9/NMOD;
|
---|
| 1369 | +height = .9/NLAG;
|
---|
| 1370 | +dleft = (.95-width*NMOD)/4;
|
---|
| 1371 | +left = dleft;
|
---|
| 1372 | +load mapanom
|
---|
| 1373 | +
|
---|
| 1374 | +% Let'go :
|
---|
| 1375 | +
|
---|
| 1376 | +% We choose an EEOF
|
---|
| 1377 | +for imod = 1 : NMOD
|
---|
| 1378 | + mod = MOD(imod);
|
---|
| 1379 | +
|
---|
| 1380 | + % and plot maps
|
---|
| 1381 | + for lag=1:NLAG
|
---|
| 1382 | + bottom = .95-height*lag;
|
---|
| 1383 | + subplot('Position',[left bottom width height]);
|
---|
| 1384 | + C = squeeze(real(CHP(mod,lag,:,:)));
|
---|
| 1385 | +% C = C./xtrm(C); % Eventually normalise field
|
---|
| 1386 | + plotm(C,typg);
|
---|
| 1387 | + if(lag==1),caxis([-abs(xtrm(C)) abs(xtrm(C))]);cx=caxis;end;
|
---|
| 1388 | + caxis(cx);
|
---|
| 1389 | + colormap(mapanom);
|
---|
| 1390 | + if(lag==1)
|
---|
| 1391 | + titre=strcat('EOF',num2str(mod),'(',num2str(EXPVAR(mod)),'%)');
|
---|
| 1392 | + titre=strcat(titre,'; DT=',num2str(DT),' ');
|
---|
| 1393 | + title(titre);
|
---|
| 1394 | + end;
|
---|
| 1395 | + end
|
---|
| 1396 | + left = left + width + dleft;
|
---|
| 1397 | +
|
---|
| 1398 | +end
|
---|
| 1399 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispSVDnbc.m
|
---|
| 1400 | ===================================================================
|
---|
| 1401 | --- ../trunk-jpl/externalpackages/pcatool/install/dispSVDnbc.m (revision 0)
|
---|
| 1402 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispSVDnbc.m (revision 21589)
|
---|
| 1403 | @@ -0,0 +1,66 @@
|
---|
| 1404 | +% dispSVDnb(typg,CHP1,CHP2,N,expvar) Display SVDs
|
---|
| 1405 | +%
|
---|
| 1406 | +% => Display SVDs in white and black with correlation form
|
---|
| 1407 | +% typg is plot type you want (see plotm.m).
|
---|
| 1408 | +% CHP contains SVDs and is of the form: CHP(iSVD,X,Y)
|
---|
| 1409 | +% N is number of SVD to display
|
---|
| 1410 | +% expvar contained the explained variance of SVDs
|
---|
| 1411 | +%
|
---|
| 1412 | +% Rq: it''s using the plotmNB function
|
---|
| 1413 | +%
|
---|
| 1414 | +%================================================================
|
---|
| 1415 | +
|
---|
| 1416 | +% Guillaume MAZE - LPO/LMD - December 2004
|
---|
| 1417 | +% gmaze@univ-brest.fr
|
---|
| 1418 | +
|
---|
| 1419 | +function [] = dispSVDnbc(typg,CHP1,CHP2,N,expvar)
|
---|
| 1420 | +
|
---|
| 1421 | +global ffile1 ffile2 nbcont
|
---|
| 1422 | +nbcont=[-1:0.2:1];
|
---|
| 1423 | +nbcont2=[-1:0.4:1];
|
---|
| 1424 | +
|
---|
| 1425 | +% --------------------------------------------------
|
---|
| 1426 | +% AFFICHAGE
|
---|
| 1427 | +% --------------------------------------------------
|
---|
| 1428 | +if (typg~=1)&(typg~=7)&(typg~=3)&(typg~=6)
|
---|
| 1429 | + CBAROR='horiz';
|
---|
| 1430 | + iw=N;jw=2;
|
---|
| 1431 | +else
|
---|
| 1432 | + CBAROR='vert';
|
---|
| 1433 | + iw=N;jw=2;
|
---|
| 1434 | +end
|
---|
| 1435 | +
|
---|
| 1436 | +
|
---|
| 1437 | +f1=figur;clf; hold on
|
---|
| 1438 | +for iN=1:N
|
---|
| 1439 | + subplot(iw,jw,2*iN-1)
|
---|
| 1440 | +C = squeeze(real(CHP1(iN,:,:)));
|
---|
| 1441 | +[cs,h]=plotmNB(C,typg);
|
---|
| 1442 | +clabel(cs,h,nbcont2,'labelspacing',100,'fontsize',9);
|
---|
| 1443 | +titre1=strcat('SVD',num2str(iN),':',ffile1);
|
---|
| 1444 | +titre2=strcat(' (',num2str(expvar(iN)),'%)');
|
---|
| 1445 | +title(strcat(titre1,titre2));
|
---|
| 1446 | +
|
---|
| 1447 | + subplot(iw,jw,2*iN)
|
---|
| 1448 | +C = squeeze(real(CHP2(iN,:,:)));
|
---|
| 1449 | +[cs,h]=plotmNB(C,typg);
|
---|
| 1450 | +clabel(cs,h,nbcont2,'labelspacing',100,'fontsize',9);
|
---|
| 1451 | +%clabel(cs,h,'labelspacing',100);
|
---|
| 1452 | +titre1=strcat('SVD',num2str(iN),':',ffile2);
|
---|
| 1453 | +titre2=strcat(' (',num2str(expvar(iN)),'%)');
|
---|
| 1454 | +title(strcat(titre1,titre2));
|
---|
| 1455 | +
|
---|
| 1456 | +end %for iN
|
---|
| 1457 | +
|
---|
| 1458 | +
|
---|
| 1459 | +
|
---|
| 1460 | +
|
---|
| 1461 | +%titre1=strcat(num2str(lat(il1)),'/',num2str(lat(il2)));
|
---|
| 1462 | +titre2=strcat(' Total explained variance:',num2str(sum(expvar)),'%');
|
---|
| 1463 | +%titre3=strcat('(Analysed files: ',ffile1,' vs ',ffile2,')');
|
---|
| 1464 | +%titre=strvcat(titre2,titre3);
|
---|
| 1465 | +suptitle(titre2);
|
---|
| 1466 | +
|
---|
| 1467 | +set(f1,'Position',[378 39 313 647]); % Laptop screen
|
---|
| 1468 | +%set(f1,'Position',[369 55 316 899]); % Desktop screen
|
---|
| 1469 | +%set(f1,'Name',strcat(ffile,'<>',titre1,'<> REAL PART'));
|
---|
| 1470 | Index: ../trunk-jpl/externalpackages/pcatool/install/test_pcatool.m
|
---|
| 1471 | ===================================================================
|
---|
| 1472 | --- ../trunk-jpl/externalpackages/pcatool/install/test_pcatool.m (revision 0)
|
---|
| 1473 | +++ ../trunk-jpl/externalpackages/pcatool/install/test_pcatool.m (revision 21589)
|
---|
| 1474 | @@ -0,0 +1,160 @@
|
---|
| 1475 | +% Here is a simple script to test caleof.m from PCATOOL package.
|
---|
| 1476 | +%
|
---|
| 1477 | +
|
---|
| 1478 | +% gmaze@mit.edu
|
---|
| 1479 | +% 2006/07/31
|
---|
| 1480 | +%
|
---|
| 1481 | +
|
---|
| 1482 | +clear
|
---|
| 1483 | +
|
---|
| 1484 | +field = 1; % The best one
|
---|
| 1485 | +
|
---|
| 1486 | +% Generate the data
|
---|
| 1487 | +x = -10 : 1 : 10 ;
|
---|
| 1488 | +y = x;
|
---|
| 1489 | +[X,Y] = meshgrid(x,y);
|
---|
| 1490 | +
|
---|
| 1491 | +switch field
|
---|
| 1492 | + case 1 % H. Bjornson and S.A. Venegas
|
---|
| 1493 | + HH = 12*( 1.2 - 0.35*sqrt( (X-0).^2 + (Y-0).^2 ) );
|
---|
| 1494 | + HH = HH - mean(mean(HH));
|
---|
| 1495 | + H(1,:,:) = 1012 + HH;
|
---|
| 1496 | + H(2,:,:) = 1012 + (1012-squeeze(H(1,:,:)));;
|
---|
| 1497 | + H(3,:,:) = 1022.8 - 3.6*Y;
|
---|
| 1498 | + H(4,:,:) = 1012 + (1012-squeeze(H(3,:,:)));
|
---|
| 1499 | + H(5,:,:) = 1001.2 + 3.6*X;
|
---|
| 1500 | + H(6,:,:) = 1012 + (1012-squeeze(H(5,:,:)));
|
---|
| 1501 | + cont = [980:5:1050];
|
---|
| 1502 | + N = 2;
|
---|
| 1503 | +
|
---|
| 1504 | + case 11 % H. Bjornson and S.A. Venegas modified
|
---|
| 1505 | + % Here it must be only 2 non-zero EOF (45degre oriented ) of similar variance 50%
|
---|
| 1506 | + H = ones(4,length(x),length(y));
|
---|
| 1507 | + H(1,:,:) = Y;
|
---|
| 1508 | + H(2,:,:) = -Y;
|
---|
| 1509 | + H(3,:,:) = X;
|
---|
| 1510 | + H(4,:,:) = -X;
|
---|
| 1511 | + N = 2;
|
---|
| 1512 | +
|
---|
| 1513 | + case 2 % Hartmann eg: analysis in place
|
---|
| 1514 | + a = [2 4 -6 8 ; 1 2 -3 4];
|
---|
| 1515 | + H(1,:,:) = a(1,:)';
|
---|
| 1516 | + H(2,:,:) = a(2,:)';
|
---|
| 1517 | +
|
---|
| 1518 | + % Get EOFs:
|
---|
| 1519 | + N = 4;
|
---|
| 1520 | + for method = 2 : -1 : 1
|
---|
| 1521 | + [E,pc,expvar] = caleof(H,N,method);
|
---|
| 1522 | + %E'
|
---|
| 1523 | + end
|
---|
| 1524 | +
|
---|
| 1525 | + return
|
---|
| 1526 | +
|
---|
| 1527 | + case 3 % My signal
|
---|
| 1528 | + np = 4; % Numer of random signal (...and eof)
|
---|
| 1529 | + nt = 10; % Number of timestep
|
---|
| 1530 | + H = zeros(nt,length(x),length(y));
|
---|
| 1531 | + for ip = 1 : np
|
---|
| 1532 | + xc(ip) = abs(fix(rand(1)*10));
|
---|
| 1533 | + yc(ip) = abs(fix(rand(1)*10));
|
---|
| 1534 | + if ip>=fix(np/2)
|
---|
| 1535 | + xc(ip) = -xc(ip);
|
---|
| 1536 | + yc(ip) = -yc(ip);
|
---|
| 1537 | + end
|
---|
| 1538 | + dd(ip) = fix(rand(1)*10);
|
---|
| 1539 | + end %for ip
|
---|
| 1540 | + f = 1/nt;
|
---|
| 1541 | + for it = 1 : nt
|
---|
| 1542 | + H2 = zeros(length(x),length(y));
|
---|
| 1543 | + for ip = 1 : ip
|
---|
| 1544 | + if it==1,[xc(ip) yc(ip) dd(ip)],end
|
---|
| 1545 | + HH = 12*( 1.2 - 0.35*sqrt( ((X-xc(ip)).^2 + (Y-yc(ip)).^2 )/dd(ip) ));
|
---|
| 1546 | + H2 = HH - mean(mean(HH));
|
---|
| 1547 | + H(it,:,:) = squeeze(H(it,:,:)) + H2.*cos(pi*it/dd(ip)) ;
|
---|
| 1548 | + end %for ip
|
---|
| 1549 | + end %for it
|
---|
| 1550 | + H = 1012 + H;
|
---|
| 1551 | + cont = [980:5:1050];
|
---|
| 1552 | + N = 3;
|
---|
| 1553 | +
|
---|
| 1554 | + case 4 % My signal 2
|
---|
| 1555 | + x = -pi : pi/6 : pi ;
|
---|
| 1556 | + y = x;
|
---|
| 1557 | + [X,Y] = meshgrid(x,y);
|
---|
| 1558 | + HH = cos(X) + cos(Y);
|
---|
| 1559 | + HH2 = cos(Y);
|
---|
| 1560 | + nt = 12;
|
---|
| 1561 | + for it = 1 : nt
|
---|
| 1562 | +% H(it,:,:) = cos(pi*it/nt)*HH; cont=[-2 2];
|
---|
| 1563 | + H(it,:,:) = 2*cos(pi*it/nt)*HH + 3*cos(pi*it/nt/2)*HH2; cont=[-10 10];
|
---|
| 1564 | + xtrm(squeeze(H(it,:,:)));
|
---|
| 1565 | + end
|
---|
| 1566 | + cont=[-2 2];
|
---|
| 1567 | + N = 3;
|
---|
| 1568 | +
|
---|
| 1569 | +end % switch field
|
---|
| 1570 | +
|
---|
| 1571 | +%return
|
---|
| 1572 | +
|
---|
| 1573 | +% Plot field time serie:
|
---|
| 1574 | +if 1
|
---|
| 1575 | +figure;iw=2;jw=size(H,1)/iw;
|
---|
| 1576 | +set(gcf,'position',[11 533 560 420]);
|
---|
| 1577 | +
|
---|
| 1578 | +for i=1:iw*jw
|
---|
| 1579 | + C = squeeze(H(i,:,:));
|
---|
| 1580 | +
|
---|
| 1581 | + subplot(iw,jw,i);
|
---|
| 1582 | + pcolor(X,Y,C);
|
---|
| 1583 | + title(num2str(i));
|
---|
| 1584 | + if i==1,cx=caxis;end
|
---|
| 1585 | + axis square
|
---|
| 1586 | + caxis(cx);
|
---|
| 1587 | +
|
---|
| 1588 | +end %for i
|
---|
| 1589 | +end %fi
|
---|
| 1590 | +%return
|
---|
| 1591 | +
|
---|
| 1592 | +% Get EOFs:
|
---|
| 1593 | +G = map2mat(ones(size(H,2),size(H,3)),H);
|
---|
| 1594 | +
|
---|
| 1595 | +for method = 1 : 4
|
---|
| 1596 | + [E,pc,expvar] = caleof(G,N,method);
|
---|
| 1597 | + eof = mat2map(ones(size(H,2),size(H,3)),E);
|
---|
| 1598 | +
|
---|
| 1599 | +
|
---|
| 1600 | +figure;iw=1;jw=N+1;
|
---|
| 1601 | +set(gcf,'MenuBar','none');
|
---|
| 1602 | +posi = [576 0 710 205];
|
---|
| 1603 | +set(gcf,'position',[posi(1) (method-1)*250+50 posi(3) posi(4)]);
|
---|
| 1604 | +
|
---|
| 1605 | +for i=1:iw*jw
|
---|
| 1606 | + if i<= iw*jw-1
|
---|
| 1607 | +
|
---|
| 1608 | + C = squeeze(eof(i,:,:));
|
---|
| 1609 | + subplot(iw,jw,i);
|
---|
| 1610 | + cont = 12;
|
---|
| 1611 | + [cs,h] = contourf(X,Y,C,cont);
|
---|
| 1612 | + clabel(cs,h);
|
---|
| 1613 | + title(strcat('EOF:',num2str(i),'/',num2str(expvar(i)),'%'));
|
---|
| 1614 | + axis square;
|
---|
| 1615 | + %caxis([cont(1) cont(end)]);
|
---|
| 1616 | +
|
---|
| 1617 | + else
|
---|
| 1618 | + subplot(iw,jw,iw*jw);
|
---|
| 1619 | + plot(pc');
|
---|
| 1620 | + grid on
|
---|
| 1621 | + xlabel('time')
|
---|
| 1622 | + title('PC')
|
---|
| 1623 | + legend(num2str([1:N]'),2);
|
---|
| 1624 | + box on
|
---|
| 1625 | +
|
---|
| 1626 | +
|
---|
| 1627 | + end %if
|
---|
| 1628 | +
|
---|
| 1629 | +end %for i
|
---|
| 1630 | +%suptitle(strcat('METHODE:',num2str(method)));
|
---|
| 1631 | +
|
---|
| 1632 | +end %for method
|
---|
| 1633 | +
|
---|
| 1634 | +
|
---|
| 1635 | Index: ../trunk-jpl/externalpackages/pcatool/install/dispSVDlag.m
|
---|
| 1636 | ===================================================================
|
---|
| 1637 | --- ../trunk-jpl/externalpackages/pcatool/install/dispSVDlag.m (revision 0)
|
---|
| 1638 | +++ ../trunk-jpl/externalpackages/pcatool/install/dispSVDlag.m (revision 21589)
|
---|
| 1639 | @@ -0,0 +1,62 @@
|
---|
| 1640 | +% dispSVDlag(typg,CHP1,CHP2,N,expvar,LAGS,dt) Display SVDs lagged
|
---|
| 1641 | +%
|
---|
| 1642 | +% => Display SVDs lagged
|
---|
| 1643 | +% typg is plot type you want (see plotm.m).
|
---|
| 1644 | +% CHP contains SVDs and is of the form: CHP(iSVD,X,Y)
|
---|
| 1645 | +% N is number of SVD to display
|
---|
| 1646 | +% expvar contained the explained variance of SVDs
|
---|
| 1647 | +%
|
---|
| 1648 | +% Rq: it''s using the plotm function
|
---|
| 1649 | +%
|
---|
| 1650 | +%================================================================
|
---|
| 1651 | +
|
---|
| 1652 | +% Guillaume MAZE - LPO/LMD - December 2004
|
---|
| 1653 | +% gmaze@univ-brest.fr
|
---|
| 1654 | +
|
---|
| 1655 | + function [] = dispSVD(typg,CHP1,CHP2,N,expvar,LAGS,dt)
|
---|
| 1656 | +
|
---|
| 1657 | +load mapanom2
|
---|
| 1658 | +global ffile1 ffile2
|
---|
| 1659 | +% --------------------------------------------------
|
---|
| 1660 | +% AFFICHAGE
|
---|
| 1661 | +% --------------------------------------------------
|
---|
| 1662 | +if (typg~=1)&(typg~=7)&(typg~=3)&(typg~=6)
|
---|
| 1663 | + CBAROR='horiz';
|
---|
| 1664 | +else
|
---|
| 1665 | + CBAROR='vert';
|
---|
| 1666 | +end
|
---|
| 1667 | +
|
---|
| 1668 | + CHP1=squeeze(CHP1(:,N,:,:));
|
---|
| 1669 | + CHP2=squeeze(CHP2(:,N,:,:));
|
---|
| 1670 | +
|
---|
| 1671 | +Nlag=size(CHP1,1);
|
---|
| 1672 | +
|
---|
| 1673 | +iw=round(Nlag/dt);jw=2;
|
---|
| 1674 | +
|
---|
| 1675 | +
|
---|
| 1676 | +f1=figur;clf; hold on
|
---|
| 1677 | +ilag=0;
|
---|
| 1678 | +for lag=1:dt:Nlag
|
---|
| 1679 | + ilag=ilag+1;
|
---|
| 1680 | +
|
---|
| 1681 | + subplot(iw,jw,2*ilag-1)
|
---|
| 1682 | +C = squeeze(real(CHP1(lag,:,:)));
|
---|
| 1683 | +plotm(C,typg);caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 1684 | +if(ilag==1);cx=caxis;end;caxis(cx);
|
---|
| 1685 | +colormap(mycolormap(mapanom,21));
|
---|
| 1686 | +c=colorbar(CBAROR);
|
---|
| 1687 | +titre1=strcat('lag:',num2str(LAGS(lag)),'y: ',ffile1);
|
---|
| 1688 | +title(titre1);
|
---|
| 1689 | +
|
---|
| 1690 | + subplot(iw,jw,2*ilag)
|
---|
| 1691 | +C = squeeze(real(CHP2(lag,:,:)));
|
---|
| 1692 | +plotm(C,typg);caxis([-abs(xtrm(C)) abs(xtrm(C))]);
|
---|
| 1693 | +if(ilag==1);cx=caxis;end;caxis(cx);
|
---|
| 1694 | +colormap(mycolormap(mapanom,21));
|
---|
| 1695 | +c=colorbar(CBAROR);
|
---|
| 1696 | +titre1=strcat('lag:',num2str(LAGS(lag)),'y: ',ffile2);
|
---|
| 1697 | +title(titre1);
|
---|
| 1698 | +
|
---|
| 1699 | +end %for iN
|
---|
| 1700 | +
|
---|
| 1701 | +suptitle(strcat('Lagged SVD, mode:',num2str(N)));
|
---|
| 1702 | Index: ../trunk-jpl/externalpackages/pcatool/install/map2mat.m
|
---|
| 1703 | ===================================================================
|
---|
| 1704 | --- ../trunk-jpl/externalpackages/pcatool/install/map2mat.m (revision 0)
|
---|
| 1705 | +++ ../trunk-jpl/externalpackages/pcatool/install/map2mat.m (revision 21589)
|
---|
| 1706 | @@ -0,0 +1,40 @@
|
---|
| 1707 | +% D = MAP2MAT(F,C) Reshaping matrix
|
---|
| 1708 | +%
|
---|
| 1709 | +% => Conversion of a 'map' matrix C(TIME,LON,LAT) into a D(TIME,PT) matrix
|
---|
| 1710 | +% under the mask F(LON,LAT).
|
---|
| 1711 | +% F is a matrix contenaing 1 where you would like to keep the point and
|
---|
| 1712 | +% 0 elsewhere.
|
---|
| 1713 | +%
|
---|
| 1714 | +% Rq: No check is done about the input.
|
---|
| 1715 | +%
|
---|
| 1716 | +% See also: mat2map
|
---|
| 1717 | +%================================================================
|
---|
| 1718 | +
|
---|
| 1719 | +% March 2004
|
---|
| 1720 | +% gmaze@univ-brest.fr
|
---|
| 1721 | +
|
---|
| 1722 | +function [D] = map2mat(F,C);
|
---|
| 1723 | +
|
---|
| 1724 | +% Get dimensions
|
---|
| 1725 | +[tps nolon nolat] = size(C);
|
---|
| 1726 | +
|
---|
| 1727 | +% So output matrix will be:
|
---|
| 1728 | +D = zeros(tps,nolon*nolat);
|
---|
| 1729 | +
|
---|
| 1730 | +% point indice
|
---|
| 1731 | +ipt = 0;
|
---|
| 1732 | +
|
---|
| 1733 | +% 'Un-mapping' :
|
---|
| 1734 | +for iy=1:nolat
|
---|
| 1735 | + for ix=1:nolon
|
---|
| 1736 | + if F(ix,iy)>0
|
---|
| 1737 | + ipt = ipt + 1;
|
---|
| 1738 | + D(:,ipt)=squeeze(C(:,ix,iy));
|
---|
| 1739 | + end % if
|
---|
| 1740 | + end % for
|
---|
| 1741 | +end %for
|
---|
| 1742 | +
|
---|
| 1743 | +% OUTPUT:
|
---|
| 1744 | +D = squeeze(D(:,1:ipt));
|
---|
| 1745 | +
|
---|
| 1746 | +
|
---|
| 1747 | Index: ../trunk-jpl/externalpackages/pcatool/install/mat2map.m
|
---|
| 1748 | ===================================================================
|
---|
| 1749 | --- ../trunk-jpl/externalpackages/pcatool/install/mat2map.m (revision 0)
|
---|
| 1750 | +++ ../trunk-jpl/externalpackages/pcatool/install/mat2map.m (revision 21589)
|
---|
| 1751 | @@ -0,0 +1,41 @@
|
---|
| 1752 | +% C = MAP2MAT(F,D) Reshaping matrix
|
---|
| 1753 | +%
|
---|
| 1754 | +% => Creation of a 'map' matrix C(TIME,LON,LAT) from D(TIME,PT)
|
---|
| 1755 | +% following mask F(LON,LAT).
|
---|
| 1756 | +% F is a matrix contenaing 1 where you would like to keep the point and
|
---|
| 1757 | +% 0 elsewhere (see mat2map).
|
---|
| 1758 | +%
|
---|
| 1759 | +% Rq: No check is done about the input.
|
---|
| 1760 | +%
|
---|
| 1761 | +% See also: map2mat
|
---|
| 1762 | +%================================================================
|
---|
| 1763 | +
|
---|
| 1764 | +% March 2004
|
---|
| 1765 | +% gmaze@univ-brest.fr
|
---|
| 1766 | +
|
---|
| 1767 | +function [C] = mat2map(F,D);
|
---|
| 1768 | +
|
---|
| 1769 | +% Get dimensions
|
---|
| 1770 | +[nolon nolat] = size(F);
|
---|
| 1771 | +[time npt] = size(D);
|
---|
| 1772 | +
|
---|
| 1773 | +% So output 'map' matrix has the form:
|
---|
| 1774 | +C = zeros(time,nolon,nolat);
|
---|
| 1775 | +
|
---|
| 1776 | +% Variables
|
---|
| 1777 | +nul = NaN.*ones(time,1);
|
---|
| 1778 | +ipt = 0 ;
|
---|
| 1779 | +
|
---|
| 1780 | +
|
---|
| 1781 | +% 'mapping' :
|
---|
| 1782 | + for iy=1:nolat
|
---|
| 1783 | + for ix=1:nolon
|
---|
| 1784 | + if F(ix,iy)>0
|
---|
| 1785 | + ipt = ipt + 1;
|
---|
| 1786 | + C(:,ix,iy) = D(:,ipt);
|
---|
| 1787 | + else
|
---|
| 1788 | + C(:,ix,iy) = nul;
|
---|
| 1789 | + end %if
|
---|
| 1790 | + end %for ix
|
---|
| 1791 | + end %for iy
|
---|
| 1792 | +
|
---|