Commit 56194900 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Bugfix in filter_fir with NaN values

parent 9243b6a7
......@@ -665,9 +665,6 @@ int data_obs::filter_fir_sym(std::vector <data_obs*>* data,
int data_obs::filter_fir_sym_data(std::vector <data_obs*>* data,
std::vector <double>* win){
// [TRE] Added temperature as one of the values being filtered
// Sum of data
double sum[N_data]={0};
// Filtered values
double filtered[N_data]={0};
// Missing data
......@@ -711,7 +708,6 @@ int data_obs::filter_fir_sym_data(std::vector <data_obs*>* data,
<< std::endl;
// Calculate filtered data
} else {
sum[j] += (data_in[j]);
filtered[j] += (data_in[j])*(win->at(i));
}
}
......@@ -725,6 +721,8 @@ int data_obs::filter_fir_sym_data(std::vector <data_obs*>* data,
// set to missing.
if (missing_N[j] == N){
this->data[j]=MD;
} else if (missing_N[j] == 0) {
this->data[j]=filtered[j];
} else {
timestamp=this->get_time("%Y-%m-%d %H:%M:%S",true);
std::cerr << "[" << timestamp << "]: ";
......@@ -742,21 +740,14 @@ int data_obs::filter_fir_sym_data(std::vector <data_obs*>* data,
int data_obs::filter_fir_sym_supp(std::vector <data_obs*>* data,
std::vector <double>* win){
// [TRE] Added temperature as one of the values being filtered
// Sum of data
double sum[N_supp]={0};
// Filtered values
double filtered[N_supp]={0};
// Missing data
double missing[N_supp]={0};
// Number of missing data
int missing_N[N_supp]={0};
// Number of data
int N[N_supp]={0};
double data_in[N_supp];
// Number of data
int N=data->size();
if (data->size() != win->size()){
std::cerr << "Number of elements in data and win"
"must match !" << std::endl;
......@@ -771,28 +762,24 @@ int data_obs::filter_fir_sym_supp(std::vector <data_obs*>* data,
for (int j=0; j<N_supp; j++){
// Look for missing data
if (data_in[j] == MD) {
missing[j]+=win->at(i);
missing_N[j]++;
// Calculate filtered data
} else {
sum[j] += (data_in[j]);
filtered[j] += (data_in[j])*(win->at(i));
if (data_in[j] != MD) {
N[j]++;
sum[j] += data_in[j];
}
}
}
// Simple average for T1 and T2
// Simple average for supplementary channels
for (int j=0; j<N_supp;j++){
// Set to missing when all missing
// TODO Define percentage of missing data here, in order to
// set to missing.
if (missing_N[j] == N){
if (N[j] == 0){
this->supp[j]=MD;
} else {
this->supp[j]=sum[j]/(N-missing_N[j]);
this->supp[j]=sum[j]/(N[j]);
}
}
......
Supports Markdown
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