#!/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): if os.path.isdir("DAT"): folder_path = "DAT" else: 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 # --- 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"\nFile: {filename}") print(f"Instantaneous Power for {filename} = " + str(10 * math.log10(meanVal / 50))) except Exception as e: print(f"{filename}: Error processing file - {e}")