-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
85 lines (71 loc) · 2.39 KB
/
Copy pathexample.py
File metadata and controls
85 lines (71 loc) · 2.39 KB
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
"""
Example usage of celltrace with OpenCellID data.
This script demonstrates:
- Loading OpenCellID cells from a CSV file
- Applying a geographic filter
- Simulating multiple network observations
- Estimating the most likely serving cell using temporal consensus
Note:
- Coordinates used here are placeholders
- Replace them with your own reference point if needed
"""
from celltrace.providers.opencellid_csv import load_opencellid_csv
from celltrace.geo import filter_cells_by_radius
from celltrace.models import Observation
from celltrace.estimator import estimate_from_observations
# --------------------------------------------------
# 1) Load OpenCellID cells (example: one country)
# --------------------------------------------------
cells = load_opencellid_csv(
path="data/opencellid/COUNTRY_CODE.csv", # e.g. 732.csv
radio_filter={"LTE"},
)
print(f"Total cells loaded: {len(cells)}")
# --------------------------------------------------
# 2) Reference point (example coordinates)
# --------------------------------------------------
reference_lat = 0.0
reference_lon = 0.0
cells_near_reference = filter_cells_by_radius(
cells,
center_lat=reference_lat,
center_lon=reference_lon,
radius_km=50,
)
print(f"Cells near reference point (50 km): {len(cells_near_reference)}")
if not cells_near_reference:
raise RuntimeError("No cells found near the reference point")
# --------------------------------------------------
# 3) Simulate repeated network observations
# --------------------------------------------------
target_cell = cells_near_reference[0]
print("Target cell:", target_cell)
observations = [
Observation(
mcc=target_cell.mcc,
mnc=target_cell.mnc,
radio=target_cell.radio,
cell_id=target_cell.cell_id,
signal=-70,
),
Observation(
mcc=target_cell.mcc,
mnc=target_cell.mnc,
radio=target_cell.radio,
cell_id=target_cell.cell_id,
signal=-73,
),
Observation(
mcc=target_cell.mcc,
mnc=target_cell.mnc,
radio=target_cell.radio,
cell_id=target_cell.cell_id,
signal=-68,
),
]
# --------------------------------------------------
# 4) Estimate cell location using temporal consensus
# --------------------------------------------------
result = estimate_from_observations(observations, cells_near_reference)
print("\n=== ESTIMATION RESULT ===")
print(result)