Skip to content

Commit 8d25b9b

Browse files
authored
DPA: Fix the CheckInterference loggers. (#870)
Previous PR has introduced special code to include all inside grants in move list and neighbor list. Unfortunately this let the logger used for analysing DPA margin failures not perfectly in line. The SAS_UUT active list of grants (reported to the log only) would not show some of the inside grants. This PR fixes that. Note that this PR has no effect whatsoever on the DPA operation, just on the logging that is used for post analysis (only when required because of a failure), possibly with provided script: tools/studies/dpa_margin_sim.py.
1 parent 8118da0 commit 8d25b9b

3 files changed

Lines changed: 21 additions & 6 deletions

File tree

src/harness/reference_models/dpa/dpa_mgr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ def CheckInterference(self, sas_uut_active_grants, margin_db,
468468
# used for logging purpose (although it could be passed to the interference
469469
# check routine for faster operation).
470470
est_keep_list_uut_managing_sas = ml.getDpaNeighborGrants(
471-
sas_uut_active_grants, self.protected_points,
471+
sas_uut_active_grants, self.protected_points, self.geometry,
472472
low_freq=channel[0] * 1e6, high_freq=channel[1] * 1e6,
473473
neighbor_distances=self.neighbor_distances)
474474
try:

src/harness/reference_models/dpa/dpa_mgr_test.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
from collections import namedtuple
1717
import json
1818
import os
19+
import shutil
20+
import tempfile
1921
import unittest
2022

2123
import numpy as np
24+
import shapely.geometry as sgeo
2225

2326
from reference_models.common import data
2427
from reference_models.geo import zones
@@ -36,10 +39,13 @@
3639
class TestDpa(unittest.TestCase):
3740

3841
def setUp(self):
39-
self.original_itm = wf_itm.CalcItmPropagationLoss
42+
self.temp_dir = tempfile.mkdtemp()
43+
self.orig_dpa_log_dir = dpa_mgr.GetDpaLogDir
44+
dpa_mgr.GetDpaLogDir = lambda: self.temp_dir
4045

4146
def tearDown(self):
42-
wf_itm.CalcItmPropagationLoss = self.original_itm
47+
dpa_mgr.GetDpaLogDir = self.orig_dpa_log_dir
48+
shutil.rmtree(self.temp_dir, ignore_errors=True)
4349

4450
def test_channelization(self):
4551
channels = dpa_mgr.GetDpaProtectedChannels([(3550, 3650)], is_portal_dpa=False)
@@ -101,6 +107,8 @@ def test_computeMoveListAndCheckInterf(self):
101107
grants_th = data.getGrantsFromRequests(regs[4:], grants[4:])
102108
channel = (3600, 3610)
103109
dpa = dpa_mgr.Dpa(protection_points,
110+
geometry=sgeo.Polygon([(pt.longitude, pt.latitude)
111+
for pt in protection_points]),
104112
name='test(East1)',
105113
threshold=-144,
106114
beamwidth=3,
@@ -125,7 +133,7 @@ def test_computeMoveListAndCheckInterf(self):
125133
result = dpa.CheckInterference([grants_uut[2], grants_th[1]],
126134
margin_db=0.01,
127135
do_abs_check_single_uut=True,
128-
extensive_print=False)
136+
extensive_print=True)
129137
self.assertEqual(result, False)
130138

131139

src/harness/reference_models/dpa/move_list.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import logging
4141

4242
import numpy as np
43+
import shapely.geometry as sgeo
4344
from shapely.geometry import Point as SPoint
4445
from shapely.geometry import Polygon as SPolygon
4546
from shapely.geometry import MultiPolygon as MPolygon
@@ -54,7 +55,7 @@
5455

5556
# Constant parameters based on requirements in the WINNF-TS-0112 [R2-SGN-24]
5657
# Monte Carlo percentile for protection
57-
PROTECTION_PERCENTILE = 95
58+
PROTECTION_PERCENTILE = 95
5859

5960
# Frequency used in propagation model (in MHz) [R2-SGN-04]
6061
FREQ_PROP_MODEL = 3625.0
@@ -495,7 +496,7 @@ def moveListConstraint(protection_point, low_freq, high_freq,
495496
return (movelist_grants, neighbor_grants)
496497

497498

498-
def getDpaNeighborGrants(grants, protection_points,
499+
def getDpaNeighborGrants(grants, protection_points, dpa_geometry,
499500
low_freq, high_freq, neighbor_distances):
500501
"""Gets the list of actual neighbor grants of a DPA, for a given channel.
501502
@@ -505,6 +506,7 @@ def getDpaNeighborGrants(grants, protection_points,
505506
grants: A list of CBSD |data.CbsdGrantInfo| active grants.
506507
protection_points: A list of protection point locations defining the DPA, each one
507508
having attributes 'latitude' and 'longitude'.
509+
dpa_geometry: The DPA |shapely.geometry| for detection of inside grants.
508510
low_freq: The low frequency of protection constraint (Hz).
509511
high_freq: The high frequency of protection constraint (Hz).
510512
neighbor_distances: The neighborhood distances (km) as a sequence:
@@ -516,6 +518,11 @@ def getDpaNeighborGrants(grants, protection_points,
516518
dpa_type = findDpaType(low_freq, high_freq)
517519

518520
neighbor_grants = set()
521+
if dpa_geometry and not isinstance(dpa_geometry, sgeo.Point):
522+
inside_grants = set(g for g in grants
523+
if sgeo.Point(g.longitude, g.latitude).intersects(dpa_geometry))
524+
neighbor_grants = set(filterGrantsForFreqRange(inside_grants, low_freq, high_freq))
525+
519526
for point in protection_points:
520527
# Assign values to the protection constraint
521528
constraint = data.ProtectionConstraint(latitude=point.latitude,

0 commit comments

Comments
 (0)