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