Skip to content
Snippets Groups Projects
Commit 47e1cd97 authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

remap_distwgt_weights(): replaced knnWgt.m_mask[i] by numWeights

parent 1be1dc51
No related branches found
No related tags found
1 merge request!281M214003/develop
......@@ -24,10 +24,10 @@ class knnWeightsType
private:
size_t m_maxNeighbors = 0;
KnnMethod m_method{ KnnMethod::distanceWeighted };
std::vector<int8_t> m_mask; // mask at nearest neighbors
public:
size_t m_numNeighbors = 0;
std::vector<int8_t> m_mask; // mask at nearest neighbors
std::vector<size_t> m_indices; // source indices at nearest neighbors
std::vector<double> m_dist; // angular distance four nearest neighbors
std::vector<size_t> m_tmpIndices;
......@@ -149,7 +149,7 @@ public:
constexpr double eps = 1.e-14;
// If distance is zero, set to small number
for (size_t i = 0; i < m_numNeighbors; ++i)
if (m_indices[i] < SIZE_MAX && m_dist[i] <= 0.0) m_dist[i] = eps;
if (m_dist[i] <= 0.0) m_dist[i] = eps;
}
size_t
......@@ -216,7 +216,7 @@ public:
double distTotal = 0.0; // sum of neighbor distances (for normalizing)
for (size_t i = 0; i < m_maxNeighbors; ++i)
for (size_t i = 0; i < m_numNeighbors; ++i)
{
m_mask[i] = false;
if (gridMask[m_indices[i]])
......@@ -227,7 +227,7 @@ public:
}
}
return normalize_weights_mask(distTotal, m_maxNeighbors);
return normalize_weights_mask(distTotal, m_numNeighbors);
}
size_t
......
......@@ -70,8 +70,7 @@ remap_distwgt_weights(size_t numNeighbors, RemapSearch &rsearch, RemapVars &rv)
// Compute weights based on inverse distance if mask is false, eliminate those points
auto numWeights = knnWgt.compute_weights(srcGrid->mask);
for (size_t i = 0; i < numWeights; ++i)
if (knnWgt.m_mask[i]) tgtGrid->cellFrac[tgtCellIndex] = 1.0;
if (numWeights) tgtGrid->cellFrac[tgtCellIndex] = 1.0;
// Store the link
store_weightlinks(0, numWeights, knnWgt.m_indices.data(), knnWgt.m_dist.data(), tgtCellIndex, weightLinks);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment