Skip to content

Commit

Permalink
autoformat code, always add logger to test actions
Browse files Browse the repository at this point in the history
  • Loading branch information
jhazentia committed Feb 28, 2024
1 parent bda63db commit 062e6ce
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 30 deletions.
20 changes: 13 additions & 7 deletions scos_actions/actions/acquire_sea_data_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 1 addition & 0 deletions scos_actions/actions/acquire_single_freq_fft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
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 @@ -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
Expand Down
4 changes: 2 additions & 2 deletions scos_actions/actions/acquire_stepped_freq_tdomain_iq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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__)


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 @@ -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
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions scos_actions/actions/interfaces/measurement_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions scos_actions/actions/tests/test_sync_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 14 additions & 10 deletions scos_actions/discover/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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)
2 changes: 1 addition & 1 deletion scos_actions/hardware/mocks/mock_gps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions scos_actions/hardware/sigan_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions scos_actions/hardware/tests/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions scos_actions/signal_processing/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 062e6ce

Please sign in to comment.