Adding reflectivity declutter capability

This commit is contained in:
Dan Paulat 2021-11-14 00:25:17 -06:00
parent e58b1f5b57
commit 77ba92ce7f
7 changed files with 130 additions and 6 deletions

View file

@ -76,6 +76,7 @@ public:
std::vector<float> vertices_;
std::vector<uint8_t> dataMoments8_;
std::vector<uint16_t> dataMoments16_;
std::vector<uint8_t> cfpMoments_;
float latitude_;
float longitude_;
@ -151,6 +152,22 @@ std::tuple<const void*, size_t, size_t> Level2ProductView::GetMomentData() const
return std::tie(data, dataSize, componentSize);
}
std::tuple<const void*, size_t, size_t>
Level2ProductView::GetCfpMomentData() const
{
const void* data = nullptr;
size_t dataSize = 0;
size_t componentSize = 1;
if (p->cfpMoments_.size() > 0)
{
data = p->cfpMoments_.data();
dataSize = p->cfpMoments_.size() * sizeof(uint8_t);
}
return std::tie(data, dataSize, componentSize);
}
void Level2ProductView::LoadColorTable(
std::shared_ptr<common::ColorTable> colorTable)
{
@ -297,6 +314,7 @@ void Level2ProductView::ComputeSweep()
// Setup data moment vector
std::vector<uint8_t>& dataMoments8 = p->dataMoments8_;
std::vector<uint16_t>& dataMoments16 = p->dataMoments16_;
std::vector<uint8_t>& cfpMoments = p->cfpMoments_;
size_t mIndex = 0;
if (momentData0->data_word_size() == 8)
@ -314,6 +332,16 @@ void Level2ProductView::ComputeSweep()
dataMoments16.resize(radials * gates * VERTICES_PER_BIN);
}
if (p->dataBlockType_ == wsr88d::rda::DataBlockType::MomentRef)
{
cfpMoments.resize(radials * gates * VERTICES_PER_BIN);
}
else
{
cfpMoments.resize(0);
cfpMoments.shrink_to_fit();
}
// Compute threshold at which to display an individual bin
const float scale = momentData0->scale();
const float offset = momentData0->offset();
@ -361,6 +389,7 @@ void Level2ProductView::ComputeSweep()
const uint8_t* dataMomentsArray8 = nullptr;
const uint16_t* dataMomentsArray16 = nullptr;
const uint8_t* cfpMomentsArray = nullptr;
if (momentData->data_word_size() == 8)
{
@ -373,6 +402,13 @@ void Level2ProductView::ComputeSweep()
reinterpret_cast<const uint16_t*>(momentData->data_moments());
}
if (cfpMoments.size() > 0)
{
cfpMomentsArray = reinterpret_cast<const uint8_t*>(
radialData->moment_data_block(wsr88d::rda::DataBlockType::MomentCfp)
->data_moments());
}
for (uint16_t gate = startGate, i = 0; gate + gateSize <= endGate;
gate += gateSize, ++i)
{
@ -390,6 +426,11 @@ void Level2ProductView::ComputeSweep()
for (size_t m = 0; m < vertexCount; m++)
{
dataMoments8[mIndex++] = dataMomentsArray8[i];
if (cfpMomentsArray != nullptr)
{
cfpMoments[mIndex - 1] = cfpMomentsArray[i];
}
}
}
else
@ -481,6 +522,11 @@ void Level2ProductView::ComputeSweep()
dataMoments16.resize(mIndex);
}
if (cfpMoments.size() > 0)
{
cfpMoments.resize(mIndex);
}
timer.stop();
BOOST_LOG_TRIVIAL(debug)
<< logPrefix_ << "Vertices calculated in " << timer.format(6, "%ws");

View file

@ -36,6 +36,7 @@ public:
void LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) override;
std::tuple<const void*, size_t, size_t> GetMomentData() const override;
std::tuple<const void*, size_t, size_t> GetCfpMomentData() const override;
static std::shared_ptr<Level2ProductView>
Create(common::Level2Product product,

View file

@ -50,6 +50,16 @@ void RadarProductView::Initialize()
ComputeSweep();
}
std::tuple<const void*, size_t, size_t>
RadarProductView::GetCfpMomentData() const
{
const void* data = nullptr;
size_t dataSize = 0;
size_t componentSize = 0;
return std::tie(data, dataSize, componentSize);
}
void RadarProductView::ComputeSweep()
{
BOOST_LOG_TRIVIAL(debug) << logPrefix_ << "ComputeSweep()";

View file

@ -35,6 +35,7 @@ public:
LoadColorTable(std::shared_ptr<common::ColorTable> colorTable) = 0;
virtual std::tuple<const void*, size_t, size_t> GetMomentData() const = 0;
virtual std::tuple<const void*, size_t, size_t> GetCfpMomentData() const;
protected:
virtual void UpdateColorTable() = 0;