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

Center filter on full second

parent 22ae1ef4
This diff is collapsed.
......@@ -223,9 +223,9 @@ int data_obs::get_min() {
int data_obs::get_sec() {
return (sec);
}
// Microseconds
long data_obs::get_msec() {
return (msec);
return(msec);
}
/********************************************************************************
......
......@@ -308,13 +308,13 @@ int data_obs_vector::filter_fir_sym(std::vector <data_obs*>* data,
std::vector <double>* win){
// Sum of data
double Xs=0.0,Ys=0.0,Zs=0.0;
double Xs=0.0,Ys=0.0,Zs=0.0,T1s=0.0,T2s=0.0;
// Filtered values
double Xf=0.0,Yf=0.0,Zf=0.0;
// Missing data
double Xm=0.0,Ym=0.0,Zm=0.0;
// Number of missing data
int XmN=0,YmN=0,ZmN=0;
int XmN=0,YmN=0,ZmN=0,T1mN=0,T2mN=0;
double tmp_f;
......@@ -323,11 +323,10 @@ int data_obs_vector::filter_fir_sym(std::vector <data_obs*>* data,
// 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;
return(-1);
std::cerr << "Number of elements in data and win"
"must match !" << std::endl;
return(-1);
}
......@@ -345,42 +344,45 @@ int data_obs_vector::filter_fir_sym(std::vector <data_obs*>* data,
// Filter the data
for (int i=0; i<data->size(); i++){
data_in = dynamic_cast <data_obs_vector*> (data->at(i));
/*
if (data.size()>200){
std::cerr << i << " "
<< X << " "
<< data_in->X << " "
<< win[i] << " "
<< std::endl;
}
*/
// Look for missing data
if ( (data_in->X) == MD) {
Xm+=win->at(i);
XmN++;
// Calculate filtered data
} else {
Xs+=(data_in->X);
Xf+=(data_in->X)*(win->at(i));
}
if ( (data_in->Y) == MD) {
Ym+=win->at(i);
YmN++;
} else {
Ys+=(data_in->Y);
Yf+=(data_in->Y)*(win->at(i));
}
if ( (data_in->Z) == MD) {
Zm+=win->at(i);
ZmN++;
} else {
Zs+=(data_in->Z);
Zf+=(data_in->Z)*(win->at(i));
}
data_in = dynamic_cast <data_obs_vector*> (data->at(i));
// Look for missing data
if ( (data_in->X) == MD) {
Xm+=win->at(i);
XmN++;
// Calculate filtered data
} else {
Xs+=(data_in->X);
Xf+=(data_in->X)*(win->at(i));
}
if ( (data_in->Y) == MD) {
Ym+=win->at(i);
YmN++;
} else {
Yf+=(data_in->Y)*(win->at(i));
Ys+=(data_in->Y);
}
if ( (data_in->Z) == MD) {
Zm+=win->at(i);
ZmN++;
} else {
Zs+=(data_in->Z);
Zf+=(data_in->Z)*(win->at(i));
}
// Simple average for temperatures
if ( (data_in->T1) == MD) {
T1mN++;
} else {
T1s++;
}
if ( (data_in->T2) == MD) {
T2mN++;
} else {
T2s++;
}
}
......@@ -388,6 +390,9 @@ int data_obs_vector::filter_fir_sym(std::vector <data_obs*>* data,
this->X=Xf+1/(N-XmN)*Xm*Xs;
this->Y=Yf+1/(N-YmN)*Ym*Ys;
this->Z=Zf+1/(N-ZmN)*Zm*Zs;
// Simple average for T1 and T2
this->T1=T1s/(N-T1mN);
this->T2=T2s/(N-T2mN);
return(0);
......
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