Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Achim Morschhauser
GeomagLogger
Commits
486e4d33
Commit
486e4d33
authored
Oct 26, 2020
by
Achim Morschhauser
Browse files
Bugfix with channel numbering; use str.fail() to check conversion
parent
3eea255f
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/data_obs.cpp
View file @
486e4d33
...
...
@@ -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.
...
...
src/data_obs_vector.cpp
View file @
486e4d33
...
...
@@ -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
());
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment