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

Fix circular import, add test survey action, add interpolated values to calibration files #48

Merged
merged 24 commits into from
Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
60e8b1f
replace dateutil isoparse with datetime.fromisoformat, remove python-…
jhazentia May 4, 2022
41efbc1
revert to using python-dateutil
jhazentia May 6, 2022
d814679
test_survey_iq_action
jhazentia Jun 28, 2022
8e6c654
Merge branch 'master' of https://github.com/NTIA/scos_actions into fi…
jhazentia Jul 25, 2022
4a2879e
increment version to 2.0.1
jhazentia Jul 25, 2022
a728a76
update dependencies, python3.8 minimum, update pre-commit
jhazentia Jul 25, 2022
142a87e
updated sigmf dependency
jhazentia Jul 26, 2022
7cc2c97
update dependencies, fix dependabot alert
jhazentia Aug 12, 2022
a19b685
add 739MHz to sensor example cal file
jhazentia Aug 22, 2022
93c0bdf
create script to add interpolated sections to cal files
jhazentia Aug 24, 2022
20fe676
add interpolated values to example cal files for usrp 700MHz actions,…
jhazentia Aug 25, 2022
d3e01ca
Merge branch 'master' of https://github.com/NTIA/scos-actions into fi…
jhazentia Aug 26, 2022
ef8d84b
Merge branch 'master' of https://github.com/NTIA/scos-actions into fi…
jhazentia Aug 29, 2022
ab17d1c
update sigmf branch
jhazentia Sep 9, 2022
f632247
Merge branch 'master' of https://github.com/NTIA/scos-actions into fi…
jhazentia Sep 19, 2022
7297c19
update sample_debug for latest changes
jhazentia Sep 19, 2022
f9cf2be
add classification to survey action config
jhazentia Sep 19, 2022
7aadcb0
Merge branch 'fix_dateutil_dependency' of https://github.com/NTIA/sco…
jhazentia Sep 19, 2022
5c7b31e
fix mock gps circular import
jhazentia Sep 20, 2022
5aea3c0
fix merge error
jhazentia Sep 20, 2022
22f11f4
Move signals to scos_actions and ran pre-commit.
dboulware Sep 21, 2022
f826372
Merge pull request #47 from NTIA/circular_fix
jhazentia Sep 22, 2022
32e2960
switch SigMF back to multi-recording-archive branch
jhazentia Sep 23, 2022
a64d79a
address review feedback, add warning message when using mocks
jhazentia Nov 3, 2022
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
2 changes: 1 addition & 1 deletion .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.1.0
rev: v4.3.0
hooks:
- id: check-ast
types: [file, python]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Depending on the type of action, a signal should be sent upon action completion.
enables SCOS Sensor to do something with the results of the action. This could range
from storing measurement data to recycling a Docker container or to fixing an unhealthy
connection to the signal analyzer. You can see the available signals in
[`scos_actions/actions/interfaces/signals.py`](scos_actions/actions/interfaces/signals.py).
[`scos_actions/signals.py`](scos_actions/signals.py).
The following signals are currently offered:

- `measurement_action_completed` - signal expects task_id, data, and metadata
Expand Down
10 changes: 7 additions & 3 deletions sample_debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import json

from scos_actions.actions.acquire_single_freq_fft import SingleFrequencyFftAcquisition
from scos_actions.actions.interfaces.signals import measurement_action_completed
from scos_actions.hardware import sigan
from scos_actions.hardware.mocks.mock_sigan import MockSignalAnalyzer
from scos_actions.signals import measurement_action_completed

