{
 "metadata": {
  "name": "",
  "signature": "sha256:f6057f567522f2ec05cc49c207f47842aee03556e2aab087a974cae3593d6b0b"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 1: Overview of optical fiber communication"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.1, Page Number: 8"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable declaration\n",
      "f1 = 100*1e3                #frequency1 = 100KHz\n",
      "f2 = 1e9                    #frequency2 = 1GHz\n",
      "T1 = 1.0/f1                 #Time period1 = 0.01ms\n",
      "T2 = 1.0/f2                 #Time period2 = 1 ns\n",
      "\n",
      "#calculation\n",
      "phi = (0.25)*360.0          # Phase shift(degree)\n",
      "\n",
      "#result\n",
      "print \"Phase shift = \",round(phi),\"Degree\",\"= \",round((round(phi)*math.pi)/180,4), \"radian\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Phase shift =  90.0 Degree =  1.5708 radian\n"
       ]
      }
     ],
     "prompt_number": 24
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.2, Page Number: 10"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable Declaration\n",
      "flow=10*1e3                  #Lowest frequency(KHz)\n",
      "fhigh=100*1e3                #Highest frequency(KHz)\n",
      "\n",
      "#calculation\n",
      "bandwidth=fhigh-flow         #bandwidth(KHz)\n",
      "\n",
      "#result\n",
      "print \"Bandwidth=\",bandwidth/1000 ,\"KHz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Bandwidth= 90.0 KHz\n"
       ]
      }
     ],
     "prompt_number": 25
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.4, Page Number: 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable Declaration\n",
      "B = 10*1e6                    # Bandwidth of noisy channel 1MHZ\n",
      "S_N = 1                       # signal to noise ratio is 1\n",
      "\n",
      "#calculation\n",
      "C=B*(math.log(1+S_N)/math.log(2))   #capacity of channel(Mb/s)\n",
      "\n",
      "#result\n",
      "print \"Capacity of channel =\",C/(10*1e6),\"Mb/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacity of channel = 1.0 Mb/s\n"
       ]
      }
     ],
     "prompt_number": 26
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.5, Page Number: 12"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable Declaration\n",
      "fLow = 3*1e6                        #low frequency = 3MHz\n",
      "fHigh = 4*1e6                       #high frequency = 4MHz\n",
      "SNR_dB = 20                         #signal to noise ratio 20 dB\n",
      "\n",
      "#calculation\n",
      "B = fHigh-fLow                             #Bandwidth(MHz)\n",
      "S_N = 10**(SNR_dB/10)                      #signal to noise ratio\n",
      "C = B*(math.log(1+S_N)/math.log(2))        #capacity of channel(Mb/s)\n",
      "\n",
      "#result\n",
      "print \"Capacity of channel=\",round(C/(1e6),1),\"Mb/s\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Capacity of channel= 6.7 Mb/s\n"
       ]
      }
     ],
     "prompt_number": 27
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.6, Page Number: 14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable Declaration\n",
      "P1 = 1                              # Let p1 be 1 watt\n",
      "P2 = P1*0.5                         # P2 is half of p1 so 1/2\n",
      "\n",
      "#calculation\n",
      "Atten_dB = 10*(math.log(P2/P1)/math.log(10))     #attenuation or loss of power(dB)\n",
      "\n",
      "#result\n",
      "print \"Attenuation loss =\",round(Atten_dB,0), \"dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Attenuation loss = -3.0 dB\n"
       ]
      }
     ],
     "prompt_number": 28
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 1.7, Page Number: 14"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import math\n",
      "\n",
      "#variable Declaration\n",
      "Loss_line1 = -9                #attenuation of signal between point 1 to 2 = 9 dB\n",
      "Amp_gain2 = 14                 #Amplification of signal between point 2 to 3 = 14 dB\n",
      "Loss_line3 = -3                #attenuation of signal between point 3 to 4 = 3 dB\n",
      "\n",
      "#calculation\n",
      "dB_at_line4 = Loss_line1+Amp_gain2+Loss_line3     #power gain(dB)\n",
      "\n",
      "#result\n",
      "print \"Power gain for a signal travelling from point1 to another point4 = \",dB_at_line4, \"dB\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Power gain for a signal travelling from point1 to another point4 =  2 dB\n"
       ]
      }
     ],
     "prompt_number": 29
    }
   ],
   "metadata": {}
  }
 ]
}