Skip to content

Commit

Permalink
test calibration behaviour for incomplete setup
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-urban committed Oct 16, 2024
1 parent 39fc34a commit 675d948
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//sourcehash: 40648d9f22eee900cfebe3d7bfa6918f9ec2273f951cb93e63d90cf0edada3ff
//sourcehash: 6a27ca0a4b841c5c3c12e8d6c28fdfe7a6e0be954e3d8901ae63d74d3ee9fd6e

/*
This file contains docstrings for use in the Python bindings.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class KongsbergAllWaterColumnCalibration
_av_calibration = std::make_unique<AmplitudeCalibration>(-std::log10(av_factor) -
_system_gain_offset);
else
_av_calibration = std::make_unique<AmplitudeCalibration>(-_system_gain_offset);
_av_calibration.reset();

_initialized = true;
check_initialization();
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 675d948

Please sign in to comment.