{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 25: Sky Wave Propagation<h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 25-5.1, Page number: 823<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "#Variable declaration\n",
      "muf = 10e6    #Maximum usable frequency (Hz)\n",
      "h = 300    #Height of reflection (km)\n",
      "n = 0.9      #Maximum value of refractive index (unitless)\n",
      "\n",
      "#Calculations\n",
      "Nmax = (1 - n**2)*(muf**2)/81    #Max. Number of electrons per cubic cm\n",
      "fc = 9*sqrt(Nmax)    #Critical frequency (Hz)\n",
      "dskip = 2*h*sqrt((muf/fc)**2 - 1)   #Skip distance (km)\n",
      "\n",
      "\n",
      "#Result\n",
      "print \"The skip distance is\", round(dskip,1), \"km\"\n",
      "\n",
      "#Numerical error in the calculation of sqrt((muf/fc)**2 - 1) "
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "2.34567901235e+11 4358898.94354\n",
        "The skip distance is 1238.8 km\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 25-5.2, Page number: 823<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Variable declaration\n",
      "fE = 3e6        #Critical frequency for E layer (Hz)\n",
      "fF1 = 5e6       #Critical frequency for F1 layer (Hz)\n",
      "fF2 = 9e6       #Critical frequency for F2 layer (Hz)\n",
      "\n",
      "#Calculations\n",
      "N_E = (fE**2)/81    #Concentration of electrons in E layer (per cubic cm)\n",
      "N_F1 = (fF1**2)/81 #Concentration of electrons in F1 layer (per cubic cm)\n",
      "N_F2 = (fF2**2)/81 #Concentration of electrons in F2 layer (per cubic cm)\n",
      "\n",
      "#Result\n",
      "print \"The concentration of electrons in E layer is\", round(N_E,-8), \"per cubic cm\"\n",
      "print \"The concentration of electrons in F1 layer is\", round(N_F1,-8), \"per cubic cm\"\n",
      "print \"The concentration of electrons in F2 layer is\", N_F2, \"per cubic cm\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The concentration of electrons in E layer is 1.111e+11 per cubic cm\n",
        "The concentration of electrons in F1 layer is 3.086e+11 per cubic cm\n",
        "The concentration of electrons in F2 layer is 1e+12 per cubic cm\n"
       ]
      }
     ],
     "prompt_number": 10
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 25-5.3, Page number: 823<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import sqrt\n",
      "\n",
      "#Variable declaration\n",
      "N_E = 0.8*0.111e12  #Concentration of electrons in E layer (per cubic cm)\n",
      "N_F1 = 0.8*0.3086e12 #Concentration of electrons in E layer (per cubic cm)\n",
      "N_F2 = 0.8*1e12     #Concentration of electrons in E layer (per cubic cm)\n",
      "\n",
      "#Calculations\n",
      "fE = 9*sqrt(N_E)    #Critical frequency in E layer (Hz)\n",
      "fF1 = 9*sqrt(N_F1)  #Cricital frequency in F1 layer (Hz)\n",
      "fF2 = 9*sqrt(N_F2)  #Critical frequency in F2 layer (Hz)\n",
      "\n",
      "#Result\n",
      "print \"The Critical frequency in E layer is\", round(fE,-4),\"Hz\"\n",
      "print \"The Critical frequency in F1 layer is\", round(fF1,-4),\"Hz\"\n",
      "print \"The Critical frequency in F2 layer is\", round(fF2,-3),\"Hz\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Critical frequency in E layer is 2680000.0 Hz\n",
        "The Critical frequency in F1 layer is 4470000.0 Hz\n",
        "The Critical frequency in F2 layer is 8050000.0 Hz\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 25-6.1, Page number: 829<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import cos, sqrt, pi\n",
      "\n",
      "#Variable declaration\n",
      "hD = 70     #Height of D layer (km)\n",
      "hE = 130     #Height of E layer (km)\n",
      "hF1 = 230     #Height of F1 layer (km)\n",
      "hF2 = 350     #Height of F2 layer (km)\n",
      "theta = 10*pi/180      #Angle of incidence (radians)\n",
      "\n",
      "#Calculations\n",
      "temp = sqrt((cos(theta))**-2 - 1)\n",
      "d1 = 2*hD*temp  #Maximum single hop distance for D layer (km)\n",
      "d2 = 2*hE*temp  #Maximum single hop distance for E layer (km)\n",
      "d3 = 2*hF1*temp #Maximum single hop distance for F1 layer (km)\n",
      "d4 = 2*hF2*temp #Maximum single hop distance for F2 layer (km)\n",
      "\n",
      "#Result\n",
      "print \"The Maximum single hop distance for D layer is\", round(d1,1), \"km\"\n",
      "print \"The Maximum single hop distance for E layer is\", round(d2,2), \"km\"\n",
      "print \"The Maximum single hop distance for F1 layer is\", round(d3,2), \"km\"\n",
      "print \"The Maximum single hop distance for F2 layer is\", round(d4,1), \"km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Maximum single hop distance for D layer is 24.7 km\n",
        "The Maximum single hop distance for E layer is 45.85 km\n",
        "The Maximum single hop distance for F1 layer is 81.11 km\n",
        "The Maximum single hop distance for F2 layer is 123.4 km\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 25-9.1, Page number: 832<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "from math import pi, sqrt, cos\n",
      "\n",
      "#Variable declaration\n",
      "d = 200     #Height of layer (km)\n",
      "beta = 20    #Takeoff angle (degrees)\n",
      "R = 6370    #Earth's radius (km)\n",
      "\n",
      "#Calculations\n",
      "phi_0 = 90 - beta   #Take off angle for flat earth (degrees)\n",
      "h = (d/2)/(sqrt((cos(phi_0*pi/180)**-2) - 1))    #Skip distance for case (a) (km)\n",
      "\n",
      "phi_02 = 90 - beta - 57.2*d/(2*R)\n",
      "                    #Take off angle for spherical earth (degrees)\n",
      "h2 = (d/2)/(sqrt((cos(phi_02*pi/180)**-2) - 1))\n",
      "                    #Skip distance for case (b) (km)\n",
      "\n",
      "#Result\n",
      "print \"The skip distance for case (a) is\", round(h,3), \"km\"\n",
      "print \"The skip distance for case (b) is\", round(h2,2), \"km\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The skip distance for case (a) is 36.397 km\n",
        "The skip distance for case (b) is 38.18 km\n"
       ]
      }
     ],
     "prompt_number": 21
    }
   ],
   "metadata": {}
  }
 ]
}