add files via upload

This commit is contained in:
2025-10-06 01:07:50 -05:00
commit 0132cb8b39
4 changed files with 241 additions and 0 deletions

56
LOSS.py Normal file
View File

@@ -0,0 +1,56 @@
#!/usr/bin/env python3
import os
import numpy as np
import math
import sys
# --- Configuration ---
#folder_path = input("Enter the folder containing the IQ data files: ")
if 1 == len(sys.argv):
print("No args provided and default folder \"DAT\" not found.")
sys.exit(1)
else:
folder_path = sys.argv[1]
count = -1 # Change this if you want to limit the number of samples per file
i = 0
losses = [0.0,0.0,0.0,0.0,0.0]
# --- Processing Loop ---
for filename in os.listdir(folder_path):
full_path = os.path.join(folder_path, filename)
# Process only files, not directories
if not os.path.isfile(full_path):
continue
try:
data = np.fromfile(full_path, dtype=np.complex64, count=count)
if len(data) == 0:
print(f"{filename}: File is empty or unreadable.")
continue
meanVal = np.mean(np.abs(data))
print(f"{filename} :: loss of {meanVal:.2f} dB")
losses[i] = meanVal
i += 1
except Exception as e:
print(f"{filename}: Error processing file - {e}")
meanAll = 0.0
j = 0
for l in losses:
meanAll += losses[j]
j += 1
j += 1
meanAll /= j
print(f"Mean path loss: {meanAll:.2f} dB")
print(f"total {i} files processed")