# csdms-contrib/slepian_echo

Switch branches/tags
Nothing to show
Fetching contributors…
Cannot retrieve contributors at this time
533 lines (487 sloc) 17.9 KB
 function varargout=loris5(wav,N,J,precon,depkm,xver,gnorjr,panel) % [vw,depkm,vstats]=LORIS5(wav,N,J,precon,depkm,xver,gnorjr,panel) % % Study of the sparsity in the models of Montelli and Ritsema % Learn from the depth-dependence of scales in a seismic model. % % INPUT: % % wav The chosen wavelet construction used, 'D2', 'D4' or 'D6' % N The power of the dyadic subdivision for the cubed sphere % J Maximum scale in both directions for the wavelet analysis % precon [1|0 1|0] toggles preconditioning in either dimension % depkm The single depth in km where the model is read and the results of the % calculations are saved - must match exactly. If a vector or % empty then you work on the result and get a plot % xver For extra verification showing some intermediate results % gnorjr 1 For the model by Montelli et al. (2006) % 2 For the model by Ritsema et al. (2010) % panel 0 Does all panels [default] % 1-6 Picks a specific panel % % OUTPUT: % % vw The wavelet-transformed single-depth cubed-sphere for all chunks % or: the panel number if you're in all-depths output mode % depkm The depth in km, if you didn't already know it % vstats A cell structure with the statistics per scale and depth % % EXAMPLE: % % panel=0; % loris5('D4',7,4,[1 1],[],0,1,panel) % Paper figure A % loris5('D4',7,4,[1 1],[],0,2) % Paper figure B % % Tested on 8.3.0.532 (R2014a) and 9.0.0.341360 (R2016a) % Reviewed by gyin-at-princeton.edu, 07/22/2016 % Last modified by fjsimons-at-alum.mit.edu, 07/22/2016 % Identify defaults defval('wav','D4') defval('N',7) defval('J',N-3-strcmp(wav,'D6')) defval('precon',[1 1]); % d=readGNmodel(NaN); % This should hold both for Montelli and Ritsema d=load('/u/fjsimons/IFILES/EARTHMODELS/MONTELLI/GNdepths'); defval('depkm',d/1000); defval('xver',0); defval('fs',11); defval('panel',0); % If 1, GN model, if 2, JR model defval('gnorjr',1) % Hardwired Earth radius, not ideal, see readGNmodel rearthkm=6371; % How many depth layers? ndeps=length(depkm); % The default is to do all depths and save the transform calculations if % they don't exist for the next time you run the program if gnorjr==1 % And now define what will come out of the analysis at the end fname2=fullfile(getenv('IFILES'),'EARTHMODELS','MONTELLI','LORIS',... sprintf('loris5_GN_%i_%i_%s_%i_%i_%i.mat',... N,J,wav,precon(1),precon(2),panel)); elseif gnorjr==2 % And now define what will come out of the analysis at the end fname2=fullfile(getenv('IFILES'),'EARTHMODELS','RITSEMA','LORIS',... sprintf('loris5_JR_%i_%i_%s_%i_%i_%i.mat',... N,J,wav,precon(1),precon(2),panel)); end % If all of the depths are to be revisited if ndeps>1 if exist(fname2,'file')==2 load(fname2) else % The percentiles that will be CALCULATED percs=[85 100]; % Study the properties of this one thresholding percentage tperc=85; % Title for the x axis xlstring1=sprintf('%s wavelet | scaling coefficients',wav); % Identify the scales in the mr=1 wavelet transform % Do one more than J so the last one is the scaling coefficients [vwlev,vwlevs]=cube2scale(N,[J J]+1,1); % Potential check at a random depth deptsj=max(1,randi(ndeps)); % Initialize the structure array for good measure fields={'deptkm','percts','mjuvar','totnum','tcount','normsq'}; % And how many here will populate this? nmflds={1, length(percs),2, 1, 1, 1 }; nmcols=[1 J+1 J+1 J+1 J+1 J+1 ]; nmrows=[ndeps ndeps ndeps 1 ndeps ndeps]; % Note that being this specific saves memory but increases speed vwstats=structempty(fields); for index=1:length(fields) vwstats.(fields{index})=... cellnan([nmrows(index) nmcols(index)],1,nmflds{index}); end % End initialization of the structure array with the results % Then we call ourselves once per depth layer, still for the straight J for index=1:ndeps % Remember that this function calls itself [vw,depchk,vstats]=... loris5(wav,N,J,precon,depkm(index),xver,gnorjr,panel); difer(depchk-depkm(index),[],[],NaN) % Here we do the panel nulling, or should we do picking if ~~panel vw(:,:,skip(1:6,panel))=0; % Let's see what picking does instead vw=vw(:,:,panel); % Remember the vwlevs was just copies in 3D vwlevs=vwlev; end % Quick plot? if xver==1 && index==deptsj for jndex=1:J+1 vwnul=vw; vwnul(vwlevs==jndex)=100; title(sprintf('Check at depth %i for scale %i',index,jndex)) % This subfunction makes a quick wavelet coefficient plot clf [cb,xcb]=quickplot(N,J,vwnul,depkm(index)); pause(1) end end % Remember, we work with the absolute values! But save the originals vworg=vw; vw=abs(vw); % Prepare for the study of the effects of their thresholding which is % here carried out per individual depth kilme=vw