Skip to content

Commit

Permalink
Merge pull request #28 from NTIA/4.0.0
Browse files Browse the repository at this point in the history
scos-actions 7.0.1, README updates
  • Loading branch information
jhazentia authored Dec 8, 2023
2 parents d6c8bad + 0331f98 commit 04bc7d6
Show file tree
Hide file tree
Showing 32 changed files with 88 additions and 26 deletions.
10 changes: 5 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ default_language_version:
python: python3.8
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v4.5.0
hooks:
- id: check-ast
types: [file, python]
Expand All @@ -18,24 +18,24 @@ repos:
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v3.2.2
rev: v3.15.0
hooks:
- id: pyupgrade
args: ["--py3-plus"]
- repo: https://github.com/pycqa/isort
rev: 5.10.1
rev: 5.12.0
hooks:
- id: isort
name: isort (python)
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 22.10.0
rev: 23.11.0
hooks:
- id: black
types: [file, python]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.32.2
rev: v0.37.0
hooks:
- id: markdownlint
types: [file, markdown]
Expand Down
27 changes: 17 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,23 @@ Requires pip>=18.1 (upgrade using `python3 -m pip install --upgrade pip`).
Below are steps to run scos-sensor with the scos-usrp plugin:

1. Clone scos-sensor: `git clone https://github.com/NTIA/scos-sensor.git`
1. Navigate to scos-sensor: `cd scos-sensor`
1. If it does not exist, create env file while in the root scos-sensor directory:
2. Navigate to scos-sensor: `cd scos-sensor`
3. If it does not exist, create env file while in the root scos-sensor directory:
`cp env.template ./env`
1. Make sure the `scos_usrp` dependency is in `requirements.txt` in `scos-sensor/src`
folder. If you are using a different branch than master, change master in the
following line to the branch you are using:
`scos_usrp @ git+https://github.com/NTIA/scos-usrp@master#egg=scos_usrp.`
1. Make sure `BASE_IMAGE` is set to `BASE_IMAGE=smsntia/uhd_b2xx_py3` in env file.
1. Get environment variables: `source ./env`
1. Build and start containers: `docker-compose up -d --build --force-recreate`
4. Replace the line starting with `scos-tekrsa` in the `requirements.in` file in
scos-sensor/src with the following:
`scos_usrp @ git+https://github.com/NTIA/scos-usrp@master`.
If you are using a different branch than master, change `master` to the branch
or tag you are using. Make sure `pip-tools` package is installed in your Python
environment (`python -m pip install pip-tools`). Then run
`pip-compile requirements.in` and `pip-compile requirements-dev.in` to update
`requirements.txt` and `requirements-dev.txt` with the dependencies needed for
scos-usrp.
5. Make sure `BASE_IMAGE` is set to `BASE_IMAGE=ghcr.io/ntia/scos-usrp/scos_usrp_uhd:0.0.2`
in the env file. This is a publicly available docker image with the necessary
UHD drivers hosted within the GitHub container registry.
6. Get environment variables: `source ./env`
7. Build and start containers: `docker-compose up -d --build --force-recreate`

## Development

Expand Down Expand Up @@ -155,4 +162,4 @@ See [LICENSE](LICENSE.md).

## Contact

For technical questions about scos-usrp, contact Justin Haze, [email protected]
For technical questions about scos-usrp, contact Justin Haze, <[email protected]>
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ dependencies = [
"django>=3.2.15,<4.0",
"environs>=9.0, <10.0",
"numpy>=1.22.0",
"scos_actions @ git+https://github.com/NTIA/scos-actions@5.0.0",
"scos_actions @ git+https://github.com/NTIA/scos-actions@7.0.1",
]

