From 675d9485c61ea13cac42a1ff8e4e426e1800fb60 Mon Sep 17 00:00:00 2001 From: Peter Urban Date: Thu, 17 Oct 2024 00:26:47 +0200 Subject: [PATCH] test calibration behaviour for incomplete setup --- ...ongsbergallwatercolumncalibration.test.cpp | 39 ++++++++++++++++++- ...kongsbergallwatercolumncalibration.doc.hpp | 2 +- .../kongsbergallwatercolumncalibration.hpp | 6 +-- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp b/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp index b0f633f5..56b302e4 100644 --- a/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp +++ b/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp @@ -49,11 +49,48 @@ TEST_CASE("KongsbergAllWaterColumnCalibration should support common functions", CHECK(obj2 == obj2); CHECK(obj != obj2); + SECTION("test incomplete setup behavior") + { + + auto obj_no_epd = KongsbergAllWaterColumnCalibration( + sound_velocity, NAN, system_gain_offset, tvg_absorption_db_m, tvg_factor); + + auto obj_no_absorption = KongsbergAllWaterColumnCalibration(sound_velocity, + effective_pulse_duration, + system_gain_offset, + 0.f, + tvg_factor); + // if the effective pulse duration is not supplied, the AV calibration will not be set + CHECK(obj_no_epd.has_valid_absorption_db_m() == true); + CHECK(obj_no_epd.has_ap_calibration() == true); + CHECK(obj_no_epd.has_av_calibration() == false); + CHECK(obj_no_epd.has_power_calibration() == true); + CHECK(obj_no_epd.has_sp_calibration() == false); + CHECK(obj_no_epd.has_sv_calibration() == false); + + // of tvg_absorption is 0, and no additional absorption is supplied, the absorption is set + // invalid + CHECK(obj_no_absorption.has_valid_absorption_db_m() == false); + CHECK(obj_no_absorption.has_ap_calibration() == true); + CHECK(obj_no_absorption.has_av_calibration() == true); + CHECK(obj_no_absorption.has_power_calibration() == true); + CHECK(obj_no_absorption.has_sp_calibration() == false); + CHECK(obj_no_absorption.has_sv_calibration() == false); + + // even 0 absorption is valid, if it was explicitly set + obj_no_absorption.set_absorption_db_m(0); + CHECK(obj_no_absorption.has_valid_absorption_db_m() == true); + obj_no_absorption.set_absorption_db_m(NAN); + CHECK(obj_no_absorption.has_valid_absorption_db_m() == false); + } + // test initialized // CHECK(obj.initialized() == true); // CHECK(obj2.initialized() == false); // test kongsberg default calibration + CHECK(obj2.has_valid_absorption_db_m() == false); + CHECK(obj.has_valid_absorption_db_m() == true); CHECK(obj.has_ap_calibration() == true); CHECK(obj.has_av_calibration() == true); CHECK(obj.has_power_calibration() == true); @@ -95,7 +132,7 @@ TEST_CASE("KongsbergAllWaterColumnCalibration should support common functions", // test print does not crash CHECK(obj.info_string().size() != 0); - // test modifying calibrations + // test modifying calibrations REQUIRE_THROWS_AS(obj.set_power_calibration(obj0), std::runtime_error); REQUIRE_THROWS_AS(obj.set_ap_calibration(obj0), std::runtime_error); REQUIRE_THROWS_AS(obj.set_av_calibration(obj0), std::runtime_error); diff --git a/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/.docstrings/kongsbergallwatercolumncalibration.doc.hpp b/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/.docstrings/kongsbergallwatercolumncalibration.doc.hpp index a36cadac..18e6fcb6 100644 --- a/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/.docstrings/kongsbergallwatercolumncalibration.doc.hpp +++ b/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/.docstrings/kongsbergallwatercolumncalibration.doc.hpp @@ -1,4 +1,4 @@ -//sourcehash: 40648d9f22eee900cfebe3d7bfa6918f9ec2273f951cb93e63d90cf0edada3ff +//sourcehash: 6a27ca0a4b841c5c3c12e8d6c28fdfe7a6e0be954e3d8901ae63d74d3ee9fd6e /* This file contains docstrings for use in the Python bindings. diff --git a/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.hpp b/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.hpp index 1878ff57..fb9cf798 100644 --- a/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.hpp +++ b/src/themachinethatgoesping/echosounders/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.hpp @@ -100,7 +100,7 @@ class KongsbergAllWaterColumnCalibration _av_calibration = std::make_unique(-std::log10(av_factor) - _system_gain_offset); else - _av_calibration = std::make_unique(-_system_gain_offset); + _av_calibration.reset(); _initialized = true; check_initialization(); @@ -146,8 +146,8 @@ class KongsbergAllWaterColumnCalibration // Effective pulse duration is NAN if no raw_range_and_angle datagram is available, but not // in the watercolumn datagram. This problem is caught in the // setup_kongsberg_em_calibrations function by setting the av_calibration factor to 1 - // TODO: this should issue a warning in the log as - //get_av is different if .wcd is read without .all + // TODO: this should issue a warning in the log as + // get_av is different if .wcd is read without .all // if (!std::isfinite(_effective_pulse_duration)) // throw_because_value_is_note_finite("effective_pulse_duration", // _effective_pulse_duration);