Commit fa88518f authored by Franco Buffa's avatar Franco Buffa
Browse files

source and data

parent 97986fb7
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
function act(srtlut,c0,a,b,clip)

%  srtlut='../20180115_2/act_holo_2.txt';
%  c0=3;
%  a=1;
%  b=-1;
%  clip=true;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Function:  act.m
@@ -34,19 +39,25 @@ function act(srtlut,c0,a,b,clip)
 lut(:,c0)=a*lut(:,c0)+b*pm;

 i0=find(abs(lut(:,c0)+lut(:,7))>stroke);
 printf('There are %d out of range data...\n',length(i0));
 n0=length(i0);
 if(n0)
  printf('There are %d out of range data:\n',n0);
  for k=1:n0
   printf('%s %s %6.3f\n',cod1{i0(k),:},cod2{i0(k),:},lut(i0(k),c0)+lut(i0(k),7));
  end

  if(clip)
   lut(i0,c0)=sign(lut(i0,7))*stroke-lut(i0,7);
   printf('Out of range data have been corrected...\n',length(i0));
  end
  
 end 
 printf('RMS new vs old LUT: %6.3f [mm]\n',std(lutc0-lut(:,c0)));
 
 fid=fopen('srtlut.txt','w');
 n0=length(lut);
 for k=1:n0
  fprintf(fid,"%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\n",lut(k,:));
  fprintf(fid,'%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\t%6.3f\n',lut(k,:));
 end
 fclose(fid);
 

dev/app.m

deleted100644 → 0
+0 −73
Original line number Diff line number Diff line
function app(fconf)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Function:  
% Package:   HoP
% Author:    Franco Buffa
% Purpose:   
% Date:      
%	
% GNU Octave Version: 4.0.2
%
% revised by 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% is a function that 
%
% Output:
% 
%
% Input:
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 if nargin>0
  run(fconf); 
 else
  run('conf.m');
 end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 load unwr.dat
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   u0=sfactor*u0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 dx=D/(mp-1)/k0;

 W=reshape(u0,mp*mp,1);
 X1=ones(mp,mp).*(1:mp); % colonna
 Y1=transpose(X1);       % riga
 
 x=dx*(X1-mp/2);
 y=dx*(Y1-mp/2);
 
 X=reshape(x,mp*mp,1);
 Y=reshape(y,mp*mp,1);
 
 X(blk)=[];
 Y(blk)=[];
 W(blk)=[];
%%%%%%%%%  
 a=[ones(length(X),1) X Y];
 c=a\W;
 u00=u0-(c(1)+x*c(2)+y*c(3));

 u00(blk)=0; 
 
 save unwr00.dat u00
 
 figure(1);
 imagesc(dx*(-mp/2:mp/2),dx*(-mp/2:mp/2),u00);
 caxis([-tol3 tol3]);
%grid minor on;
 axis('square');
 colormap(cmap);
 colorbar;
 title('AP phase distribution [rad]');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
end
 
 No newline at end of file
+4 −3
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ function preproc(fconf)
  run('conf.m');
 end

 [az el c03 c04 c05 c06 c07 c08 c09 c10 c11 c12 c13]=textread(filename,'%f %f %f %f %f %f %f %f %f %f %f %s %s');
 [az el tp c04 c05 c06 c07 c08 c09 c10 c11 c12 c13]=textread(filename,'%f %f %f %f %f %f %f %f %f %f %f %s %s');

 er=c06./sqrt(c04);
 ei=c07./sqrt(c05);
@@ -146,6 +146,7 @@ function preproc(fconf)
 el=el1;
 e_re=e_re(i1);
 e_im=e_im(i1);
 tp=tp(i1);
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   figure(4);
@@ -225,7 +226,7 @@ function preproc(fconf)
%  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 out=[az el e_re e_im];
 out=[az el e_re e_im tp];
 save -ascii azel.txt out
end
 

dev/preproc.old.m

