-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from RFingAdam/dev
Merge 3d plotting updates
- Loading branch information
Showing
15 changed files
with
542 additions
and
347 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ __pycache__/ | |
# Build and distribution folders | ||
build/ | ||
dist/ | ||
debug/ | ||
|
||
# PyInstaller spec files | ||
*.spec | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import numpy as np | ||
|
||
|
||
#Auto Determine Polarization for HPOL & VPOL Files | ||
def determine_polarization(file_path): | ||
with open(file_path, 'r') as f: | ||
content = f.read() | ||
if "Horizontal Polarization" in content: | ||
return "HPol" | ||
else: | ||
return "VPol" | ||
|
||
#Verify angle data and frequencies are not mismatched | ||
def angles_match(start_phi_h, stop_phi_h, inc_phi_h, start_theta_h, stop_theta_h, inc_theta_h, | ||
start_phi_v, stop_phi_v, inc_phi_v, start_theta_v, stop_theta_v, inc_theta_v): | ||
|
||
return (start_phi_h == start_phi_v and stop_phi_h == stop_phi_v and inc_phi_h == inc_phi_v and | ||
start_theta_h == start_theta_v and stop_theta_h == stop_theta_v and inc_theta_h == inc_theta_v) | ||
|
||
#Extract Frequency points for selection in the drop-down menu | ||
def extract_passive_frequencies(file_path): | ||
with open(file_path, 'r') as file: | ||
content = file.readlines() | ||
|
||
# Extracting frequencies | ||
frequencies = [float(line.split("=")[1].split()[0]) for line in content if "Test Frequency" in line] | ||
|
||
return frequencies | ||
|
||
#Calculate Total Gain Vector and add cable loss etc - Use Phase for future implementation? | ||
def calculate_passive_variables(hpol_data, vpol_data, cable_loss, start_phi, stop_phi, inc_phi, start_theta, stop_theta, inc_theta, freq_list, selected_frequency): | ||
theta_points = int((stop_theta - start_theta) / inc_theta + 1) | ||
phi_points = int((stop_phi - start_phi) / inc_phi + 1) | ||
data_points = theta_points * phi_points | ||
|
||
theta_angles_deg = np.zeros((data_points, len(freq_list))) | ||
phi_angles_deg = np.zeros((data_points, len(freq_list))) | ||
v_gain_dB = np.zeros((data_points, len(freq_list))) | ||
h_gain_dB = np.zeros((data_points, len(freq_list))) | ||
v_phase = np.zeros((data_points, len(freq_list))) | ||
h_phase = np.zeros((data_points, len(freq_list))) | ||
|
||
for m, (hpol_entry, vpol_entry) in enumerate(zip(hpol_data, vpol_data)): | ||
for n, (theta_h, phi_h, mag_h, phase_h, theta_v, phi_v, mag_v, phase_v) in enumerate(zip(hpol_entry['theta'], hpol_entry['phi'], hpol_entry['mag'], hpol_entry['phase'], vpol_entry['theta'], vpol_entry['phi'], vpol_entry['mag'], vpol_entry['phase'])): | ||
v_gain = mag_v | ||
h_gain = mag_h | ||
v_ph = phase_v | ||
h_ph = phase_h | ||
|
||
theta_angles_deg[n, m] = theta_h | ||
phi_angles_deg[n, m] = phi_h | ||
v_gain_dB[n, m] = v_gain | ||
h_gain_dB[n, m] = h_gain | ||
v_phase[n, m] = v_ph | ||
h_phase[n, m] = h_ph | ||
|
||
cable_loss_matrix = np.ones((phi_points * theta_points, len(freq_list))) * cable_loss | ||
v_gain_dB += cable_loss_matrix | ||
h_gain_dB += cable_loss_matrix | ||
|
||
Total_Gain_dB = 10 * np.log10(10**(v_gain_dB/10) + 10**(h_gain_dB/10)) | ||
|
||
|
||
return theta_angles_deg, phi_angles_deg, v_gain_dB, h_gain_dB, Total_Gain_dB |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
Configuration file for the RFlect application. | ||
This module contains constants and configuration values used throughout the application. | ||
""" | ||
|
||
#3D Plotting Interpolation Resolution | ||
PHI_RESOLUTION = 1440 #default 360 = 1deg spacing | ||
THETA_RESOLUTION = 720 #default 180 - 1deg spacing | ||
|
||
# GUI Settings | ||
# Colors | ||
DARK_BG_COLOR = "#2E2E2E" | ||
LIGHT_TEXT_COLOR = "#FFFFFF" | ||
ACCENT_BLUE_COLOR = "#4A90E2" | ||
BUTTON_COLOR = "#3A3A3A" | ||
HOVER_COLOR = "#4A4A4A" | ||
ACCENT_GREEN_COLOR = "#4CAF50" | ||
|
||
# Fonts | ||
HEADER_FONT = ("Arial", 14, "bold") | ||
LABEL_FONT = ("Arial", 12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
from config import ACCENT_GREEN_COLOR, ACCENT_BLUE_COLOR | ||
|
||
import os | ||
|
||
#Read in TRP/Active Scan File | ||
def read_active_file(file_path): | ||
with open(file_path, 'r') as file: | ||
content = file.readlines() | ||
return parse_active_file(content) | ||
|
||
# Read in Passive HPOL/VPOL Files | ||
def read_passive_file(file_path): | ||
with open(file_path, 'r') as file: | ||
content = file.readlines() | ||
return parse_passive_file(content) | ||
|
||
# Function to parse the data from active TRP files | ||
def parse_active_file(content): | ||
#tbd | ||
return | ||
|
||
# Function to parse the data from HPOL/VPOL files | ||
def parse_passive_file(content): | ||
""" | ||
Parse passive files and return a consolidated dataframe. | ||
This function reads and processes passive scan files (typically in .csv format). | ||
It consolidates the data from these files into a single dataframe. | ||
Parameters: | ||
- files (list): List of file paths to be parsed. | ||
Returns: | ||
- DataFrame: A pandas DataFrame containing the consolidated data from the files. | ||
""" | ||
|
||
# Initialize variables to store PHI and THETA details | ||
all_data = [] | ||
start_phi, stop_phi, inc_phi = None, None, None | ||
start_theta, stop_theta, inc_theta = None, None, None | ||
|
||
# Extract Theta & PHI details | ||
for line in content: | ||
if "Axis1 Start Angle" in line: | ||
start_phi = float(line.split(":")[1].split("Deg")[0].strip()) | ||
elif "Axis1 Stop Angle" in line: | ||
stop_phi = float(line.split(":")[1].split("Deg")[0].strip()) | ||
elif "Axis1 Increment" in line: | ||
inc_phi = float(line.split(":")[1].split("Deg")[0].strip()) | ||
elif "Axis2 Start Angle" in line: | ||
start_theta = float(line.split(":")[1].split("Deg")[0].strip()) | ||
elif "Axis2 Stop Angle" in line: | ||
stop_theta = float(line.split(":")[1].split("Deg")[0].strip()) | ||
elif "Axis2 Increment" in line: | ||
inc_theta = float(line.split(":")[1].split("Deg")[0].strip()) | ||
|
||
# Calculate the expected number of data points | ||
theta_points = (stop_theta - start_theta) / inc_theta + 1 | ||
phi_points = (stop_phi - start_phi) / inc_phi + 1 | ||
data_points = int(theta_points * phi_points) | ||
|
||
# Extract data for each frequency | ||
while content: | ||
cal_factor_line = next((line for line in content if "Cal Std Antenna Peak Gain Factor" in line), None) | ||
if not cal_factor_line: | ||
break | ||
cal_factor_value = float(cal_factor_line.split('=')[1].strip().split(' ')[0]) | ||
|
||
freq_line = next((line for line in content if "Test Frequency = " in line), None) | ||
freq_value = float(freq_line.split('=')[1].strip().split(' ')[0]) | ||
|
||
start_index = next((i for i, line in enumerate(content) if "THETA\t PHI\t Mag\t Phase" in line), None) | ||
if start_index is None: | ||
break | ||
start_index += 2 | ||
|
||
data_lines = content[start_index:start_index+data_points] | ||
theta, phi, mag, phase = [], [], [], [] | ||
for line in data_lines: | ||
line_data = line.strip().split('\t') | ||
if len(line_data) != 4: | ||
break | ||
t, p, m, ph = map(float, line_data) | ||
theta.append(t) | ||
phi.append(p) | ||
mag.append(m) | ||
phase.append(ph) | ||
|
||
freq_data = { | ||
"frequency": freq_value, | ||
"cal_factor": cal_factor_value, | ||
"theta": theta, | ||
"phi": phi, | ||
"mag": mag, | ||
"phase": phase | ||
} | ||
all_data.append(freq_data) | ||
content = content[start_index + data_points:] | ||
|
||
return all_data, start_phi, stop_phi, inc_phi, start_theta, stop_theta, inc_theta | ||
|
||
def save_to_results_folder(filename, content, widget): | ||
""" | ||
Save the given data to the specified file within the results folder. | ||
Parameters: | ||
- filename (str): The name of the file to save to. | ||
- data (Any): The data to be saved. | ||
Returns: | ||
- str: The path to the saved file. | ||
""" | ||
|
||
# Check if a results folder exists or not | ||
if not os.path.exists("results"): | ||
os.makedirs("results") | ||
|
||
# Save the content to the file in the results folder | ||
with open(os.path.join("results", filename), "w") as f: | ||
f.write(content) | ||
|
||
# Provide feedback through the widget (in this case, a button) | ||
widget.config(text="Save Results to File (Saved!)", bg=ACCENT_GREEN_COLOR) | ||
widget.after(2000, lambda: widget.config(text="Save Results to File", bg=ACCENT_BLUE_COLOR)) |
Oops, something went wrong.