From 062e6ced01defb6ca6b5c576346a87f117b40237 Mon Sep 17 00:00:00 2001 From: Justin Haze Date: Wed, 28 Feb 2024 10:49:47 -0700 Subject: [PATCH] autoformat code, always add logger to test actions --- .../actions/acquire_sea_data_product.py | 20 ++++++++++------ .../actions/acquire_single_freq_fft.py | 1 + .../actions/acquire_single_freq_tdomain_iq.py | 4 ++-- .../acquire_stepped_freq_tdomain_iq.py | 4 ++-- scos_actions/actions/calibrate_y_factor.py | 4 ++-- .../actions/interfaces/measurement_action.py | 1 + scos_actions/actions/tests/test_sync_gps.py | 4 +--- scos_actions/discover/__init__.py | 24 +++++++++++-------- scos_actions/hardware/mocks/mock_gps.py | 2 +- scos_actions/hardware/sigan_iface.py | 1 + scos_actions/hardware/tests/test_sensor.py | 4 +--- scos_actions/signal_processing/calibration.py | 1 + 12 files changed, 40 insertions(+), 30 deletions(-) diff --git a/scos_actions/actions/acquire_sea_data_product.py b/scos_actions/actions/acquire_sea_data_product.py index 03b5c784..8b6fdba6 100644 --- a/scos_actions/actions/acquire_sea_data_product.py +++ b/scos_actions/actions/acquire_sea_data_product.py @@ -1136,13 +1136,19 @@ def create_capture_segment( ), ) if self.cal_adjust: - capture_segment.sensor_calibration=ntia_sensor.Calibration( - datetime=measurement_result["sensor_cal"]["datetime"], - gain=round(measurement_result["sensor_cal"]["gain"], 3), - noise_figure=round(measurement_result["sensor_cal"]["noise_figure"], 3), - temperature=round(measurement_result["sensor_cal"]["temperature"], 1), - reference=DATA_REFERENCE_POINT, - ), + capture_segment.sensor_calibration = ( + ntia_sensor.Calibration( + datetime=measurement_result["sensor_cal"]["datetime"], + gain=round(measurement_result["sensor_cal"]["gain"], 3), + noise_figure=round( + measurement_result["sensor_cal"]["noise_figure"], 3 + ), + temperature=round( + measurement_result["sensor_cal"]["temperature"], 1 + ), + reference=DATA_REFERENCE_POINT, + ), + ) self.sigmf_builder.add_capture(capture_segment) def get_sigmf_builder( diff --git a/scos_actions/actions/acquire_single_freq_fft.py b/scos_actions/actions/acquire_single_freq_fft.py index 7c7d8fd4..d1ec2aba 100644 --- a/scos_actions/actions/acquire_single_freq_fft.py +++ b/scos_actions/actions/acquire_single_freq_fft.py @@ -89,6 +89,7 @@ import logging from numpy import float32, ndarray + from scos_actions.actions.interfaces.measurement_action import MeasurementAction from scos_actions.hardware.mocks.mock_gps import MockGPS from scos_actions.metadata.structs import ntia_algorithm diff --git a/scos_actions/actions/acquire_single_freq_tdomain_iq.py b/scos_actions/actions/acquire_single_freq_tdomain_iq.py index 60559d7a..a6d2cf2e 100644 --- a/scos_actions/actions/acquire_single_freq_tdomain_iq.py +++ b/scos_actions/actions/acquire_single_freq_tdomain_iq.py @@ -34,12 +34,12 @@ import logging from numpy import complex64 + +from scos_actions import utils from scos_actions.actions.interfaces.measurement_action import MeasurementAction from scos_actions.hardware.mocks.mock_gps import MockGPS from scos_actions.utils import get_parameter -from scos_actions import utils - logger = logging.getLogger(__name__) # Define parameter keys diff --git a/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py b/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py index 495be7e2..39575f8b 100644 --- a/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py +++ b/scos_actions/actions/acquire_stepped_freq_tdomain_iq.py @@ -38,6 +38,8 @@ import logging import numpy as np + +from scos_actions import utils from scos_actions.actions.acquire_single_freq_tdomain_iq import ( CAL_ADJUST, DURATION_MS, @@ -51,8 +53,6 @@ from scos_actions.signals import measurement_action_completed from scos_actions.utils import get_parameter -from scos_actions import utils - logger = logging.getLogger(__name__) diff --git a/scos_actions/actions/calibrate_y_factor.py b/scos_actions/actions/calibrate_y_factor.py index d26bb743..15cf9fd9 100644 --- a/scos_actions/actions/calibrate_y_factor.py +++ b/scos_actions/actions/calibrate_y_factor.py @@ -75,6 +75,8 @@ import numpy as np from scipy.constants import Boltzmann from scipy.signal import sosfilt + +from scos_actions import utils from scos_actions.actions.interfaces.action import Action from scos_actions.hardware.sensor import Sensor from scos_actions.hardware.sigan_iface import SIGAN_SETTINGS_KEYS @@ -92,8 +94,6 @@ from scos_actions.signals import trigger_api_restart from scos_actions.utils import ParameterException, get_parameter -from scos_actions import utils - logger = logging.getLogger(__name__) # Define parameter keys diff --git a/scos_actions/actions/interfaces/measurement_action.py b/scos_actions/actions/interfaces/measurement_action.py index f0b06e54..88a0a239 100644 --- a/scos_actions/actions/interfaces/measurement_action.py +++ b/scos_actions/actions/interfaces/measurement_action.py @@ -3,6 +3,7 @@ from typing import Optional import numpy as np + from scos_actions.actions.interfaces.action import Action from scos_actions.hardware.sensor import Sensor from scos_actions.metadata.structs import ntia_sensor diff --git a/scos_actions/actions/tests/test_sync_gps.py b/scos_actions/actions/tests/test_sync_gps.py index 71c3cd4c..024dbcee 100644 --- a/scos_actions/actions/tests/test_sync_gps.py +++ b/scos_actions/actions/tests/test_sync_gps.py @@ -31,9 +31,7 @@ def callback(sender, **kwargs): location_action_completed.connect(callback) action = test_actions["test_sync_gps"] sigan = MockSignalAnalyzer() - sensor = Sensor( - signal_analyzer=sigan, capabilities={}, gps=MockGPS(sigan) - ) + sensor = Sensor(signal_analyzer=sigan, capabilities={}, gps=MockGPS(sigan)) if sys.platform == "linux": action(sensor, SYNC_GPS, 1) assert _latitude diff --git a/scos_actions/discover/__init__.py b/scos_actions/discover/__init__.py index 0d8eeb64..48c38c76 100644 --- a/scos_actions/discover/__init__.py +++ b/scos_actions/discover/__init__.py @@ -3,10 +3,10 @@ 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.settings import ACTION_DEFINITIONS_DIR, SIGAN_MODULE, SIGAN_CLASS +from scos_actions.settings import ACTION_DEFINITIONS_DIR, SIGAN_CLASS, SIGAN_MODULE actions = {"logger": Logger()} -test_actions = {} +test_actions = {"logger": Logger()} def init( @@ -25,12 +25,16 @@ def init( yaml_actions, yaml_test_actions = init() actions.update(yaml_actions) -if SIGAN_MODULE == "scos_actions.hardware.mocks.mock_sigan" and SIGAN_CLASS == "MockSignalAnalyzer": - test_actions.update({ - "test_sync_gps": SyncGps(parameters={"name": "test_sync_gps"}), - "test_monitor_sigan": MonitorSignalAnalyzer( - parameters={"name": "test_monitor_sigan"} - ), - "logger": Logger() - }) +if ( + SIGAN_MODULE == "scos_actions.hardware.mocks.mock_sigan" + and SIGAN_CLASS == "MockSignalAnalyzer" +): + test_actions.update( + { + "test_sync_gps": SyncGps(parameters={"name": "test_sync_gps"}), + "test_monitor_sigan": MonitorSignalAnalyzer( + parameters={"name": "test_monitor_sigan"} + ), + } + ) test_actions.update(yaml_test_actions) diff --git a/scos_actions/hardware/mocks/mock_gps.py b/scos_actions/hardware/mocks/mock_gps.py index 203919c7..e794dd0b 100644 --- a/scos_actions/hardware/mocks/mock_gps.py +++ b/scos_actions/hardware/mocks/mock_gps.py @@ -9,7 +9,7 @@ class MockGPS(GPSInterface): def __init__(self, sigan): self.sigan = sigan - + def get_location(timeout_s=1): logger.warning("Using mock GPS!") return 39.995118, -105.261572, 1651.0 diff --git a/scos_actions/hardware/sigan_iface.py b/scos_actions/hardware/sigan_iface.py index 7ed01d45..3b211113 100644 --- a/scos_actions/hardware/sigan_iface.py +++ b/scos_actions/hardware/sigan_iface.py @@ -4,6 +4,7 @@ from typing import Dict, Optional from its_preselector.web_relay import WebRelay + from scos_actions.calibration.calibration import Calibration from scos_actions.hardware.utils import power_cycle_sigan from scos_actions.utils import convert_string_to_millisecond_iso_format diff --git a/scos_actions/hardware/tests/test_sensor.py b/scos_actions/hardware/tests/test_sensor.py index 50b3338f..ccf1b749 100644 --- a/scos_actions/hardware/tests/test_sensor.py +++ b/scos_actions/hardware/tests/test_sensor.py @@ -8,9 +8,7 @@ def test_sensor(): sigan = MockSignalAnalyzer() - sensor = Sensor( - signal_analyzer=sigan, capabilities={}, gps=MockGPS(sigan) - ) + sensor = Sensor(signal_analyzer=sigan, capabilities={}, gps=MockGPS(sigan)) assert sensor is not None assert sensor.signal_analyzer is not None assert sensor.gps is not None diff --git a/scos_actions/signal_processing/calibration.py b/scos_actions/signal_processing/calibration.py index 41ef5d71..785685d3 100644 --- a/scos_actions/signal_processing/calibration.py +++ b/scos_actions/signal_processing/calibration.py @@ -4,6 +4,7 @@ import numpy as np from its_preselector.preselector import Preselector from scipy.constants import Boltzmann + from scos_actions.signal_processing.unit_conversion import ( convert_celsius_to_fahrenheit, convert_celsius_to_kelvins,