diff --git a/src/pymodule/py_pingtools/c_pingsampleselector.cpp b/src/pymodule/py_pingtools/c_pingsampleselector.cpp index 224c386d..a6b9c57d 100644 --- a/src/pymodule/py_pingtools/c_pingsampleselector.cpp +++ b/src/pymodule/py_pingtools/c_pingsampleselector.cpp @@ -30,11 +30,13 @@ void init_c_pingsampleselector(pybind11::module& m) // --- main interface --- .def("apply_selection", - py::overload_cast(&PingSampleSelector::apply_selection), + py::overload_cast( + &PingSampleSelector::apply_selection), DOC_PingSampleSelector(apply_selection), py::arg("ping_watercolumn")) .def("apply_selection", - py::overload_cast(&PingSampleSelector::apply_selection), + py::overload_cast( + &PingSampleSelector::apply_selection), DOC_PingSampleSelector(apply_selection), py::arg("ping_bottom")) @@ -63,6 +65,15 @@ void init_c_pingsampleselector(pybind11::module& m) .def("get_max_sample_range", &PingSampleSelector::get_max_sample_range, DOC_PingSampleSelector(max_sample_range)) + .def("get_transmit_sectors", + &PingSampleSelector::get_transmit_sectors, + DOC_PingSampleSelector(transmit_sectors)) + .def("get_transmit_sector_min_beam_angle", + &PingSampleSelector::get_transmit_sector_min_beam_angle, + DOC_PingSampleSelector(transmit_sector_min_beam_angle)) + .def("get_transmit_sector_max_beam_angle", + &PingSampleSelector::get_transmit_sector_max_beam_angle, + DOC_PingSampleSelector(transmit_sector_max_beam_angle)) .def("get_beam_step", &PingSampleSelector::get_beam_step, DOC_PingSampleSelector(beam_step)) .def("get_sample_step", &PingSampleSelector::get_sample_step, @@ -81,6 +92,12 @@ void init_c_pingsampleselector(pybind11::module& m) .def("clear_sample_range_range", &PingSampleSelector::clear_sample_range_range, DOC_PingSampleSelector(clear_sample_range_range)) + .def("clear_transmit_sectors", + &PingSampleSelector::clear_transmit_sectors, + DOC_PingSampleSelector(clear_transmit_sectors)) + .def("clear_transmit_sector_beam_angle_range", + &PingSampleSelector::clear_transmit_sector_beam_angle_range, + DOC_PingSampleSelector(clear_transmit_sector_beam_angle_range)) .def("clear_beam_step", &PingSampleSelector::clear_beam_step, DOC_PingSampleSelector(clear_beam_step)) @@ -114,6 +131,16 @@ void init_c_pingsampleselector(pybind11::module& m) py::arg("min_sample_range"), py::arg("max_sample_range"), py::arg("sample_step") = std::nullopt) + .def("select_transmit_sectors", + &PingSampleSelector::select_transmit_sectors, + DOC_PingSampleSelector(select_transmit_sectors), + py::arg("transmit_sectors")) + .def("select_transmit_sectors_by_beam_angles", + &PingSampleSelector::select_transmit_sectors_by_beam_angles, + DOC_PingSampleSelector(select_transmit_sectors_by_beam_angles), + py::arg("transmit_sector_min_beam_angle") = std::nullopt, + py::arg("transmit_sector_max_beam_angle") = std::nullopt) + .def("set_sample_step", &PingSampleSelector::set_sample_step, DOC_PingSampleSelector(set_sample_step), diff --git a/src/tests/filetemplates/datatypes/calibration/watercolumncalibration.test.cpp b/src/tests/filetemplates/datatypes/calibration/watercolumncalibration.test.cpp index ea891ee1..e7a024b8 100644 --- a/src/tests/filetemplates/datatypes/calibration/watercolumncalibration.test.cpp +++ b/src/tests/filetemplates/datatypes/calibration/watercolumncalibration.test.cpp @@ -35,7 +35,7 @@ TEST_CASE("WaterColumnCalibration should support common functions", TESTTAG) // test hash (should be stable if class is not changed) CHECK(obj.binary_hash() == 14297201401130263458ULL); - CHECK(obj2.binary_hash() == 13359915444826610029ULL); + CHECK(obj2.binary_hash() == 5753520697174627545ULL); // test equality // test inequality diff --git a/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp b/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp index 56b302e4..ddd58a95 100644 --- a/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp +++ b/src/tests/kongsbergall/filedatatypes/calibration/kongsbergallwatercolumncalibration.test.cpp @@ -40,7 +40,7 @@ TEST_CASE("KongsbergAllWaterColumnCalibration should support common functions", auto obj2 = KongsbergAllWaterColumnCalibration(); // test hash (should be stable if class is not changed) - CHECK(obj.binary_hash() == 4129550967388344509ULL); + CHECK(obj.binary_hash() == 3596872097889454741ULL); CHECK(obj2.binary_hash() == 770061992534893794ULL); // test equality diff --git a/src/tests/pingtools/pingsampleselector.test.cpp b/src/tests/pingtools/pingsampleselector.test.cpp index aeb9eb64..7822fbae 100644 --- a/src/tests/pingtools/pingsampleselector.test.cpp +++ b/src/tests/pingtools/pingsampleselector.test.cpp @@ -17,39 +17,63 @@ TEST_CASE("PingSampleselector should support common functions", TESTTAG) // initialize class structure auto obj = PingSampleSelector(); + // make sure binary_hash is stable for empty object + // the hash tests need to be updated in case the object structure changes + CHECK(obj.binary_hash() == 564375710488919660ULL); + // set some variables obj.select_beam_range_by_numbers(1, -1, 1); REQUIRE(obj.get_min_beam_number() == 1); REQUIRE(obj.get_max_beam_number() == -1); REQUIRE(obj.get_beam_step() == 1); + // test binary (inbetween) + REQUIRE(obj == PingSampleSelector(obj.from_binary(obj.to_binary()))); obj.select_sample_range_by_numbers(-2, 2, 2); REQUIRE(obj.get_min_sample_number() == -2); REQUIRE(obj.get_max_sample_number() == 2); REQUIRE(obj.get_sample_step() == 2); + // test binary (inbetween) + REQUIRE(obj == PingSampleSelector(obj.from_binary(obj.to_binary()))); obj.select_beam_range_by_angles(-3.3, 4.4, 10); REQUIRE(obj.get_min_beam_angle() == Catch::Approx(-3.3)); REQUIRE(obj.get_max_beam_angle() == Catch::Approx(4.4)); REQUIRE(obj.get_beam_step() == 10); + // test binary (inbetween) + REQUIRE(obj == PingSampleSelector(obj.from_binary(obj.to_binary()))); obj.select_sample_range_by_ranges(4.3, -5.4, 20); REQUIRE(obj.get_min_sample_range() == Catch::Approx(4.3)); REQUIRE(obj.get_max_sample_range() == Catch::Approx(-5.4)); REQUIRE(obj.get_sample_step() == 20); + // test binary (inbetween) + REQUIRE(obj == PingSampleSelector(obj.from_binary(obj.to_binary()))); + obj.select_transmit_sectors({ 3, 1 }); + REQUIRE(obj.get_transmit_sectors().value().at(0) == 3); + REQUIRE(obj.get_transmit_sectors().value().at(1) == 1); + + // test binary (inbetween) + REQUIRE(obj == PingSampleSelector(obj.from_binary(obj.to_binary()))); + obj.select_transmit_sectors_by_beam_angles(-2.3, 6.4); + REQUIRE(obj.get_transmit_sector_min_beam_angle() == Catch::Approx(-2.3)); + REQUIRE(obj.get_transmit_sector_max_beam_angle() == Catch::Approx(6.4)); + obj.set_sample_step(12); REQUIRE(obj.get_sample_step() == 12); obj.set_beam_step(13); REQUIRE(obj.get_beam_step() == 13); + CHECK(obj.binary_hash() == 3607378432970521986ULL); + // test inequality REQUIRE(obj != PingSampleSelector()); // test copy REQUIRE(obj == PingSampleSelector(obj)); - // test binary + // test binary (inbetween) REQUIRE(obj == PingSampleSelector(obj.from_binary(obj.to_binary()))); // test stream diff --git a/src/tests/simradraw/datatypes/calibration/simradrawwatercolumncalibration.test.cpp b/src/tests/simradraw/datatypes/calibration/simradrawwatercolumncalibration.test.cpp index 4041ddc1..f5125563 100644 --- a/src/tests/simradraw/datatypes/calibration/simradrawwatercolumncalibration.test.cpp +++ b/src/tests/simradraw/datatypes/calibration/simradrawwatercolumncalibration.test.cpp @@ -1052,8 +1052,8 @@ TEST_CASE("SimradRawWaterColumnCalibration should support common functions", TES { // test hash (should be stable if class is not changed) CHECK(cal0.binary_hash() == 17881936019455399031ULL); - CHECK(cal_power.binary_hash() == 17028420629437399240ULL); - CHECK(cal_cmplx.binary_hash() == 11449725189696852697ULL); + CHECK(cal_power.binary_hash() == 7583670336073361441ULL); + CHECK(cal_cmplx.binary_hash() == 4293420015706961800ULL); // test equality CHECK(cal0 == cal0); 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 18e6fcb6..4195be13 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: 6a27ca0a4b841c5c3c12e8d6c28fdfe7a6e0be954e3d8901ae63d74d3ee9fd6e +//sourcehash: d806933ede2881d41e86e3edf9ee9093d4afbdbe28369bed9e6c3e4041ac2302 /* This file contains docstrings for use in the Python bindings. diff --git a/src/themachinethatgoesping/echosounders/pingtools/.docstrings/pingsampleselector.doc.hpp b/src/themachinethatgoesping/echosounders/pingtools/.docstrings/pingsampleselector.doc.hpp index 175d93c3..e254a279 100644 --- a/src/themachinethatgoesping/echosounders/pingtools/.docstrings/pingsampleselector.doc.hpp +++ b/src/themachinethatgoesping/echosounders/pingtools/.docstrings/pingsampleselector.doc.hpp @@ -1,4 +1,4 @@ -//sourcehash: 4951ef14139d3a86a9820d23d4058f579dd5b1a51a17c400154496eb15f3214b +//sourcehash: 762f19736a2115c1023633e93f6cc81621d8cf6fdeb49b703343e684bc983dae /* This file contains docstrings for use in the Python bindings. @@ -62,6 +62,10 @@ static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampl static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_clear_sample_step = R"doc()doc"; +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_clear_transmit_sector_beam_angle_range = R"doc()doc"; + +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_clear_transmit_sectors = R"doc()doc"; + static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_from_stream = R"doc(Return a PingSampleSelector read from a binary stream @@ -91,6 +95,12 @@ static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampl static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_get_sample_step = R"doc()doc"; +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_get_transmit_sector_max_beam_angle = R"doc()doc"; + +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_get_transmit_sector_min_beam_angle = R"doc()doc"; + +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_get_transmit_sectors = R"doc()doc"; + static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_max_beam_angle = R"doc(< max beam angle to select (°))doc"; static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_max_beam_number = R"doc(< max beam number to select)doc"; @@ -129,6 +139,10 @@ static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampl static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_select_sample_range_by_ranges = R"doc()doc"; +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_select_transmit_sectors = R"doc()doc"; + +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_select_transmit_sectors_by_beam_angles = R"doc()doc"; + static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_set_beam_step = R"doc()doc"; static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_set_sample_step = R"doc()doc"; @@ -139,6 +153,16 @@ R"doc(Write a PingSampleSelector to a binary stream Parameter ``os``: output stream)doc"; +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_transmit_sector_max_beam_angle = +R"doc(< select transmit sectors with angles < <= +_transmit_sector_max_beam_angle)doc"; + +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_transmit_sector_min_beam_angle = +R"doc(< select transmit sectors with angles < >= +_transmit_sector_min_beam_angle)doc"; + +static const char *__doc_themachinethatgoesping_echosounders_pingtools_PingSampleSelector_transmit_sectors = R"doc(< transmit_sectors to select)doc"; + #if defined(__GNUG__) #pragma GCC diagnostic pop #endif diff --git a/src/themachinethatgoesping/echosounders/pingtools/pingsampleselector.hpp b/src/themachinethatgoesping/echosounders/pingtools/pingsampleselector.hpp index 8db8e8fa..4a212d93 100644 --- a/src/themachinethatgoesping/echosounders/pingtools/pingsampleselector.hpp +++ b/src/themachinethatgoesping/echosounders/pingtools/pingsampleselector.hpp @@ -37,6 +37,13 @@ class PingSampleSelector std::optional _min_sample_range; ///< min sample range to select (m) std::optional _max_sample_range; ///< max sample range to select (m) + // transmit sectors + std::optional> _transmit_sectors; ///< transmit_sectors to select + std::optional _transmit_sector_min_beam_angle; ///< select transmit sectors with angles + ///< >= _transmit_sector_min_beam_angle + std::optional _transmit_sector_max_beam_angle; ///< select transmit sectors with angles + ///< <= _transmit_sector_max_beam_angle + size_t _beam_step = 1; ///< step size for beam numbers size_t _sample_step = 1; ///< step size for sample numbers @@ -47,7 +54,8 @@ class PingSampleSelector bool operator==(const PingSampleSelector& other) const = default; // get selection - BeamSampleSelection apply_selection(filetemplates::datatypes::I_PingWatercolumn& ping_watercolumn) + BeamSampleSelection apply_selection( + filetemplates::datatypes::I_PingWatercolumn& ping_watercolumn) { BeamSampleSelection selection; @@ -67,6 +75,11 @@ class PingSampleSelector size_t min_beam_number = _min_beam_number ? *_min_beam_number : 0; size_t max_beam_number = _max_beam_number ? *_max_beam_number : number_of_beams - 1; + // initialize transmit sector selection + auto beam_numbers_selected_by_transmit_sector = + get_beam_numbers_selected_by_transmit_sector(ping_watercolumn, beam_crosstrack_angles); + + // create beam indexer tools::pyhelper::PyIndexer beam_indexer( number_of_beams, min_beam_number, max_beam_number + 1, _beam_step); @@ -74,6 +87,11 @@ class PingSampleSelector { auto bn = beam_indexer(counter); + // check transmit sector selection + if (beam_numbers_selected_by_transmit_sector.has_value()) + if (!beam_numbers_selected_by_transmit_sector.value()[bn]) + continue; + if (_min_beam_angle && beam_crosstrack_angles.unchecked(bn) < *_min_beam_angle) continue; if (_max_beam_angle && beam_crosstrack_angles.unchecked(bn) > *_max_beam_angle) @@ -109,7 +127,7 @@ class PingSampleSelector BeamSelection selection; // select beams according to the options - const auto number_of_beams = ping_bottom.get_number_of_beams(); + const auto number_of_beams = ping_bottom.get_number_of_beams(); const auto beam_crosstrack_angles = ping_bottom.get_beam_crosstrack_angles(); if (beam_crosstrack_angles.size() < number_of_beams) @@ -118,11 +136,22 @@ class PingSampleSelector beam_crosstrack_angles.size(), number_of_beams)); + const auto tx_sector_per_beam = ping_bottom.get_tx_sector_per_beam(); + if (tx_sector_per_beam.size() != number_of_beams) + throw std::runtime_error(fmt::format("Number of transmit sectors per beam ({}) is " + "different from the number of beams ({})", + tx_sector_per_beam.size(), + number_of_beams)); + // convert min/max beam numbers to indices (if set, and according to python negative // indexing) size_t min_beam_number = _min_beam_number ? *_min_beam_number : 0; size_t max_beam_number = _max_beam_number ? *_max_beam_number : number_of_beams - 1; + // initialize transmit sector selection + auto beam_numbers_selected_by_transmit_sector = + get_beam_numbers_selected_by_transmit_sector(ping_bottom, beam_crosstrack_angles); + tools::pyhelper::PyIndexer beam_indexer( number_of_beams, min_beam_number, max_beam_number + 1, _beam_step); @@ -130,6 +159,11 @@ class PingSampleSelector { auto bn = beam_indexer(counter); + // check transmit sector selection + if (beam_numbers_selected_by_transmit_sector.has_value()) + if (!beam_numbers_selected_by_transmit_sector.value()[bn]) + continue; + if (_min_beam_angle && beam_crosstrack_angles.unchecked(bn) < *_min_beam_angle) continue; if (_max_beam_angle && beam_crosstrack_angles.unchecked(bn) > *_max_beam_angle) @@ -153,6 +187,9 @@ class PingSampleSelector auto get_max_sample_range() const { return _max_sample_range; } auto get_beam_step() const { return _beam_step; } auto get_sample_step() const { return _sample_step; } + auto get_transmit_sectors() const { return _transmit_sectors; } + auto get_transmit_sector_min_beam_angle() const { return _transmit_sector_min_beam_angle; } + auto get_transmit_sector_max_beam_angle() const { return _transmit_sector_max_beam_angle; } // resetters void clear_beam_number_range() @@ -179,6 +216,14 @@ class PingSampleSelector _max_sample_range.reset(); } + void clear_transmit_sectors() { _transmit_sectors.reset(); } + + void clear_transmit_sector_beam_angle_range() + { + _transmit_sector_min_beam_angle.reset(); + _transmit_sector_max_beam_angle.reset(); + } + void clear_beam_step() { _beam_step = 1; } void clear_sample_step() { _sample_step = 1; } @@ -190,10 +235,11 @@ class PingSampleSelector clear_sample_range_range(); clear_beam_step(); clear_sample_step(); + clear_transmit_sectors(); + clear_transmit_sector_beam_angle_range(); } // selectors - void select_beam_range_by_numbers(size_t min_beam_number, size_t max_beam_number, std::optional beam_step = std::nullopt) @@ -234,6 +280,18 @@ class PingSampleSelector _sample_step = *sample_step; } + void select_transmit_sectors(std::vector transmit_sectors) + { + _transmit_sectors = transmit_sectors; + } + + void select_transmit_sectors_by_beam_angles(std::optional transmit_sector_min_beam_angle, + std::optional transmit_sector_max_beam_angle) + { + _transmit_sector_min_beam_angle = transmit_sector_min_beam_angle; + _transmit_sector_max_beam_angle = transmit_sector_max_beam_angle; + } + void set_sample_step(size_t sample_step) { _sample_step = sample_step; } void set_beam_step(size_t beam_step) { _beam_step = beam_step; } @@ -246,6 +304,7 @@ class PingSampleSelector */ static PingSampleSelector from_stream(std::istream& is) { + using themachinethatgoesping::tools::classhelper::stream::optional_container_from_stream; using themachinethatgoesping::tools::classhelper::stream::optional_from_stream; using themachinethatgoesping::tools::classhelper::stream::optional_set_from_stream; @@ -258,6 +317,10 @@ class PingSampleSelector object._max_beam_angle = optional_from_stream(is); object._min_sample_range = optional_from_stream(is); object._max_sample_range = optional_from_stream(is); + object._transmit_sectors = optional_container_from_stream>(is); + object._transmit_sector_min_beam_angle = optional_from_stream(is); + object._transmit_sector_max_beam_angle = optional_from_stream(is); + is.read(reinterpret_cast(&object._beam_step), sizeof(object._beam_step)); is.read(reinterpret_cast(&object._sample_step), sizeof(object._sample_step)); @@ -271,6 +334,7 @@ class PingSampleSelector */ void to_stream(std::ostream& os) const { + using themachinethatgoesping::tools::classhelper::stream::optional_container_to_stream; using themachinethatgoesping::tools::classhelper::stream::optional_set_to_stream; using themachinethatgoesping::tools::classhelper::stream::optional_to_stream; @@ -282,6 +346,9 @@ class PingSampleSelector optional_to_stream(os, _max_beam_angle); optional_to_stream(os, _min_sample_range); optional_to_stream(os, _max_sample_range); + optional_container_to_stream(os, _transmit_sectors); + optional_to_stream(os, _transmit_sector_min_beam_angle); + optional_to_stream(os, _transmit_sector_max_beam_angle); os.write(reinterpret_cast(&_beam_step), sizeof(_beam_step)); os.write(reinterpret_cast(&_sample_step), sizeof(_sample_step)); } @@ -343,6 +410,23 @@ class PingSampleSelector else inactive_filters += "max_sample_range, "; + if (_transmit_sectors) + printer.register_container("transmit_sectors", *_transmit_sectors); + else + inactive_filters += "transmit_sectors, "; + + if (_transmit_sector_min_beam_angle) + printer.register_value( + "transmit_sector_min_beam_angle", *_transmit_sector_min_beam_angle, "°"); + else + inactive_filters += "transmit_sector_min_beam_angle, "; + + if (_transmit_sector_max_beam_angle) + printer.register_value( + "transmit_sector_max_beam_angle", *_transmit_sector_max_beam_angle, "°"); + else + inactive_filters += "transmit_sector_max_beam_angle, "; + printer.register_value("beam_step", _beam_step); printer.register_value("sample_step", _sample_step); @@ -362,6 +446,72 @@ class PingSampleSelector __STREAM_DEFAULT_TOFROM_BINARY_FUNCTIONS__(PingSampleSelector) // define info_string and print functions (needs the __printer__ function) __CLASSHELPER_DEFAULT_PRINTING_FUNCTIONS__ + + private: + template + std::optional> get_beam_numbers_selected_by_transmit_sector( + ping_watercolumn_or_bottom& ping_w, + const t_angles& beam_crosstrack_angles) + { + + if (!_transmit_sector_min_beam_angle.has_value() && + !_transmit_sector_max_beam_angle.has_value() && !_transmit_sectors.has_value()) + return std::nullopt; + + // init transmit_sector_selection + const auto tx_sector_per_beam = ping_w.get_tx_sector_per_beam(); + std::vector transmit_sector_selection; + + if (tx_sector_per_beam.size() != beam_crosstrack_angles.size()) + throw std::runtime_error( + fmt::format("Number of transmit sectors per beam ({}) is " + "different from the number of beam crosstrack angles ({})", + tx_sector_per_beam.size(), + beam_crosstrack_angles.size())); + + if (_transmit_sector_min_beam_angle.has_value() or + _transmit_sector_max_beam_angle.has_value()) + { + float min_ba = + _transmit_sector_min_beam_angle.value_or(std::numeric_limits::lowest()); + float max_ba = + _transmit_sector_max_beam_angle.value_or(std::numeric_limits::max()); + + for (unsigned int bn = 0; bn < tx_sector_per_beam.size(); ++bn) + { + if (!transmit_sector_selection.empty()) + if (tx_sector_per_beam[bn] == transmit_sector_selection.back()) + continue; + + if (beam_crosstrack_angles.unchecked(bn) >= min_ba && + beam_crosstrack_angles.unchecked(bn) <= max_ba) + { + if (_transmit_sectors.has_value()) + if (std::find(_transmit_sectors->begin(), + _transmit_sectors->end(), + tx_sector_per_beam[bn]) == _transmit_sectors->end()) + continue; + + transmit_sector_selection.push_back(tx_sector_per_beam[bn]); + } + } + } + else + { + transmit_sector_selection = *_transmit_sectors; + } + + std::vector beam_number_is_selected; + beam_number_is_selected.resize(tx_sector_per_beam.size()); + + for (unsigned int bn = 0; bn < tx_sector_per_beam.size(); ++bn) + if (std::find(transmit_sector_selection.begin(), + transmit_sector_selection.end(), + tx_sector_per_beam[bn]) != transmit_sector_selection.end()) + beam_number_is_selected[bn] = 1; + + return beam_number_is_selected; + } }; } // namespace pingtools diff --git a/src/themachinethatgoesping/echosounders/simradraw/filedatatypes/calibration/.docstrings/simradrawwatercolumncalibration.doc.hpp b/src/themachinethatgoesping/echosounders/simradraw/filedatatypes/calibration/.docstrings/simradrawwatercolumncalibration.doc.hpp index 6ed0d9b9..02bff8a9 100644 --- a/src/themachinethatgoesping/echosounders/simradraw/filedatatypes/calibration/.docstrings/simradrawwatercolumncalibration.doc.hpp +++ b/src/themachinethatgoesping/echosounders/simradraw/filedatatypes/calibration/.docstrings/simradrawwatercolumncalibration.doc.hpp @@ -1,4 +1,4 @@ -//sourcehash: eed179f9e3cf38f6a5ea03a6260c5fc3375e5974ce38b30e24760abcac723f55 +//sourcehash: 2d4971b64e95d0f3efe2f86cb02acbedfb356fd2dce227a19fe19e9f1b926b0e /* This file contains docstrings for use in the Python bindings.