diff --git a/common/StatusVector.cpp b/common/StatusVector.cpp index d0e04e43..a4e18ef4 100644 --- a/common/StatusVector.cpp +++ b/common/StatusVector.cpp @@ -64,8 +64,7 @@ int32_t StatusVector::GetActualBinning(int32_t bin_size) const { return mean; } -MultiLinePlotStruct StatusVector::GetMeanPerBin(int32_t bin_size, float x_start, float x_incr, - const std::optional &fill_value) const { +MultiLinePlotStruct StatusVector::GetMeanPerBin(int32_t bin_size, float x_start, float x_incr) const { std::unique_lock ul(m); MultiLinePlotStruct ret; @@ -89,13 +88,8 @@ MultiLinePlotStruct StatusVector::GetMeanPerBin(int32_t bin_size, float x_start, if (bin_size == 1) { for (int i = 0; i < content.size(); i++) { - if (std::isfinite(content[i])) { - ret.x.push_back(x_start + x_incr * i); - ret.y.push_back(content[i]); - } else if (fill_value) { - ret.x.push_back(x_start + x_incr * i); - ret.y.push_back(fill_value.value()); - } + ret.x.push_back(x_start + x_incr * i); + ret.y.push_back(content[i]); } } else { for (int bin = 0; bin < elems; bin++) { @@ -110,22 +104,18 @@ MultiLinePlotStruct StatusVector::GetMeanPerBin(int32_t bin_size, float x_start, } float bin_x = static_cast(bin_size) * (bin + 0.5f); - - if (count_bin > 0) { - ret.x.push_back(x_start + x_incr * bin_x); + ret.x.push_back(x_start + x_incr * bin_x); + if (count_bin > 0) ret.y.push_back(static_cast(sum_bin / static_cast(count_bin))); - } else if (fill_value) { - ret.x.push_back(x_start + x_incr * bin_x); - ret.y.push_back(fill_value.value()); - } + else + ret.y.push_back(NAN); } } } return ret; } -MultiLinePlotStruct StatusVector::GetMaxPerBin(int32_t bin_size, float x_start, float x_incr, - const std::optional &fill_value) const { +MultiLinePlotStruct StatusVector::GetMaxPerBin(int32_t bin_size, float x_start, float x_incr) const { std::unique_lock ul(m); MultiLinePlotStruct ret; @@ -142,13 +132,8 @@ MultiLinePlotStruct StatusVector::GetMaxPerBin(int32_t bin_size, float x_start, if (bin_size == 1) { for (int i = 0; i < content.size(); i++) { - if (std::isfinite(content[i])) { - ret.x.push_back(x_start + x_incr * i); - ret.y.push_back(content[i]); - } else if (fill_value) { - ret.x.push_back(x_start + x_incr * i); - ret.y.push_back(fill_value.value()); - } + ret.x.push_back(x_start + x_incr * i); + ret.y.push_back(content[i]); } } else { for (int bin = 0; bin < elems; bin++) { @@ -164,30 +149,26 @@ MultiLinePlotStruct StatusVector::GetMaxPerBin(int32_t bin_size, float x_start, float bin_x = static_cast(bin_size) * (bin + 0.5f); - if (max_bin_set) { - ret.x.push_back(x_start + x_incr * bin_x); + ret.x.push_back(x_start + x_incr * bin_x); + if (max_bin_set) ret.y.push_back(max_in_bin); - } else if (fill_value) { - ret.x.push_back(x_start + x_incr * bin_x); - ret.y.push_back(fill_value.value()); - } + else + ret.y.push_back(NAN); } } } return ret; } -MultiLinePlot StatusVector::GetMeanPlot(int64_t bin_size, float x_start, float x_incr, - const std::optional &fill_value) const { +MultiLinePlot StatusVector::GetMeanPlot(int64_t bin_size, float x_start, float x_incr) const { MultiLinePlot ret; - ret.AddPlot(GetMeanPerBin(bin_size, x_start, x_incr, fill_value)); + ret.AddPlot(GetMeanPerBin(bin_size, x_start, x_incr)); return ret; } -MultiLinePlot StatusVector::GetMaxPlot(int64_t bin_size, float x_start, float x_incr, - const std::optional &fill_value) const { +MultiLinePlot StatusVector::GetMaxPlot(int64_t bin_size, float x_start, float x_incr) const { MultiLinePlot ret; - ret.AddPlot(GetMaxPerBin(bin_size, x_start, x_incr, fill_value)); + ret.AddPlot(GetMaxPerBin(bin_size, x_start, x_incr)); return ret; } @@ -210,23 +191,21 @@ void StatusMultiVector::AddElement(const std::string &s, uint32_t id, std::optio } MultiLinePlotStruct StatusMultiVector::GetMeanPerBin(const std::string &in_key, int64_t bin_size, float x_start, - float x_incr, - const std::optional &fill_value) const { + float x_incr) const { MultiLinePlotStruct ret{}; for (const auto &[key, value]: status) { if (key == in_key) { - ret = value->GetMeanPerBin(bin_size, x_start, x_incr, fill_value); + ret = value->GetMeanPerBin(bin_size, x_start, x_incr); ret.title = key; } } return ret; } -MultiLinePlot StatusMultiVector::GetMeanPlot(int64_t bin_size, float x_start, float x_incr, - const std::optional &fill_value) const { +MultiLinePlot StatusMultiVector::GetMeanPlot(int64_t bin_size, float x_start, float x_incr) const { MultiLinePlot ret; for (const auto &[key, value]: status) { - auto tmp = value->GetMeanPerBin(bin_size, x_start, x_incr, fill_value); + auto tmp = value->GetMeanPerBin(bin_size, x_start, x_incr); tmp.title = key; ret.AddPlot(tmp); } diff --git a/common/StatusVector.h b/common/StatusVector.h index 79fe79da..7661a0fb 100644 --- a/common/StatusVector.h +++ b/common/StatusVector.h @@ -31,14 +31,10 @@ public: int32_t GetActualBinning(int32_t bin_size) const; [[nodiscard]] std::vector ExportArray(float def_value) const; [[nodiscard]] float Mean() const; - MultiLinePlotStruct GetMeanPerBin(int32_t bin_size, float x_start, float x_incr, - const std::optional &fill_value = {}) const; - [[nodiscard]] MultiLinePlotStruct GetMaxPerBin(int32_t bin_size, float x_start, float x_incr, - const std::optional &fill_value = {}) const; - MultiLinePlot GetMeanPlot(int64_t bin_size, float x_start, float x_incr, - const std::optional &fill_value = {}) const; - MultiLinePlot GetMaxPlot(int64_t bin_size, float x_start, float x_incr, - const std::optional &fill_value = {}) const; + MultiLinePlotStruct GetMeanPerBin(int32_t bin_size, float x_start, float x_incr) const; + [[nodiscard]] MultiLinePlotStruct GetMaxPerBin(int32_t bin_size, float x_start, float x_incr) const; + MultiLinePlot GetMeanPlot(int64_t bin_size, float x_start, float x_incr) const; + MultiLinePlot GetMaxPlot(int64_t bin_size, float x_start, float x_incr) const; }; class StatusMultiVector { @@ -49,10 +45,8 @@ public: void AddElement(const std::string& s, uint32_t id, float val); void AddElement(const std::string& s, uint32_t id, std::optional val); - [[nodiscard]] MultiLinePlotStruct GetMeanPerBin(const std::string& in_key, int64_t bin_size, float x_start, float x_incr, - const std::optional &fill_value = {}) const; - [[nodiscard]] MultiLinePlot GetMeanPlot(int64_t bin_size, float x_start, float x_incr, - const std::optional &fill_value = {}) const; + [[nodiscard]] MultiLinePlotStruct GetMeanPerBin(const std::string& in_key, int64_t bin_size, float x_start, float x_incr) const; + [[nodiscard]] MultiLinePlot GetMeanPlot(int64_t bin_size, float x_start, float x_incr) const; [[nodiscard]] std::vector ExportArray(const std::string& s, float def_value) const; }; diff --git a/receiver/JFJochReceiverPlots.cpp b/receiver/JFJochReceiverPlots.cpp index 0e5da611..36a81c80 100644 --- a/receiver/JFJochReceiverPlots.cpp +++ b/receiver/JFJochReceiverPlots.cpp @@ -152,70 +152,70 @@ MultiLinePlot JFJochReceiverPlots::GetPlots(const PlotRequest &request) { switch (request.type) { case PlotType::SpotCount: - ret = spot_count.GetMeanPlot(nbins, start, incr, NAN); + ret = spot_count.GetMeanPlot(nbins, start, incr); break; case PlotType::SpotCountLowRes: - ret = spot_count_low_res.GetMeanPlot(nbins, start, incr, NAN); + ret = spot_count_low_res.GetMeanPlot(nbins, start, incr); break; case PlotType::SpotCountIndexed: - ret = spot_count_indexed.GetMeanPlot(nbins, start, incr, NAN); + ret = spot_count_indexed.GetMeanPlot(nbins, start, incr); break; case PlotType::SpotCountIceRing: - ret = spot_count_ice.GetMeanPlot(nbins, start, incr, NAN); + ret = spot_count_ice.GetMeanPlot(nbins, start, incr); break; case PlotType::IndexingRate: - ret = indexing_solution.GetMeanPlot(nbins, start, incr, NAN); + ret = indexing_solution.GetMeanPlot(nbins, start, incr); break; case PlotType::BkgEstimate: - ret = bkg_estimate.GetMeanPlot(nbins, start, incr, NAN); + ret = bkg_estimate.GetMeanPlot(nbins, start, incr); break; case PlotType::ResolutionEstimate: - ret = resolution_estimate.GetMeanPlot(nbins, start, incr, NAN); + ret = resolution_estimate.GetMeanPlot(nbins, start, incr); break; case PlotType::ErrorPixels: - ret = error_pixels.GetMeanPlot(nbins, start, incr, NAN); + ret = error_pixels.GetMeanPlot(nbins, start, incr); break; case PlotType::SaturatedPixels: - ret = saturated_pixels.GetMeanPlot(nbins, start, incr, NAN); + ret = saturated_pixels.GetMeanPlot(nbins, start, incr); break; case PlotType::IndexingTime: - ret = indexing_time.GetMeanPlot(nbins, start, incr, NAN); + ret = indexing_time.GetMeanPlot(nbins, start, incr); break; case PlotType::ProfileRadius: - ret = profile_radius.GetMeanPlot(nbins, start, incr, NAN); + ret = profile_radius.GetMeanPlot(nbins, start, incr); break; case PlotType::BFactor: - ret = b_factor.GetMeanPlot(nbins, start, incr, NAN); + ret = b_factor.GetMeanPlot(nbins, start, incr); break; case PlotType::ImageCollectionEfficiency: - ret = image_collection_efficiency.GetMeanPlot(nbins, start, incr, NAN); + ret = image_collection_efficiency.GetMeanPlot(nbins, start, incr); break; case PlotType::ReceiverDelay: - ret = receiver_delay.GetMeanPlot(nbins, start, incr, NAN); + ret = receiver_delay.GetMeanPlot(nbins, start, incr); break; case PlotType::ReceiverFreeSendBuf: - ret = receiver_free_send_buf.GetMeanPlot(nbins, start, incr, NAN); + ret = receiver_free_send_buf.GetMeanPlot(nbins, start, incr); break; case PlotType::StrongPixels: - ret = strong_pixels.GetMeanPlot(nbins, start, incr, NAN); + ret = strong_pixels.GetMeanPlot(nbins, start, incr); break; case PlotType::ROISum: - ret = roi_sum.GetMeanPlot(nbins, start, incr, NAN); + ret = roi_sum.GetMeanPlot(nbins, start, incr); break; case PlotType::ROIMaxCount: - ret = roi_max_count.GetMeanPlot(nbins, start, incr, NAN); + ret = roi_max_count.GetMeanPlot(nbins, start, incr); break; case PlotType::ROIPixels: - ret = roi_pixels.GetMeanPlot(nbins, start, incr, NAN); + ret = roi_pixels.GetMeanPlot(nbins, start, incr); break; case PlotType::ROIMean: - ret = roi_mean.GetMeanPlot(nbins, start, incr, NAN); + ret = roi_mean.GetMeanPlot(nbins, start, incr); break; case PlotType::ROIWeightedX: - ret = roi_x.GetMeanPlot(nbins, start, incr, NAN); + ret = roi_x.GetMeanPlot(nbins, start, incr); break; case PlotType::ROIWeightedY: - ret = roi_y.GetMeanPlot(nbins, start, incr, NAN); + ret = roi_y.GetMeanPlot(nbins, start, incr); break; case PlotType::AzInt: ret = GetAzIntProfilePlot(false, request.azint_unit); @@ -224,28 +224,28 @@ MultiLinePlot JFJochReceiverPlots::GetPlots(const PlotRequest &request) { ret = GetAzIntProfilePlot(true, request.azint_unit); break; case PlotType::IndexingUnitCellLength: - ret = indexing_unit_cell_len.GetMeanPlot(nbins, start, incr, NAN); + ret = indexing_unit_cell_len.GetMeanPlot(nbins, start, incr); break; case PlotType::IndexingUnitCellAngle: - ret = indexing_unit_cell_angle.GetMeanPlot(nbins, start, incr, NAN); + ret = indexing_unit_cell_angle.GetMeanPlot(nbins, start, incr); break; case PlotType::PacketsReceived: - ret = packets_received.GetMeanPlot(nbins, start, incr, NAN); + ret = packets_received.GetMeanPlot(nbins, start, incr); break; case PlotType::MaxValue: - ret = max_value.GetMaxPlot(nbins, start, incr, NAN); + ret = max_value.GetMaxPlot(nbins, start, incr); break; // doesn't make sense to give mean here case PlotType::PixelSum: - ret = pixel_sum.GetMeanPlot(nbins, start, incr, NAN); + ret = pixel_sum.GetMeanPlot(nbins, start, incr); break; case PlotType::ImageProcessingTime: - ret = processing_time.GetMeanPlot(nbins, start, incr, NAN); + ret = processing_time.GetMeanPlot(nbins, start, incr); break; case PlotType::RefinementBeamX: - ret = beam_center_x.GetMeanPlot(nbins, start, incr, NAN); + ret = beam_center_x.GetMeanPlot(nbins, start, incr); break; case PlotType::RefinementBeamY: - ret = beam_center_y.GetMeanPlot(nbins, start, incr, NAN); + ret = beam_center_y.GetMeanPlot(nbins, start, incr); break; default: // Do nothing diff --git a/tests/JFJochReceiverPlotsTest.cpp b/tests/JFJochReceiverPlotsTest.cpp index d2b0e238..9bb55469 100644 --- a/tests/JFJochReceiverPlotsTest.cpp +++ b/tests/JFJochReceiverPlotsTest.cpp @@ -33,14 +33,16 @@ TEST_CASE("JFJochReceiverPlots") { REQUIRE(p.GetUnits() == MultiLinePlotUnits::ImageNumber); REQUIRE(p.GetPlots().size() == 1); - REQUIRE(p.GetPlots()[0].x.size() == 2); - REQUIRE(p.GetPlots()[0].y.size() == 2); + REQUIRE(p.GetPlots()[0].x.size() == 3); + REQUIRE(p.GetPlots()[0].y.size() == 3); REQUIRE(p.GetPlots()[0].z.empty()); REQUIRE(p.GetPlots()[0].x[0] == 0); - REQUIRE(p.GetPlots()[0].x[1] == 2); + REQUIRE(p.GetPlots()[0].x[1] == 1); + REQUIRE(p.GetPlots()[0].x[2] == 2); REQUIRE(p.GetPlots()[0].y[0] == 11); - REQUIRE(p.GetPlots()[0].y[1] == 12); + REQUIRE(std::isnan(p.GetPlots()[0].y[1])); + REQUIRE(p.GetPlots()[0].y[2] == 12); } TEST_CASE("JFJochReceiverPlots_Angle") { @@ -72,14 +74,16 @@ TEST_CASE("JFJochReceiverPlots_Angle") { REQUIRE(p.GetUnits() == MultiLinePlotUnits::Angle_deg); REQUIRE(p.GetPlots().size() == 1); - REQUIRE(p.GetPlots()[0].x.size() == 2); - REQUIRE(p.GetPlots()[0].y.size() == 2); + REQUIRE(p.GetPlots()[0].x.size() == 3); + REQUIRE(p.GetPlots()[0].y.size() == 3); REQUIRE(p.GetPlots()[0].z.empty()); REQUIRE(p.GetPlots()[0].x[0] == 15.0); - REQUIRE(p.GetPlots()[0].x[1] == 15.0 + 2.0 * 2); + REQUIRE(p.GetPlots()[0].x[1] == 15.0 + 2.0 * 1); + REQUIRE(p.GetPlots()[0].x[2] == 15.0 + 2.0 * 2); REQUIRE(p.GetPlots()[0].y[0] == 11); - REQUIRE(p.GetPlots()[0].y[1] == 12); + REQUIRE(std::isnan(p.GetPlots()[0].y[1])); + REQUIRE(p.GetPlots()[0].y[2] == 12); } TEST_CASE("JFJochReceiverPlots_Grid") { @@ -122,21 +126,32 @@ TEST_CASE("JFJochReceiverPlots_Grid") { REQUIRE(p.GetUnits() == MultiLinePlotUnits::Grid_um); REQUIRE(p.GetPlots().size() == 1); - REQUIRE(p.GetPlots()[0].x.size() == 3); - REQUIRE(p.GetPlots()[0].y.size() == 3); - REQUIRE(p.GetPlots()[0].z.size() == 3); + REQUIRE(p.GetPlots()[0].x.size() == 12); + REQUIRE(p.GetPlots()[0].y.size() == 12); + REQUIRE(p.GetPlots()[0].z.size() == 12); - REQUIRE(p.GetPlots()[0].x[0] == 0.5 * 10.0); - REQUIRE(p.GetPlots()[0].x[1] == 2.5 * 10.0); - REQUIRE(p.GetPlots()[0].x[2] == 1.5 * 10.0); + CHECK(p.GetPlots()[0].x[0] == 0.5 * 10.0); + CHECK(p.GetPlots()[0].x[1] == 1.5 * 10.0); + CHECK(p.GetPlots()[0].x[2] == 2.5 * 10.0); + CHECK(p.GetPlots()[0].x[3] == 3.5 * 10.0); + CHECK(p.GetPlots()[0].x[4] == 4.5 * 10.0); + CHECK(p.GetPlots()[0].x[5] == 0.5 * 10.0); + CHECK(p.GetPlots()[0].x[11] == 1.5 * 10.0); - REQUIRE(p.GetPlots()[0].y[0] == 0.5 * 20.0); - REQUIRE(p.GetPlots()[0].y[1] == 0.5 * 20.0); - REQUIRE(p.GetPlots()[0].y[2] == 2.5 * 20.0); + CHECK(p.GetPlots()[0].y[0] == 0.5 * 20.0); + CHECK(p.GetPlots()[0].y[1] == 0.5 * 20.0); + CHECK(p.GetPlots()[0].y[2] == 0.5 * 20.0); + CHECK(p.GetPlots()[0].y[3] == 0.5 * 20.0); + CHECK(p.GetPlots()[0].y[4] == 0.5 * 20.0); + CHECK(p.GetPlots()[0].y[5] == 1.5 * 20.0); + CHECK(p.GetPlots()[0].y[11] == 2.5 * 20.0); - REQUIRE(p.GetPlots()[0].z[0] == 11); - REQUIRE(p.GetPlots()[0].z[1] == 12); - REQUIRE(p.GetPlots()[0].z[2] == 8); + CHECK(p.GetPlots()[0].z[0] == 11); + CHECK(std::isnan(p.GetPlots()[0].z[1])); + CHECK(p.GetPlots()[0].z[2] == 12); + CHECK(std::isnan(p.GetPlots()[0].z[3])); + CHECK(std::isnan(p.GetPlots()[0].z[6])); + CHECK(p.GetPlots()[0].z[11] == 8); REQUIRE(p.GetSizeX() == 10.0 * 5); REQUIRE(p.GetSizeY() == 20.0 * 3); diff --git a/tests/StatusVectorTest.cpp b/tests/StatusVectorTest.cpp index f6a17c2c..e79d6dc8 100644 --- a/tests/StatusVectorTest.cpp +++ b/tests/StatusVectorTest.cpp @@ -17,41 +17,43 @@ TEST_CASE("StatusVector_GetMeanPerBin","[StatusVector]") { SECTION("Binning 1000") { plot = status_vector.GetMeanPerBin(1000, 0.0, 1.0); - REQUIRE(plot.x.size() == 2); - REQUIRE(plot.y.size() == 2); + REQUIRE(plot.x.size() == 3); + REQUIRE(plot.y.size() == 3); CHECK(plot.x[0] == Catch::Approx(500)); - CHECK(plot.x[1] == Catch::Approx(2500)); + CHECK(plot.x[1] == Catch::Approx(1500)); + CHECK(plot.x[2] == Catch::Approx(2500)); CHECK(plot.y[0] == Catch::Approx(11)); - CHECK(plot.y[1] == Catch::Approx((45 + 44 + 41) / 3.0)); + CHECK(std::isnan(plot.y[1])); + CHECK(plot.y[2] == Catch::Approx((45 + 44 + 41) / 3.0)); } SECTION("Binning 500") { plot = status_vector.GetMeanPerBin(500, 0.0, 1.0); - REQUIRE(plot.x.size() == 3); - REQUIRE(plot.y.size() == 3); + REQUIRE(plot.x.size() == 6); + REQUIRE(plot.y.size() == 6); CHECK(plot.x[0] == Catch::Approx(250)); - CHECK(plot.x[1] == Catch::Approx(2250)); - CHECK(plot.x[2] == Catch::Approx(2750)); + CHECK(plot.x[4] == Catch::Approx(2250)); + CHECK(plot.x[5] == Catch::Approx(2750)); CHECK(plot.y[0] == Catch::Approx(11)); - CHECK(plot.y[1] == Catch::Approx(45)); - CHECK(plot.y[2] == Catch::Approx((44 + 41) / 2.0)); + CHECK(plot.y[4] == Catch::Approx(45)); + CHECK(plot.y[5] == Catch::Approx((44 + 41) / 2.0)); } SECTION("Binning 1") { plot = status_vector.GetMeanPerBin(1, 0.0, 1.0); - REQUIRE(plot.x.size() == 4); - REQUIRE(plot.y.size() == 4); - CHECK(plot.x[0] == Catch::Approx(5)); - CHECK(plot.x[1] == Catch::Approx(2000)); - CHECK(plot.x[2] == Catch::Approx(2543)); - CHECK(plot.x[3] == Catch::Approx(2600)); + REQUIRE(plot.x.size() == 2601); + REQUIRE(plot.y.size() == 2601); + CHECK(plot.x[5] == Catch::Approx(5)); + CHECK(plot.x[2000] == Catch::Approx(2000)); + CHECK(plot.x[2543] == Catch::Approx(2543)); + CHECK(plot.x[2600] == Catch::Approx(2600)); - CHECK(plot.y[0] == Catch::Approx(11)); - CHECK(plot.y[1] == Catch::Approx(45)); - CHECK(plot.y[2] == Catch::Approx(44)); - CHECK(plot.y[3] == Catch::Approx(41)); + CHECK(plot.y[5] == Catch::Approx(11)); + CHECK(plot.y[2000] == Catch::Approx(45)); + CHECK(plot.y[2543] == Catch::Approx(44)); + CHECK(plot.y[2600] == Catch::Approx(41)); } } @@ -71,28 +73,28 @@ TEST_CASE("StatusVector_GetMeanPerBin_Start_Incr","[StatusVector]") { SECTION("Binning") { plot = status_vector.GetMeanPerBin(1000, start, incr); - REQUIRE(plot.x.size() == 2); - REQUIRE(plot.y.size() == 2); + REQUIRE(plot.x.size() == 3); + REQUIRE(plot.y.size() == 3); CHECK(plot.x[0] == Catch::Approx(start + 500 * incr)); - CHECK(plot.x[1] == Catch::Approx(start + 2500 * incr)); + CHECK(plot.x[2] == Catch::Approx(start + 2500 * incr)); CHECK(plot.y[0] == Catch::Approx(11)); - CHECK(plot.y[1] == Catch::Approx((45 + 44 + 41) / 3.0)); + CHECK(plot.y[2] == Catch::Approx((45 + 44 + 41) / 3.0)); } SECTION("No binning") { plot = status_vector.GetMeanPerBin(1, start, incr); - REQUIRE(plot.x.size() == 4); - REQUIRE(plot.y.size() == 4); - CHECK(plot.x[0] == Catch::Approx(start + 5 * incr)); - CHECK(plot.x[1] == Catch::Approx(start + 2000 * incr)); - CHECK(plot.x[2] == Catch::Approx(start + 2543 * incr)); - CHECK(plot.x[3] == Catch::Approx(start + 2600 * incr)); + REQUIRE(plot.x.size() == 2601); + REQUIRE(plot.y.size() == 2601); + CHECK(plot.x[5] == Catch::Approx(start + 5 * incr)); + CHECK(plot.x[2000] == Catch::Approx(start + 2000 * incr)); + CHECK(plot.x[2543] == Catch::Approx(start + 2543 * incr)); + CHECK(plot.x[2600] == Catch::Approx(start + 2600 * incr)); - CHECK(plot.y[0] == Catch::Approx(11)); - CHECK(plot.y[1] == Catch::Approx(45)); - CHECK(plot.y[2] == Catch::Approx(44)); - CHECK(plot.y[3] == Catch::Approx(41)); + CHECK(plot.y[5] == Catch::Approx(11)); + CHECK(plot.y[2000] == Catch::Approx(45)); + CHECK(plot.y[2543] == Catch::Approx(44)); + CHECK(plot.y[2600] == Catch::Approx(41)); } } @@ -109,17 +111,17 @@ TEST_CASE("StatusVector_GetMaxPerBin_Start_Incr","[StatusVector]") { float start = 545.0f; float incr = 2.5f; plot = status_vector.GetMaxPerBin(1, start, incr); - REQUIRE(plot.x.size() == 4); - REQUIRE(plot.y.size() == 4); - CHECK(plot.x[0] == Catch::Approx(start + 5 * incr)); - CHECK(plot.x[1] == Catch::Approx(start + 2000 * incr)); - CHECK(plot.x[2] == Catch::Approx(start + 2543 * incr)); - CHECK(plot.x[3] == Catch::Approx(start + 2600 * incr)); + REQUIRE(plot.x.size() == 2601); + REQUIRE(plot.y.size() == 2601); + CHECK(plot.x[5] == Catch::Approx(start + 5 * incr)); + CHECK(plot.x[2000] == Catch::Approx(start + 2000 * incr)); + CHECK(plot.x[2543] == Catch::Approx(start + 2543 * incr)); + CHECK(plot.x[2600] == Catch::Approx(start + 2600 * incr)); - CHECK(plot.y[0] == Catch::Approx(11)); - CHECK(plot.y[1] == Catch::Approx(45)); - CHECK(plot.y[2] == Catch::Approx(44)); - CHECK(plot.y[3] == Catch::Approx(41)); + CHECK(plot.y[5] == Catch::Approx(11)); + CHECK(plot.y[2000] == Catch::Approx(45)); + CHECK(plot.y[2543] == Catch::Approx(44)); + CHECK(plot.y[2600] == Catch::Approx(41)); } TEST_CASE("StatusVector_GetMeanPerBin_Fill","[StatusVector]") { @@ -134,10 +136,9 @@ TEST_CASE("StatusVector_GetMeanPerBin_Fill","[StatusVector]") { float start = 545.0f; float incr = 2.5f; - float fill = -345.0f; SECTION("Binning") { - plot = status_vector.GetMeanPerBin(1000, start, incr, fill); + plot = status_vector.GetMeanPerBin(1000, start, incr); REQUIRE(plot.x.size() == 3); REQUIRE(plot.y.size() == 3); @@ -145,12 +146,12 @@ TEST_CASE("StatusVector_GetMeanPerBin_Fill","[StatusVector]") { CHECK(plot.x[1] == Catch::Approx(start + 1500 * incr)); CHECK(plot.x[2] == Catch::Approx(start + 2500 * incr)); CHECK(plot.y[0] == Catch::Approx(11.0)); - CHECK(plot.y[1] == Catch::Approx(fill)); + CHECK(std::isnan(plot.y[1])); CHECK(plot.y[2] == Catch::Approx((45 + 44 + 41) / 3.0f)); } SECTION("No Binning") { - plot = status_vector.GetMeanPerBin(1, start, incr, fill); + plot = status_vector.GetMeanPerBin(1, start, incr); REQUIRE(plot.x.size() == 2601); REQUIRE(plot.y.size() == 2601); @@ -159,13 +160,13 @@ TEST_CASE("StatusVector_GetMeanPerBin_Fill","[StatusVector]") { CHECK(plot.x[2] == Catch::Approx(start + 2 * incr)); CHECK(plot.x[2600] == Catch::Approx(start + 2600 * incr)); - CHECK(plot.y[0] == Catch::Approx(fill)); - CHECK(plot.y[1] == Catch::Approx(fill)); - CHECK(plot.y[2] == Catch::Approx(fill)); - CHECK(plot.y[5] == Catch::Approx(11)); + CHECK(std::isnan(plot.y[0])); + CHECK(std::isnan(plot.y[1])); + CHECK(std::isnan(plot.y[2])); + CHECK(plot.y[5] == Catch::Approx(11.0f)); CHECK(plot.y[2000] == Catch::Approx(45)); CHECK(plot.y[2543] == Catch::Approx(44)); - CHECK(plot.y[2599] == Catch::Approx(fill)); + CHECK(std::isnan(plot.y[2599])); CHECK(plot.y[2600] == Catch::Approx(41)); } } @@ -199,32 +200,34 @@ TEST_CASE("StatusVector_GetMaxPerBin","[StatusVector]") { auto status_out = status_vector.GetMaxPerBin(1000, 0.0, 1.0); - REQUIRE(status_out.x.size() == 2); - REQUIRE(status_out.y.size() == 2); + REQUIRE(status_out.x.size() == 3); + REQUIRE(status_out.y.size() == 3); REQUIRE(status_out.x[0] == 500); - REQUIRE(status_out.x[1] == 2500); + REQUIRE(status_out.x[1] == 1500); + REQUIRE(status_out.x[2] == 2500); REQUIRE(status_out.y[0] == 11); - REQUIRE(status_out.y[1] == 45); + REQUIRE(std::isnan(status_out.y[1])); + REQUIRE(status_out.y[2] == 45); status_out = status_vector.GetMaxPerBin(500, 0.0, 1.0); - REQUIRE(status_out.x.size() == 3); - REQUIRE(status_out.y.size() == 3); + REQUIRE(status_out.x.size() == 6); + REQUIRE(status_out.y.size() == 6); REQUIRE(status_out.y[0] == 11); - REQUIRE(status_out.y[1] == 45); - REQUIRE(status_out.y[2] == 44); + REQUIRE(status_out.y[4] == 45); + REQUIRE(status_out.y[5] == 44); status_out = status_vector.GetMaxPerBin(1, 0.0, 1.0); - REQUIRE(status_out.x.size() == 4); - REQUIRE(status_out.y.size() == 4); - REQUIRE(status_out.x[0] == 5); - REQUIRE(status_out.y[0] == 11); - REQUIRE(status_out.x[1] == 2000); - REQUIRE(status_out.y[1] == 45); - REQUIRE(status_out.x[2] == 2543); - REQUIRE(status_out.y[2] == 44); - REQUIRE(status_out.x[3] == 2600); - REQUIRE(status_out.y[3] == 41); + REQUIRE(status_out.x.size() == 2601); + REQUIRE(status_out.y.size() == 2601); + REQUIRE(status_out.x[5] == 5); + REQUIRE(status_out.y[5] == 11); + REQUIRE(status_out.x[2000] == 2000); + REQUIRE(status_out.y[2000] == 45); + REQUIRE(status_out.x[2543] == 2543); + REQUIRE(status_out.y[2543] == 44); + REQUIRE(status_out.x[2600] == 2600); + REQUIRE(status_out.y[2600] == 41); } TEST_CASE("StatusVector_ExportArray","[StatusVector]") { @@ -252,12 +255,14 @@ TEST_CASE("StatusVector_Plot_OneBin","[StatusVector]") { auto plot_out = status_vector.GetMeanPlot(1000, 0.0, 1.0); REQUIRE(plot_out.GetPlots().size() == 1); - REQUIRE(plot_out.GetPlots()[0].x.size() == 2); - REQUIRE(plot_out.GetPlots()[0].y.size() == 2); - REQUIRE(plot_out.GetPlots()[0].x[0] == Catch::Approx(5)); - REQUIRE(plot_out.GetPlots()[0].y[0] == Catch::Approx(11)); - REQUIRE(plot_out.GetPlots()[0].x[1] == Catch::Approx(7)); - REQUIRE(plot_out.GetPlots()[0].y[1] == Catch::Approx(12)); + REQUIRE(plot_out.GetPlots()[0].x.size() == 8); + REQUIRE(plot_out.GetPlots()[0].y.size() == 8); + REQUIRE(plot_out.GetPlots()[0].x[3] == Catch::Approx(3)); + REQUIRE(std::isnan(plot_out.GetPlots()[0].y[3])); + REQUIRE(plot_out.GetPlots()[0].x[5] == Catch::Approx(5)); + REQUIRE(plot_out.GetPlots()[0].y[5] == Catch::Approx(11)); + REQUIRE(plot_out.GetPlots()[0].x[7] == Catch::Approx(7)); + REQUIRE(plot_out.GetPlots()[0].y[7] == Catch::Approx(12)); } TEST_CASE("StatusVector_Plot_NoBinning","[StatusVector]") { @@ -266,10 +271,12 @@ TEST_CASE("StatusVector_Plot_NoBinning","[StatusVector]") { auto plot_out = status_vector.GetMaxPlot(1, 0.0, 1.0); REQUIRE(plot_out.GetPlots().size() == 1); - REQUIRE(plot_out.GetPlots()[0].x.size() == 1); - REQUIRE(plot_out.GetPlots()[0].y.size() == 1); - REQUIRE(plot_out.GetPlots()[0].x[0] == Catch::Approx(5)); - REQUIRE(plot_out.GetPlots()[0].y[0] == Catch::Approx(11)); + REQUIRE(plot_out.GetPlots()[0].x.size() == 6); + REQUIRE(plot_out.GetPlots()[0].y.size() == 6); + REQUIRE(plot_out.GetPlots()[0].x[4] == Catch::Approx(4)); + REQUIRE(std::isnan(plot_out.GetPlots()[0].y[4])); + REQUIRE(plot_out.GetPlots()[0].x[5] == Catch::Approx(5)); + REQUIRE(plot_out.GetPlots()[0].y[5] == Catch::Approx(11)); } TEST_CASE("StatusMultiVector","[StatusMultiVector]") { @@ -310,9 +317,16 @@ TEST_CASE("StatusVector_Clear","[StatusVector]") { auto plot = status_vector.GetMeanPlot(1, 0.0, 1.0); REQUIRE(plot.GetPlots().size() == 1); - REQUIRE(plot.GetPlots()[0].x.size() == 2); - REQUIRE(plot.GetPlots()[0].x[0] == 50); - REQUIRE(plot.GetPlots()[0].x[1] == 80); + REQUIRE(plot.GetPlots()[0].x.size() == 81); + REQUIRE(plot.GetPlots()[0].y.size() == 81); + REQUIRE(plot.GetPlots()[0].x[5] == 5); + REQUIRE(plot.GetPlots()[0].x[8] == 8); + REQUIRE(std::isnan(plot.GetPlots()[0].y[5])); + REQUIRE(std::isnan(plot.GetPlots()[0].y[8])); + REQUIRE(plot.GetPlots()[0].x[50] == 50); + REQUIRE(plot.GetPlots()[0].x[80] == 80); + REQUIRE(plot.GetPlots()[0].y[50] == 200); + REQUIRE(plot.GetPlots()[0].y[80] == 100); } TEST_CASE("StatusVector_GetElement","[StatusVector]") {