summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarald Welte <laforge@gnumonks.org>2016-05-23 20:34:30 +0200
committerHarald Welte <laforge@gnumonks.org>2016-05-23 20:52:50 +0200
commita83df2448514796c9c79f09a826e455bcecfd8e2 (patch)
tree65906d5b6da6ccbc2b9981fbc56cfc9c33712eba
parentbc55a9c7e8177dc2503e3b9f46b80618db48001c (diff)
add inverse functions of path lossHEADmaster
using the rf_range_* functions, we can compute the signal range possible at the given permitted path loss in dB.
-rw-r--r--pathloss/pathloss-func.py76
-rw-r--r--pathloss/plugin.xml4
2 files changed, 69 insertions, 11 deletions
diff --git a/pathloss/pathloss-func.py b/pathloss/pathloss-func.py
index a9e9a65..8eb64ea 100644
--- a/pathloss/pathloss-func.py
+++ b/pathloss/pathloss-func.py
@@ -34,6 +34,17 @@ def func_fsl(freq_mhz, dist_m):
return -20 * math.log10(wavelen / (4*3.1416*dist_m))
+def func_fsl_inverse(freq_mhz, path_loss):
+ '@FUNCTION=RF_RANGE_FREESPACE\n'\
+ '@SYNTAX=rf_range_freespace(freq_mhz, path_loss_db)\n'\
+ '@DESCRIPTION=Compute Signal Range (in m) as per Free Space Loss Model\n'\
+ '@SEEALSO=pathloss_freespace,rf_range_egli,rf_range_hata\n'
+
+ wavelen = lambda_by_mhz(freq_mhz)
+ dist_m = (wavelen/10**(path_loss/-20)) / (4*3.1416)
+ return dist_m
+
+
def hata_ch(envi, freq_mhz, rx_ant_m):
logfreq = math.log10(freq_mhz)
ch = 0
@@ -63,6 +74,22 @@ def hata_cm(envi, freq_mhz):
att = 0
return att
+def hata_c0(freq_mhz):
+ # http://morse.colorado.edu/~tlen5510/text/classwebch3.html
+ if freq_mhz <= 1500:
+ c0 = 69.55
+ else:
+ c0 = 46.3
+ return c0
+
+def hata_cf(freq_mhz):
+ # http://morse.colorado.edu/~tlen5510/text/classwebch3.html
+ if freq_mhz <= 1500:
+ cf = 26.16
+ else:
+ cf = 33.9
+ return cf
+
def func_hata(envi, freq_mhz, dist_m, bts_ant_m, ms_ant_m):
'@FUNCTION=PATHLOSS_HATA\n'\
'@SYNTAX=pathloss_hata(environment, freq_mhz, dist_m, bts_ant_m, ms_ant_m)\n'\
@@ -75,16 +102,8 @@ def func_hata(envi, freq_mhz, dist_m, bts_ant_m, ms_ant_m):
if not envi in environs:
raise GnumericError,GnumericErrorVALUE
- # http://morse.colorado.edu/~tlen5510/text/classwebch3.html
- if freq_mhz <= 1500:
- c0 = 69.55
- cf = 26.16
- else:
- c0 = 46.3
- cf = 33.9
-
# https://en.wikipedia.org/wiki/Hata_model_for_urban_areas
- hata = c0 + cf * math.log10(freq_mhz)
+ hata = hata_c0(freq_mhz) + hata_cf(freq_mhz) * math.log10(freq_mhz)
hata -= 13.82 * math.log10(bts_ant_m)
hata -= hata_ch(envi, freq_mhz, ms_ant_m)
hata += (44.9 - 6.55 * math.log10(bts_ant_m)) * math.log10(dist_m/1000)
@@ -93,11 +112,32 @@ def func_hata(envi, freq_mhz, dist_m, bts_ant_m, ms_ant_m):
return hata
+def func_hata_inverse(envi, freq_mhz, path_loss, bts_ant_m, ms_ant_m):
+ '@FUNCTION=RF_RANGE_HATA\n'\
+ '@SYNTAX=rf_range_hata(environment, freq_mhz, path_loss_db, bts_ant_m, ms_ant_m)\n'\
+ '@DESCRIPTION=Compute Signal Range (in m) as per Hata Model\n'\
+ '@SEEALSO=pathloss_hata,rf_range_freespace,rF_range_egli\n'
+
+ l = hata_c0(freq_mhz) + hata_cf(freq_mhz) * math.log10(freq_mhz)
+ l -= 13.82 * math.log10(bts_ant_m)
+ l -= hata_ch(envi, freq_mhz, ms_ant_m)
+ l += hata_cm(envi, freq_mhz)
+ # subtract all non-distance related losses from path loss,
+ # remainder is the only term depending on distance
+ r = path_loss - l
+ mult = (44.9 - 6.55 * math.log10(bts_ant_m))
+ att_dist = r / mult
+ # now we just need the inverse of log10
+ dist_km = 10 ** att_dist
+
+ return dist_km * 1000
+
+
def func_egli(freq_mhz, dist_m, tx_ant_m, rx_ant_m):
'@FUNCTION=PATHLOSS_EGLI\n'\
'@SYNTAX=pathloss_egli(freq_mhz, dist_m, tx_ant_m, rx_ant_m)\n'\
'@DESCRIPTION=Compute Path Loss (in dB) as per Egli Model\n'\
- '@SEEALSO=foo\n'
+ '@SEEALSO=pathloss_freespace,pathloss_hata\n'
# https://en.wikipedia.org/wiki/Egli_model
att = -20 * math.log10(rx_ant_m*tx_ant_m / (dist_m*dist_m))
@@ -105,8 +145,24 @@ def func_egli(freq_mhz, dist_m, tx_ant_m, rx_ant_m):
return att
+def func_egli_inverse(freq_mhz, path_loss, bts_ant_m, ms_ant_m):
+ '@FUNCTION=RF_RANGE_EGLI\n'\
+ '@SYNTAX=rf_range_egli(freq_mhz, path_loss_db, bts_ant_m, ms_ant_m)\n'\
+ '@DESCRIPTION=Compute Signal Range (in m) as per Egli Model\n'\
+ '@SEEALSO=pathloss_egli,rf_range_freespace,rf_range_hata\n'
+
+ l = 20 * math.log10(freq_mhz/40)
+ r = path_loss - l
+ x = ms_ant_m*bts_ant_m
+ dist_m = math.sqrt(x/(10**(r/-20)))
+ return dist_m
+
+
pathlossfunc_functions = {
'pathloss_freespace': ('ff', 'freq_mhz, dist_m', func_fsl),
+ 'rf_range_freespace': ('ff', 'freq_mhz, path_loss', func_fsl_inverse),
'pathloss_egli': ('ffff', 'freq_mhz, dist_m, tx_ant_m, rx_ant_m', func_egli),
+ 'rf_range_egli': ('ffff', 'freq_mhz, path_loss_db, bts_ant_m, ms_ant_m', func_egli_inverse),
'pathloss_hata': ('sffff', 'environ, freq_mhz, dist_m, bts_ant_m, ms_ant_m', func_hata),
+ 'rf_range_hata': ('sffff', 'environ, freq_mhz, path_loss_db, bts_ant_m, ms_ant_m', func_hata_inverse),
}
diff --git a/pathloss/plugin.xml b/pathloss/plugin.xml
index 8ece45a..d17e632 100644
--- a/pathloss/plugin.xml
+++ b/pathloss/plugin.xml
@@ -12,9 +12,11 @@
<category>Local Python</category>
<functions>
<function name='pathloss_freespace'/>
+ <function name='rf_range_freespace'/>
<function name='pathloss_egli'/>
+ <function name='rf_range_egli'/>
<function name='pathloss_hata'/>
- <function name='pathloss_cost_hata'/>
+ <function name='rf_range_hata'/>
</functions>
</service>
</services>
personal git repositories of Harald Welte. Your mileage may vary