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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rf_funcitons_py
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: First package from a notebook
5
5
  Author-email: Avery Books <abooks104@gmail.com>
6
6
  Requires-Python: >3.8
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "rf_funcitons_py"
7
- version = "0.1.3"
7
+ version = "0.1.5"
8
8
  description = "First package from a notebook"
9
9
  readme = "README.md"
10
10
  authors = [{name = "Avery Books", email = "abooks104@gmail.com"}]
@@ -0,0 +1,3 @@
1
+ from .logic import id_signal_candidates
2
+ from .filters import RF_filter, bpf_kernel, get_acf_amplitude, plot_frequency_response
3
+ from .bpf_filter import create_bpf_kernel
@@ -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()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rf_funcitons_py
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: First package from a notebook
5
5
  Author-email: Avery Books <abooks104@gmail.com>
6
6
  Requires-Python: >3.8
@@ -1,9 +1,8 @@
1
1
  README.md
2
2
  pyproject.toml
3
3
  rafpy/__init__.py
4
- rafpy/bpf_kernal.py
4
+ rafpy/filters.py
5
5
  rafpy/logic.py
6
- rafpy/rf_filter.py
7
6
  rf_funcitons_py.egg-info/PKG-INFO
8
7
  rf_funcitons_py.egg-info/SOURCES.txt
9
8
  rf_funcitons_py.egg-info/dependency_links.txt
@@ -1,3 +0,0 @@
1
- from .logic import id_signal_candidates
2
- from .rf_filter import RF_filter
3
- from .bpf_filter import create_bpf_kernel
@@ -1,3 +0,0 @@
1
- def create_bpf_kernel(low_kb, high_kb, fs, num_taps=101):
2
- """Utility to generate a Band-Pass Filter kernel."""
3
- return sp_signal.firwin(num_taps, [low_kb, high_kb], fs=fs, pass_zero=False)