Commit 486e4d33 authored by Achim Morschhauser's avatar Achim Morschhauser
Browse files

Bugfix with channel numbering; use str.fail() to check conversion

parent 3eea255f
......@@ -331,7 +331,7 @@ int data_obs::get_data(std::vector<double>& values){
double data_obs::get_data(int channel){
if (channel <= N_data){
return(data[channel]);
return(data[channel-1]);
}
return(MD);
}
......@@ -339,7 +339,7 @@ double data_obs::get_data(int channel){
int data_obs::set_data(double value, int channel){
if (channel <= N_data){
data[channel] = value;
data[channel-1] = value;
return(0);
}
return(-1);
......@@ -380,7 +380,7 @@ int data_obs::get_supp(std::vector<double>& values){
double data_obs::get_supp(int channel){
if (channel <= N_supp){
return(supp[channel]);
return(supp[channel-1]);
}
return(MD);
}
......@@ -388,7 +388,7 @@ double data_obs::get_supp(int channel){
int data_obs::set_supp(double value, int channel){
if (channel <= N_supp){
supp[channel] = value;
supp[channel-1] = value;
return(0);
}
return(-1);
......@@ -525,18 +525,13 @@ int data_obs::parse(std::string* string) {
istringstream str(*string);
if (!(str >> year))
return (-1);
if (!(str >> mon))
return (-1);
if (!(str >> day))
return (-1);
if (!(str >> hour))
return (-1);
if (!(str >> min))
return (-1);
if (!(str >> secmsec))
return (-1);
str >> year;
str >> mon;
str >> day;
str >> hour;
str >> min;
str >> secmsec;
if (str.fail()) return(-1);
sec = (int) secmsec;
msec = (secmsec - sec) * 1e9;
......@@ -778,7 +773,7 @@ int data_obs::filter_fir_sym_supp(std::vector <data_obs*>* data,
// Simple average for T1 and T2
for (int j=1; j<N_supp;j++){
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.
......
......@@ -185,11 +185,13 @@ int data_obs_vector::parse(std::string* string) {
str.seekg(pos, str.beg);
for (int i=0; i<N_data; i++){
if (!(str >> data[i])); return (-1);
str >> data[i];
if (str.fail()) return(-1);
}
for (int i=0; i<N_supp; i++){
if (!(str >> supp[i])); return (-1);
str >> supp[i];
if (str.fail()) return(-1);
}
return (str.tellg());
......
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