%%%%%%%%%%%%%%%%%评估指标为点目标距离向和方位向峰值坐标、峰值旁瓣比、一维积分旁瓣比、二维积分旁瓣比、剖面图%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%处理矩阵列为距离向%%%%%%%%%%%%%%%%%
%%%%%一维积分旁瓣比定义第一零点以外为旁瓣,二维积分旁瓣比主瓣近似矩形计算%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%
clc;
clear all;
Nr=512;
Na=2048;
fs=1e9;
v0=6887.683;
PRF=44887.73;
c=3e8;
%%%%%%%%%%%%%%%%读取数据%%%%%%%%%%%%%%%%%%%%
%回波数据
echo=[];
shu=[];
M=[];
guodu=zeros(1,Nr);
fid=fopen('评估结果.SAR_Result.dat','rb');
for i=1:Na
M=fread(fid,Nr*2,'float');
for m=1:Nr
guodu(1,m)=M(2*m-1)+M(2*m)*1j;
end
echo(i,:)=guodu;
end
fclose(fid);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%二维插值处理,D2为二维插值倍数%%%%%%%%%%%%%%%%%%
echo=echo';%%每列有512个点,列为距离向
Max=max(max(abs(echo))); %最大值
[X,Y]=find(abs(echo)==Max);%峰值坐标
DArea=echo(X-128:X+128,Y-128:Y+128); %%取257*257区域
E1=fftshift(fft(DArea),1);%先距离向
E2=fftshift(fft(E1.'),1);
D2=8;%二维D2倍插值
A3=[zeros(257,floor(257*(D2-1)/2)) E2 zeros(257,(D2-1)*257-floor(257*(D2-1)/2))];
A4=[zeros(D2*257,floor(257*(D2-1)/2)) A3.' zeros(D2*257,(D2-1)*257-floor(257*(D2-1)/2))];
A4=A4.';
A5=ifft(fftshift(A4,1));
A6=ifft(fftshift(A5.',1));%%%转回时域;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%一维维插值处理,D1为插值倍数%%%%%%%%%%%%%%%%%%
Max_one=max(max(abs(A6))); %最大值
[i,j]=find(abs(A6)==Max_one);%最大值所在行列
A=A6(i-128:i+128,j);%抽取列,距离向
B=A6(i,j-128:j+128);%抽取行,方位向
A1=fftshift(fft(A.'));
B1=fftshift(fft(B));
D1=128;%插值倍数
R1=[zeros(1,floor(length(A1)*(D1-1)/2)) A1 zeros(1,floor(length(A1)*(D1-1)/2))];
B2=[zeros(1,floor(length(B1)*(D1-1)/2)) B1 zeros(1,floor(length(B1)*(D1-1)/2))];
R2=abs(ifft(fftshift(R1)));%%距离向插值后到时域
A2=abs(ifft(fftshift(B2)));%%方位向插值后到时域
r2=20*log10(R2/max(R2));%%距离向归一化
a2=20*log10(A2/max(A2));%%方位向归一化
%%%%%%%%%%%距离向分辨率%%%%%%%%%%%%%%%%%%%%%%
[max_r,POS_r]=max(r2);
r3=POS_r;
%%%%%%%%%%%%%%左边3DB点%%%%%%%%%%%%
while(r2(r3)>-3)
r3=r3-1;
end;
rWidth_3db1=r3;
%%%%%%%%%%%%%找左边第一零点%%%%%%%%%%%%%%
for r4=rWidth_3db1:-1:1
if R2(r4)<R2(r4-1)
break
end
end
zero_left=r4;
%%%%%%%%%%%%%找左边第一旁瓣值%%%%%%%%%%%%%%
for r5=zero_left-1:-1:1
if R2(r5)>R2(r5-1)
break
end
end
%%%%%%%%%%%%%左边旁瓣能量%%%%%%%%%%%%%%
r_Sum_sidelobe1=0;
for rs1=1:zero_left-1
r_Sum_sidelobe1 = r_Sum_sidelobe1 +R2(rs1) * R2(rs1);%%%左边旁瓣求和
end
%%%%%%%%%%%%%%右边3DB点%%%%%%%%%%%%
r3=POS_r+1;
while(r2(r3)>-3)
r3=r3+1;
end;
rWidth_3db2=r3;
%%%%%%%%%%%%%找右边第一零点%%%%%%%%%%%%%%
for r6=rWidth_3db2:length(r2)
if R2(r6)<R2(r6+1)
break
end
end
zero_right=r6;
%%%%%%%%%%%%%找右边第一旁瓣值%%%%%%%%%%%%%%
for r7=zero_right+1:length(r2)
if R2(r7)>R2(r7+1)
break
end
end
%%%%%%%%%%%%%主瓣能量%%%%%%%%%%%%%%
r_Sum_mainlobe=0;
for r8=zero_left:zero_right
r_Sum_mainlobe= r_Sum_mainlobe+R2(r8)*R2(r8);
end
%%%%%%%%%%%%%右边旁瓣能量%%%%%%%%%%%%%%
r_Sum_sidelobe =r_Sum_sidelobe1 ;
for rs2=zero_right+1:length(r2)
r_Sum_sidelobe=r_Sum_sidelobe +R2(rs2)*R2(rs2);
end
%%%%%%%%%%%%找第一旁瓣较大值%%%%%%%%%%%%%%
rMax_sidelobe=max(R2(r5),R2(r7));
rMax_mainlobe=max(R2);
%%%%%%%%%%%%%距离向指标计算%%%%%%%%%%%%%
figure(1);plot(r2);title('距离向切面');
ISLRr=10*log10(r_Sum_sidelobe/r_Sum_mainlobe);%%%距离向积分旁瓣比
PSLRr=20*log10(rMax_sidelobe/rMax_mainlobe);;%%%距离向峰值旁瓣比
r_3db=rWidth_3db2-rWidth_3db1+2;%3db 带宽
fenbianlv_r=c*r_3db/(2*fs*D1*D2);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%方位向分辨率%%%%%%%%%%%%%%%%%%%%%%
[max_a,POS_a]=max(a2);
a3=POS_a;
a_Sum_sidelobe1=0;
%%%%%%%%%%%%%%左边3DB点%%%%%%%%%%%%
while(a2(a3)>-3)
a3=a3-1;
end;
aWidth_3db1=a3;
%%%%%%%%%%%%%找左边第一零点%%%%%%%%%%%%%%
for a4=aWidth_3db1:-1:1
if A2(a4)<A2(a4-1)
break
end
end
a_zero_left=a4;
%%%%%%%%%%%%%找左边第一旁瓣值%%%%%%%%%%%%%%
for a5=a_zero_left-1:-1:1
if A2(a5)>A2(a5-1)
break
end
end
%%%%%%%%%%%%%左边旁瓣能量%%%%%%%%%%%%%%
for as1=1:a_zero_left-1
a_Sum_sidelobe1 = a_Sum_sidelobe1 +A2(as1) * A2(as1);%%%左边旁瓣求和
end
%%%%%%%%%%%%%%右边3DB点%%%%%%%%%%%%
a3=POS_a+1;
while(a2(a3)>-3)
a3=a3+1;
end;
aWidth_3db2=a3;
%%%%%%%%%%%%%找右边第一零点%%%%%%%%%%%%%%
for a6=aWidth_3db2:length(a2)
if A2(a6)<A2(a6+1)
break
end
end
a_zero_right=a6;
%%%%%%%%%%%%%找右边第一旁瓣值%%%%%%%%%%%%%%
for a7=a_zero_right+1:length(a2)
if A2(a7)>A2(a7+1)
break
end
end
%%%%%%%%%%%%%主瓣能量%%%%%%%%%%%%%%
a_Sum_mainlobe=0;
for a8=a_zero_left:a_zero_right
a_Sum_mainlobe=a_Sum_mainlobe+A2(a8)*A2(a8);
end
%%%%%%%%%%%%%右边旁瓣能量%%%%%%%%%%%%%%
a_Sum_sidelobe =a_Sum_sidelobe1 ;
for as2=a_zero_right+1:length(a2)
a_Sum_sidelobe=a_Sum_sidelobe +A2(as2)*A2(as2);
end
%%%%%%%%%%%%找第一旁瓣较大值%%%%%%%%%%%%%%
aMax_sidelobe=max(A2(a5),A2(a7));
aMax_mainlobe=max(A2);
%%%%%%%%%%%%%方位向指标计算%%%%%%%%%%%%%
figure(2);plot(a2);title('方位向切面');
a_3db=aWidth_3db2-aWidth_3db1+2;%3db 带宽
fenbianlv_a=v0*a_3db/(PRF*D1*D2);
ISLRa=10*log10(a_Sum_sidelobe/a_Sum_mainlobe);%%%距离向积分旁瓣比
PSLRa=20*log10(aMax_sidelobe/aMax_mainlobe);%%%距离向峰值旁瓣比
%%%%%%%%%%%%二维积分旁瓣比%%%%%%%%%%%%%
%%%%%%%%%%%主瓣近似矩形计算%%%%%%%%%%%%%
%%%%%%%%%%%%%计算总能量%%%%%%%%%%%%%
totallobe=0;
A7=abs(A6);
for m=1:length(A7)
for n=1:length(A7)
totallobe=totallobe+A7(m,n)*A7(m,n);
end
end
%%%%%%%%%%%%%确定主瓣%%%%%%%%%%%%%
two_r_zero=floor((zero_right-zero_left)/D1);
two_a_zero=floor((a_zero_right-a_zero_left)/D1);
%%%%%%%%%%%%%计算主瓣能量%%%%%%%%%%%%%
mainlobe=0;
for t1=i-floor(two_a_zero/2):i+floor(two_a_zero/2)
for t2=j-floor(two_r_zero/2):j+floor(two_r_zero/2)
mainlobe=mainlobe+A7(t1,t2)*A7(t1,t2);
end
end
ISLR=10*log10(( totallobe-mainlobe)/mainlobe);
%%%%%%%%%%%%%X,Y为峰值坐标%%%%%%%%%%%%%