Commit 3515d38f authored by Jean-Benoist Leger's avatar Jean-Benoist Leger

changing imputation strategy for missing value on elevation

parent 41a4d999
......@@ -142,10 +142,11 @@ int main(int argc, char** argv)
unsigned int iter = 0;
unsigned int old_missing_data_size = missing_data.size();
unsigned int threshold = 8;
while(missing_data.size()!=0)
{
iter++;
fprintf(stderr, "Pass %i... ",iter);
fprintf(stderr, "Pass %i, threshold %u... ",iter, threshold);
std::list< std::pair< std::pair<int32_t,int32_t>, elevation_value> > new_data;
......@@ -166,36 +167,37 @@ int main(int argc, char** argv)
int32_t lat_s_n = lat_s + 3;
elevation_value *pneiW, *pneiE, *pneiS, *pneiN;
elevation_value *pneiNW, *pneiSW, *pneiNE, *pneiSE;
pneiE = db.grid_point(lon_s_e, lat_s);
pneiW = db.grid_point(lon_s_w, lat_s);
pneiS = db.grid_point(lon_s, lat_s_s);
pneiN = db.grid_point(lon_s, lat_s_n);
if( !(!pneiN) + !(!pneiS) + !(!pneiW) + !(!pneiE) >= 2)
pneiNW = db.grid_point(lon_s_w, lat_s_n);
pneiSW = db.grid_point(lon_s_w, lat_s_s);
pneiNE = db.grid_point(lon_s_e, lat_s_n);
pneiSE = db.grid_point(lon_s_e, lat_s_s);
unsigned int n = !(!pneiN) + !(!pneiS) + !(!pneiW) + !(!pneiE) + !(!pneiNW) + !(!pneiSW) + !(!pneiNE) + !(!pneiSE);
if( n >= threshold)
{
elevation_value sum = 0;
int n=0;
if(pneiE)
{
sum += *pneiE;
n += 1;
}
if(pneiW)
{
sum += *pneiW;
n += 1;
}
if(pneiS)
{
sum += *pneiS;
n += 1;
}
if(pneiN)
{
sum += *pneiN;
n += 1;
}
if(pneiNW)
sum += *pneiNW;
if(pneiSW)
sum += *pneiSW;
if(pneiNE)
sum += *pneiNE;
if(pneiSE)
sum += *pneiSE;
elevation_value elev = sum/n;
new_data.push_back(std::pair< std::pair<int32_t,int32_t>, elevation_value>( *missing_data_it, elev));
......@@ -227,12 +229,17 @@ int main(int argc, char** argv)
fprintf(stderr,"Length of missing data: %lu\n",missing_data.size());
if(old_missing_data_size == missing_data.size())
{
fprintf(stderr,"Erreur\n");
for(std::list<std::pair<int32_t,int32_t> >::iterator m = missing_data.begin();m!=missing_data.end();m++)
if(threshold>1)
threshold--;
else
{
fprintf(stderr,"%u\t%u\n",m->first,m->second);
fprintf(stderr,"Erreur\n");
for(std::list<std::pair<int32_t,int32_t> >::iterator m = missing_data.begin();m!=missing_data.end();m++)
{
fprintf(stderr,"%u\t%u\n",m->first,m->second);
}
abort();
}
abort();
}
old_missing_data_size = missing_data.size();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment