Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
dboulware committed Mar 19, 2024
1 parent a5314a1 commit 83cf9de
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
5 changes: 4 additions & 1 deletion scos_actions/actions/acquire_stepped_freq_tdomain_iq.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ def __call__(self, sensor: Sensor, schedule_entry: dict, task_id: int):
sigan_settings=sigan_settings,
)
sensor_cal = self.sensor.sensor_calibration_data
if sensor_cal is not None:
if (
sensor_cal is not None
and measurement_result["applied_calibration"] is not None
):
capture_segment.sensor_calibration = self.get_calibration(
measurement_result
)
Expand Down
39 changes: 25 additions & 14 deletions scos_actions/actions/interfaces/measurement_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,26 +52,37 @@ def create_capture_segment(
sensor_cal = self.sensor.sensor_calibration_data
# Rename compression point keys if they exist
# then set calibration metadata if it exists
if sensor_cal is not None:
if (
sensor_cal is not None
and measurement_result["applied_calibration"] is not None
):
capture_segment.sensor_calibration = self.get_calibration(
measurement_result
)
return capture_segment

def get_calibration(self, measurement_result: dict) -> ntia_sensor.Calibration:
cal_meta = ntia_sensor.Calibration(
datetime=self.sensor.sensor_calibration_data["datetime"],
gain=round(measurement_result["applied_calibration"]["gain"], 3),
noise_figure=round(
measurement_result["applied_calibration"]["noise_figure"], 3
),
temperature=round(self.sensor.sensor_calibration_data["temperature"], 1),
reference=measurement_result["reference"],
)
if "compression_point" in measurement_result["applied_calibration"]:
cal_meta.compression_point = measurement_result["applied_calibration"][
"compression_point"
]
cal_meta = None
if (
self.sensor.sensor_calibration_data
is measurement_result["applied_calibration"]
is not None
):
cal_meta = ntia_sensor.Calibration(
datetime=self.sensor.sensor_calibration_data["datetime"],
gain=round(measurement_result["applied_calibration"]["gain"], 3),
noise_figure=round(
measurement_result["applied_calibration"]["noise_figure"], 3
),
temperature=round(
self.sensor.sensor_calibration_data["temperature"], 1
),
reference=measurement_result["reference"],
)
if "compression_point" in measurement_result["applied_calibration"]:
cal_meta.compression_point = measurement_result["applied_calibration"][
"compression_point"
]
return cal_meta

def create_metadata(
Expand Down
2 changes: 1 addition & 1 deletion scos_actions/calibration/tests/test_sensor_calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ def test_get_calibration_dict_within_range(self):
_ = cal.get_calibration_dict({"sample_rate": 100.0, "frequency": 250.0})
assert e_info.value.args[0] == (
f"Could not locate calibration data at 250.0"
+ f"\nAttempted lookup using key '250.0' and 250.0"
+ f"\nAttempted lookup using key '250.0'"
+ f"\nUsing calibration data: {cal.calibration_data['100.0']}"
)

Expand Down

0 comments on commit 83cf9de

Please sign in to comment.