{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Calculate path propagation/attenuation according to ITU-R P.452 (16)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## License\n",
"\n",
"```\n",
"Calculate path propagation/attenuation according to ITU-R P.452 (16).\n",
"Copyright (C) 2015+ Benjamin Winkel (bwinkel@mpifr.de)\n",
"\n",
"This program is free software; you can redistribute it and/or\n",
"modify it under the terms of the GNU General Public License\n",
"as published by the Free Software Foundation; either version 2\n",
"of the License, or (at your option) any later version.\n",
"\n",
"This program is distributed in the hope that it will be useful,\n",
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
"GNU General Public License for more details.\n",
"\n",
"You should have received a copy of the GNU General Public License\n",
"along with this program; if not, write to the Free Software\n",
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from matplotlib import animation, rc\n",
"from pycraf import pathprof\n",
"from pycraf import conversions as cnv\n",
"from astropy import units as u\n",
"\n",
"rc('animation', html='html5')\n",
"FRAMES = 120"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Influence of the free parameters"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The propagation losses depend on a lot of different parameters, such as frequency, distance, weather etc. Here, we try to visualize some of the effects. The generic (flat-Earth) case is used (without loss of generality)."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"distance = 100 * u.km\n",
"hprof_step = 50 * u.m\n",
"lon_t, lat_t = 0 * u.deg, 50 * u.deg"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"hprof_data = pathprof.height_path_data_generic(\n",
" distance, hprof_step, lon_t, lat_t,\n",
" )"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def plot_helper(freq, temp, press, h_tg, h_rg, time_percent, titles):\n",
" \n",
" plt.close()\n",
" fig = plt.figure(figsize=(14, 10))\n",
" ax = fig.add_axes((0.1, 0.1, 0.8, 0.8))\n",
"\n",
" lines_dict = {}\n",
" for key, name, style in zip(\n",
" ['L_b0p', 'L_bd', 'L_bs', 'L_ba', 'L_b'],\n",
" ['LOS', 'Diffraction', 'Troposcatter', 'Ducting', 'Total'], \n",
" ['b-', 'r-', 'c-', 'g-', 'k--']\n",
" ):\n",
" results = pathprof.atten_path_fast(\n",
" freq[0], temp[0], press[0],\n",
" h_tg[0], h_rg[0], time_percent[0],\n",
" hprof_data,\n",
" )\n",
" lines_dict[key] = ax.plot(\n",
" hprof_data['distances'][5:],\n",
" results[key][5:],\n",
" style, label=name\n",
" )[0]\n",
"\n",
" ax.legend(\n",
" *ax.get_legend_handles_labels(), \n",
" loc='lower right', fontsize=8, handlelength=3\n",
" )\n",
" title = ax.set_title(titles[0], loc='center', fontsize=20)\n",
"\n",
" ax.set_xlim((0, 100))\n",
" ax.set_ylim((80, 260))\n",
" ax.set_xlabel('Distance [km]')\n",
" ax.set_ylabel('Path attenuation [dB]')\n",
" ax.grid()\n",
"\n",
"\n",
" def animate_freq(i):\n",
"\n",
" results = pathprof.atten_path_fast(\n",
" freq[i], temp[i], press[i],\n",
" h_tg[i], h_rg[i], time_percent[i],\n",
" hprof_data,\n",
" )\n",
"\n",
" title.set_text(titles[i])\n",
" for key in ['L_b0p', 'L_bd', 'L_bs', 'L_ba', 'L_b']:\n",
"\n",
" lines_dict[key].set_ydata(results[key][5:])\n",
"\n",
" return list(lines_dict.values())\n",
"\n",
" def init():\n",
" return animate_freq(0)\n",
"\n",
" # call the animator. blit=True means only re-draw the parts that have changed.\n",
" anim = animation.FuncAnimation(\n",
" fig, animate_freq, init_func=init, frames=FRAMES, interval=50, blit=True\n",
" )\n",
"\n",
" # this takes a while!\n",
" plt.close(anim._fig)\n",
"\n",
" return anim"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Frequency dependence"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"h_tg, h_rg = np.full(FRAMES, 30) * u.m, np.full(FRAMES, 30) * u.m\n",
"freq = np.logspace(np.log10(0.1), np.log10(50), FRAMES) * u.GHz\n",
"temp = np.full(FRAMES, 293.15) * u.K\n",
"press = np.full(FRAMES, 1013.) * u.hPa\n",
"\n",
"time_percent = np.full(FRAMES, 2) * u.percent\n",
"\n",
"titles = ['Frequency: {:5.2f}'.format(f) for f in freq]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_helper(freq, temp, press, h_tg, h_rg, time_percent, titles)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Temperature dependence"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"h_tg, h_rg = np.full(FRAMES, 30) * u.m, np.full(FRAMES, 30) * u.m\n",
"freq = np.full(FRAMES, 10.) * u.GHz\n",
"temp = np.linspace(250., 330, FRAMES) * u.K\n",
"press = np.full(FRAMES, 1013.) * u.hPa\n",
"\n",
"time_percent = np.full(FRAMES, 2) * u.percent\n",
"\n",
"titles = ['Temperature: {:5.2f}'.format(t) for t in temp]"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false,
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_helper(freq, temp, press, h_tg, h_rg, time_percent, titles)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Time-percent dependence"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"h_tg, h_rg = np.full(FRAMES, 30) * u.m, np.full(FRAMES, 30) * u.m\n",
"freq = np.full(FRAMES, 10.) * u.GHz\n",
"temp = np.full(FRAMES, 293.15) * u.K\n",
"press = np.full(FRAMES, 1013.) * u.hPa\n",
"\n",
"time_percent = np.logspace(np.log10(0.1), np.log10(50), FRAMES) * u.percent\n",
"\n",
"titles = ['Time percent: {:5.2f}'.format(p) for p in time_percent]"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
""
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot_helper(freq, temp, press, h_tg, h_rg, time_percent, titles)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Python [conda root]",
"language": "python",
"name": "conda-root-py"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
}