parameters = {
"name": "test_single_frequency_m4s_action",
Expand All @@ -15,6 +15,8 @@
"sample_rate": 15.36e6,
"fft_size": 1024,
"nffts": 300,
"nskip": 0,
"classification": "UNCLASSIFIED",
}
schedule_entry_json = {
"name": "test_m4s_multi_1",
Expand Down Expand Up @@ -48,7 +50,9 @@ def callback(sender, **kwargs):

measurement_action_completed.connect(callback)

action = SingleFrequencyFftAcquisition(parameters=parameters, sigan=sigan)
action = SingleFrequencyFftAcquisition(
parameters=parameters, sigan=MockSignalAnalyzer(randomize_values=True)
)
action(schedule_entry_json, 1)
print("metadata:")
print(json.dumps(_metadata, indent=4))
Expand Down
4 changes: 2 additions & 2 deletions scos_actions/actions/acquire_single_freq_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
from numpy import float32, ndarray

from scos_actions.actions.interfaces.measurement_action import MeasurementAction
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.metadata.annotations import FrequencyDomainDetection
from scos_actions.metadata.sigmf_builder import Domain, MeasurementType, SigMFBuilder
from scos_actions.signal_processing.fft import (
Expand Down Expand Up @@ -143,7 +143,7 @@ class SingleFrequencyFftAcquisition(MeasurementAction):
:param sigan: Instance of SignalAnalyzerInterface.
"""

def __init__(self, parameters, sigan, gps=mock_gps):
def __init__(self, parameters, sigan, gps=MockGPS()):
super().__init__(parameters, sigan, gps)
# Pull parameters from action config
self.fft_size = get_parameter(FFT_SIZE, self.parameters)
Expand Down
4 changes: 2 additions & 2 deletions scos_actions/actions/acquire_single_freq_tdomain_iq.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

from scos_actions import utils
from scos_actions.actions.interfaces.measurement_action import MeasurementAction
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.metadata.annotations import TimeDomainDetection
from scos_actions.metadata.sigmf_builder import Domain, MeasurementType, SigMFBuilder
from scos_actions.utils import get_parameter
Expand Down Expand Up @@ -72,7 +72,7 @@ class SingleFrequencyTimeDomainIqAcquisition(MeasurementAction):
:param sigan: instance of SignalAnalyzerInterface.
"""

def __init__(self, parameters, sigan, gps=mock_gps):
def __init__(self, parameters, sigan, gps=MockGPS()):
super().__init__(parameters=parameters, sigan=sigan, gps=gps)
# Pull parameters from action config
self.nskip = get_parameter(NUM_SKIP, self.parameters)
Expand Down
6 changes: 3 additions & 3 deletions scos_actions/actions/acquire_stepped_freq_tdomain_iq.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
NUM_SKIP,
SingleFrequencyTimeDomainIqAcquisition,
)
from scos_actions.actions.interfaces.signals import measurement_action_completed
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.metadata.sigmf_builder import Domain, MeasurementType
from scos_actions.signals import measurement_action_completed
from scos_actions.utils import get_parameter

logger = logging.getLogger(__name__)
Expand All @@ -75,7 +75,7 @@ class SteppedFrequencyTimeDomainIqAcquisition(SingleFrequencyTimeDomainIqAcquisi
:param sigan: instance of SignalAnalyzerInterface
"""

def __init__(self, parameters, sigan, gps=mock_gps):
def __init__(self, parameters, sigan, gps=MockGPS()):
super().__init__(parameters=parameters, sigan=sigan, gps=gps)
num_center_frequencies = len(parameters[FREQUENCY])

Expand Down
4 changes: 2 additions & 2 deletions scos_actions/actions/calibrate_y_factor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
from scos_actions import utils
from scos_actions.actions.interfaces.action import Action
from scos_actions.calibration import sensor_calibration
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.settings import SENSOR_CALIBRATION_FILE
from scos_actions.signal_processing.calibration import (
get_linear_enr,
Expand Down Expand Up @@ -138,7 +138,7 @@ class YFactorCalibration(Action):
:param sigan: instance of SignalAnalyzerInterface.
"""

def __init__(self, parameters, sigan, gps=mock_gps):
def __init__(self, parameters, sigan, gps=MockGPS()):
logger.debug("Initializing calibration action")
super().__init__(parameters, sigan, gps)
self.sigan = sigan
Expand Down
5 changes: 2 additions & 3 deletions scos_actions/actions/interfaces/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
from copy import deepcopy

from scos_actions.capabilities import capabilities
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware import preselector
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.utils import ParameterException, get_parameter


logger = logging.getLogger(__name__)


Expand All @@ -32,7 +31,7 @@ class Action(ABC):

PRESELECTOR_PATH_KEY = "rf_path"

def __init__(self, parameters, sigan, gps=mock_gps):
def __init__(self, parameters, sigan, gps=MockGPS()):
self.parameters = deepcopy(parameters)
self.sigan = sigan
self.gps = gps
Expand Down
6 changes: 3 additions & 3 deletions scos_actions/actions/interfaces/measurement_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
from abc import abstractmethod

from scos_actions.actions.interfaces.action import Action
from scos_actions.actions.interfaces.signals import measurement_action_completed
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.metadata.annotations import CalibrationAnnotation, SensorAnnotation
from scos_actions.metadata.measurement_global import MeasurementMetadata
from scos_actions.metadata.sigmf_builder import SigMFBuilder
from scos_actions.signals import measurement_action_completed

logger = logging.getLogger(__name__)

Expand All @@ -19,7 +19,7 @@ class MeasurementAction(Action):

"""

def __init__(self, parameters, sigan, gps=mock_gps):
def __init__(self, parameters, sigan, gps=MockGPS()):
super().__init__(parameters, sigan, gps)
self.received_samples = 0

Expand Down
6 changes: 3 additions & 3 deletions scos_actions/actions/monitor_sigan.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
import logging

from scos_actions.actions.interfaces.action import Action
from scos_actions.actions.interfaces.signals import monitor_action_completed
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.signals import monitor_action_completed

logger = logging.getLogger(__name__)


class MonitorSignalAnalyzer(Action):
"""Monitor signal analyzer connection and restart container if unreachable."""

def __init__(self, sigan, parameters={"name": "monitor_sigan"}, gps=mock_gps):
def __init__(self, sigan, parameters={"name": "monitor_sigan"}, gps=MockGPS()):
super().__init__(parameters=parameters, sigan=sigan, gps=gps)

def __call__(self, schedule_entry_json, task_id):
Expand Down
2 changes: 1 addition & 1 deletion scos_actions/actions/sync_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import subprocess

from scos_actions.actions.interfaces.action import Action
from scos_actions.actions.interfaces.signals import location_action_completed
from scos_actions.signals import location_action_completed

logger = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion scos_actions/actions/tests/test_acquire_single_freq_fft.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from scos_actions.actions.interfaces.signals import measurement_action_completed
from scos_actions.actions.tests.utils import SENSOR_DEFINITION, check_metadata_fields
from scos_actions.capabilities import capabilities
from scos_actions.discover import test_actions as actions
from scos_actions.signals import measurement_action_completed

SINGLE_FREQUENCY_FFT_ACQUISITION = {
"name": "test_acq",
Expand Down
2 changes: 1 addition & 1 deletion scos_actions/actions/tests/test_monitor_radio.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from scos_actions.actions.interfaces.signals import monitor_action_completed
from scos_actions.discover import test_actions as actions
from scos_actions.signals import monitor_action_completed

MONITOR_SIGAN_SCHEDULE = {
"name": "test_monitor",
Expand Down
2 changes: 1 addition & 1 deletion scos_actions/actions/tests/test_single_freq_tdomain_iq.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pytest

from scos_actions.actions.interfaces.signals import measurement_action_completed
from scos_actions.actions.tests.utils import check_metadata_fields
from scos_actions.discover import test_actions as actions
from scos_actions.signals import measurement_action_completed

SINGLE_TIMEDOMAIN_IQ_ACQUISITION = {
"name": "test_acq",
Expand Down
3 changes: 1 addition & 2 deletions scos_actions/actions/tests/test_stepped_freq_tdomain_iq.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from scos_actions.actions.interfaces.signals import measurement_action_completed
from scos_actions.actions.tests.utils import SENSOR_DEFINITION, check_metadata_fields
from scos_actions.discover import test_actions as actions
from scos_actions.signals import measurement_action_completed

SINGLE_TIMEDOMAIN_IQ_MULTI_RECORDING_ACQUISITION = {
"name": "test_multirec_acq",
Expand Down
3 changes: 1 addition & 2 deletions scos_actions/actions/tests/test_sync_gps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from scos_actions.actions.interfaces.signals import location_action_completed
from scos_actions.actions.tests.utils import SENSOR_DEFINITION
from scos_actions.discover import test_actions
from scos_actions.signals import location_action_completed

SYNC_GPS = {
"name": "sync_gps",
Expand Down
58 changes: 58 additions & 0 deletions scos_actions/configs/actions/test_survey_iq_action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
stepped_frequency_time_domain_iq:
name: test_survey_iq_action
classification: UNCLASSIFIED
frequency:
- 700.5e6
- 709e6
- 731.5e6
- 739e6
- 751e6
- 763e6
- 772e6
- 782e6
- 793e6
- 802e6
gain:
- 40
- 40
- 40
- 40
- 40
- 40
- 40
- 40
- 40
- 40
sample_rate:
- 15.36e6
- 15.36e6
- 15.36e6
- 15.36e6
- 15.36e6
- 15.36e6
- 15.36e6
- 15.36e6
- 15.36e6
- 15.36e6
duration_ms:
- 1000
- 1000
- 1000
- 1000
- 1000
- 1000
- 10000
aromanielloNTIA marked this conversation as resolved.
Show resolved Hide resolved
- 1000
- 1000
- 10000
nskip:
- 15.36e4
- 15.36e4
- 15.36e4
- 15.36e4
- 15.36e4
- 15.36e4
- 15.36e4
- 15.36e4
- 15.36e4
- 15.36e4
1,592 changes: 1,591 additions & 1 deletion scos_actions/configs/sensor_calibration_example.json

Large diffs are not rendered by default.

19,734 changes: 19,733 additions & 1 deletion scos_actions/configs/sigan_calibration_example.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions scos_actions/discover/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from scos_actions.actions import action_classes
from scos_actions.actions.interfaces.signals import register_component_with_status
from scos_actions.actions.logger import Logger
from scos_actions.actions.monitor_sigan import MonitorSignalAnalyzer
from scos_actions.actions.sync_gps import SyncGps
from scos_actions.discover.yaml import load_from_yaml
from scos_actions.hardware import gps as mock_gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.hardware.mocks.mock_sigan import MockSignalAnalyzer
from scos_actions.settings import ACTION_DEFINITIONS_DIR, MOCK_SIGAN
from scos_actions.signals import register_component_with_status

mock_sigan = MockSignalAnalyzer(randomize_values=True)
mock_gps = MockGPS()
if MOCK_SIGAN:
register_component_with_status.send(mock_sigan.__class__, component=mock_sigan)
actions = {"logger": Logger()}
Expand Down
3 changes: 2 additions & 1 deletion scos_actions/discover/tests/test_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from scos_actions import actions
from scos_actions.discover.yaml import load_from_yaml
from scos_actions.hardware import gps
from scos_actions.hardware.mocks.mock_gps import MockGPS
from scos_actions.hardware.mocks.mock_sigan import MockSignalAnalyzer

INVALID_YAML = b"""\
Expand All @@ -24,6 +24,7 @@
"""

sigan = MockSignalAnalyzer()
gps = MockGPS()


def test_load_from_yaml_existing():
Expand Down
3 changes: 1 addition & 2 deletions scos_actions/hardware/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from its_preselector.controlbyweb_web_relay import ControlByWebWebRelay

from scos_actions import utils
from scos_actions.actions.interfaces.signals import register_component_with_status
from scos_actions.capabilities import capabilities
from scos_actions.hardware.mocks.mock_gps import MockGPS
aromanielloNTIA marked this conversation as resolved.
Show resolved Hide resolved
from scos_actions.settings import (
Expand All @@ -15,6 +14,7 @@
PRESELECTOR_MODULE,
SWITCH_CONFIGS_DIR,
)
from scos_actions.signals import register_component_with_status
from scos_actions.status.status_registration_handler import status_registration_handler

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -72,7 +72,6 @@ def load_preselector(preselector_config, module, preselector_class_name):

register_component_with_status.connect(status_registration_handler)
logger.info("Connected status registration handler")
gps = MockGPS()
preselector = load_preslector_from_file(PRESELECTOR_CONFIG_FILE)
switches = load_switches(SWITCH_CONFIGS_DIR)
logger.info("Loaded {switch_count} switches.".format(switch_count=(len(switches))))
File renamed without changes.