spectre-core 0.0.10__py3-none-any.whl → 0.0.11__py3-none-any.whl

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.
@@ -131,10 +131,8 @@ def _validate_step_interval(
131
131
 
132
132
  step_interval = samples_per_step * 1/ sample_rate # [s]
133
133
  if step_interval < api_latency:
134
- warning_message = (f"The computed step interval of {step_interval} [s] is of the order of empirically "
135
- f"derived api latency {api_latency} [s]; you may experience undefined behaviour!")
136
- warn(warning_message)
137
- _LOGGER.warning(warning_message)
134
+ raise ValueError(f"The computed step interval of {step_interval} [s] is of the order of empirically "
135
+ f"derived api latency {api_latency} [s]; you may experience undefined behaviour!")
138
136
 
139
137
 
140
138
  def _validate_fixed_center_frequency_parameters(
@@ -104,7 +104,7 @@ class BaseEventHandler(ABC, FileSystemEventHandler):
104
104
  self._cached_spectrogram = join_spectrograms([self._cached_spectrogram, spectrogram])
105
105
 
106
106
  # if the time range is not specified
107
- time_range = self._capture_config.get_parameter_value(PNames.TIME_RANGE) or self._capture_config.get_parameter_value(PNames.BATCH_SIZE)
107
+ time_range = self._capture_config.get_parameter_value(PNames.TIME_RANGE) or 0.0
108
108
 
109
109
  if self._cached_spectrogram.time_range >= time_range:
110
110
  self._flush_cache()
@@ -5,6 +5,7 @@
5
5
  # register decorators take effect on import
6
6
  from .library._test import _Receiver
7
7
  from .library._rsp1a import _Receiver
8
+ from .library._rspduo import _Receiver
8
9
 
9
10
  from ._base import BaseReceiver
10
11
  from ._factory import get_receiver
@@ -177,176 +177,4 @@ class BaseReceiver(ABC):
177
177
  parameters = self.capture_template.apply_template(capture_config.parameters)
178
178
  self.pvalidator(parameters)
179
179
 
180
- return parameters
181
-
182
-
183
- class SDRPlayReceiver(BaseReceiver):
184
- def _get_pvalidator_fixed_center_frequency(self) -> Callable:
185
- def pvalidator(parameters: Parameters):
186
- PValidators.fixed_center_frequency(parameters)
187
- return pvalidator
188
-
189
-
190
- def _get_pvalidator_swept_center_frequency(self) -> None:
191
- def pvalidator(parameters: Parameters):
192
- PValidators.swept_center_frequency(parameters,
193
- self.get_spec(SpecNames.API_RETUNING_LATENCY))
194
- return pvalidator
195
-
196
-
197
- def _get_capture_template_fixed_center_frequency(self) -> CaptureTemplate:
198
- #
199
- # Create the base template
200
- #
201
- capture_template = get_base_capture_template( CaptureModes.FIXED_CENTER_FREQUENCY )
202
- capture_template.add_ptemplate( get_base_ptemplate(PNames.BANDWIDTH) )
203
- capture_template.add_ptemplate( get_base_ptemplate(PNames.IF_GAIN) )
204
- capture_template.add_ptemplate( get_base_ptemplate(PNames.RF_GAIN) )
205
-
206
- #
207
- # Update the defaults
208
- #
209
- capture_template.set_defaults(
210
- (PNames.BATCH_SIZE, 3.0),
211
- (PNames.CENTER_FREQUENCY, 95800000),
212
- (PNames.SAMPLE_RATE, 600000),
213
- (PNames.BANDWIDTH, 600000),
214
- (PNames.WINDOW_HOP, 512),
215
- (PNames.WINDOW_SIZE, 1024),
216
- (PNames.WINDOW_TYPE, "blackman"),
217
- (PNames.RF_GAIN, -30),
218
- (PNames.IF_GAIN, -30)
219
- )
220
-
221
- #
222
- # Adding pconstraints
223
- #
224
- capture_template.add_pconstraint(
225
- PNames.CENTER_FREQUENCY,
226
- [
227
- Bound(
228
- lower_bound=self.get_spec(SpecNames.FREQUENCY_LOWER_BOUND),
229
- upper_bound=self.get_spec(SpecNames.FREQUENCY_UPPER_BOUND)
230
- )
231
- ]
232
- )
233
- capture_template.add_pconstraint(
234
- PNames.SAMPLE_RATE,
235
- [
236
- Bound(
237
- lower_bound=self.get_spec(SpecNames.SAMPLE_RATE_LOWER_BOUND),
238
- upper_bound=self.get_spec(SpecNames.SAMPLE_RATE_UPPER_BOUND)
239
- )
240
- ]
241
- )
242
- capture_template.add_pconstraint(
243
- PNames.BANDWIDTH,
244
- [
245
- OneOf(
246
- self.get_spec( SpecNames.BANDWIDTH_OPTIONS )
247
- )
248
- ]
249
- )
250
- capture_template.add_pconstraint(
251
- PNames.IF_GAIN,
252
- [
253
- Bound(
254
- upper_bound=self.get_spec(SpecNames.IF_GAIN_UPPER_BOUND)
255
- )
256
- ]
257
- )
258
- capture_template.add_pconstraint(
259
- PNames.RF_GAIN,
260
- [
261
- Bound(
262
- upper_bound=self.get_spec(SpecNames.RF_GAIN_UPPER_BOUND)
263
- )
264
- ]
265
- )
266
- return capture_template
267
-
268
-
269
- def _get_capture_template_swept_center_frequency(self) -> CaptureTemplate:
270
- #
271
- # Create the base template
272
- #
273
- capture_template = get_base_capture_template( CaptureModes.SWEPT_CENTER_FREQUENCY )
274
- capture_template.add_ptemplate( get_base_ptemplate(PNames.BANDWIDTH) )
275
- capture_template.add_ptemplate( get_base_ptemplate(PNames.IF_GAIN) )
276
- capture_template.add_ptemplate( get_base_ptemplate(PNames.RF_GAIN) )
277
-
278
-
279
- #
280
- # Update the defaults
281
- #
282
- capture_template.set_defaults(
283
- (PNames.BATCH_SIZE, 3.0),
284
- (PNames.MIN_FREQUENCY, 90000000),
285
- (PNames.MAX_FREQUENCY, 110000000),
286
- (PNames.SAMPLES_PER_STEP, 300000),
287
- (PNames.FREQUENCY_STEP, 1536000),
288
- (PNames.SAMPLE_RATE, 1536000),
289
- (PNames.BANDWIDTH, 1536000),
290
- (PNames.WINDOW_HOP, 512),
291
- (PNames.WINDOW_SIZE, 1024),
292
- (PNames.WINDOW_TYPE, "blackman"),
293
- (PNames.RF_GAIN, -30),
294
- (PNames.IF_GAIN, -30)
295
- )
296
-
297
-
298
- #
299
- # Adding pconstraints
300
- #
301
- capture_template.add_pconstraint(
302
- PNames.MIN_FREQUENCY,
303
- [
304
- Bound(
305
- lower_bound=self.get_spec(SpecNames.FREQUENCY_LOWER_BOUND),
306
- upper_bound=self.get_spec(SpecNames.FREQUENCY_UPPER_BOUND)
307
- )
308
- ]
309
- )
310
- capture_template.add_pconstraint(
311
- PNames.MAX_FREQUENCY,
312
- [
313
- Bound(
314
- lower_bound=self.get_spec(SpecNames.FREQUENCY_LOWER_BOUND),
315
- upper_bound=self.get_spec(SpecNames.FREQUENCY_UPPER_BOUND)
316
- )
317
- ]
318
- )
319
- capture_template.add_pconstraint(
320
- PNames.SAMPLE_RATE,
321
- [
322
- Bound(
323
- lower_bound=self.get_spec(SpecNames.SAMPLE_RATE_LOWER_BOUND),
324
- upper_bound=self.get_spec(SpecNames.SAMPLE_RATE_UPPER_BOUND)
325
- )
326
- ]
327
- )
328
- capture_template.add_pconstraint(
329
- PNames.BANDWIDTH,
330
- [
331
- OneOf(
332
- self.get_spec( SpecNames.BANDWIDTH_OPTIONS )
333
- )
334
- ]
335
- )
336
- capture_template.add_pconstraint(
337
- PNames.IF_GAIN,
338
- [
339
- Bound(
340
- upper_bound=self.get_spec(SpecNames.IF_GAIN_UPPER_BOUND)
341
- )
342
- ]
343
- )
344
- capture_template.add_pconstraint(
345
- PNames.RF_GAIN,
346
- [
347
- Bound(
348
- upper_bound=self.get_spec(SpecNames.RF_GAIN_UPPER_BOUND)
349
- )
350
- ]
351
- )
352
- return capture_template
180
+ return parameters
@@ -13,7 +13,7 @@
13
13
  # SPDX-License-Identifier: GPL-3.0-or-later
14
14
 
15
15
  #
16
- # Test receiver top blocks
16
+ # RSP1A receiver top blocks
17
17
  #
18
18
 
19
19
  from functools import partial
@@ -31,7 +31,7 @@ class _fixed_center_frequency(gr.top_block):
31
31
  def __init__(self,
32
32
  tag: str,
33
33
  parameters: Parameters):
34
- gr.top_block.__init__(self, "fixed-center-frequency", catch_exceptions=True)
34
+ gr.top_block.__init__(self, catch_exceptions=True)
35
35
 
36
36
  ##################################################
37
37
  # Unpack capture config
@@ -42,7 +42,7 @@ class _fixed_center_frequency(gr.top_block):
42
42
  bandwidth = parameters.get_parameter_value(PNames.BANDWIDTH)
43
43
  if_gain = parameters.get_parameter_value(PNames.IF_GAIN)
44
44
  rf_gain = parameters.get_parameter_value(PNames.RF_GAIN)
45
- is_sweeping = False
45
+
46
46
 
47
47
  ##################################################
48
48
  # Blocks
@@ -86,7 +86,7 @@ class _swept_center_frequency(gr.top_block):
86
86
  def __init__(self,
87
87
  tag: str,
88
88
  parameters: Parameters):
89
- gr.top_block.__init__(self, "sweep", catch_exceptions=True)
89
+ gr.top_block.__init__(self, catch_exceptions=True)
90
90
 
91
91
  ##################################################
92
92
  # Unpack capture config
@@ -155,4 +155,4 @@ class _swept_center_frequency(gr.top_block):
155
155
  @dataclass(frozen=True)
156
156
  class CaptureMethods:
157
157
  fixed_center_frequency = partial(capture, top_block_cls=_fixed_center_frequency)
158
- _swept_center_frequency = partial(capture, top_block_cls=_swept_center_frequency)
158
+ swept_center_frequency = partial(capture, top_block_cls=_swept_center_frequency)
@@ -0,0 +1,227 @@
1
+ #!/usr/bin/env python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ #
5
+ # SPDX-License-Identifier: GPL-3.0
6
+ #
7
+ # GNU Radio Python Flow Graph
8
+ # Title: Test receiver
9
+ # GNU Radio version: 3.10.1.1
10
+
11
+ # SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
12
+ # This file is part of SPECTRE
13
+ # SPDX-License-Identifier: GPL-3.0-or-later
14
+
15
+ #
16
+ # RSPduo receiver top blocks
17
+ #
18
+
19
+ from functools import partial
20
+ from dataclasses import dataclass
21
+
22
+ from gnuradio import gr
23
+ from gnuradio import spectre
24
+ from gnuradio import sdrplay3
25
+
26
+ from spectre_core.capture_configs import Parameters, PNames
27
+ from spectre_core.config import get_chunks_dir_path
28
+ from ._base import capture
29
+
30
+
31
+ class _tuner_1_fixed_center_frequency(gr.top_block):
32
+ def __init__(self,
33
+ tag: str,
34
+ parameters: Parameters):
35
+ gr.top_block.__init__(self, catch_exceptions=True)
36
+ gr.top_block.__init__(self, "tuner_1_fixed", catch_exceptions=True)
37
+
38
+ ##################################################
39
+ # Unpack capture config
40
+ ##################################################
41
+ sample_rate = parameters.get_parameter_value(PNames.SAMPLE_RATE)
42
+ batch_size = parameters.get_parameter_value(PNames.BATCH_SIZE)
43
+ center_freq = parameters.get_parameter_value(PNames.CENTER_FREQUENCY)
44
+ bandwidth = parameters.get_parameter_value(PNames.BANDWIDTH)
45
+ if_gain = parameters.get_parameter_value(PNames.IF_GAIN)
46
+ rf_gain = parameters.get_parameter_value(PNames.RF_GAIN)
47
+
48
+ ##################################################
49
+ # Blocks
50
+ ##################################################
51
+ self.spectre_batched_file_sink_0 = spectre.batched_file_sink(get_chunks_dir_path(),
52
+ tag,
53
+ batch_size,
54
+ sample_rate)
55
+ self.sdrplay3_rspduo_0 = sdrplay3.rspduo(
56
+ '',
57
+ rspduo_mode="Single Tuner",
58
+ antenna="Tuner 1 50 ohm",
59
+ stream_args=sdrplay3.stream_args(
60
+ output_type='fc32',
61
+ channels_size=1
62
+ ),
63
+ )
64
+ self.sdrplay3_rspduo_0.set_sample_rate(sample_rate)
65
+ self.sdrplay3_rspduo_0.set_center_freq(center_freq)
66
+ self.sdrplay3_rspduo_0.set_bandwidth(bandwidth)
67
+ self.sdrplay3_rspduo_0.set_antenna("Tuner 1 50 ohm")
68
+ self.sdrplay3_rspduo_0.set_gain_mode(False)
69
+ self.sdrplay3_rspduo_0.set_gain(if_gain, 'IF')
70
+ self.sdrplay3_rspduo_0.set_gain(rf_gain, 'RF')
71
+ self.sdrplay3_rspduo_0.set_freq_corr(0)
72
+ self.sdrplay3_rspduo_0.set_dc_offset_mode(False)
73
+ self.sdrplay3_rspduo_0.set_iq_balance_mode(False)
74
+ self.sdrplay3_rspduo_0.set_agc_setpoint(-30)
75
+ self.sdrplay3_rspduo_0.set_rf_notch_filter(False)
76
+ self.sdrplay3_rspduo_0.set_dab_notch_filter(False)
77
+ self.sdrplay3_rspduo_0.set_am_notch_filter(False)
78
+ self.sdrplay3_rspduo_0.set_biasT(False)
79
+ self.sdrplay3_rspduo_0.set_debug_mode(False)
80
+ self.sdrplay3_rspduo_0.set_sample_sequence_gaps_check(False)
81
+ self.sdrplay3_rspduo_0.set_show_gain_changes(False)
82
+
83
+
84
+ ##################################################
85
+ # Connections
86
+ ##################################################
87
+ self.connect((self.sdrplay3_rspduo_0, 0), (self.spectre_batched_file_sink_0, 0))
88
+
89
+
90
+ class _tuner_2_fixed_center_frequency(gr.top_block):
91
+ def __init__(self,
92
+ tag: str,
93
+ parameters: Parameters):
94
+ gr.top_block.__init__(self, catch_exceptions=True)
95
+ gr.top_block.__init__(self, "tuner_1_fixed", catch_exceptions=True)
96
+
97
+ ##################################################
98
+ # Unpack capture config
99
+ ##################################################
100
+ sample_rate = parameters.get_parameter_value(PNames.SAMPLE_RATE)
101
+ batch_size = parameters.get_parameter_value(PNames.BATCH_SIZE)
102
+ center_freq = parameters.get_parameter_value(PNames.CENTER_FREQUENCY)
103
+ bandwidth = parameters.get_parameter_value(PNames.BANDWIDTH)
104
+ if_gain = parameters.get_parameter_value(PNames.IF_GAIN)
105
+ rf_gain = parameters.get_parameter_value(PNames.RF_GAIN)
106
+
107
+ ##################################################
108
+ # Blocks
109
+ ##################################################
110
+ self.spectre_batched_file_sink_0 = spectre.batched_file_sink(get_chunks_dir_path(),
111
+ tag,
112
+ batch_size,
113
+ sample_rate)
114
+ self.sdrplay3_rspduo_0 = sdrplay3.rspduo(
115
+ '',
116
+ rspduo_mode="Single Tuner",
117
+ antenna="Tuner 2 50 ohm",
118
+ stream_args=sdrplay3.stream_args(
119
+ output_type='fc32',
120
+ channels_size=1
121
+ ),
122
+ )
123
+ self.sdrplay3_rspduo_0.set_sample_rate(sample_rate)
124
+ self.sdrplay3_rspduo_0.set_center_freq(center_freq)
125
+ self.sdrplay3_rspduo_0.set_bandwidth(bandwidth)
126
+ self.sdrplay3_rspduo_0.set_antenna("Tuner 2 50 ohm")
127
+ self.sdrplay3_rspduo_0.set_gain_mode(False)
128
+ self.sdrplay3_rspduo_0.set_gain(if_gain, 'IF')
129
+ self.sdrplay3_rspduo_0.set_gain(rf_gain, 'RF', False)
130
+ self.sdrplay3_rspduo_0.set_freq_corr(0)
131
+ self.sdrplay3_rspduo_0.set_dc_offset_mode(False)
132
+ self.sdrplay3_rspduo_0.set_iq_balance_mode(False)
133
+ self.sdrplay3_rspduo_0.set_agc_setpoint(-30)
134
+ self.sdrplay3_rspduo_0.set_rf_notch_filter(False)
135
+ self.sdrplay3_rspduo_0.set_dab_notch_filter(False)
136
+ self.sdrplay3_rspduo_0.set_am_notch_filter(False)
137
+ self.sdrplay3_rspduo_0.set_biasT(False)
138
+ self.sdrplay3_rspduo_0.set_stream_tags(False)
139
+ self.sdrplay3_rspduo_0.set_debug_mode(False)
140
+ self.sdrplay3_rspduo_0.set_sample_sequence_gaps_check(False)
141
+ self.sdrplay3_rspduo_0.set_show_gain_changes(False)
142
+
143
+
144
+ ##################################################
145
+ # Connections
146
+ ##################################################
147
+ self.connect((self.sdrplay3_rspduo_0, 0), (self.spectre_batched_file_sink_0, 0))
148
+
149
+
150
+ class _tuner_1_swept_center_frequency(gr.top_block):
151
+ def __init__(self,
152
+ tag: str,
153
+ parameters: Parameters):
154
+ gr.top_block.__init__(self, catch_exceptions=True)
155
+
156
+ ##################################################
157
+ # Unpack capture config
158
+ ##################################################
159
+ sample_rate = parameters.get_parameter_value(PNames.SAMPLE_RATE)
160
+ bandwidth = parameters.get_parameter_value(PNames.BANDWIDTH)
161
+ min_frequency = parameters.get_parameter_value(PNames.MIN_FREQUENCY)
162
+ max_frequency = parameters.get_parameter_value(PNames.MAX_FREQUENCY)
163
+ frequency_step = parameters.get_parameter_value(PNames.FREQUENCY_STEP)
164
+ samples_per_step = parameters.get_parameter_value(PNames.SAMPLES_PER_STEP)
165
+ if_gain = parameters.get_parameter_value(PNames.IF_GAIN)
166
+ rf_gain = parameters.get_parameter_value(PNames.RF_GAIN)
167
+ batch_size = parameters.get_parameter_value(PNames.BATCH_SIZE)
168
+
169
+ ##################################################
170
+ # Blocks
171
+ ##################################################
172
+ self.spectre_sweep_driver_0 = spectre.sweep_driver(min_frequency,
173
+ max_frequency,
174
+ frequency_step,
175
+ sample_rate,
176
+ samples_per_step,
177
+ 'freq')
178
+ self.spectre_batched_file_sink_0 = spectre.batched_file_sink(get_chunks_dir_path(),
179
+ tag,
180
+ batch_size,
181
+ sample_rate,
182
+ True,
183
+ 'freq',
184
+ min_frequency)
185
+ self.sdrplay3_rspduo_0 = sdrplay3.rspduo(
186
+ '',
187
+ rspduo_mode="Single Tuner",
188
+ antenna="Tuner 1 50 ohm",
189
+ stream_args=sdrplay3.stream_args(
190
+ output_type='fc32',
191
+ channels_size=1
192
+ ),
193
+ )
194
+ self.sdrplay3_rspduo_0.set_sample_rate(sample_rate, True)
195
+ self.sdrplay3_rspduo_0.set_center_freq(min_frequency, True)
196
+ self.sdrplay3_rspduo_0.set_bandwidth(bandwidth)
197
+ self.sdrplay3_rspduo_0.set_antenna("Tuner 1 50 ohm")
198
+ self.sdrplay3_rspduo_0.set_gain_mode(False)
199
+ self.sdrplay3_rspduo_0.set_gain(if_gain, 'IF', True)
200
+ self.sdrplay3_rspduo_0.set_gain(rf_gain, 'RF', True)
201
+ self.sdrplay3_rspduo_0.set_freq_corr(0)
202
+ self.sdrplay3_rspduo_0.set_dc_offset_mode(False)
203
+ self.sdrplay3_rspduo_0.set_iq_balance_mode(False)
204
+ self.sdrplay3_rspduo_0.set_agc_setpoint(-30)
205
+ self.sdrplay3_rspduo_0.set_rf_notch_filter(False)
206
+ self.sdrplay3_rspduo_0.set_dab_notch_filter(True)
207
+ self.sdrplay3_rspduo_0.set_am_notch_filter(False)
208
+ self.sdrplay3_rspduo_0.set_biasT(False)
209
+ self.sdrplay3_rspduo_0.set_stream_tags(True)
210
+ self.sdrplay3_rspduo_0.set_debug_mode(False)
211
+ self.sdrplay3_rspduo_0.set_sample_sequence_gaps_check(False)
212
+ self.sdrplay3_rspduo_0.set_show_gain_changes(False)
213
+
214
+
215
+ ##################################################
216
+ # Connections
217
+ ##################################################
218
+ self.msg_connect((self.spectre_sweep_driver_0, 'freq'), (self.sdrplay3_rspduo_0, 'freq'))
219
+ self.connect((self.sdrplay3_rspduo_0, 0), (self.spectre_batched_file_sink_0, 0))
220
+ self.connect((self.sdrplay3_rspduo_0, 0), (self.spectre_sweep_driver_0, 0))
221
+
222
+
223
+ @dataclass(frozen=True)
224
+ class CaptureMethods:
225
+ tuner_1_fixed_center_frequency = partial(capture, top_block_cls=_tuner_1_fixed_center_frequency)
226
+ tuner_2_fixed_center_frequency = partial(capture, top_block_cls=_tuner_2_fixed_center_frequency)
227
+ tuner_1_swept_center_frequency = partial(capture, top_block_cls=_tuner_1_swept_center_frequency)
@@ -33,7 +33,7 @@ class _cosine_signal_1(gr.top_block):
33
33
  def __init__(self,
34
34
  tag: str,
35
35
  parameters: Parameters):
36
- gr.top_block.__init__(self, "cosine-signal-1", catch_exceptions=True)
36
+ gr.top_block.__init__(self, catch_exceptions=True)
37
37
 
38
38
  ##################################################
39
39
  # Unpack capture config
@@ -80,7 +80,7 @@ class _tagged_staircase(gr.top_block):
80
80
  def __init__(self,
81
81
  tag: str,
82
82
  parameters: Parameters):
83
- gr.top_block.__init__(self, "tagged-staircase", catch_exceptions=True)
83
+ gr.top_block.__init__(self, catch_exceptions=True)
84
84
 
85
85
  ##################################################
86
86
  # Unpack capture config
@@ -11,7 +11,7 @@ from spectre_core.capture_configs import (
11
11
  )
12
12
  from ..gr._rsp1a import CaptureMethods
13
13
  from .._spec_names import SpecNames
14
- from .._base import SDRPlayReceiver
14
+ from ._sdrplay_receiver import SDRPlayReceiver
15
15
  from .._register import register_receiver
16
16
 
17
17
  @dataclass
@@ -44,7 +44,7 @@ class _Receiver(SDRPlayReceiver):
44
44
  self.add_capture_method(Modes.FIXED_CENTER_FREQUENCY,
45
45
  CaptureMethods.fixed_center_frequency)
46
46
  self.add_capture_method(Modes.SWEPT_CENTER_FREQUENCY,
47
- CaptureMethods._swept_center_frequency)
47
+ CaptureMethods.swept_center_frequency)
48
48
 
49
49
 
50
50
  def _add_capture_templates(self):
@@ -55,7 +55,7 @@ class _Receiver(SDRPlayReceiver):
55
55
 
56
56
 
57
57
  def _add_pvalidators(self):
58
- self.add_pvalidator(CaptureModes.FIXED_CENTER_FREQUENCY,
58
+ self.add_pvalidator(Modes.FIXED_CENTER_FREQUENCY,
59
59
  self._get_pvalidator_fixed_center_frequency())
60
- self.add_pvalidator(CaptureModes.SWEPT_CENTER_FREQUENCY,
60
+ self.add_pvalidator(Modes.SWEPT_CENTER_FREQUENCY,
61
61
  self._get_pvalidator_swept_center_frequency())
@@ -0,0 +1,69 @@
1
+ # SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
2
+ # This file is part of SPECTRE
3
+ # SPDX-License-Identifier: GPL-3.0-or-later
4
+
5
+ from typing import Optional
6
+ from dataclasses import dataclass
7
+ from functools import partial
8
+
9
+ from spectre_core.capture_configs import (
10
+ CaptureModes
11
+ )
12
+ from ..gr._rspduo import CaptureMethods
13
+ from .._spec_names import SpecNames
14
+ from ._sdrplay_receiver import SDRPlayReceiver
15
+ from .._register import register_receiver
16
+
17
+ @dataclass
18
+ class Modes:
19
+ TUNER_1_FIXED_CENTER_FREQUENCY = f"tuner-1-{CaptureModes.FIXED_CENTER_FREQUENCY}"
20
+ TUNER_2_FIXED_CENTER_FREQUENCY = f"tuner-2-{CaptureModes.FIXED_CENTER_FREQUENCY}"
21
+ TUNER_1_SWEPT_CENTER_FREQUENCY = f"tuner-1-{CaptureModes.SWEPT_CENTER_FREQUENCY}"
22
+
23
+
24
+ @register_receiver("rspduo")
25
+ class _Receiver(SDRPlayReceiver):
26
+ def __init__(self,
27
+ name: str,
28
+ mode: Optional[str]):
29
+ super().__init__(name,
30
+ mode)
31
+
32
+
33
+ def _add_specs(self) -> None:
34
+ self.add_spec( SpecNames.SAMPLE_RATE_LOWER_BOUND, 200e3 ) # Hz
35
+ self.add_spec( SpecNames.SAMPLE_RATE_UPPER_BOUND, 10e6 ) # Hz
36
+ self.add_spec( SpecNames.FREQUENCY_LOWER_BOUND , 1e3 ) # Hz
37
+ self.add_spec( SpecNames.FREQUENCY_UPPER_BOUND , 2e9 ) # Hz
38
+ self.add_spec( SpecNames.IF_GAIN_UPPER_BOUND , -20 ) # dB
39
+ self.add_spec( SpecNames.RF_GAIN_UPPER_BOUND , 0 ) # dB
40
+ self.add_spec( SpecNames.API_RETUNING_LATENCY , 50 * 1e-3 ) # s
41
+ self.add_spec( SpecNames.BANDWIDTH_OPTIONS,
42
+ [200000, 300000, 600000, 1536000, 5000000, 6000000, 7000000, 8000000])
43
+
44
+
45
+ def _add_capture_methods(self) -> None:
46
+ self.add_capture_method(Modes.TUNER_1_FIXED_CENTER_FREQUENCY,
47
+ CaptureMethods.tuner_1_fixed_center_frequency)
48
+ self.add_capture_method(Modes.TUNER_2_FIXED_CENTER_FREQUENCY,
49
+ CaptureMethods.tuner_2_fixed_center_frequency)
50
+ self.add_capture_method(Modes.TUNER_1_SWEPT_CENTER_FREQUENCY,
51
+ CaptureMethods.tuner_1_swept_center_frequency)
52
+
53
+
54
+ def _add_capture_templates(self):
55
+ self.add_capture_template(Modes.TUNER_1_FIXED_CENTER_FREQUENCY,
56
+ self._get_capture_template_fixed_center_frequency())
57
+ self.add_capture_template(Modes.TUNER_2_FIXED_CENTER_FREQUENCY,
58
+ self._get_capture_template_fixed_center_frequency())
59
+ self.add_capture_template(Modes.TUNER_1_SWEPT_CENTER_FREQUENCY,
60
+ self._get_capture_template_swept_center_frequency())
61
+
62
+
63
+ def _add_pvalidators(self):
64
+ self.add_pvalidator(Modes.TUNER_1_FIXED_CENTER_FREQUENCY,
65
+ self._get_pvalidator_fixed_center_frequency())
66
+ self.add_pvalidator(Modes.TUNER_2_FIXED_CENTER_FREQUENCY,
67
+ self._get_pvalidator_fixed_center_frequency())
68
+ self.add_pvalidator(Modes.TUNER_1_SWEPT_CENTER_FREQUENCY,
69
+ self._get_pvalidator_swept_center_frequency())
@@ -0,0 +1,185 @@
1
+ # SPDX-FileCopyrightText: © 2024 Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
2
+ # This file is part of SPECTRE
3
+ # SPDX-License-Identifier: GPL-3.0-or-later
4
+
5
+ from abc import ABC, abstractmethod
6
+ from typing import Callable, Optional
7
+ from numbers import Number
8
+
9
+ from spectre_core.capture_configs import (
10
+ CaptureTemplate, CaptureModes, Parameters, Bound, PValidators, PNames,
11
+ get_base_capture_template, get_base_ptemplate, OneOf, CaptureConfig
12
+ )
13
+ from .._base import BaseReceiver
14
+ from .._spec_names import SpecNames
15
+
16
+ class SDRPlayReceiver(BaseReceiver):
17
+ def _get_pvalidator_fixed_center_frequency(self) -> Callable:
18
+ def pvalidator(parameters: Parameters):
19
+ PValidators.fixed_center_frequency(parameters)
20
+ return pvalidator
21
+
22
+
23
+ def _get_pvalidator_swept_center_frequency(self) -> None:
24
+ def pvalidator(parameters: Parameters):
25
+ PValidators.swept_center_frequency(parameters,
26
+ self.get_spec(SpecNames.API_RETUNING_LATENCY))
27
+ return pvalidator
28
+
29
+
30
+ def _get_capture_template_fixed_center_frequency(self) -> CaptureTemplate:
31
+ #
32
+ # Create the base template
33
+ #
34
+ capture_template = get_base_capture_template( CaptureModes.FIXED_CENTER_FREQUENCY )
35
+ capture_template.add_ptemplate( get_base_ptemplate(PNames.BANDWIDTH) )
36
+ capture_template.add_ptemplate( get_base_ptemplate(PNames.IF_GAIN) )
37
+ capture_template.add_ptemplate( get_base_ptemplate(PNames.RF_GAIN) )
38
+
39
+ #
40
+ # Update the defaults
41
+ #
42
+ capture_template.set_defaults(
43
+ (PNames.BATCH_SIZE, 3.0),
44
+ (PNames.CENTER_FREQUENCY, 95800000),
45
+ (PNames.SAMPLE_RATE, 600000),
46
+ (PNames.BANDWIDTH, 600000),
47
+ (PNames.WINDOW_HOP, 512),
48
+ (PNames.WINDOW_SIZE, 1024),
49
+ (PNames.WINDOW_TYPE, "blackman"),
50
+ (PNames.RF_GAIN, -30),
51
+ (PNames.IF_GAIN, -30)
52
+ )
53
+
54
+ #
55
+ # Adding pconstraints
56
+ #
57
+ capture_template.add_pconstraint(
58
+ PNames.CENTER_FREQUENCY,
59
+ [
60
+ Bound(
61
+ lower_bound=self.get_spec(SpecNames.FREQUENCY_LOWER_BOUND),
62
+ upper_bound=self.get_spec(SpecNames.FREQUENCY_UPPER_BOUND)
63
+ )
64
+ ]
65
+ )
66
+ capture_template.add_pconstraint(
67
+ PNames.SAMPLE_RATE,
68
+ [
69
+ Bound(
70
+ lower_bound=self.get_spec(SpecNames.SAMPLE_RATE_LOWER_BOUND),
71
+ upper_bound=self.get_spec(SpecNames.SAMPLE_RATE_UPPER_BOUND)
72
+ )
73
+ ]
74
+ )
75
+ capture_template.add_pconstraint(
76
+ PNames.BANDWIDTH,
77
+ [
78
+ OneOf(
79
+ self.get_spec( SpecNames.BANDWIDTH_OPTIONS )
80
+ )
81
+ ]
82
+ )
83
+ capture_template.add_pconstraint(
84
+ PNames.IF_GAIN,
85
+ [
86
+ Bound(
87
+ upper_bound=self.get_spec(SpecNames.IF_GAIN_UPPER_BOUND)
88
+ )
89
+ ]
90
+ )
91
+ capture_template.add_pconstraint(
92
+ PNames.RF_GAIN,
93
+ [
94
+ Bound(
95
+ upper_bound=self.get_spec(SpecNames.RF_GAIN_UPPER_BOUND)
96
+ )
97
+ ]
98
+ )
99
+ return capture_template
100
+
101
+
102
+ def _get_capture_template_swept_center_frequency(self) -> CaptureTemplate:
103
+ #
104
+ # Create the base template
105
+ #
106
+ capture_template = get_base_capture_template( CaptureModes.SWEPT_CENTER_FREQUENCY )
107
+ capture_template.add_ptemplate( get_base_ptemplate(PNames.BANDWIDTH) )
108
+ capture_template.add_ptemplate( get_base_ptemplate(PNames.IF_GAIN) )
109
+ capture_template.add_ptemplate( get_base_ptemplate(PNames.RF_GAIN) )
110
+
111
+
112
+ #
113
+ # Update the defaults
114
+ #
115
+ capture_template.set_defaults(
116
+ (PNames.BATCH_SIZE, 4.0),
117
+ (PNames.MIN_FREQUENCY, 95000000),
118
+ (PNames.MAX_FREQUENCY, 100000000),
119
+ (PNames.SAMPLES_PER_STEP, 80000),
120
+ (PNames.FREQUENCY_STEP, 1536000),
121
+ (PNames.SAMPLE_RATE, 1536000),
122
+ (PNames.BANDWIDTH, 1536000),
123
+ (PNames.WINDOW_HOP, 512),
124
+ (PNames.WINDOW_SIZE, 1024),
125
+ (PNames.WINDOW_TYPE, "blackman"),
126
+ (PNames.RF_GAIN, -30),
127
+ (PNames.IF_GAIN, -30)
128
+ )
129
+
130
+
131
+ #
132
+ # Adding pconstraints
133
+ #
134
+ capture_template.add_pconstraint(
135
+ PNames.MIN_FREQUENCY,
136
+ [
137
+ Bound(
138
+ lower_bound=self.get_spec(SpecNames.FREQUENCY_LOWER_BOUND),
139
+ upper_bound=self.get_spec(SpecNames.FREQUENCY_UPPER_BOUND)
140
+ )
141
+ ]
142
+ )
143
+ capture_template.add_pconstraint(
144
+ PNames.MAX_FREQUENCY,
145
+ [
146
+ Bound(
147
+ lower_bound=self.get_spec(SpecNames.FREQUENCY_LOWER_BOUND),
148
+ upper_bound=self.get_spec(SpecNames.FREQUENCY_UPPER_BOUND)
149
+ )
150
+ ]
151
+ )
152
+ capture_template.add_pconstraint(
153
+ PNames.SAMPLE_RATE,
154
+ [
155
+ Bound(
156
+ lower_bound=self.get_spec(SpecNames.SAMPLE_RATE_LOWER_BOUND),
157
+ upper_bound=self.get_spec(SpecNames.SAMPLE_RATE_UPPER_BOUND)
158
+ )
159
+ ]
160
+ )
161
+ capture_template.add_pconstraint(
162
+ PNames.BANDWIDTH,
163
+ [
164
+ OneOf(
165
+ self.get_spec( SpecNames.BANDWIDTH_OPTIONS )
166
+ )
167
+ ]
168
+ )
169
+ capture_template.add_pconstraint(
170
+ PNames.IF_GAIN,
171
+ [
172
+ Bound(
173
+ upper_bound=self.get_spec(SpecNames.IF_GAIN_UPPER_BOUND)
174
+ )
175
+ ]
176
+ )
177
+ capture_template.add_pconstraint(
178
+ PNames.RF_GAIN,
179
+ [
180
+ Bound(
181
+ upper_bound=self.get_spec(SpecNames.RF_GAIN_UPPER_BOUND)
182
+ )
183
+ ]
184
+ )
185
+ return capture_template
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: spectre-core
3
- Version: 0.0.10
3
+ Version: 0.0.11
4
4
  Summary: The core Python package used by the spectre program.
5
5
  Maintainer-email: Jimmy Fitzpatrick <jcfitzpatrick12@gmail.com>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -8,7 +8,7 @@ spectre_core/capture_configs/_capture_templates.py,sha256=P-oU_c8ICIuIkXDgfIsWts
8
8
  spectre_core/capture_configs/_parameters.py,sha256=TYMrRwdqI8nruBKmZbxOcqmWinBJNro-efHl_0yYLpM,3708
9
9
  spectre_core/capture_configs/_pconstraints.py,sha256=262ocQn11v3sJIiaQ-5Ihr4ZoLGTH2_pyFSA2dJb_pc,3241
10
10
  spectre_core/capture_configs/_ptemplates.py,sha256=TzOcJG1RthYEXIsekInmV6Hp4kncEQQi9Fn7fozOGQs,23578
11
- spectre_core/capture_configs/_pvalidators.py,sha256=uXAfyM8xUpLKKCPsQQGWJZKi4M0Wqy1csdP7zcg9MzU,7263
11
+ spectre_core/capture_configs/_pvalidators.py,sha256=uE9ZkQgGWtgTIbMrshj58ItI0GH3Nn-CsGRkXa8qVtQ,7188
12
12
  spectre_core/chunks/__init__.py,sha256=w2PPNbw0kyRL7EV4ERRhObX1y3yt_uqSpYL75i1TeVE,604
13
13
  spectre_core/chunks/_base.py,sha256=bm9EwsUUqCpaLMWqI9rgcMHpJoYhnlJsz9u1ewqaoUU,3561
14
14
  spectre_core/chunks/_chunks.py,sha256=na4dCwdCpIRZzPUJ4wjVGcezyn03E4JMxzfKAQJbWuc,6968
@@ -30,24 +30,25 @@ spectre_core/plotting/_format.py,sha256=3nB3xiiCjjerxkfMdhcOoeknLb2FimoN5sPPkrp1
30
30
  spectre_core/plotting/_panel_stack.py,sha256=T1aASyTJEeJcSzy3vkxLcrFg5SpyVnPjV_0mS5t1W8A,5023
31
31
  spectre_core/plotting/_panels.py,sha256=dasPkarjfFHmWf6I9a-Te6BXUP_HPM6NsOxLBRrdGp0,8661
32
32
  spectre_core/post_processing/__init__.py,sha256=zQlqEEvhPkWQvBRjOWNqmfdo-jczNsusqEnalZotXtk,486
33
- spectre_core/post_processing/_base.py,sha256=dmKVUKxF1e7wm1ObwbGBk4WVd55AzMtnCzdSKXdv9ww,4981
33
+ spectre_core/post_processing/_base.py,sha256=hYGvUEUB1IXee-ns70ZjFoxx0xAR4qKhOJ33l2wqUdE,4925
34
34
  spectre_core/post_processing/_factory.py,sha256=AwTN74mrq87Hraaa8prrEHwKTpfgTUlI9LLjxxSa_ws,1119
35
35
  spectre_core/post_processing/_post_processor.py,sha256=2hIBGng5xx_uZJg-EjVg0gBNI_iNKJidoCRTnejCCmA,1414
36
36
  spectre_core/post_processing/_register.py,sha256=DwlkU92IFkZ1_qvGfhep_OfuqTOIR_efY5qFpn1perw,498
37
37
  spectre_core/post_processing/library/_fixed_center_frequency.py,sha256=ctSDzOTcAroBeV_iN_h4xEgzCO2pXJPzX6-qLZVnLV0,4349
38
38
  spectre_core/post_processing/library/_swept_center_frequency.py,sha256=VKo838E17yzkwSLxSVHRxmvj18DelzAVCtEfCFyYv3o,19476
39
- spectre_core/receivers/__init__.py,sha256=UfLEIjuOhULlbGnqAwIGZaBcdj39LEtYf4QEC287GDM,514
40
- spectre_core/receivers/_base.py,sha256=7Lhu5Izx7YcRZsPax6wcSpeOywqoEcNVckeeBq78MRU,10833
39
+ spectre_core/receivers/__init__.py,sha256=ZYoKKkv6ml8mOAYameUmuh2b6UESmnGeVMe8fR2wZHs,553
40
+ spectre_core/receivers/_base.py,sha256=hBNs0om8g7uaTNEOuSZE4OVCII8q37rwrmOBNHOKeCw,5011
41
41
  spectre_core/receivers/_factory.py,sha256=3P1bxNnt4OxQS0tRNUEZ0Wc1iGc0hgjE9_qS8fGJPRM,822
42
42
  spectre_core/receivers/_register.py,sha256=xHcRnT-3NQxyIWL3nyT3P9qT14Wl5liM9HbflOvOUAM,617
43
43
  spectre_core/receivers/_spec_names.py,sha256=RlQzzD10V0-_ZyqaMUmG9LCoSLGAzyxmQ_eS7e6qvqY,936
44
44
  spectre_core/receivers/gr/__init__.py,sha256=oFSWmGoXQLK5X5xHvWzTdNr9amuaiiGjZirXZVogACU,154
45
45
  spectre_core/receivers/gr/_base.py,sha256=uBtV-nFMzfp8YFeoSbfWmxhEtpLplyjdvfGOqPBmzVI,882
46
- spectre_core/receivers/gr/_rsp1a.py,sha256=9LJ2E_NgQSows06Q7M1Z1zwZ8RYcTgZ_DHPCGaqFXcA,7276
47
- spectre_core/receivers/gr/_rspduo.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
- spectre_core/receivers/gr/_test.py,sha256=_nA3VRGglLCgrKBT2pC3J48-KxBUqq8tD_QWCQcJ7XI,5933
49
- spectre_core/receivers/library/_rsp1a.py,sha256=TjC8B-R4zS82LAL94RID5FH2XL0TpeZ-j9Ji0njt1Ew,2537
50
- spectre_core/receivers/library/_rspduo.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
46
+ spectre_core/receivers/gr/_rsp1a.py,sha256=5kDZMYR_xYT2P0Nk4nLtFQAKNSSO00-aqsNHK5ODJOc,7223
47
+ spectre_core/receivers/gr/_rspduo.py,sha256=z17gItngH-iW7qM658rF6PR3_0QVs97uAWpFtr544VQ,10852
48
+ spectre_core/receivers/gr/_test.py,sha256=re0gnHxGcrpT4VabR2EeXA6krziitT3xzeZimbqlHrE,5894
49
+ spectre_core/receivers/library/_rsp1a.py,sha256=a1BY27MzFgrSMH3zf2BbQxwYMRfcl1WZmX6FURe7-04,2533
50
+ spectre_core/receivers/library/_rspduo.py,sha256=T5NIOsyEO1eiS7V44L-GtZSLWp6B6me_7jtusyCX2YQ,3180
51
+ spectre_core/receivers/library/_sdrplay_receiver.py,sha256=br8uX_m-vpZB1Z-TZtSTHREoNm3YMhiL_Kx5BqU0LUM,6334
51
52
  spectre_core/receivers/library/_test.py,sha256=VeGveqfQJ4RsgapQEUuul-AFmzEaZlghJmThWWwd1_c,8278
52
53
  spectre_core/spectrograms/__init__.py,sha256=3_BmRi41isVW8oEM_-Ce61eg9kaF_WUZFNciITTDlhY,721
53
54
  spectre_core/spectrograms/_analytical.py,sha256=k6ZDKwAyVbT4QhQDaso84yENvp6uiV4hoCKn7ID89zo,9054
@@ -56,8 +57,8 @@ spectre_core/spectrograms/_spectrogram.py,sha256=f8q6V3V4_fVMJox1oX-L76FdTcOyFJu
56
57
  spectre_core/spectrograms/_transform.py,sha256=GQqL8LlP1EdqK-1HX4nmnQV3YZXZ9hRpeBV0_EQZCZk,12564
57
58
  spectre_core/wgetting/__init__.py,sha256=dP7qu__escq8w47x0fRCa4gd481f1Bv4drGTo8b7AEQ,301
58
59
  spectre_core/wgetting/_callisto.py,sha256=cOpTaI7L0dNN8R5VsRkcRaPjkV0n5_JwWdspfoyFuWw,4667
59
- spectre_core-0.0.10.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
60
- spectre_core-0.0.10.dist-info/METADATA,sha256=XUQoFIdLs7r4Q09d47kLUgQ_-BX_Z7GfiymAsAR52SA,42151
61
- spectre_core-0.0.10.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
62
- spectre_core-0.0.10.dist-info/top_level.txt,sha256=-UsyjpFohXgZpgcZ9QbVeXhsIyF3Am8RxNFNDV_Ta2Y,13
63
- spectre_core-0.0.10.dist-info/RECORD,,
60
+ spectre_core-0.0.11.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
61
+ spectre_core-0.0.11.dist-info/METADATA,sha256=2S0_bvGt_0nmlHJuAoy0vYsEa8Mcw1QLWA4hMWtzdMw,42151
62
+ spectre_core-0.0.11.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
63
+ spectre_core-0.0.11.dist-info/top_level.txt,sha256=-UsyjpFohXgZpgcZ9QbVeXhsIyF3Am8RxNFNDV_Ta2Y,13
64
+ spectre_core-0.0.11.dist-info/RECORD,,