-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_template.py
More file actions
131 lines (109 loc) · 5.16 KB
/
test_template.py
File metadata and controls
131 lines (109 loc) · 5.16 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
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
#!/usr/bin/env python3
"""
Template test script for coverage calculation with proper progress reporting.
Use this template for all future tests.
"""
import requests
import time
import json
import numpy as np
from datetime import datetime
def test_coverage():
"""Test coverage calculation with template configuration."""
print("🚀 Coverage Test Template")
print("=" * 50)
# Test configuration - 3km range with 10m height resolution
test_config = {
"sensor_id": "test-sensor-template",
"latitude": 51.493,
"longitude": -0.0669,
"height": 5.0,
"config": {
"maxRange": 3.0, # 3km range
"minHeight": 0,
"maxHeight": 40, # Reduced from 100 to 40m
"heightRes": 10, # 10m height resolution
"txFrequency": 1090,
"txPower": 20,
"txGain": 0,
"rxGain": 0,
"rxSensitivity": -110,
"gridResolution": 0.5,
"fresnelSamplingDensity": 500
}
}
print(f"📍 Sensor location: {test_config['latitude']}, {test_config['longitude']}")
print(f"📡 Range: {test_config['config']['maxRange']}km")
print(f"🛩️ Height range: {test_config['config']['minHeight']}-{test_config['config']['maxHeight']}m")
print(f"🔧 Height resolution: {test_config['config']['heightRes']}m")
print(f"🔧 Grid resolution: {test_config['config']['gridResolution']}km")
print()
# Submit job
print("🔄 Submitting coverage computation job...")
response = requests.post("http://localhost:8000/", json=test_config)
if response.status_code != 200:
print(f"❌ Error: {response.status_code}")
return
job_data = response.json()
job_id = job_data.get("job_id")
print(f"✅ Job submitted successfully!")
print(f"📋 Job ID: {job_id}")
print()
# Monitor progress
print("📊 Monitoring progress...")
print("=" * 50)
start_time = time.time()
last_progress = 0
while True:
try:
progress_response = requests.get(f"http://localhost:8000/progress/{job_id}")
if progress_response.status_code == 200:
progress_data = progress_response.json()
# Show progress
progress = progress_data.get("progress", 0)
stage = progress_data.get("stage", "")
substage = progress_data.get("substage", "")
# Only show progress if it changed
if progress != last_progress:
elapsed = time.time() - start_time
timestamp = datetime.now().strftime("%H:%M:%S")
print(f"[{timestamp}] Progress: {progress}% | {stage} | {substage} | {elapsed:.1f}s")
last_progress = progress
# Check if job is complete
if progress_data.get("status") == "completed":
elapsed = time.time() - start_time
results = progress_data.get("results", [])
print("=" * 50)
print("🎉 COMPLETED!")
print(f"📊 Results:")
print(f" • Total cells processed: {len(results)}")
print(f" • Total time: {elapsed:.1f} seconds")
print(f" • Average time per cell: {elapsed/len(results):.3f}s" if results else " • No cells processed")
# Calculate detailed statistics
if results:
agl_values = [result.get('agl', 0) for result in results]
cells_with_zero_agl = len([agl for agl in agl_values if agl == 0])
cells_with_coverage = len([agl for agl in agl_values if agl > 0])
min_agl = min(agl_values) if agl_values else 0
max_agl = max(agl_values) if agl_values else 0
mean_agl = np.mean(agl_values) if agl_values else 0
print()
print("📈 DETAILED RESULTS:")
print(f" • Number of cells computed: {len(results)}")
print(f" • Number of cells with 0m AGL (ground coverage): {cells_with_zero_agl}")
print(f" • Number of cells with >0m AGL (airborne coverage): {cells_with_coverage}")
print(f" • Minimum AGL: {min_agl}m")
print(f" • Maximum AGL: {max_agl}m")
print(f" • Mean AGL: {mean_agl:.1f}m")
print()
print("✅ Test completed!")
break
else:
print(f"❌ Error getting progress: {progress_response.status_code}")
break
except requests.exceptions.RequestException as e:
print(f"❌ Network error: {e}")
break
time.sleep(0.5) # Poll every 500ms
if __name__ == "__main__":
test_coverage()