0 → 100644
+240 −0
Original line number Diff line number Diff line
function preproc(fconf)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Function:  preproc.m
% Package:   HoP
% Author:    Franco Buffa
% Purpose:   
% Date:      
%	
% GNU Octave Version: 4.0.2
%
% revised by 
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% preproc.m  is a function that 
%
% Output:
% 
%
% Input:
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 if nargin>0
  run(fconf); 
 else
  run('conf.m');
 end

 [az el c03 c04 c05 c06 c07 c08 c09 c10 c11 c12 c13]=textread(filename,'%f %f %f %f %f %f %f %f %f %f %f %s %s');

 er=c06./sqrt(c04);
 ei=c07./sqrt(c05);

 i0=find((az>azcut(1)-azcut(2))&(az<azcut(1)+azcut(2)) & (el>elcut(1)-elcut(2))&(el<elcut(1)+elcut(2)));
 q=[az(i0),el(i0),er(i0),ei(i0)];
 
 az=az(i0);
 el=el(i0);
 e_re=er(i0);
 e_im=ei(i0);

 da=diff(az);
 da=[0;da];
 de=diff(el);
 de=[0;de];
 figure(1);
 xlabel('Points');
   
 flag=zeros(length(az),1); % all'inizio sono tutti flaggati a zero, cioe' sono da scartare 
 printf('********************************\n'); 
 
%   if(!exist('scn','var'))
%     scn='az';
%   end
 switch(scn)
  case('az')
   printf('Azimuth scan\n');
   for j1=1:size(dam)(1)
    i0=find((da>dam(j1,1))&(da<dam(j1,2)));
    flag(i0)=1; % quelli flaggati a 1 sono quelli che appartengono alle scansioni
   end  
   ylabel('Azimuth speed (deg/s)');
   plot(da,'o');
  case('el')
   printf('Elevation scan\n');
   for j1=1:size(dam)(1)
    i0=find((de>dam(j1,1))&(de<dam(j1,2)));
    flag(i0)=1; % quelli flaggati a 1 sono quelli che appartengono alle scansioni
   end  
   ylabel('Elevation speed (deg/s)');
   plot(de,'o');
  otherwise
   printf('error: invalid scn parameter!\n');
   return;
 end
%
 i0=find((flag==0)&(az>azcut(1)-azcut(3))&(az<azcut(1)+azcut(3))&(el>elcut(1)-elcut(3))&(el<elcut(1)+elcut(3)));  
 flag(i0)=2;
% 
 i1=find(flag==1);
 el1=el(i1);
 az1=az(i1);
 figure(2);
 plot(az1,el1,'.g;map points;')
 title('AzEl map')
 hold on;
 i2=find(flag==0);
 el2=el(i2);
 az2=az(i2);
 plot(az2,el2,'*r;outliers;')
 i3=find(flag==2);

 el3=el(i3);
 az3=az(i3);
 plot(az3,el3,'ob;sat points;')
 hold off;
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 e_re_s=e_re(i3);
 e_im_s=e_im(i3); 

 n=length(az3);
 n1=length(az1);
 x=(1:n)';
 y=(linspace(1,n,n1))';
%   x=x/max(x);
%   y=y/max(y);
 
%ph1=atan(e_im_s./e_re_s);
 ph1=atan2(e_im_s,e_re_s);
 ph3=movave(ph1,nma);
 figure(3);
 plot(180/pi*ph1,'.1;source phase (deg);');
 hold on;
 plot(180/pi*ph3,'3','LineWidth',4);
 hold off;
 grid minor on;
%print -dpng source_phase.png
 ph2=interp1(x,ph3,y);   
 
 amp1=sqrt(e_im_s.^2+ e_re_s.^2);
 maxamp1=max(max(amp1));
 amp1=amp1/maxamp1; 
 amp3=movave(amp1,nma);
 figure(4);
 plot(x,amp1,'.1;source amp;');
 hold on;
 plot(x,amp3,'3','LineWidth',4);
 hold off;
 grid minor on;
%print -dpng source_amp.png
 amp2=interp1(x,amp3,y);   
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 az=az1;
 el=el1;
 e_re=e_re(i1);
 e_im=e_im(i1);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   figure(4);
