Use parallel std::find_if to find radial at azimuth

This commit is contained in:
Dan Paulat 2024-01-02 23:23:59 -06:00
parent 20191dce07
commit b67f546774

View file

@ -556,33 +556,38 @@ Level3RadialView::GetBinLevel(const common::Coordinate& coordinate) const
// Find Radial // Find Radial
const std::uint16_t numRadials = radialData->number_of_radials(); const std::uint16_t numRadials = radialData->number_of_radials();
std::uint16_t radial = numRadials; auto radials = boost::irange<std::uint32_t>(0u, numRadials);
double nextAngle = radialData->start_angle(0);
for (std::uint16_t i = 0; i < numRadials; ++i)
{
double startAngle = nextAngle;
nextAngle = radialData->start_angle((i + 1) % numRadials);
if (startAngle < nextAngle) auto radial = std::find_if( //
std::execution::par_unseq,
radials.begin(),
radials.end(),
[&](std::uint32_t i)
{ {
if (startAngle <= azi1 && azi1 < nextAngle) bool found = false;
{ double startAngle = radialData->start_angle(i);
radial = i; double nextAngle = radialData->start_angle((i + 1) % numRadials);
break;
}
}
else
{
// If the bin crosses 0/360 degrees, special handling is needed
if (startAngle <= azi1 || azi1 < nextAngle)
{
radial = i;
break;
}
}
}
if (radial == numRadials) if (startAngle < nextAngle)
{
if (startAngle <= azi1 && azi1 < nextAngle)
{
found = true;
}
}
else
{
// If the bin crosses 0/360 degrees, special handling is needed
if (startAngle <= azi1 || azi1 < nextAngle)
{
found = true;
}
}
return found;
});
if (radial == radials.end())
{ {
// No radial was found (not likely to happen without a gap in data) // No radial was found (not likely to happen without a gap in data)
return std::nullopt; return std::nullopt;
@ -590,7 +595,7 @@ Level3RadialView::GetBinLevel(const common::Coordinate& coordinate) const
// Compute threshold at which to display an individual bin // Compute threshold at which to display an individual bin
const std::uint16_t snrThreshold = descriptionBlock->threshold(); const std::uint16_t snrThreshold = descriptionBlock->threshold();
const std::uint8_t level = radialData->level(radial).at(gate); const std::uint8_t level = radialData->level(*radial).at(gate);
if (level < snrThreshold && level != RANGE_FOLDED) if (level < snrThreshold && level != RANGE_FOLDED)
{ {