Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only recompute calibration data if gain_adjust is True #21

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
[settings]
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True
line_length=88
known_third_party = django,environs,numpy,pytest,scos_actions,setuptools
3 changes: 3 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default: true
MD013:
line_length: 88
6 changes: 0 additions & 6 deletions .ml_style.rb

This file was deleted.

48 changes: 29 additions & 19 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,31 +1,41 @@
default_language_version:
python: python3.7
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
types: [file, python]
- id: check-case-conflict
- id: check-docstring-first
types: [file, python]
- id: check-merge-conflict
- id: check-yaml
types: [file, yaml]
- id: debug-statements
- repo: https://github.com/asottile/seed-isort-config
rev: v2.2.0
types: [file, python]
- id: detect-private-key
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/asottile/pyupgrade
rev: v2.34.0
hooks:
- id: seed-isort-config
language_version: python3.7
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.10.1
- id: pyupgrade
- repo: https://github.com/pycqa/isort
rev: 5.10.1
hooks:
- id: isort
language_version: python3.7
- repo: https://github.com/ambv/black
rev: 22.1.0
name: isort (python)
types: [file, python]
args: ["--profile", "black", "--filter-files", "--gitignore"]
- repo: https://github.com/psf/black
rev: 22.6.0
hooks:
- id: black
language_version: python3.7
# TODO markdownlint broken
# - repo: https://github.com/markdownlint/markdownlint
# rev: v0.9.0
# hooks:
# - id: markdownlint
# args: [-s, .ml_style.rb, README.md]
# exclude: GitHubRepoPublicReleaseApproval.md|LICENSE.md
types: [file, python]
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.31.1
hooks:
- id: markdownlint
types: [file, markdown]
exclude: GitHubRepoPublicReleaseApproval.md|LICENSE.md
5 changes: 0 additions & 5 deletions scos_usrp/hardware/tests/test_usrp.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ def test_tune_result(self):
self.rx.tune_frequency(f_lo, f_dsp)
assert f_lo == self.rx.lo_freq and f_dsp == self.rx.dsp_freq


def test_set_sample_rate_also_sets_clock_rate(self):
"""Setting sample_rate should adjust clock_rate"""

Expand All @@ -108,7 +107,3 @@ def test_set_sample_rate_also_sets_clock_rate(self):
observed_clock_rate = self.rx.clock_rate

assert expected_clock_rate == observed_clock_rate




28 changes: 14 additions & 14 deletions scos_usrp/hardware/usrp_sigan.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@
import numpy as np
from scos_actions import utils
from scos_actions.hardware.sigan_iface import SignalAnalyzerInterface
from scos_actions.settings import sensor_calibration
from scos_actions.settings import sigan_calibration
from scos_actions.settings import sensor_calibration, sigan_calibration

from scos_usrp import settings
from scos_usrp.hardware.mocks.usrp_block import MockUsrp


logger = logging.getLogger(__name__)
logger.debug(f"USRP_CONNECTION_ARGS = {settings.USRP_CONNECTION_ARGS}")

Expand All @@ -33,15 +31,13 @@


class USRPSignalAnalyzer(SignalAnalyzerInterface):

@property
def last_calibration_time(self):
"""Returns the last calibration time from calibration data."""
return utils.convert_string_to_millisecond_iso_format(
sensor_calibration.calibration_datetime
sensor_calibration.calibration_datetime
)


@property
def overload(self):
"""Returns True if overload occurred, otherwise returns False."""
Expand All @@ -66,7 +62,6 @@ def __init__(self):
self.requested_sample_rate = 0
self.connect()


def connect(self):
if self._is_available:
return True
Expand Down Expand Up @@ -228,7 +223,9 @@ def check_sensor_overload(self, data):
> self.sensor_calibration_data["1db_compression_sensor"]
)

def acquire_time_domain_samples(self, num_samples, num_samples_skip=0, retries=5,gain_adjust=True):
def acquire_time_domain_samples(
self, num_samples, num_samples_skip=0, retries=5, gain_adjust=True
):
"""Acquire num_samples_skip+num_samples samples and return the last num_samples

:type num_samples: int
Expand All @@ -251,16 +248,19 @@ def acquire_time_domain_samples(self, num_samples, num_samples_skip=0, retries=5
"""
self._sigan_overload = False
self._capture_time = None
# Get the calibration data for the acquisition
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)
logger.debug(
"Using requested sample rate of " + str(self.requested_sample_rate)
)

nsamps = int(num_samples)
nskip = int(num_samples_skip)

# Compute the linear gain
db_gain = self.sensor_calibration_data["gain_sensor"]
if gain_adjust:
# Get the calibration data for the acquisition
calibration_args = [self.requested_sample_rate, self.frequency, self.gain]
self.recompute_calibration_data(calibration_args)
# Compute the linear gain
db_gain = self.sensor_calibration_data["gain_sensor"]
linear_gain = 10 ** (db_gain / 20.0)
else:
linear_gain = 1
Expand Down