[project.optional-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion scos_usrp/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.0"
__version__ = "4.0.0"
1 change: 1 addition & 0 deletions scos_usrp/configs/actions/acquire_iq_700MHz_ATT_DL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
1 change: 1 addition & 0 deletions scos_usrp/configs/actions/acquire_iq_700MHz_ATT_UL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 10000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 10000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
1 change: 1 addition & 0 deletions scos_usrp/configs/actions/acquire_iq_700MHz_Verizon_DL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
1 change: 1 addition & 0 deletions scos_usrp/configs/actions/acquire_iq_700MHz_Verizon_UL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ single_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
1 change: 1 addition & 0 deletions scos_usrp/configs/actions/acquire_m4s_700MHz_ATT_DL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
1 change: 1 addition & 0 deletions scos_usrp/configs/actions/acquire_m4s_700MHz_ATT_UL.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ single_frequency_fft:
nffts: 300
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ stepped_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ stepped_frequency_time_domain_iq:
duration_ms: 80
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ stepped_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ stepped_frequency_time_domain_iq:
duration_ms: 80
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ stepped_frequency_time_domain_iq:
duration_ms: 1000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ stepped_frequency_time_domain_iq:
duration_ms: 80
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
1 change: 1 addition & 0 deletions scos_usrp/configs/actions/survey_700MHz_band_iq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ stepped_frequency_time_domain_iq:
- 10000
nskip: 15.36e4
classification: UNCLASSIFIED
calibration_adjust: true
46 changes: 37 additions & 9 deletions scos_usrp/hardware/usrp_sigan.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from scos_actions.calibration import sensor_calibration, sigan_calibration
from scos_actions.hardware.sigan_iface import SignalAnalyzerInterface

from scos_usrp import __version__ as SCOS_USRP_VERSION
from scos_usrp import settings
from scos_usrp.hardware.mocks.usrp_block import MockUsrp

Expand Down Expand Up @@ -50,6 +51,7 @@ def overload(self):

def __init__(self):
super().__init__()
self._plugin_version = SCOS_USRP_VERSION
self.uhd = None
self.usrp = None
self._is_available = False
Expand All @@ -59,6 +61,9 @@ def __init__(self):
self._sensor_overload = False
self._capture_time = None
self.requested_sample_rate = 0
self.requested_frequency = 0
self.requested_gain = 0
self.requested_clock_rate = 0
self.connect()

def connect(self):
Expand Down Expand Up @@ -101,6 +106,11 @@ def connect(self):
logger.exception(err)
return False

@property
def plugin_version(self):
"""Returns the current version of scos-usrp."""
return self._plugin_version

@property
def is_available(self):
"""Returns True if initialized and ready to make measurements, otherwise returns False."""
Expand Down Expand Up @@ -145,6 +155,7 @@ def clock_rate(self, rate):
:type rate: float
:param rate: Clock rate in hertz
"""
self.requested_clock_rate = rate
self.usrp.set_master_clock_rate(rate)
clk_MHz = self.clock_rate / 1e6
logger.debug("set USRP clock rate: {:.2f} MHz".format(clk_MHz))
Expand All @@ -161,6 +172,7 @@ def frequency(self, freq):
:type freq: float
:param freq: Frequency in hertz
"""
self.requested_frequency = freq
self.tune_frequency(freq)

def tune_frequency(self, rf_freq, dsp_freq=0):
Expand Down Expand Up @@ -201,7 +213,7 @@ def gain(self, gain):
err += "Choose one of {!r}.".format(VALID_GAINS)
logger.error(err)
return

self.requested_gain = gain
self.usrp.set_rx_gain(gain)
msg = "set USRP gain: {:.1f} dB"
logger.debug(msg.format(self.usrp.get_rx_gain()))
Expand All @@ -216,14 +228,14 @@ def check_sensor_overload(self, data):
) # Convert log(V^2) to dBm
self._sensor_overload = False
# explicitly check is not None since 1db compression could be 0
if self.sensor_calibration_data["1db_compression_sensor"] is not None:
self._sensor_overload = (
if self.sensor_calibration_data["1db_compression_point"] is not None:
self._sensor_overload = bool(
time_domain_avg_power
> self.sensor_calibration_data["1db_compression_sensor"]
> self.sensor_calibration_data["1db_compression_point"]
)

def acquire_time_domain_samples(
self, num_samples, num_samples_skip=0, retries=5, gain_adjust=True
self, num_samples, num_samples_skip=0, retries=5, cal_adjust: bool = True
):
"""Acquire num_samples_skip+num_samples samples and return the last num_samples
Expand Down Expand Up @@ -251,14 +263,30 @@ def acquire_time_domain_samples(
logger.debug(
"Using requested sample rate of " + str(self.requested_sample_rate)
)
calibration_args = [self.requested_sample_rate, self.frequency, self.gain]
self.recompute_calibration_data(calibration_args)
cal_params = []

if sensor_calibration is not None:
cal_params = sensor_calibration.calibration_parameters
try:
logger.debug(f"Using cal params: {cal_params}")
cal_args = []
if cal_params is not None:
for p in cal_params:
cal_args.append(getattr(self, "requested_" + p))
else:
cal_args = None
except KeyError:
raise Exception(
"One or more required cal parameters is not a valid sigan setting."
)
logger.debug(f"Calibration arguments:{cal_args}")
self.recompute_sensor_calibration_data(cal_args)
nsamps = int(num_samples)
nskip = int(num_samples_skip)

# Compute the linear gain
db_gain = self.sensor_calibration_data["gain_sensor"]
if gain_adjust:
db_gain = self.sensor_calibration_data["gain"]
if cal_adjust:
linear_gain = 10 ** (db_gain / 20.0)
else:
linear_gain = 1
Expand Down

0 comments on commit 04bc7d6

Please sign in to comment.