%   plot(e_re,'.1;real;');
%   hold on;
%   plot(e_im,'.2;imag;');
%   hold off;
%   grid minor on;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 src_pos=5;
 switch(src_pos)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  case(1)
   n=length(az3);
   n1=length(az1);
   x=(1:n)';
   y=(linspace(1,n,n1))';
   A=[x.^2 x ones(n,1)];
   B=[y.^2 y ones(n1,1)]; 
   z=A\az3;
   az0=B*z;  
   z=A\el3;
   el0=B*z;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 case(2)
   az0=mean(az3);
   el0=mean(el3);
 case(3)
   az0=mean(az);
   el0=mean(el);
 case(4)
   n=length(az3);
   x=(1:n)';
   A=[x.^2 x ones(n,1)];
   z=A\az3;
   az4=A*z;  
   z=A\el3;
   el4=A*z;
   az0=mean(az4);
   el0=mean(el4);
 case(5)
   az0=azcut(1);
   el0=elcut(1);
 otherwise
   az0=0;
   el0=0;
 end 
 az=az-az0;
 el=el-el0;
 
 ph_std=std(ph1-ph3);
 am_std=std(amp1-amp3);
 snr0=mean(amp1)/am_std;
 
 printf('Scan points=%d\n',size(az)(1)); 
 printf('On source points=%d\n',size(az3)(1)); 
 printf('az0=%f, el0=%f (deg)\n',az0,el0); 
 printf('RMS_phase=%f (deg)\n',180/pi*ph_std); 
 printf('phase_err=%f (um)\n',1E6*ph_std*lambda/6/pi); 
 printf('RMS_ampl=%f\n',am_std); 
 printf('SNR=%f\n',snr0);
 printf('********************************\n'); 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   
 if (source)
  amp1=sqrt(e_re.^2+e_im.^2);
  ph1=atan2(e_im,e_re);
  ph1=ph1-ph2;
  amp1=amp1./amp2;
% 
  e_re=amp1.*cos(ph1);
  e_im=amp1.*sin(ph1);
 end
%  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 out=[az el e_re e_im];
 save -ascii azel.txt out
end
 
function y=movave(x,n)
 m=length(x);
 y=zeros(n,1);
 for i=n:m-n
  y(i)=mean(x(i-n+1:i+n));
 end
 y(1:n-1)=y(n);
 y(m-n+1:m)=y(m-n);
end
+29 −6
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ function uv(fconf)
 el=azel(:,2);
 e_re=azel(:,3);
 e_im=azel(:,4);
 tp=sqrt(azel(:,5));
 azel=[];

%%%%%%%%%%%%%%%%%%  uv transformation %%%%%%%%%%%%%%%%%%%%%
@@ -80,29 +81,51 @@ function uv(fconf)
 i0=find(isnan(ei));
 ei(i0)=0.0;
 %
 tp=griddata (u1,v1,tp,u,v);
 i0=find(isnan(tp));
 tp(i0)=0.0;
%
% 

 figure(1);
 emod=abs(er+i*ei);
%emod=sqrt(er.^2+ei.^2);
 emod=emod/max(max(emod));
 emod=20*log10(emod);
 imagesc(uu,vv,emod);
%   imagesc(emod);
 axis('square');
 colorbar;
 xlabel('u');
 ylabel('v');
 title('HFF');
%print -dpng preproc.png
%
% 

 [pr0 pc0]=find(emod==0);
 [nr0 nc0]=size(emod);
 z=zeros(mp,mp);
 z(mp/2-pr0:mp/2-pr0+nr0-1,mp/2-pc0:mp/2-pc0+nc0-1)=er;
 er=z;
 
 z=zeros(mp,mp);
 z(mp/2-pr0:mp/2-pr0+nr0-1,mp/2-pc0:mp/2-pc0+nc0-1)=ei;
 ei=z;
 
 
 figure(2);
 emod=tp;
 emod=emod/max(max(emod));
 emod=20*log10(emod);
 imagesc(uu,vv,emod);
%   imagesc(emod);
 axis('square');
 colorbar;
 xlabel('u');
 ylabel('v');
 title('Total Power');
   
 z=zeros(mp,mp);
 z(mp/2-pr0:mp/2-pr0+nr0-1,mp/2-pc0:mp/2-pc0+nc0-1)=tp;
 tp=z;
 
%   pr0=mp/2-fix(size(er)(1)/2);
%   pc0=mp/2-fix(size(er)(2)/2);
%   z=zeros(mp,mp);
@@ -112,7 +135,7 @@ function uv(fconf)
%   z(pr0:pr0+size(ei)(1)-1,pc0:pc0+size(ei)(2)-1)=ei;
%   ei=z;
%
 save uuvv.dat er ei
 save uuvv.dat er ei tp
%  
end
 
Loading