{
 "metadata": {
  "name": "",
  "signature": "sha256:52a8123efdb6330b1c01d828fbdcc37a6411e5ce1469de2c94b22a16e7b4d8c8"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 10: Antennas, Diversity and Link Analysis"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.1, Page 292"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "D=10000;  #in metres\n",
      "TxEIRP=30;  #Effective Isotropic Radiated Power(EIRP)dBW\n",
      "lamda=0.2;  #in metres\n",
      "Pt=10;  #Transmitted power in dBW\n",
      "Gt=20; #transmitter gain in dBi\n",
      "Gr=3;  #receiver gain in dBi\n",
      "Lo=6;#total system lossses in dB\n",
      "Nf=5;  #noise figure in dB\n",
      "BW=1.25; #mHz\n",
      "k=1.38*10**-23;  #Boltzmann constant\n",
      "T=290;  #temperature in degree kelvin\n",
      "\n",
      "#Calculations\n",
      "Lp=20*math.log10(lamda/(4*math.pi*D));   #free space loss\n",
      "Pr=Lp+Pt+Gt+Gr-Lo;# received power in dBW\n",
      "No=10*math.log10(k*T);  #Noise density in dBW\n",
      "NO=No+30;  #factor of '30' to convert from dBW to dBm\n",
      "Pn=Nf+10*math.log10(BW*10**6)+NO;# noise signal power in dBm\n",
      "SNR=(Pr+30)-Pn;\n",
      "\n",
      "#Results\n",
      "print 'The received signal power is %d dBm'%(round(Pr+30)); #factor of '30' to convert from dBW to dBm\n",
      "print 'SNR is %d dB'%SNR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The received signal power is -59 dBm\n",
        "SNR is 49 dB\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.2, Page 293"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "#As we have to use data from Eg 10.1, \n",
      "D=10000;  # in metres\n",
      "TxEIRP=30;  #Effective Isotropic Radiated Power(EIRP)dBW\n",
      "lamda=0.2;  #in metres\n",
      "Pt=10;  #trasmitted power in dBW\n",
      "Gt=20; #transmitter gain in dBi\n",
      "Gr=3;  #receiver gain in dBi\n",
      "Lo=6;#total system lossses in dB\n",
      "Nf=5;  #noise figure in dB\n",
      "BW=1.25; #mHz\n",
      "k=1.38*10**-23;  #Boltzmann constant\n",
      "T=290;  #temperature in degree kelvin\n",
      "#additional data given in this eg\n",
      "hr=40.; #height of receiver in metre\n",
      "ht=2; #trasmittter antenna height in metres\n",
      "\n",
      "#Calculations\n",
      "Lp=20*math.log10(hr*ht/D**2);\n",
      "Pr=Lp+Pt+Gt+Gr-Lo;# received power in dBW\n",
      "No=10*math.log10(k*T);  #Noise density in dBW\n",
      "NO=No+30;  #factor of '30' to convert from dBW to dBm\n",
      "Pn=Nf+10*math.log10(BW*10**6)+NO;# noise signal power in dBm\n",
      "SNR=(Pr+30)-Pn;\n",
      "\n",
      "#Result\n",
      "print 'The received signal power is %d dBm'%(round(Pr+30)); #factor of '30' to convert from dBW to dBm\n",
      "print 'SNR is %d dB'%SNR"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The received signal power is -65 dBm\n",
        "SNR is 43 dB\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.3, Page 299"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "Pin=12.;  #Input power in watts\n",
      "Ploss=3;  #resistive losses in Watts\n",
      "D=5;  #Directivity\n",
      "\n",
      "#Calculations\n",
      "Eff=(Pin-Ploss)/Pin;\n",
      "G=Eff*D;\n",
      "\n",
      "#Results\n",
      "print 'Gain of the antenna is %.2f dB = %.2f'%(10*math.log10(G),G);"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Gain of the antenna is 5.74 dB = 3.75\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.4, Page 299"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "G=12.; #Gain of antenna in dBi\n",
      "\n",
      "#Calculations\n",
      "Theta=101.5/10**(G/10);\n",
      "\n",
      "#Result\n",
      "print 'The 3-dB beam width of a linear element antenna is %.1f degrees'%Theta"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The 3-dB beam width of a linear element antenna is 6.4 degrees\n"
       ]
      }
     ],
     "prompt_number": 4
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.5, Page 299"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#Variable declaration\n",
      "N=12; #number of turns\n",
      "fr=1.8; #frequency in GHz\n",
      "\n",
      "#Calculations\n",
      "lamda=3*10**8/(fr*10**9);\n",
      "DH=lamda/math.pi;# diameter of helix in milli-meters\n",
      "S=lamda/4;#turn spacing in millimetres\n",
      "L=N*S;\n",
      "G=15*N*S*(DH*math.pi)**2/lamda**3;\n",
      "Theta=52*lamda/(math.pi*DH)*math.sqrt(lamda/(N*S));\n",
      "\n",
      "#Results\n",
      "print 'The optimim diameter is %d mm'%(DH*1000);\n",
      "print 'Spacing is  %.1f mm'%(S*1000);\n",
      "print 'Total Length of antenna is %d mm'%(L*1000);\n",
      "print 'The antenna gain is %.1f dBi'%(10*math.log10(G));\n",
      "print 'The BeamWidth of antenna is %d degrees'%Theta"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The optimim diameter is 53 mm\n",
        "Spacing is  41.7 mm\n",
        "Total Length of antenna is 500 mm\n",
        "The antenna gain is 16.5 dBi\n",
        "The BeamWidth of antenna is 30 degrees\n"
       ]
      }
     ],
     "prompt_number": 6
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.6, Page 305"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "E0=1000.; #average SNR\n",
      "Eg=10; #threshold value for SNR\n",
      "M=3;  #3-Branch Combiner\n",
      "e=2.71828; #Euler's number\n",
      "\n",
      "#Calculations&Results\n",
      "x=Eg/E0;\n",
      "P3=(1-e**(-x))**M; #Considering 3-branch selection combiner\n",
      "print 'By considering 3-branch selection combiner technique, probability comes to be %.e'%P3;\n",
      "P1=(1-e**(-x));#M=1;\n",
      "print ' BY not considering diversity technique, probability comes to be %.e'%P1;"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "By considering 3-branch selection combiner technique, probability comes to be 1e-06\n",
        " BY not considering diversity technique, probability comes to be 1e-02\n"
       ]
      }
     ],
     "prompt_number": 7
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 10.7, Page 312"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "SR=3.84; #spreading rate in Mcps\n",
      "\n",
      "#Calculations\n",
      "ChipDur=1./(SR*10**6);\n",
      "Speed=3*10**8;\n",
      "Dd=ChipDur*Speed;\n",
      "\n",
      "#Result\n",
      "print 'Minimum delay distance to successfully resolve the multipath components and operate the Rake receiver is %d m'%Dd"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Minimum delay distance to successfully resolve the multipath components and operate the Rake receiver is 78 m\n"
       ]
      }
     ],
     "prompt_number": 8
    }
   ],
   "metadata": {}
  }
 ]
}