-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreference.py
3019 lines (2340 loc) · 110 KB
/
reference.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- coding: utf-8 -*-
"""
Created on Tue 27 Sep 2022
@author: eeveetza
"""
import os
import numpy as np
def bt_loss(f, p, d, h, R, Ct, zone, htg, hrg, pol, phi_t, phi_r, lam_t, lam_r, **kwargs):
"""
P1812.bt_loss basic transmission loss according to P.1812-6
Lb = P1812.bt_lossbt_loss(f, p, d, h, R, Ct, zone, htg, hrg, pol, phi_t, phi_r, lam_t, lam_r)
This is the MAIN function that computes the basic transmission loss not exceeded for p% time
and pL% locations, including additional losses due to terminal surroundings
and the field strength exceeded for p% time and pL% locations
as defined in ITU-R P.1812-6.
This function:
does not include the building entry loss (only outdoor scenarios implemented)
Other functions called from this function are in ./private/ subfolder.
Input parameters:
f - Frequency (GHz)
p - Required time percentage for which the calculated basic
transmission loss is not exceeded
d - vector of distances di of the i-th profile point (km)
h - vector of heights hi of the i-th profile point (meters
above mean sea level.
R - vector of representative clutter height Ri of the i-th profile point (m)
Ct - vector of representative clutter type Cti of the i-th profile point
Water/sea (1), Open/rural (2), Suburban (3),
Urban/trees/forest (4), Dense urban (5)
if empty or all zeros, the default clutter used is Open/rural
zone - vector of radio-climatic zone types: Inland (4), Coastal land (3), or Sea (1)
htg - Tx Antenna center heigth above ground level (m)
hrg - Rx Antenna center heigth above ground level (m)
pol - polarization of the signal (1) horizontal, (2) vertical
phi_t - latitude of Tx station (degrees)
phi_r - latitude of Rx station (degrees)
lam_t - longitude of Tx station (degrees)
lam_r - longitude of Rx station (degrees)
Optional input parameters (using keywords):
pL - Required time percentage for which the calculated basic
transmission loss is not exceeded (1% - 99%)
sigmaL - location variability standard deviations computed using
stdDev.m according to §4.8 and §4.10
the value of 5.5 dB used for planning Broadcasting DTT
Ptx - Transmitter power (kW), default value 1 kW
DN - The average radio-refractive index lapse-rate through the
lowest 1 km of the atmosphere (it is a positive quantity in this
procedure) (N-units/km)
N0 - The sea-level surface refractivity, is used only by the
troposcatter model as a measure of location variability of the
troposcatter mechanism. The correct values of DN and N0 are given by
the path-centre values as derived from the appropriate
maps (N-units)
dct - Distance over land from the transmit and receive
dcr antennas to the coast along the great-circle interference path (km).
default values dct = 500 km, dcr = 500 km, or
set to zero for a terminal on a ship or sea platform
flag4 - Set to 1 if the alternative method is used to calculate Lbulls
without using terrain profile analysis (Attachment 4 to Annex 1)
debug - Set to 1 if the log files are to be written,
otherwise set to default 0
fid_log - if debug == 1, a file identifier of the log file can be
provided, if not, the default file with a file
containing a timestamp will be created
Output parameters:
Lb - basic transmission loss according to P.1812-6
Example:
1) Call with required input parameters
Lb = bt_loss(f,p,d,h,R,Ct,zone,htg,hrg,pol,phi_t,phi_r,lam_t,lam_r)
2) Call with required input parameters and optional input parameters as keyword
Lb = bt_loss(f,p,d,h,R,Ct,zone,htg,hrg,pol,phi_t,phi_r,lam_t,lam_r,DN = 50, N0 = 400)
Rev Date Author Description
-------------------------------------------------------------------------------
v0 28SEP22 Ivica Stevanovic, OFCOM Initial version
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
THE AUTHOR(S) AND OFCOM (CH) DO NOT PROVIDE ANY SUPPORT FOR THIS SOFTWARE
"""
# Set default values for optional arguments
pL = kwargs.get('pL', 50.0)
sigmaL = kwargs.get('sigmaL', 0.0)
Ptx = kwargs.get('Ptx', 1.0)
DN = kwargs.get('DN', 45.0)
N0 = kwargs.get('N0', 325.0)
dct = kwargs.get('dct', 500.0)
dcr = kwargs.get('dcr', 500.0)
flag4 = kwargs.get('flag4', 0)
debug = kwargs.get('debug', 0)
fid_log = kwargs.get('fid_log', [])
# Ensure that vector d is ascending
if (not issorted(d)):
raise ValueError(
'The array of path profile points d(i) must be in ascending order.')
# Ensure that d[0] = 0 (Tx position)
if d[0] > 0.0:
raise ValueError(
'The first path profile point d[0] = ' + str(d[0]) + ' must be zero.')
# verify input argument values and limits
if not (f >= 0.03 and f <= 6.0):
print('Warning: frequency must be in the range [0.03, 6] GHz. ')
print(
'Computation will continue but the parameters are outside of the valid domain.')
if not (p >= 1 and p <= 50):
raise ValueError('The time percentage must be in the range [1, 50]%')
if not (htg >= 1 and htg <= 3000):
raise ValueError(
'The Tx antenna height must be in the range [1, 3000] m')
if not (hrg >= 1 and hrg <= 3000):
raise ValueError(
'The Rx antenna height must be in the range [1, 3000] m')
if not (pol == 1 or pol == 2):
raise ValueError(
'The polarization pol can be either 1 (horizontal) or 2 (vertical).')
# make sure that there is enough points in the path profile
if (len(d) <= 4):
raise ValueError(
'The number of points in path profile should be larger than 4')
xx = np.logical_or(zone == 1, np.logical_or(zone == 3, zone == 4))
if (np.any(xx == False)):
raise ValueError(
'The vector of radio-climatic zones zone may only contain integers 1, 3, or 4.')
if not (pL > 0 and pL < 100):
raise ValueError(
'The location percentage must be in the range (0, 100)%')
if not (Ptx > 0):
raise ValueError('The Tx power must be positive.')
if (dct < 0 or dcr < 0):
raise ValueError('Distances dct and dcr must be positive.')
if (sigmaL < 0):
raise ValueError(
'Standard deviation in location variability must be positive.')
if not (flag4 == 0 or flag4 == 1):
raise ValueError('The parameter flag4 can be either 0 or 1.')
NN = len(d)
# the number of elements in d and path need to be the same
if not (len(h) == NN):
raise ValueError(
'The number of elements in the array d and the array h must be the same.')
if isempty(R):
R = np.zeros(h.shape) # default is clutter height zero
elif not (len(R) == NN):
raise ValueError(
'The number of elements in the array d and the array R must be the same.')
if isempty(Ct):
Ct = 2*np.ones(h.shape) # default is Open/rural clutter type
elif Ct.any() == 0:
Ct = 2*np.ones(h.shape) # default is Open/rural clutter type
else:
if not (len(Ct) == NN):
raise ValueError(
'The number of elements in the array d and the array Ct must be the same.')
if isempty(zone):
# default is Inland radio-meteorological zone
zone = 4*np.ones(h.shape)
else:
if not (len(zone) == NN):
raise ValueError(
'The number of elements in the array d and the array zone must be the same.')
if zone[0] == 1: # Tx at sea
dct = 0
if zone[-1] == 1: # Rx at sea
dcr = 0
# handle number fidlog is reserved here for writing the files
# if fidlog is already open outside of this function, the file needs to be
# empty (nothing written), otherwise it will be closed and opened again
# if fid is not open, then a file with a name corresponding to the time
# stamp will be opened and closed within this function.
inside_file = 0
if (debug):
if (isempty(fid_log)):
fid_log = open('P1812_log.csv', 'w')
inside_file = 1
if (fid_log == -1):
raise IOError('The log file could not be opened')
else:
inside_file = 0
floatformat = '%.10g,\n'
if (debug):
fid_log.write('# Parameter,Ref,,Value,\n')
fid_log.write('Ptx (kW),,,' + floatformat % (Ptx))
fid_log.write('f (GHz),,,' + floatformat % (f))
fid_log.write('p (%),,,' + floatformat % (p))
fid_log.write('pL (%),,,' + floatformat % (pL))
fid_log.write('sigmaL (dB),,,' + floatformat % (sigmaL))
fid_log.write('phi_t (deg),,,' + floatformat % (phi_t))
fid_log.write('phi_r (deg),,,' + floatformat % (phi_r))
fid_log.write('lam_t (deg),,,' + floatformat % (lam_t))
fid_log.write('lam_r (deg),,,' + floatformat % (lam_r))
fid_log.write('htg (m),,,' + floatformat % (htg))
fid_log.write('hrg (m),,,' + floatformat % (hrg))
fid_log.write('pol,,,' '%d,\n' % (pol))
fid_log.write('DN ,,,' + floatformat % (DN))
fid_log.write('N0 ,,,' + floatformat % (N0))
fid_log.write('dct (km) ,,,' + floatformat % (dct))
fid_log.write('dcr (km) ,,,' + floatformat % (dcr))
fid_log.write('R2 (m) ,,,' + floatformat % (R[1]))
fid_log.write('Rn-1 (m) ,,,' + floatformat % (R[-2]))
fid_log.write('Ct Tx ,Table 2,,' + floatformat % (Ct[1]))
fid_log.write('Ct Rx ,Table 2,,' + floatformat % (Ct[-2]))
# Compute the path profile parameters
# Path center latitude
Re = 6371
dpnt = 0.5 * (d[-1]-d[0])
lam_path, phi_path, Bt2r, dgc = great_circle_path(
lam_r, lam_t, phi_r, phi_t, Re, dpnt)
# Compute dtm - the longest continuous land (inland + coastal =34) section of the great-circle path (km)
zone_r = 34
dtm = longest_cont_dist(d, zone, zone_r)
# Compute dlm - the longest continuous inland section (4) of the great-circle path (km)
zone_r = 4
dlm = longest_cont_dist(d, zone, zone_r)
# Compute b0
b0 = beta0(phi_path, dtm, dlm)
ae, ab = earth_rad_eff(DN)
# Compute the path fraction over see Eq (1)
omega = path_fraction(d, zone, 1)
# Derive parameters for the path profile analysis
hst_n, hsr_n, hst, hsr, hstd, hsrd, hte, hre, hm, dlt, dlr, theta_t, theta_r, theta, pathtype = smooth_earth_heights(
d, h, R, htg, hrg, ae, f)
dtot = d[-1] - d[0]
# Tx and Rx antenna heights above mean sea level amsl (m)
hts = h[0] + htg
hrs = h[-1] + hrg
# Modify the path by adding representative clutter, according to Section 3.2
# excluding the first and the last point
g = h + R
g[0] = h[0]
g[-1] = h[-1]
# Compute htc and hrc as defined in Table 5 (P.1812-6)
htc = hts
hrc = hrs
if (debug):
fid_log.write(',,,,\n')
fid_log.write('d (km),,,' + floatformat % (dtot))
fid_log.write('dlt (km),Eq (78),,' + floatformat % (dlt))
fid_log.write('dlr (km),Eq (81a),,' + floatformat % (dlr))
fid_log.write('th_t (mrad),Eqs (76-78),,' + floatformat % (theta_t))
fid_log.write('th_r (mrad),Eqs (79-81),,' + floatformat % (theta_r))
fid_log.write('th (mrad),Eq (82),,' + floatformat % (theta))
fid_log.write('hts (m),,,' + floatformat % (hts))
fid_log.write('hrs (m),,,' + floatformat % (hrs))
fid_log.write('htc (m),Table 5,,' + floatformat % (htc))
fid_log.write('hrc (m),Table 5,,' + floatformat % (hrc))
fid_log.write('w,Table 5,,' + floatformat % (omega))
fid_log.write('dtm (km),Sec 3.6,,' + floatformat % (dtm))
fid_log.write('dlm (km),Sec 3.6,,' + floatformat % (dlm))
fid_log.write('phi (deg),Eq (4),,' + floatformat % (phi_path))
fid_log.write('b0 (%),Eq (5),,' + floatformat % (b0))
fid_log.write('ae (km),Eq (7a),,' + floatformat % (ae))
fid_log.write('hst (m),Eq (85),,' + floatformat % (hst_n))
fid_log.write('hsr (m),Eq (86),,' + floatformat % (hsr_n))
fid_log.write('hst (m),Eq (90a),,' + floatformat % (hst))
fid_log.write('hsr (m),Eq (90b),,' + floatformat % (hsr))
fid_log.write('hstd (m),Eq (89),,' + floatformat % (hstd))
fid_log.write('hsrd (m),Eq (89),,' + floatformat % (hsrd))
fid_log.write('htc'' (m),Eq (37a),,' + floatformat % (htc-hstd))
fid_log.write('hrc'' (m),Eq (37b),,' + floatformat % (hrc-hsrd))
fid_log.write('hte (m),Eq (92a),,' + floatformat % (hte))
fid_log.write('hre (m),Eq (92b),,' + floatformat % (hre))
fid_log.write('hm (m),Eq (93),,' + floatformat % (hm))
fid_log.write('\n')
# Calculate an interpolation factor Fj to take account of the path angular
# distance Eq (57)
THETA = 0.3
KSI = 0.8
Fj = 1.0 - 0.5*(1.0 + np.tanh(3.0 * KSI * (theta-THETA)/THETA))
# Calculate an interpolation factor, Fk, to take account of the great
# circle path distance:
dsw = 20
kappa = 0.5
Fk = 1.0 - 0.5*(1.0 + np.tanh(3.0 * kappa * (dtot-dsw)/dsw)) # eq (58)
Lbfs, Lb0p, Lb0b = pl_los(dtot, hts, hrs, f, p, b0, dlt, dlr)
Ldp, Ldb, Ld50, Lbulla50, Lbulls50, Ldsph50 = dl_p(
d, g, htc, hrc, hstd, hsrd, f, omega, p, b0, DN, flag4)
# The median basic transmission loss associated with diffraction Eq (42)
Lbd50 = Lbfs + Ld50
# The basic tranmission loss associated with diffraction not exceeded for
# p% time Eq (43)
Lbd = Lb0p + Ldp
# A notional minimum basic transmission loss associated with LoS
# propagation and over-sea sub-path diffraction
Lminb0p = Lb0p + (1-omega)*Ldp
# eq (40a)
Fi = 1
if p >= b0:
Fi = inv_cum_norm(p/100.0)/inv_cum_norm(b0/100.0)
Lminb0p = Lbd50 + (Lb0b + (1-omega)*Ldp - Lbd50)*Fi # eq (59)
# Calculate a notional minimum basic transmission loss associated with LoS
# and transhorizon signal enhancements
eta = 2.5
Lba = tl_anomalous(dtot, dlt, dlr, dct, dcr, dlm, hts, hrs,
hte, hre, hm, theta_t, theta_r, f, p, omega, ae, b0)
Lminbap = eta*np.log(np.exp(Lba/eta) + np.exp(Lb0p/eta)) # eq (60)
# Calculate a notional basic transmission loss associated with diffraction
# and LoS or ducting/layer reflection enhancements
Lbda = Lbd
if Lminbap <= Lbd[0]:
Lbda[0] = Lminbap + (Lbd[0]-Lminbap)*Fk
if Lminbap <= Lbd[1]:
Lbda[1] = Lminbap + (Lbd[1]-Lminbap)*Fk
# Calculate a modified basic transmission loss, which takes diffraction and
# LoS or ducting/layer-reflection enhancements into account
Lbam = Lbda + (Lminb0p - Lbda)*Fj # eq (62)
# Calculate the basic transmission loss due to troposcatter not exceeded
# for any time percantage p
Lbs = tl_tropo(dtot, theta, f, p, N0)
# Calculate the final transmission loss not exceeded for p% time
Lbc_pol = -5*np.log10(10**(-0.2*Lbs) + 10**(-0.2*Lbam)) # eq (63)
Lbc = Lbc_pol[int(pol-1)]
Lloc = 0.0 # outdoors only (67a)
# Location variability of losses (Section 4.8)
if not (zone[-1] == 1): # Rx not at sea
Lloc = -inv_cum_norm(pL/100.0) * sigmaL
# Basic transmission loss not exceeded for p% time and pL% locations
# (Sections 4.8 and 4.9) not implemented
Lb = max(Lb0p, Lbc + Lloc) # eq (69)
# The field strength exceeded for p% time and pL% locations
Ep = 199.36 + 20*np.log10(f) - Lb # eq (70)
# Scale to the transmitter power
EpPtx = Ep + 10*np.log10(Ptx)
Ep = EpPtx
if (debug):
fid_log.write('Fi,Eq (40),,' + floatformat % (Fi))
fid_log.write('Fj,Eq (57),,' + floatformat % (Fj))
fid_log.write('Fk,Eq (58),,' + floatformat % (Fk))
fid_log.write('Lbfs,Eq (8),,' + floatformat % (Lbfs))
fid_log.write('Lb0p,Eq (10),,' + floatformat % (Lb0p))
fid_log.write('Lb0b,Eq (11),,' + floatformat % (Lb0b))
fid_log.write('Lbulla (dB),Eq (21),,' + floatformat % (Lbulla50))
fid_log.write('Lbulls (dB),Eq (21),,' + floatformat % (Lbulls50))
fid_log.write('Ldsph (dB),Eq (27),,' + floatformat %
(Ldsph50[int(pol-1)]))
fid_log.write('Ld50 (dB),Eq (39),,' + floatformat % (Ld50[int(pol-1)]))
fid_log.write('Ldb (dB),Eq (39),,' + floatformat % (Ldb[int(pol-1)]))
fid_log.write('Ldp (dB),Eq (41),,' + floatformat % (Ldp[int(pol-1)]))
fid_log.write('Lbd50 (dB),Eq (42),,' + floatformat %
(Lbd50[int(pol-1)]))
fid_log.write('Lbd (dB),Eq (43),,' + floatformat % (Lbd[int(pol-1)]))
fid_log.write('Lminb0p (dB),Eq (59),,' + floatformat %
(Lminb0p[int(pol-1)]))
fid_log.write('Lba (dB),Eq (46),,' + floatformat % (Lba))
fid_log.write('Lminbap (dB),Eq (60),,' + floatformat % (Lminbap))
fid_log.write('Lbda (dB),Eq (61),,' + floatformat % (Lbda[int(pol-1)]))
fid_log.write('Lbam (dB),Eq (62),,' + floatformat % (Lbam[int(pol-1)]))
fid_log.write('Lbs (dB),Eq (44),,' + floatformat % (Lbs))
fid_log.write('Lbc (dB),Eq (63),,' + floatformat % (Lbc))
fid_log.write('Lb (dB),Eq (69),,' + floatformat % (Lb))
fid_log.write('Ep (dBuV/m),Eq (70),,' + floatformat % (Ep))
fid_log.write('Ep (dBuV/m) w.r.t. Ptx,,,' + floatformat % (EpPtx))
return Lb, Ep
def tl_tropo(dtot, theta, f, p, N0):
"""
tl_tropo Basic transmission loss due to troposcatterer to P.1812-6
Lbs = tl_tropo(dtot, theta, f, p, N0)
This function computes the basic transmission loss due to troposcatterer
not exceeded for p% of time
as defined in ITU-R P.1812-6 (Section 4.4)
Input parameters:
dtot - Great-circle path distance (km)
theta - Path angular distance (mrad)
f - frequency expressed in GHz
p - percentage of time
N0 - path centre sea-level surface refractivity derived from Fig. 6
Output parameters:
Lbs - the basic transmission loss due to troposcatterer
not exceeded for p% of time
Example:
Lbs = tl_tropo(dtot, theta, f, p, N0)
Rev Date Author Description
-------------------------------------------------------------------------------
v0 29SEP22 Ivica Stevanovic, OFCOM Initial version
"""
# Frequency dependent loss
Lf = 25*np.log10(f) - 2.5*(np.log10(f/2.0))**2 # eq (45)
# the basic transmission loss due to troposcatter not exceeded for any time
# percentage p, below 50# is given
Lbs = 190.1 + Lf + 20 * \
np.log10(dtot) + 0.573*theta - 0.15*N0 - \
10.125*(np.log10(50.0/p))**(0.7)
return Lbs
def tl_anomalous(dtot, dlt, dlr, dct, dcr, dlm, hts, hrs, hte, hre, hm, theta_t, theta_r, f, p, omega, ae, b0):
"""
tl_anomalous Basic transmission loss due to anomalous propagation according to P.452-17
Lba = tl_anomalous(dtot, dlt, dlr, dct, dcr, dlm, hts, hrs, hte, hre, hm, theta_t, theta_r, f, p, omega, ae, b0)
This function computes the basic transmission loss occuring during
periods of anomalous propagation (ducting and layer reflection)
as defined in ITU-R P.1812-6 (Section 4.5)
Input parameters:
dtot - Great-circle path distance (km)
dlt - interfering antenna horizon distance (km)
dlr - Interfered-with antenna horizon distance (km)
dct, dcr - Distance over land from the transmit and receive
antennas tothe coast along the great-circle interference path (km).
Set to zero for a terminal on a ship or sea platform
dlm - the longest continuous inland section of the great-circle path (km)
hts, hrs - Tx and Rx antenna heights aobe mean sea level amsl (m)
hte, hre - Tx and Rx terminal effective heights for the ducting/layer reflection model (m)
hm - The terrain roughness parameter (m)
theta_t - Interfering antenna horizon elevation angle (mrad)
theta_r - Interfered-with antenna horizon elevation angle (mrad)
f - frequency expressed in GHz
p - percentage of time
omega - fraction of the total path over water
ae - the median effective Earth radius (km)
b0 - the time percentage that the refractivity gradient (DELTA-N) exceeds 100 N-units/km in the first 100m of the lower atmosphere
Output parameters:
Lba - the basic transmission loss due to anomalous propagation
(ducting and layer reflection)
Example:
Lba = tl_anomalous(dtot, dlt, dlr, dct, dcr, dlm, hts, hrs, hte, hre, hm, theta_t, theta_r, f, p, omega, b0)
Rev Date Author Description
-------------------------------------------------------------------------------
v0 29SEP22 Ivica Stevanovic, OFCOM Initial version
"""
# empirical correction to account for the increasing attenuation with
# wavelength inducted propagation (47a)
Alf = 0
if f < 0.5:
Alf = 45.375 - 137.0*f + 92.5*f*f
# site-shielding diffraction losses for the interfering and interfered-with
# stations (48)
theta_t2 = theta_t - 0.1*dlt # eq (48a)
theta_r2 = theta_r - 0.1*dlr
Ast = 0
Asr = 0
if theta_t2 > 0:
Ast = 20*np.log10(1 + 0.361*theta_t2*np.sqrt(f*dlt)
) + 0.264*theta_t2*f**(1.0/3.0)
if theta_r2 > 0:
Asr = 20*np.log10(1 + 0.361*theta_r2*np.sqrt(f*dlr)
) + 0.264*theta_r2*f**(1.0/3.0)
# over-sea surface duct coupling correction for the interfering and
# interfered-with stations (49) and (49a)
Act = 0
Acr = 0
if dct <= 5:
if dct <= dlt:
if omega >= 0.75:
Act = -3*np.exp(-0.25*dct*dct)*(1 + np.tanh(0.07*(50-hts)))
if dcr <= 5:
if dcr <= dlr:
if omega >= 0.75:
Acr = -3*np.exp(-0.25*dcr*dcr)*(1 + np.tanh(0.07*(50-hrs)))
# specific attenuation (51)
gamma_d = 5e-5 * ae * f ** (1.0/3.0)
# angular distance (corrected where appropriate) (52-52a)
theta_t1 = theta_t
theta_r1 = theta_r
if theta_t > 0.1*dlt:
theta_t1 = 0.1*dlt
if theta_r > 0.1*dlr:
theta_r1 = 0.1*dlr
theta1 = 1e3*dtot/ae + theta_t1 + theta_r1
dI = min(dtot - dlt - dlr, 40) # eq (56a)
mu3 = 1
if hm > 10:
mu3 = np.exp(-4.6e-5 * (hm-10)*(43+6*dI)) # eq (56)
tau = 1 - np.exp(-(4.12e-4*dlm**2.41)) # eq (3)
epsilon = 3.5
alpha = -0.6 - epsilon*1e-9*dtot**(3.1)*tau # eq (55a)
if alpha < -3.4:
alpha = -3.4
# correction for path geometry:
mu2 = (500/ae * dtot**2/(np.sqrt(hte) + np.sqrt(hre))**2)**alpha # eq (55)
if mu2 > 1:
mu2 = 1
beta = b0 * mu2 * mu3 # eq (54)
# beta = max(beta, eps) # to avoid division by zero
Gamma = 1.076/(2.0058-np.log10(beta))**1.012 * \
np.exp(-(9.51 - 4.8*np.log10(beta) + 0.198*(np.log10(beta)) ** 2)
* 1e-6*dtot**(1.13)) # eq (53a)
# time percentage variablity (cumulative distribution):
Ap = -12 + (1.2 + 3.7e-3*dtot)*np.log10(p/beta) + \
12 * (p/beta)**Gamma # eq (53)
# time percentage and angular-distance dependent losses within the
# anomalous propagation mechanism
Adp = gamma_d*theta1 + Ap # eq (50)
# total of fixed coupling losses (except for local clutter losses) between
# the antennas and the anomalous propagation structure within the
# atmosphere (47)
Af = 102.45 + 20*np.log10(f) + 20*np.log10(dlt +
dlr) + Alf + Ast + Asr + Act + Acr
# total basic transmission loss occuring during periods of anomalaous
# propagation (46)
Lba = Af + Adp
return Lba
def smooth_earth_heights(d, h, R, htg, hrg, ae, f):
"""
smooth_earth_heights smooth-Earth effective antenna heights according to ITU-R P.1812-6
hst_n, hsr_n, hst, hsr, hstd, hsrd, hte, hre, hm, dlt, dlr, theta_t, theta_r, theta_tot, pathtype = smooth_earth_heights(d, h, R, htg, hrg, ae, f)
This function derives smooth-Earth effective antenna heights according to
Sections 4 and 5 of the Attachment 1 to Annex 1 of ITU-R P.1812-6
Input parameters:
d - vector of terrain profile distances from Tx [0,dtot] (km)
h - vector of terrain profile heigths amsl (m)
R - vector of representative clutter heights (m)
htg, hrg - Tx and Rx antenna heights above ground level (m)
ae - median effective Earth's radius (c.f. Eq (6a))
f - frequency (GHz)
Output parameters:
hst_n, hsr_n - Not corrected Tx and Rx antenna heigts of the smooth-Earth surface amsl (m)
hst, hsr - Tx and Rx antenna heigts of the smooth-Earth surface amsl (m)
hstd, hsrd - Tx and Rx effective antenna heigts for the diffraction model (m)
hte, hre - Tx and Rx terminal effective heights for the ducting/layer reflection model (m)
hm - The terrain roughness parameter (m)
dlt - interfering antenna horizon distance (km)
dlr - Interfered-with antenna horizon distance (km)
theta_t - Interfering antenna horizon elevation angle (mrad)
theta_r - Interfered-with antenna horizon elevation angle (mrad)
theta_tot - Angular distance (mrad)
pathtype - 1 = 'los', 2 = 'transhorizon'
Rev Date Author Description
-------------------------------------------------------------------------------
v0 29SEP22 Ivica Stevanovic, OFCOM First implementation in python
"""
n = len(d)
dtot = d[-1]
# Tx and Rx antenna heights above mean sea level amsl (m)
hts = h[0] + htg
hrs = h[-1] + hrg
g = h + R
g[0] = h[0]
g[-1] = h[-1]
htc = hts
hrc = hrs
# Section 5.6.1 Deriving the smooth-Earth surface
v1 = 0
for ii in range(1, n):
v1 = v1 + (d[ii]-d[ii-1])*(h[ii]+h[ii-1]) # Eq (85)
v2 = 0
for ii in range(1, n):
v2 = v2 + (d[ii]-d[ii-1])*(h[ii]*(2*d[ii] + d[ii-1]) +
h[ii-1] * (d[ii] + 2*d[ii-1])) # Eq (86)
hst = (2*v1*dtot - v2)/dtot ** 2 # Eq (87)
hsr = (v2 - v1*dtot)/dtot ** 2 # Eq (88)
hst_n = hst
hsr_n = hsr
# Section 5.6.2 Smooth-surface heights for the diffraction model
HH = h - (htc*(dtot-d) + hrc*d)/dtot # Eq (89d)
hobs = max(HH[1:-1]) # Eq (89a)
alpha_obt = max(HH[1:-1] / d[1:-1]) # Eq (89b)
alpha_obr = max(HH[1:-1] / (dtot - d[1:-1])) # Eq (89c)
# Calculate provisional values for the Tx and Rx smooth surface heights
gt = alpha_obt/(alpha_obt + alpha_obr) # Eq (90e)
gr = alpha_obr/(alpha_obt + alpha_obr) # Eq (90f)
if hobs <= 0:
hstp = hst # Eq (90a)
hsrp = hsr # Eq (90b)
else:
hstp = hst - hobs*gt # Eq (90c)
hsrp = hsr - hobs*gr # Eq (90d)
# calculate the final values as required by the diffraction model
if hstp >= h[0]:
hstd = h[0] # Eq (91a)
else:
hstd = hstp # Eq (91b)
if hsrp > h[-1]:
hsrd = h[-1] # Eq (91c)
else:
hsrd = hsrp # Eq (91d)
# Interfering antenna horizon elevation angle and distance
ii = range(1, n-1)
theta = 1000 * np.arctan((h[ii] - hts) /
(1000 * d[ii]) - d[ii] / (2*ae)) # Eq (77)
# theta(theta < 0) = 0 # condition below equation (152)
theta_td = 1000 * np.arctan((hrs - hts) /
(1000 * dtot) - dtot / (2*ae)) # Eq (78)
theta_rd = 1000 * np.arctan((hts - hrs) /
(1000 * dtot) - dtot / (2*ae)) # Eq (81)
theta_max = max(theta) # Eq (76)
if theta_max > theta_td: # Eq (150): test for the trans-horizon path
pathtype = 2 # transhorizon
else:
pathtype = 1 # los
theta_t = max(theta_max, theta_td) # Eq (79)
if (pathtype == 2): # transhorizon
(kindex, ) = np.where(theta == theta_max)
# in order to map back to path d indices, as theta takes path indices 2 to n-1,
lt = kindex[0]+1
dlt = d[lt] # Eq (80)
# Interfered-with antenna horizon elevation angle and distance
theta = 1000 * \
np.arctan((h[ii] - hrs) / (1000 * (dtot - d[ii])) -
(dtot - d[ii]) / (2*ae)) # Eq (82a)
theta_r = max(theta)
(kindex,) = np.where(theta == theta_r)
# in order to map back to path d indices, as theta takes path indices 2 to n-1,
lr = kindex[-1] + 1
dlr = dtot - d[lr] # Eq (83)
else: # pathtype == 1 (LoS)
theta_r = theta_rd # Eq (81)
ii = range(1, n-1)
# speed of light as per ITU.R P.2001
lam = 0.2998/f
Ce = 1.0/ae # Section 4.3.1 supposing median effective Earth radius
nu = (h[ii] + 500*Ce*d[ii] * (dtot-d[ii]) - (hts*(dtot - d[ii]) + hrs * d[ii])/dtot) * \
np.sqrt(0.002*dtot / (lam * d[ii] * (dtot-d[ii]))) # Eq (81)
numax = max(nu)
(kindex,) = np.where(nu == numax)
# in order to map back to path d indices, as theta takes path indices 2 to n-1,
lt = kindex[-1] + 1
dlt = d[lt] # Eq (80)
dlr = dtot - dlt # Eq (83a)
lr = lt
# Angular distance
theta_tot = 1e3 * dtot/ae + theta_t + theta_r # Eq (84)
# Section 5.6.3 Ducting/layer-reflection model
# Calculate the smooth-Earth heights at transmitter and receiver as
# required for the roughness factor
hst = min(hst, h[0]) # Eq (92a)
hsr = min(hsr, h[-1]) # Eq (92b)
# Slope of the smooth-Earth surface
m = (hsr - hst) / dtot # Eq (93)
# The terminal effective heigts for the ducting/layer-reflection model
hte = htg + h[0] - hst # Eq (94a)
hre = hrg + h[-1] - hsr # Eq (94b)
ii = range(lt, lr + 1)
hm = max(h[ii] - (hst + m*d[ii])) # Eq (95)
return hst_n, hsr_n, hst, hsr, hstd, hsrd, hte, hre, hm, dlt, dlr, theta_t, theta_r, theta_tot, pathtype
def pl_los(d, hts, hrs, f, p, b0, dlt, dlr):
"""
pl_los Line-of-sight transmission loss according to ITU-R P.1812-6
This function computes line-of-sight transmission loss (including short-term effects)
as defined in ITU-R P.1812-67.
Input parameters:
d - Great-circle path distance (km)
f - Frequency (GHz)
hts - Tx antenna height above sea level (masl)
hrs - Rx antenna height above sea level (masl)
p - Required time percentage(s) for which the calculated basic
transmission loss is not exceeded (%)
b0 - Point incidence of anomalous propagation for the path
central location (%)
w - Fraction of the total path over water (%)
temp - Temperature (degrees C)
press - Dry air pressure (hPa)
dlt - For a transhorizon path, distance from the transmit antenna to
its horizon (km). For a LoS path, each is set to the distance
from the terminal to the profile point identified as the Bullington
point in the diffraction method for 50% time
dlr - For a transhorizon path, distance from the receive antenna to
its horizon (km). The same note as for dlt applies here.
Output parameters:
Lbfs - Basic transmission loss due to free-space propagation
Lb0p - Basic transmission loss not exceeded for time percentage, p%, due to LoS propagation
Lb0b - Basic transmission loss not exceedd for time percentage, b0%, due to LoS propagation
Example:
Lbfs, Lb0p, Lb0b = pl_los(d, f, p, b0, dlt, dlr)
Rev Date Author Description
-------------------------------------------------------------------------------
v0 29SEP22 Ivica Stevanovic, OFCOM First implementation
"""
# Basic transmission loss due to free-space propagation
dfs2 = d**2 + ((hts - hrs)/1000.0)**2 # (8a)
Lbfs = 92.4 + 20.0*np.log10(f) + 10.0*np.log10(dfs2) # (8)
# Corrections for multipath and focusing effects at p and b0
Esp = 2.6 * (1 - np.exp(-0.1 * (dlt + dlr))) * np.log10(p/50) # (9a)
Esb = 2.6 * (1 - np.exp(-0.1 * (dlt + dlr))) * np.log10(b0/50) # (9b)
# Basic transmission loss not exceeded for time percentage p# due to
# LoS propagation
Lb0p = Lbfs + Esp # (10)
# Basic transmission loss not exceeded for time percentage b0% due to
# LoS propagation
Lb0b = Lbfs + Esb # (11)
return Lbfs, Lb0p, Lb0b
def path_fraction(d, zone, zone_r):
"""
path_fraction Path fraction belonging to a given zone_r
omega = path_fraction(d, zone, zone_r)
This function computes the path fraction belonging to a given zone_r
of the great-circle path (km)
Input arguments:
d - vector of distances in the path profile
zone - vector of zones in the path profile
zone_r - reference zone for which the fraction is computed
Output arguments:
omega - path fraction belonging to the given zone_r
Example:
omega = path_fraction(d, zone, zone_r)
Rev Date Author Description
-------------------------------------------------------------------------------
v0 17MAR22 Ivica Stevanovic, OFCOM First implementation in python
"""
dm = 0
start, stop = find_intervals((zone == zone_r))
n = len(start)
for i in range(0, n):
delta = 0
if (d[stop[i]] < d[-1]):
delta = delta + (d[stop[i]+1]-d[stop[i]])/2.0
if (d[start[i]] > 0):
delta = delta + (d[stop[i]]-d[stop[i]-1])/2.0
dm = dm + d[stop[i]]-d[start[i]] + delta
omega = dm/(d[-1]-d[0])
return omega
def longest_cont_dist(d, zone, zone_r):
"""
longest_cont_dist Longest continuous path belonging to the zone_r
dm = longest_cont_dist(d, zone, zone_r)
This function computes the longest continuous section of the
great-circle path (km) for a given zone_r
Input arguments:
d - vector of distances in the path profile
zone - vector of zones in the path profile
zone_r - reference zone for which the longest continuous section
is computed
Output arguments:
dm - the longest continuous section of the great-circle path (km) for a given zone_r
Example:
dm = longest_cont_dist(d, zone, zone_r)
Rev Date Author Description
-------------------------------------------------------------------------------
v0 29SEP22 Ivica Stevanovic, OFCOM Initial version
"""
dm = 0
if zone_r == 34: # inland + coastal land
start, stop = find_intervals((zone == 3)+(zone == 4))
else:
start, stop = find_intervals((zone == zone_r))
n = len(start)
for i in range(0, n):
delta = 0
if (d[stop[i]] < d[-1]):
delta = delta + (d[stop[i]+1]-d[stop[i]])/2.0