NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/DPWP/trunk/DPWP/diwasp_1_1GD/private/IMLM.m

Revision 334 (checked in by gdusek, 14 years ago)

Total update to the DPWP code. Significant changes made to direspec, specmultiplot, radialtouvw and IMLM code. 6/14/10

Line 
1 function [S]=IMLM(xps,trm,kx,Ss,pidirs,miter,displ)
2
3 %this code was edited significantly on 5/2010 --- see comments for details
4
5 gamma=.1;
6 beta=1.0;
7 alpha=0.1;
8
9 szd=size(xps,1);
10 ffreqs=size(xps,3);
11 ddirs=size(trm,3);
12
13 ddir=8*atan(1.0)/ddirs;
14
15 if(displ<2)
16    warning off;
17 end
18
19
20 for ff=1:ffreqs
21    if(displ>=1)
22       disp(['calculating for frequency' blanks(1) num2str(ff) ' of' blanks(1) num2str(ffreqs)]);
23   end
24    
25    for m=1:szd
26       for n=1:szd
27         H(1:ddirs,m,n)=trm(n,ff,1:ddirs);
28       Hs(1:ddirs,m,n)=conj(trm(m,ff,1:ddirs));
29       expx(1:ddirs,m,n)=exp(i*kx(m,n,ff,1:ddirs));
30       iexpx(1:ddirs,m,n)=exp(-i*kx(m,n,ff,1:ddirs));
31       Htemp(:,m,n)=H(:,m,n).*Hs(:,m,n).*expx(:,m,n);
32       iHtemp(:,m,n)=H(:,m,n).*Hs(:,m,n).*iexpx(:,m,n);
33    end
34    end
35    
36    I=eye(m)*sqrt(eps);
37    invcps=pinv(xps(:,:,ff)+I); %changed on 5/5/10 to pinv and +I
38    Sftmp=zeros(ddirs,1);
39    for m=1:szd
40       for n=1:szd
41                 xtemp=invcps(m,n)*Htemp(:,m,n);
42                         Sftmp(:)=Sftmp(:)+xtemp;
43                 end
44    end
45    Eo=(1./real(Sftmp(:))); %added 5/5/10 to take just the real part
46    [Eo]=normalize(Eo,ddir); %added 5/11/10 to remove negative values before normalizing
47    E=Eo;
48    T=Eo;
49
50    for it=1:miter   
51       for m=1:szd
52         for n=1:szd
53                 expG(m,n,:)=iHtemp(:,m,n).*E(:);   
54                         ixps(m,n)=sum(expG(m,n,:))*ddir;
55                 end
56       end
57       invcps=pinv(ixps+I); % changed on 5/5/10 to pinv and +I
58       Sftmp=zeros(ddirs,1);
59       for m=1:szd
60         for n=1:szd
61                 xtemp=invcps(m,n)*Htemp(:,m,n);
62                         Sftmp(:)=Sftmp(:)+xtemp;
63                         end
64         end
65         Told=T;
66       T=(1./real(Sftmp(:))); %added on 5/5/10 to take just real part
67       [T]=normalize(T,ddir); %added 5/11/10 to remove negative values before normalizing
68      
69       %lambda=ones(size(T))-(T./Eo)
70       %ei=gamma*lambda.*E;
71       ei=gamma*((Eo-T)+alpha*(T-Told));
72       %lambda=Eo-T;      %edited on 5/5/10 to calculate ei slightly differently
73       %ei=(abs(lambda).^(beta+1))./(gamma.*lambda);
74       E=E+ei;
75       [E]=normalize(E,ddir);%added 5/11/10 to remove negative values before normalizing
76
77            
78    end
79          
80    S(ff,:)=Ss(1,ff)*E';
81 end
82
83 warning on;
84
85
86
Note: See TracBrowser for help on using the browser.