function varargout=ptoslep(phi,theta,omega,TH,L,m,amax) % [lm,cosi,glma,EL,EM,V]=PTOSLEP(phi,theta,omega,TH,L,m,amax) % % Computes SINGLE-CAP FIXED-ORDER azimuthally rotated bandlimited or % passband Slepian tapers centered at a desired geographical location % from an initial North-Polar location, that is. % % INPUT: % % phi Longitude of the new center (degrees) % theta Colatitude of the new center (degrees) % omega Clockwise azimuthal rotation (degrees) % This is consistent with PLM2ROT(lmcosi,omega,-theta,-phi) % TH Radius of the concentration region (degrees) % L Bandwidth of the Slepian basis, or passband (two degrees) % m Single angular order of the Slepian basis function, -l=0))=C(:,index); % Rotate the tapers to a position on the sphere tempry=kindeks(plm2rot(lmcosi,omega,-theta,-phi),3:4); % Put them into the lmcosi type matrix cosi(:,:,index)=tempry; % Put them into the not-block-ordered GLMALPHA type matrix glma(:,index)=tempry(ronm); end % Supply the indices for the GLMALPHA type matrix [EM,EL]=addmout(maxL); % Assign output varns={lm,cosi,glma,EL,EM,V}; varargout=varns(1:nargout); elseif strcmp(phi,'demo1') phi=round(rand*180)+90; theta=round(rand*90)+45; omega=round(rand*360); TH=30; L=18; m=1; [lm,cosi]=ptoslep(phi,theta,omega,TH,L,m,4); clf % Calculate cap coordinates [lon1,lat1]=caploc([phi 90-theta],TH); % Calculate azimuth coordinates, define EAST from SOUTH [lon2,lat2]=grcazim([phi 90-theta],... linspace(0,TH*fralmanac('DegDis')/1000,100),180+omega); for index=1:4 ah(index)=subplot(2,2,index); r=plm2xyz([lm cosi(:,:,index)],1); imagef([],[],r) set(gca,'xtick',[0 phi 360],'xtickl',[0 phi 360]) set(gca,'ytick',[-90 90-theta 90],'ytickl',[-90 90-theta 90]) hold on p1(index)=plot(lon1,lat1,'k','LineW',1); p2(index)=plot(lon2,lat2,'k','LineW',1); end supertit(ah(1:2),sprintf('lon= %i ; lat= %i ; rot = %i',phi,90-theta,omega)); movev(ah(1:2),-0.025) longticks(ah) set(ah,'xgrid','on','ygrid','on') elseif strcmp(phi,'demo2') phi=round(rand*180)+90; phi=180; theta=round(rand*90)+45; theta=90; % Pick parameters; positive order m is TH=30; L=12; m=-2; % Make a "sine taper" from a "cosine taper" omega=180/2/abs(m); [lm,cosi1]=ptoslep(phi,theta,omega,TH,L,m,2); % Make the "sine taper" by flipping the sign of the order [lm,cosi2]=ptoslep(phi,theta,0,TH,L,-m,2); % Calculate cap coordinates [lon1,lat1]=caploc([phi 90-theta],TH); % Calculate azimuth coordinates, define EAST from SOUTH [lon2,lat2]=grcazim([phi 90-theta],... linspace(0,TH*fralmanac('DegDis')/1000,100),180-omega); % Start plot subdivision clf [ah,ha]=krijetem(subnum(2,2)); % Plot the rotated cosine taper for index=1:2 axes(ah(index)) r=plm2xyz([lm cosi1(:,:,index)],1); imagef([],[],r) set(gca,'xtick',[0 phi 360],'xtickl',[0 phi 360]) set(gca,'ytick',[-90 90-theta 90],'ytickl',[-90 90-theta 90]) hold on p1(index)=plot(lon1,lat1,'k','LineW',1); p2(index)=plot(lon2,lat2,'k','LineW',1); end hold off % Plot the sine taper for index=1:2 axes(ah(index+2)) r=plm2xyz([lm cosi2(:,:,index)],1); imagef([],[],r) set(gca,'xtick',[0 phi 360],'xtickl',[0 phi 360]) set(gca,'ytick',[-90 90-theta 90],'ytickl',[-90 90-theta 90]) hold on p1(index)=plot(lon1,lat1,'k','LineW',1); end hold off supertit(ah(1:2),sprintf('lon= %i ; lat= %i ; rot = %i',phi,90-theta,omega)); movev(ah(1:2),-0.025) longticks(ah) set(ah,'xgrid','on','ygrid','on') elseif strcmp(phi,'demo3') phi=round(rand*180)+90; phi=180; theta=round(rand*90)+45; theta=90; % Pick parameters; positive order m is the cosine taper TH=30; L=12; m=-1; % Make a "sine taper" from a "cosine taper" omega=linspace(0,360,8); clf % Calculate cap coordinates [lon1,lat1]=caploc([phi 90-theta],TH); % Start plot subdivision [ah,ha]=krijetem(subnum(2,4)); % Plot the rotated cosine taper for index=1:length(omega) axes(ah(index)) % Make the taper [lm,cosi]=ptoslep(phi,theta,omega(index),TH,L,m,1); % Calculate azimuth coordinates, define EAST from SOUTH [lon2,lat2]=grcazim([phi 90-theta],... linspace(0,TH*fralmanac('DegDis')/1000,100),... 180-omega(index)); % Perform the expansion r=plm2xyz([lm cosi],1); imagef([],[],r) set(gca,'xtick',[0 phi 360],'xtickl',[0 phi 360]) set(gca,'ytick',[-90 90-theta 90],'ytickl',[-90 90-theta 90]) hold on p1(index)=plot(lon1,lat1,'k','LineW',1); p2(index)=plot(lon2,lat2,'k','LineW',1); x(index)=xlabel(sprintf('rot = %i',round(omega(index)))); end supertit(ah(1:length(omega)/2),sprintf('lon= %i ; lat= %i',phi,90-theta)); movev(ah(1:length(omega)/2),-0.025) longticks(ah) set(ah,'xgrid','on','ygrid','on') fig2print(gcf,'landscape') elseif strcmp(phi,'demo4') % Check that output from GLMALPHA equals PTOSLEP at North Pole and omega=0 TH=30; L=18; m=-L:L; % Figure out where the equivalent sits in the output of GLMALPHA alpha=cumsum([1 L+1 gamini(L:-1:1,2)]); % See GLMALPHA for a bandpass update for index=1:length(m) [lm,cosi,glma,EL,EM]=ptoslep(0,0,0,TH,L,m(index),1); [G,V,EL2,EM2]=glmalpha(TH,L,1); difer(glma-G(:,alpha(2*abs(m(index))+(m(index)>=0)))); end elseif strcmp(phi,'demo5') % The first cosine coefficient, rotated by omega+180/(2|m|)... m=-1; omega=30; L=18; phi=78; theta=78; TH=30; [a,b,G1]=ptoslep(phi,theta,omega+180/2/abs(m),TH,L,m,1); % ... should be the same as the sine coefficient, rotated by just omega m=1; [a,b,G2]=ptoslep(phi,theta,omega,TH,L,m,1); difer(G1-G2) % Next check this with GLMALPHAPTO elseif strcmp(phi,'demo6') % What should be the relation between +/-m? % Well, the result is NOT simply a rotation around the z-axis, so much % is clear, but rather an azimuthal rotation around the center m=3; [lm1,cosi1,glma1,EL1,EM1,V1]=ptoslep(40,70,10,30,12,m,1); [lm2,cosi2,glma2,EL2,EM2,V2]=ptoslep(40,70,10+180/2/abs(m),30,12,-m,1); difer(lm1-lm2); difer(EL1-EL2); difer(EM1-EM2); difer(V1-V2) difer(glma1-glma2); difer(cosi1-cosi2) clf subplot(211); plotplm([lm1 cosi1(:,:,1)],[],[],4,1) subplot(212); plotplm([lm2 cosi2(:,:,1)],[],[],4,1) end