rf-funcitons-py 0.1.3__tar.gz → 0.1.5__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/PKG-INFO +1 -1
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/pyproject.toml +1 -1
- rf_funcitons_py-0.1.5/rafpy/__init__.py +3 -0
- rf_funcitons_py-0.1.3/rafpy/rf_filter.py → rf_funcitons_py-0.1.5/rafpy/filters.py +65 -1
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/rf_funcitons_py.egg-info/PKG-INFO +1 -1
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/rf_funcitons_py.egg-info/SOURCES.txt +1 -2
- rf_funcitons_py-0.1.3/rafpy/__init__.py +0 -3
- rf_funcitons_py-0.1.3/rafpy/bpf_kernal.py +0 -3
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/README.md +0 -0
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/rafpy/logic.py +0 -0
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/rf_funcitons_py.egg-info/dependency_links.txt +0 -0
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/rf_funcitons_py.egg-info/requires.txt +0 -0
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/rf_funcitons_py.egg-info/top_level.txt +0 -0
- {rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/setup.cfg +0 -0
|
@@ -35,4 +35,68 @@ def RF_filter(signal_array, filter_kernel, caption_text1, caption_text2, samplin
|
|
|
35
35
|
ax2.text(0.5, -0.3, textwrap.fill(desc_2, width = 100), transform=ax2.transAxes, ha='center', va='top', fontsize=10, color='darkgreen', bbox=dict(boxstyle="round,pad=0.3", fc="white", ec="gray", alpha=0.5))
|
|
36
36
|
|
|
37
37
|
plt.show()
|
|
38
|
-
return filtered_signal
|
|
38
|
+
return filtered_signal
|
|
39
|
+
|
|
40
|
+
def get_acf_amplitude(signal_array):
|
|
41
|
+
# 1. Remove DC offset (Center the signal at 0)
|
|
42
|
+
centered_signal = signal_array - np.mean(signal_array)
|
|
43
|
+
|
|
44
|
+
# 2. Calculate the Autocorrelation
|
|
45
|
+
# 'same' mode keeps the output the same length as the input
|
|
46
|
+
acf = np.correlate(centered_signal, centered_signal, mode='full')
|
|
47
|
+
|
|
48
|
+
# 3. Get the value at zero lag (the center of the 'full' correlation)
|
|
49
|
+
zero_lag_index = len(acf) // 2
|
|
50
|
+
r_0 = acf[zero_lag_index] / len(centered_signal) # Normalize by length
|
|
51
|
+
|
|
52
|
+
# 4. Calculate RMS and Peak Amplitude
|
|
53
|
+
rms = np.sqrt(r_0)
|
|
54
|
+
peak_amplitude = rms * np.sqrt(2)
|
|
55
|
+
|
|
56
|
+
return peak_amplitude
|
|
57
|
+
|
|
58
|
+
def create_bpf_kernel(low_kb, high_kb, fs, num_taps=101):
|
|
59
|
+
"""Utility to generate a Band-Pass Filter kernel."""
|
|
60
|
+
return sp_signal.firwin(num_taps, [low_kb, high_kb], fs=fs, pass_zero=False)
|
|
61
|
+
|
|
62
|
+
def plot_frequency_response(data_list, use_acf=True):
|
|
63
|
+
"""
|
|
64
|
+
Plots Max Voltage vs Frequency, handling 1.5MHz and 3MHz separately.
|
|
65
|
+
data_list: list of (freq_hz, filename, fs_hz)
|
|
66
|
+
"""
|
|
67
|
+
data_1_5 = []
|
|
68
|
+
data_3_0 = []
|
|
69
|
+
|
|
70
|
+
for freq, filename, fs in data_list:
|
|
71
|
+
try:
|
|
72
|
+
data_file = np.load(filename)
|
|
73
|
+
signal_data = data_file["arr_0"][2]
|
|
74
|
+
|
|
75
|
+
# Choose amplitude method
|
|
76
|
+
val = get_acf_amplitude(signal_data) if use_acf else np.max(np.abs(signal_data))
|
|
77
|
+
|
|
78
|
+
if fs == 1500000:
|
|
79
|
+
data_1_5.append((freq / 1000, val))
|
|
80
|
+
else:
|
|
81
|
+
data_3_0.append((freq / 1000, val))
|
|
82
|
+
except Exception as e:
|
|
83
|
+
print(f"Error loading {filename}: {e}")
|
|
84
|
+
|
|
85
|
+
# Sort to prevent the 'sawtooth' lines
|
|
86
|
+
data_1_5.sort()
|
|
87
|
+
data_3_0.sort()
|
|
88
|
+
|
|
89
|
+
plt.figure(figsize=(10, 6))
|
|
90
|
+
if data_1_5:
|
|
91
|
+
x15, y15 = zip(*data_1_5)
|
|
92
|
+
plt.plot(x15, y15, 'bo-', label='1.5 MHz Fs', alpha=0.8)
|
|
93
|
+
if data_3_0:
|
|
94
|
+
x30, y30 = zip(*data_3_0)
|
|
95
|
+
plt.plot(x30, y30, 'ro-', label='3.0 MHz Fs', alpha=0.8)
|
|
96
|
+
|
|
97
|
+
plt.title(f"Frequency Response ({'ACF' if use_acf else 'Raw'} Peak)")
|
|
98
|
+
plt.xlabel("Signal Frequency (kHz)")
|
|
99
|
+
plt.ylabel("Amplitude (V)")
|
|
100
|
+
plt.legend()
|
|
101
|
+
plt.grid(True, alpha=0.3)
|
|
102
|
+
plt.show()
|
|
File without changes
|
|
File without changes
|
{rf_funcitons_py-0.1.3 → rf_funcitons_py-0.1.5}/rf_funcitons_py.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|