From f0ba7296d546fe9d38bb5c6fb20ec0a2be0253e1 Mon Sep 17 00:00:00 2001 From: AdenKoperczak Date: Fri, 14 Mar 2025 11:09:43 -0400 Subject: [PATCH] use non-standard coordinates for tdwr and optimize there generation --- .../scwx/qt/manager/radar_product_manager.cpp | 15 +++++- .../scwx/qt/manager/radar_product_manager.hpp | 1 + .../scwx/qt/view/level3_radial_view.cpp | 50 +++++++++++++------ 3 files changed, 49 insertions(+), 17 deletions(-) diff --git a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp index 9768c9da..edafecf5 100644 --- a/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp +++ b/scwx-qt/source/scwx/qt/manager/radar_product_manager.cpp @@ -428,9 +428,16 @@ const scwx::util::time_zone* RadarProductManager::default_time_zone() const } } +bool RadarProductManager::is_tdwr() const +{ + return p->radarSite_->type() == "tdwr"; +} + float RadarProductManager::gate_size() const { - return (p->radarSite_->type() == "tdwr") ? 150.0f : 250.0f; + // tdwr is 150 meter per gate, wsr88d is 250 meter per gate + // NOLINTNEXTLINE(cppcoreguidelines-avoid-magic-numbers) + return (is_tdwr()) ? 150.0f : 250.0f; } std::string RadarProductManager::radar_id() const @@ -454,6 +461,12 @@ void RadarProductManager::Initialize() logger_->debug("Initialize()"); + if (is_tdwr()) + { + p->initialized_ = true; + return; + } + boost::timer::cpu_timer timer; // Calculate half degree azimuth coordinates diff --git a/scwx-qt/source/scwx/qt/manager/radar_product_manager.hpp b/scwx-qt/source/scwx/qt/manager/radar_product_manager.hpp index 3f4899ea..ee54f147 100644 --- a/scwx-qt/source/scwx/qt/manager/radar_product_manager.hpp +++ b/scwx-qt/source/scwx/qt/manager/radar_product_manager.hpp @@ -44,6 +44,7 @@ public: [[nodiscard]] const std::vector& coordinates(common::RadialSize radialSize, bool smoothingEnabled) const; [[nodiscard]] const scwx::util::time_zone* default_time_zone() const; + [[nodiscard]] bool is_tdwr() const; [[nodiscard]] float gate_size() const; [[nodiscard]] std::string radar_id() const; [[nodiscard]] std::shared_ptr radar_site() const; diff --git a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp index 135f5e65..29afba2d 100644 --- a/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp +++ b/scwx-qt/source/scwx/qt/view/level3_radial_view.cpp @@ -45,7 +45,8 @@ public: void ComputeCoordinates( const std::shared_ptr& radialData, - bool smoothingEnabled); + bool smoothingEnabled, + float gateSize); [[nodiscard]] inline std::uint8_t RemapDataMoment(std::uint8_t dataMoment) const; @@ -269,17 +270,24 @@ void Level3RadialView::ComputeSweep() } common::RadialSize radialSize; - if (radials == common::MAX_0_5_DEGREE_RADIALS) + if (radarProductManager->is_tdwr()) { - radialSize = common::RadialSize::_0_5Degree; - } - else if (radials == common::MAX_1_DEGREE_RADIALS) - { - radialSize = common::RadialSize::_1Degree; + radialSize = common::RadialSize::NonStandard; } else { - radialSize = common::RadialSize::NonStandard; + if (radials == common::MAX_0_5_DEGREE_RADIALS) + { + radialSize = common::RadialSize::_0_5Degree; + } + else if (radials == common::MAX_1_DEGREE_RADIALS) + { + radialSize = common::RadialSize::_1Degree; + } + else + { + radialSize = common::RadialSize::NonStandard; + } } const std::vector& coordinates = @@ -323,11 +331,21 @@ void Level3RadialView::ComputeSweep() // Compute threshold at which to display an individual bin const uint16_t snrThreshold = descriptionBlock->threshold(); + // Compute gate interval + const std::uint16_t dataMomentInterval = + descriptionBlock->x_resolution_raw(); + + // Get the gate length in meters. Use dataMomentInterval for NonStandard to + // avoid generating >1 base gates per bin. + const float gateLength = radialSize == common::RadialSize::NonStandard ? + static_cast(dataMomentInterval) : + radarProductManager->gate_size(); + // Determine which radial to start at std::uint16_t startRadial; if (radialSize == common::RadialSize::NonStandard) { - p->ComputeCoordinates(radialData, smoothingEnabled); + p->ComputeCoordinates(radialData, smoothingEnabled, gateLength); startRadial = 0; } else @@ -337,15 +355,11 @@ void Level3RadialView::ComputeSweep() startRadial = std::lroundf(startAngle * radialMultiplier); } - // Compute gate interval - const std::uint16_t dataMomentInterval = - descriptionBlock->x_resolution_raw(); - // Compute gate size (number of base gates per bin) const std::uint16_t gateSize = std::max( 1, dataMomentInterval / - static_cast(radarProductManager->gate_size())); + static_cast(gateLength)); // Compute gate range [startGate, endGate) std::uint16_t startGate = 0; @@ -526,7 +540,8 @@ Level3RadialView::Impl::RemapDataMoment(std::uint8_t dataMoment) const void Level3RadialView::Impl::ComputeCoordinates( const std::shared_ptr& radialData, - bool smoothingEnabled) + bool smoothingEnabled, + float gateSize) { logger_->debug("ComputeCoordinates()"); @@ -537,7 +552,6 @@ void Level3RadialView::Impl::ComputeCoordinates( auto radarProductManager = self_->radar_product_manager(); auto radarSite = radarProductManager->radar_site(); - const float gateSize = radarProductManager->gate_size(); const double radarLatitude = radarSite->latitude(); const double radarLongitude = radarSite->longitude(); @@ -583,6 +597,10 @@ void Level3RadialView::Impl::ComputeCoordinates( const float range = (static_cast(gate) + gateRangeOffset) * gateSize; const std::size_t offset = static_cast(radialGate) * 2; + if (offset + 1 >= coordinates_.size()) + { + return; + } double latitude = 0.0; double longitude = 0.0;