Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Seitosh
Seitosh
Commits
5828a100
Commit
5828a100
authored
Dec 30, 2018
by
thomas.forbriger
Browse files
libtsxx [WP][FEATURE]: provide function TimeSeriesCollection::overlap
parent
ea762cda
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/libs/libtsxx/tscollection.h
View file @
5828a100
...
...
@@ -80,6 +80,27 @@ namespace ts {
* of time series headers in the collection
*/
bool
are_consistent
(
const
::
sff
::
WID2compare
comparer
)
const
;
/*! \brief Check is all time series have a common time window
*
* Check whether all time series overlap in time. This is a necessary
* prerequisite for trimming all time series to a common time window.
*
* \return true, if time series overlap
*/
bool
overlap
()
const
;
/*! \brief Trim to same start time
*
* Check the consistency of the time series in the collections based on
* header data. For example this can be used to check whether all time
* series have the same number of samples.
*
* \param comparer defines the header fields to be compared
* \return true, if comparer returns true for comparison of all pairs
* of time series headers in the collection
*/
bool
trim_to_date
(
const
::
sff
::
WID2compare
comparer
)
const
;
};
// class TimeSeriesCollection
...
...
@@ -103,6 +124,36 @@ namespace ts {
return
(
retval
);
}
// bool TimeSeriesCollection<T>::are_consistent(const ::sff::WID2compare comparer) const
/* ---------------------------------------------------------------------- */
template
<
typename
T
>
bool
TimeSeriesCollection
<
T
>::
overlap
()
const
{
bool
retval
=
true
;
if
(
this
->
size
()
>
1
)
{
typename
Tbase
::
const_iterator
i_series
=
this
->
begin
();
Theader
header
=
i_series
->
header
;
libtime
::
TAbsoluteTime
begin
=
header
.
date
;
libtime
::
TRelativeTime
dt
=
libtime
::
double2time
(
header
.
dt
);
libtime
::
TAbsoluteTime
end
=
header
.
date
+
(
dt
*
(
header
.
nsamples
-
1
));
++
i_series
;
while
((
i_series
!=
this
->
end
())
&&
retval
)
{
header
=
i_series
->
header
;
libtime
::
TAbsoluteTime
thisbegin
=
header
.
date
;
libtime
::
TRelativeTime
thisdt
=
libtime
::
double2time
(
header
.
dt
);
libtime
::
TAbsoluteTime
thisend
=
header
.
date
+
(
thisdt
*
(
header
.
nsamples
-
1
));
begin
=
thisbegin
>
begin
?
thisbegin
:
begin
;
end
=
thisend
<
end
?
thisend
:
end
;
++
i_series
;
}
retval
=
(
end
>=
begin
);
}
return
(
retval
);
}
// bool TimeSeriesCollection<T>::overlap() const
}
// namespace ts
#endif // TS_TSCOLLECTION_H_VERSION (includeguard)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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