% m10464_14.m Detector signal and noise levels
format compact
lambda=10.59e-6 % m
dstar=1e10  % cm sqrt(hz)/W
b=1e9  % Hz
.0050
diameter=100e-6 % m
nep=sqrt(pi*(diameter*100/2)^2*b)/dstar % diameter*100 is cm
eta=0.8
e=1.6e-19
h =6.6260e-034
c=2.99e8 % m/sec
responsivity=eta*e/(h*c/lambda)
dstarcurrent=eta*e/(h*c/lambda)*nep
r=50 % ohms
preampgain=10 % db
dstarv=dstarcurrent*r*10^(preampgain/20)  % at the preamp output
dstardbm=10*log10(dstarv^2/50/1e-3) % convert to dBm

disp(' ---------------- ')
disp('Johnson Noise');
k=1.3810e-023
t=300
johnsoncurrent=sqrt(4*k*t*b/r)
johnsonv=johnsoncurrent*r*10^(preampgain/20) % at the preamp output
johnsondbm=10*log10(johnsonv^2/50/1e-3) % convert to dBm
johnsonpower=johnsoncurrent/(eta*e/(h*c/lambda))

% signal calculation
disp(' ---------------- ')
disp('Signal');
ptransmit=10 %W
telescopediameter=0.3 %m
range=1000
refl=0.03 % per steradian
psig=ptransmit*pi*telescopediameter^2/4/range^2
signalcurrent=psig*eta*e/(h*c/lambda)
signalv=signalcurrent*r*10^(preampgain/20)  % at the preamp output
signaldbm=10*log10(signalv^2/50/1e-3) % convert to dBm

disp(' ---------------- ')
disp('Quantum Noise');
signalphotons=signalcurrent/e/b
sigma=sqrt(signalphotons)
quantumcurrent=sigma*e*b
quantumv=quantumcurrent*r*10^(preampgain/20)  % at the preamp output
quantumdbm=10*log10(quantumv^2/50/1e-3) % convert to dBm

% After bandpass filter
bpf=1e6;
quantumcurrentafterfilter=sqrt(signalcurrent*e*bpf)
quantumvafterfilter=quantumcurrentafterfilter*r*10^(preampgain/20)  % at the preamp output
quantumdbmafterfilter=10*log10(quantumvafterfilter^2/50/1e-3) % convert to dBm

disp(' ---------------- ')
disp('Sunlit ground background');
bkgm=1000*0.0143*0.03 % reflected ground radiant exitance in band 8-12 microns
bkgp=bkgm*1e-7*pi*telescopediameter^2/4 % 0.1 microsteradian (about 300 microradians)
bkgi=bkgp*eta*e/(h*c/lambda)
bkgv=bkgi*r*10^(preampgain/20)  % at the preamp output
bkgdbm=10*log10(bkgv^2/50/1e-3) % convert to dBm
bkgnoisecurrent=sqrt(bkgi*e*b)
bkgnv=bkgnoisecurrent*r*10^(preampgain/20)  % at the preamp output
bkgndbm=10*log10(bkgnv^2/50/1e-3) % convert to dBm

disp(' ---------------- ')
disp('300k (Thermal) background');
tbkgi=1330*pi/4*diameter^2
tbkgv=tbkgi*r*10^(preampgain/20)  % at the preamp output
tbkgdbm=10*log10(tbkgv^2/50/1e-3) % convert to dBm
tbkgnoisecurrent=sqrt(tbkgi*e*b)
tbkgnv=tbkgnoisecurrent*r*10^(preampgain/20)  % at the preamp output
tbkgndbm=10*log10(tbkgnv^2/50/1e-3) % convert to dBm


disp(' ---------------- ')
plo=1e-3
bnarrow=1e5
disp('Signal');
mixsig=sqrt(psig*plo)

mixsigcurrent=mixsig*responsivity
mixsigv=mixsigcurrent*r*10^(preampgain/20)
mixsigdbm=10*log10(mixsigv^2/50/1e-3) % convert to dBm

disp('Quantum noise of LO');
quantumcurrent=sqrt(plo*responsivity*e*b)
quantumv=quantumcurrent*r*10^(preampgain/20)
quantumvdbm=10*log10(quantumv^2/50/1e-3) % convert to dBm

quantumcurrentnarrowband=sqrt(plo*responsivity*e*bnarrow)
quantumnarrowbandv=quantumcurrentnarrowband*r*10^(preampgain/20)
quantumnarrowbandvdbm=10*log10(quantumnarrowbandv^2/50/1e-3) % convert to dBm

disp('Sunlit Background');
bkgpcoh=bkgm*(lambda/telescopediameter)^2*pi*telescopediameter^2/4 % diffraction limited FOV
bkgmix=sqrt(plo*bkgpcoh)
bkgicoh=bkgmix*eta*e/(h*c/lambda)
bkgvcoh=bkgicoh*r*10^(preampgain/20)  % at the preamp output
bkgcohdbm=10*log10(bkgvcoh^2/50/1e-3) % convert to dBm
deltaibkgcoh=sqrt(bkgicoh*e*b)
deltavbkgcoh=deltaibkgcoh*r*10^(preampgain/20)
deltavbkgcohdbm=10*log10(deltavbkgcoh^2/50/1e-3) % convert to dBm
