fix: full-repo ruff lint cleanup and CI migration to uv
Resolve all 374 ruff errors across 36 Python files (E501, E702, E722, E741, F821, F841, invalid-syntax) bringing `ruff check .` to zero errors repo-wide with line-length=100. Rewrite CI workflow to use uv for dependency management, whole-repo `ruff check .`, py_compile syntax gate, and merged python-tests job. Add pyproject.toml with ruff config and uv dependency groups. CI structure proposed by hcm444.
This commit is contained in:
@@ -15,12 +15,20 @@ def generate_radar_csv(filename="pulse_compression_output.csv"):
|
||||
timestamp_ns = 0
|
||||
|
||||
# Target parameters
|
||||
targets = [
|
||||
{'range': 3000, 'velocity': 25, 'snr': 30, 'azimuth': 10, 'elevation': 5}, # Fast moving target
|
||||
{'range': 5000, 'velocity': -15, 'snr': 25, 'azimuth': 20, 'elevation': 2}, # Approaching target
|
||||
{'range': 8000, 'velocity': 5, 'snr': 20, 'azimuth': 30, 'elevation': 8}, # Slow moving target
|
||||
{'range': 12000, 'velocity': -8, 'snr': 18, 'azimuth': 45, 'elevation': 3}, # Distant target
|
||||
]
|
||||
targets = [
|
||||
{
|
||||
'range': 3000, 'velocity': 25, 'snr': 30, 'azimuth': 10, 'elevation': 5
|
||||
}, # Fast moving target
|
||||
{
|
||||
'range': 5000, 'velocity': -15, 'snr': 25, 'azimuth': 20, 'elevation': 2
|
||||
}, # Approaching target
|
||||
{
|
||||
'range': 8000, 'velocity': 5, 'snr': 20, 'azimuth': 30, 'elevation': 8
|
||||
}, # Slow moving target
|
||||
{
|
||||
'range': 12000, 'velocity': -8, 'snr': 18, 'azimuth': 45, 'elevation': 3
|
||||
}, # Distant target
|
||||
]
|
||||
|
||||
# Noise parameters
|
||||
noise_std = 5
|
||||
@@ -38,7 +46,7 @@ def generate_radar_csv(filename="pulse_compression_output.csv"):
|
||||
q_val = np.random.normal(0, noise_std)
|
||||
|
||||
# Add clutter (stationary targets)
|
||||
clutter_range = 2000 # Fixed clutter at 2km
|
||||
_clutter_range = 2000 # Fixed clutter at 2km
|
||||
if sample < 100: # Simulate clutter in first 100 samples
|
||||
i_val += np.random.normal(0, clutter_std)
|
||||
q_val += np.random.normal(0, clutter_std)
|
||||
@@ -47,7 +55,9 @@ def generate_radar_csv(filename="pulse_compression_output.csv"):
|
||||
for target in targets:
|
||||
# Calculate range bin (simplified)
|
||||
range_bin = int(target['range'] / 20) # ~20m per bin
|
||||
doppler_phase = 2 * math.pi * target['velocity'] * chirp / 100 # Doppler phase shift
|
||||
doppler_phase = (
|
||||
2 * math.pi * target['velocity'] * chirp / 100
|
||||
) # Doppler phase shift
|
||||
|
||||
# Target appears around its range bin with some spread
|
||||
if abs(sample - range_bin) < 10:
|
||||
@@ -96,7 +106,9 @@ def generate_radar_csv(filename="pulse_compression_output.csv"):
|
||||
for target in targets:
|
||||
# Range bin calculation (different for short chirps)
|
||||
range_bin = int(target['range'] / 40) # Different range resolution
|
||||
doppler_phase = 2 * math.pi * target['velocity'] * (chirp + 5) / 80 # Different Doppler
|
||||
doppler_phase = (
|
||||
2 * math.pi * target['velocity'] * (chirp + 5) / 80
|
||||
) # Different Doppler
|
||||
|
||||
# Target appears around its range bin
|
||||
if abs(sample - range_bin) < 8:
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import numpy as np
|
||||
from numpy.fft import fft, ifft
|
||||
from numpy.fft import fft
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
@@ -15,7 +15,10 @@ theta_n= 2*np.pi*(pow(N,2)*pow(Ts,2)*(fmax-fmin)/(2*Tb)+fmin*N*Ts) # instantaneo
|
||||
y = 1 + np.sin(theta_n) # ramp signal in time domain
|
||||
|
||||
M = np.arange(n, 2*n, 1)
|
||||
theta_m= 2*np.pi*(pow(M,2)*pow(Ts,2)*(-fmax+fmin)/(2*Tb)+(-fmin+2*fmax)*M*Ts)-2*np.pi*((fmin-fmax)*Tb/2+(2*fmax-fmin)*Tb) # instantaneous phase
|
||||
theta_m= (
|
||||
2*np.pi*(pow(M,2)*pow(Ts,2)*(-fmax+fmin)/(2*Tb)+(-fmin+2*fmax)*M*Ts)
|
||||
- 2*np.pi*((fmin-fmax)*Tb/2+(2*fmax-fmin)*Tb)
|
||||
) # instantaneous phase
|
||||
z = 1 + np.sin(theta_m) # ramp signal in time domain
|
||||
|
||||
x = np.concatenate((y, z))
|
||||
@@ -23,9 +26,9 @@ x = np.concatenate((y, z))
|
||||
t = Ts*np.arange(0,2*n,1)
|
||||
X = fft(x)
|
||||
L =len(X)
|
||||
l = np.arange(L)
|
||||
freq_indices = np.arange(L)
|
||||
T = L*Ts
|
||||
freq = l/T
|
||||
freq = freq_indices/T
|
||||
|
||||
|
||||
plt.figure(figsize = (12, 6))
|
||||
|
||||
@@ -15,7 +15,10 @@ theta_n= 2*np.pi*(pow(N,2)*pow(Ts,2)*(fmax-fmin)/(2*Tb)+fmin*N*Ts) # instantaneo
|
||||
y = 1 + np.sin(theta_n) # ramp signal in time domain
|
||||
|
||||
M = np.arange(n, 2*n, 1)
|
||||
theta_m= 2*np.pi*(pow(M,2)*pow(Ts,2)*(-fmax+fmin)/(2*Tb)+(-fmin+2*fmax)*M*Ts)-2*np.pi*((fmin-fmax)*Tb/2+(2*fmax-fmin)*Tb) # instantaneous phase
|
||||
theta_m= (
|
||||
2*np.pi*(pow(M,2)*pow(Ts,2)*(-fmax+fmin)/(2*Tb)+(-fmin+2*fmax)*M*Ts)
|
||||
- 2*np.pi*((fmin-fmax)*Tb/2+(2*fmax-fmin)*Tb)
|
||||
) # instantaneous phase
|
||||
z = 1 + np.sin(theta_m) # ramp signal in time domain
|
||||
|
||||
x = np.concatenate((y, z))
|
||||
@@ -24,9 +27,9 @@ t = Ts*np.arange(0,2*n,1)
|
||||
plt.plot(t, x)
|
||||
X = fft(x)
|
||||
L =len(X)
|
||||
l = np.arange(L)
|
||||
freq_indices = np.arange(L)
|
||||
T = L*Ts
|
||||
freq = l/T
|
||||
freq = freq_indices/T
|
||||
|
||||
print("The Array is: ", x) #printing the array
|
||||
|
||||
|
||||
@@ -221,7 +221,10 @@ class RadarCalculatorGUI:
|
||||
temp = self.get_float_value(self.entries["Temperature (K):"])
|
||||
|
||||
# Validate inputs
|
||||
if None in [f_ghz, pulse_duration_us, prf, p_dbm, g_dbi, sens_dbm, rcs, losses_db, nf_db, temp]:
|
||||
if None in [
|
||||
f_ghz, pulse_duration_us, prf, p_dbm, g_dbi,
|
||||
sens_dbm, rcs, losses_db, nf_db, temp,
|
||||
]:
|
||||
messagebox.showerror("Error", "Please enter valid numeric values for all fields")
|
||||
return
|
||||
|
||||
@@ -235,7 +238,7 @@ class RadarCalculatorGUI:
|
||||
g_linear = 10 ** (g_dbi / 10)
|
||||
sens_linear = 10 ** ((sens_dbm - 30) / 10)
|
||||
losses_linear = 10 ** (losses_db / 10)
|
||||
nf_linear = 10 ** (nf_db / 10)
|
||||
_nf_linear = 10 ** (nf_db / 10)
|
||||
|
||||
# Calculate receiver noise power
|
||||
if k is None:
|
||||
@@ -298,11 +301,14 @@ class RadarCalculatorGUI:
|
||||
messagebox.showinfo("Success", "Calculation completed successfully!")
|
||||
|
||||
except Exception as e:
|
||||
messagebox.showerror("Calculation Error", f"An error occurred during calculation:\n{str(e)}")
|
||||
messagebox.showerror(
|
||||
"Calculation Error",
|
||||
f"An error occurred during calculation:\n{str(e)}",
|
||||
)
|
||||
|
||||
def main():
|
||||
root = tk.Tk()
|
||||
app = RadarCalculatorGUI(root)
|
||||
_app = RadarCalculatorGUI(root)
|
||||
root.mainloop()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -12,13 +12,22 @@ def calculate_patch_antenna_parameters(frequency, epsilon_r, h_sub, h_cu, array)
|
||||
lamb = c /(frequency * 1e9)
|
||||
|
||||
# Calculate the effective dielectric constant
|
||||
epsilon_eff = (epsilon_r + 1) / 2 + (epsilon_r - 1) / 2 * (1 + 12 * h_sub_m / (array[1] * h_cu_m)) ** (-0.5)
|
||||
epsilon_eff = (
|
||||
(epsilon_r + 1) / 2
|
||||
+ (epsilon_r - 1) / 2 * (1 + 12 * h_sub_m / (array[1] * h_cu_m)) ** (-0.5)
|
||||
)
|
||||
|
||||
# Calculate the width of the patch
|
||||
W = c / (2 * frequency * 1e9) * np.sqrt(2 / (epsilon_r + 1))
|
||||
|
||||
# Calculate the effective length
|
||||
delta_L = 0.412 * h_sub_m * (epsilon_eff + 0.3) * (W / h_sub_m + 0.264) / ((epsilon_eff - 0.258) * (W / h_sub_m + 0.8))
|
||||
delta_L = (
|
||||
0.412
|
||||
* h_sub_m
|
||||
* (epsilon_eff + 0.3)
|
||||
* (W / h_sub_m + 0.264)
|
||||
/ ((epsilon_eff - 0.258) * (W / h_sub_m + 0.8))
|
||||
)
|
||||
|
||||
# Calculate the length of the patch
|
||||
L = c / (2 * frequency * 1e9 * np.sqrt(epsilon_eff)) - 2 * delta_L
|
||||
@@ -31,7 +40,10 @@ def calculate_patch_antenna_parameters(frequency, epsilon_r, h_sub, h_cu, array)
|
||||
|
||||
# Calculate the feeding line width (W_feed)
|
||||
Z0 = 50 # Characteristic impedance of the feeding line (typically 50 ohms)
|
||||
A = Z0 / 60 * np.sqrt((epsilon_r + 1) / 2) + (epsilon_r - 1) / (epsilon_r + 1) * (0.23 + 0.11 / epsilon_r)
|
||||
A = (
|
||||
Z0 / 60 * np.sqrt((epsilon_r + 1) / 2)
|
||||
+ (epsilon_r - 1) / (epsilon_r + 1) * (0.23 + 0.11 / epsilon_r)
|
||||
)
|
||||
W_feed = 8 * h_sub_m / np.exp(A) - 2 * h_cu_m
|
||||
|
||||
# Convert results back to mm
|
||||
@@ -50,7 +62,9 @@ h_sub = 0.102 # Height of substrate in mm
|
||||
h_cu = 0.07 # Height of copper in mm
|
||||
array = [2, 2] # 2x2 array
|
||||
|
||||
W_mm, L_mm, dx_mm, dy_mm, W_feed_mm = calculate_patch_antenna_parameters(frequency, epsilon_r, h_sub, h_cu, array)
|
||||
W_mm, L_mm, dx_mm, dy_mm, W_feed_mm = calculate_patch_antenna_parameters(
|
||||
frequency, epsilon_r, h_sub, h_cu, array
|
||||
)
|
||||
|
||||
print(f"Width of the patch: {W_mm:.4f} mm")
|
||||
print(f"Length of the patch: {L_mm:.4f} mm")
|
||||
|
||||
Reference in New Issue
Block a user