Skip to content

Commit

Permalink
Merge pull request #196 from SuperDARNCanada/fix_rx_tx_bandwidth_check
Browse files Browse the repository at this point in the history
Quick fix to avoid edges of our tx/rx bandwidths. See Issue #195
  • Loading branch information
mardet987 authored Apr 28, 2020
2 parents ce02b71 + 426edc6 commit bbcbdc7
Showing 1 changed file with 27 additions and 18 deletions.
45 changes: 27 additions & 18 deletions experiment_prototype/experiment_prototype.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@

default_rx_bandwidth = 5.0e6
default_output_rx_rate = 10.0e3/3
transition_bandwidth = 750.0e3

class ExperimentPrototype(object):
"""
Expand Down Expand Up @@ -634,9 +635,11 @@ def tx_maxfreq(self):
The maximum transmit frequency.
This is the maximum tx frequency possible in this experiment (either maximum in our license
or maximum given by the centre frequency and sampling rate).
or maximum given by the centre frequency, and sampling rate). The maximum is slightly less
than that allowed by the centre frequency and txrate, to stay away from the edges of the
possible transmission band where the signal is distorted.
"""
max_freq = self.txctrfreq * 1000 + (self.txrate/2.0)
max_freq = self.txctrfreq * 1000 + (self.txrate/2.0) - transition_bandwidth
if max_freq < self.options.max_freq:
return max_freq
else:
Expand All @@ -649,9 +652,11 @@ def tx_minfreq(self):
The minimum transmit frequency.
This is the minimum tx frequency possible in this experiment (either minimum in our license
or minimum given by the centre frequency and sampling rate).
or minimum given by the centre frequency and sampling rate). The minimum is slightly more
than that allowed by the centre frequency and txrate, to stay away from the edges of the
possible transmission band where the signal is distorted.
"""
min_freq = self.txctrfreq * 1000 - (self.txrate/2.0)
min_freq = self.txctrfreq * 1000 - (self.txrate/2.0) + transition_bandwidth
if min_freq > self.options.min_freq:
return min_freq
else:
Expand All @@ -671,9 +676,11 @@ def rx_maxfreq(self):
The maximum receive frequency.
This is the maximum tx frequency possible in this experiment (maximum given by the centre
frequency and sampling rate), as license doesn't matter for receiving.
frequency and sampling rate), as license doesn't matter for receiving. The maximum is
slightly less than that allowed by the centre frequency and rxrate, to stay away from the
edges of the possible receive band where the signal may be distorted.
"""
max_freq = self.rxctrfreq * 1000 + (self.rxrate/2.0)
max_freq = self.rxctrfreq * 1000 + (self.rxrate/2.0) - transition_bandwidth
return max_freq

@property
Expand All @@ -682,9 +689,11 @@ def rx_minfreq(self):
The minimum receive frequency.
This is the minimum rx frequency possible in this experiment (minimum given by the centre
frequency and sampling rate) - license doesn't restrict receiving.
frequency and sampling rate) - license doesn't restrict receiving. The minimum is
slightly more than that allowed by the centre frequency and rxrate, to stay away from the
edges of the possible receive band where the signal may be distorted.
"""
min_freq = self.rxctrfreq * 1000 - (self.rxrate/2.0)
min_freq = self.rxctrfreq * 1000 - (self.rxrate/2.0) + transition_bandwidth
if min_freq > 1000: #Hz
return min_freq
else:
Expand Down Expand Up @@ -1105,23 +1114,23 @@ def check_slice_specific_requirements(self, exp_slice):
if exp_slice['clrfrqrange'][0] >= exp_slice['clrfrqrange'][1]:
errmsg = """clrfrqrange must be between min and max tx frequencies {} and rx
frequencies {} according to license and/or centre frequencies / sampling
rates, and must have lower frequency first.
rates / transition bands, and must have lower frequency first.
""".format((self.tx_minfreq, self.tx_maxfreq),
(self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)
if (exp_slice['clrfrqrange'][1] * 1000) >= self.tx_maxfreq or \
(exp_slice['clrfrqrange'][1] * 1000) >= self.rx_maxfreq:
errmsg = """clrfrqrange must be between min and max tx frequencies {} and rx
frequencies {} according to license and/or centre frequencies / sampling
rates, and must have lower frequency first.
rates / transition bands, and must have lower frequency first.
""".format((self.tx_minfreq, self.tx_maxfreq),
(self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)
if (exp_slice['clrfrqrange'][0] * 1000) <= self.tx_minfreq or \
(exp_slice['clrfrqrange'][0] * 1000) <= self.rx_minfreq:
errmsg = """clrfrqrange must be between min and max tx frequencies {} and rx
frequencies {} according to license and/or centre frequencies / sampling
rates, and must have lower frequency first.
rates / transition bands, and must have lower frequency first.
""".format((self.tx_minfreq, self.tx_maxfreq),
(self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)
Expand Down Expand Up @@ -1175,14 +1184,14 @@ def check_slice_specific_requirements(self, exp_slice):
if not isinstance(exp_slice['rxfreq'], int) and not isinstance(exp_slice['rxfreq'],
float):
errmsg = """rxfreq must be a number (kHz) between rx min and max frequencies {} for
the radar license and be within range given centre frequency and
sampling rate.""".format((self.rx_minfreq, self.rx_maxfreq))
the radar license and be within range given centre frequency, sampling
rate and transition band.""".format((self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)
if (exp_slice['rxfreq'] * 1000) >= self.rx_maxfreq or (exp_slice['rxfreq'] *
1000) <= self.rx_minfreq:
errmsg = """rxfreq must be a number (kHz) between rx min and max frequencies {} for
the radar license and be within range given centre frequency and
sampling rate.""".format((self.rx_minfreq, self.rx_maxfreq))
the radar license and be within range given centre frequency, sampling
rate and transition band.""".format((self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)

else: # TX-specific mode , without a clear frequency search.
Expand All @@ -1191,23 +1200,23 @@ def check_slice_specific_requirements(self, exp_slice):
float):
errmsg = """txfreq must be a number (kHz) between tx min and max frequencies {} and
rx min and max frequencies {} for the radar license and be within range
given centre frequencies and sampling rates.
given centre frequencies, sampling rates and transition band.
""".format((self.tx_minfreq, self.tx_maxfreq),
(self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)
if (exp_slice['txfreq'] * 1000) >= self.tx_maxfreq or (exp_slice['txfreq'] * 1000) >= \
self.rx_maxfreq:
errmsg = """txfreq must be a number (kHz) between tx min and max frequencies {} and
rx min and max frequencies {} for the radar license and be within range
given centre frequencies and sampling rates.
given centre frequencies, sampling rates and transition band.
""".format((self.tx_minfreq, self.tx_maxfreq),
(self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)
if (exp_slice['txfreq'] * 1000) <= self.tx_minfreq or (exp_slice['txfreq'] * 1000) <= \
self.rx_minfreq:
errmsg = """txfreq must be a number (kHz) between tx min and max frequencies {} and
rx min and max frequencies {} for the radar license and be within range
given centre frequencies and sampling rates.
given centre frequencies, sampling rates and transition band.
""".format((self.tx_minfreq, self.tx_maxfreq),
(self.rx_minfreq, self.rx_maxfreq))
raise ExperimentException(errmsg)
Expand Down

0 comments on commit bbcbdc7

Please sign in to comment.