%Radar range equation for SAR
%G. L. Charvat
%12/23/12

close all;
clear all;
clc;

%constants
c = 3E8; %(m/s) speed of light

%parameters
Pave = 1E-3; %(W) average transmit power, for CW radar tArxhis is the transmit power
fc = 3E9; %(Hz) transmit frequency
lambda_c = c/fc; %(m) wavelength
Gtx = 12; %(dBi) measured gain of transmit antenna
Gtx = 10^(Gtx/10); %convert to linear
Grx = 12; %(dBi) measured gain of receive antenna
Grx = 10^(Grx/10); %convert to linear
%from Grx we can back-out effective aperture Arx
Arx = Grx*lambda_c^2/(4*pi); %let rho_rx=1 because rho is already factored into Grx
sigma = 0; %(dBsm) RCS of the target of interst
sigma = 10^(sigma/10); %convert to linear
Ls = 6; %(dB) misc system losses
Ls = 10^(Ls/10); %convert to linear
att = 0; %attenuation constant of propagation medium, for such a short-range
%radar this constant is usually 0 unless operating in the mmW bands, we can
%then let the term e^(2*att*Rmax) = 1
Fn = 3.5; %(dB) cascaded noise figure
Fn = 10^(Fn/10); %convert to linear
k = 1.38E-23; %(joul/deg) Boltzman's constant
To = 290; %(deg Kelvin) standard temperature
t_sample = 2.5E-3; %(s) discrete sample length
Bn = 2/t_sample; %(Hz) system noise bandiwdth
SNR1 = 13.4; %(dB) required SNR for Probability of detection = 95% and 
%Probability of false alarm = 10^-6
SNR1 = 10^(13.4/10); %convert to linear
N = 44; %(#) range profiles to acquire a SAR image
Lwall = 2*22.5; %dB one-way wall loss
Lwall = 10^(Lwall/10);

%---------- calculate maximum range -------------%
Rmax = ((N*Pave*Gtx*Arx*sigma)/((4*pi)^2*k*To*Fn*Bn*SNR1*Ls*(Lwall)))^(1/4)

%minimum RCS within the radar's maximum range.
%BW = 4.9820e+09; %(Hz) chirp bandwidth for X-band UWB system

%bandwidth for S-band UWB system
fstart = 1.926E9; %(Hz) LFM start frequency
fstop = 4.069E9; %(Hz) LFM stop frequency

%bandwidth for coffee can radar, in two configurations
%fstart = 2260E6; %(Hz) LFM start frequency
%fstop = 2590E6; %(Hz) LFM stop frequency
%fstart = 2402E6; %(Hz) LFM start frequency for ISM band
%fstop = 2495E6; %(Hz) LFM stop frequency for ISM band
BW = fstop-fstart; %(Hz) transmti bandwidth

f3db = 80E3; %(Hz) video amplifier -3 dB bandwidth
cr = BW/t_sample; %(Hz/s) chirp rate
clear Rmax;
Rmax = f3db*c/cr %(m) maximum range given video amplifier bandwidth

%-------------------------------------------------%
%calculate minimum RCS at maximum range limited by video bandwidth in dBsm
sigma = 10*log10(Rmax^4*((4*pi)^2*k*To*Fn*Bn*SNR1*Ls)/(N*Pave*Gtx*Arx))

%--------- calculate down range resolution ------------%
%Aperture weighting
%Kr = 1.43; %Hanning
%Kr = 1.03; %Uniform Circular
Kr = 0.89; %Uniform Rectangular

range_resolution = c*Kr/(2*BW) %(m) expected range resolution


%--------- calculate cross range resolution ------------%
%Aperture weighting
%Kr = 1.43; %Hanning
%Kr = 1.03; %Uniform Circular
Kr = 0.89; %Uniform Rectangular

Rt=30*.3048;
L = 96/12*.3048; %(m) aperture length from first range profile to last
phi_dc = pi/2; %(rad) aspect angle from aperture to target center
delta_theta = (pi/2-atan(Rt/(L/2+.25)))+(pi/2-atan(Rt/(L/2-.25)));
%(m) expected cross-range reoslution
cross_range_resolution = lambda_c*Kr*Rt/(2*L*sin(phi_dc)*cos(delta_theta/2))
