25 #ifndef WDATASETTIMESERIES_H
26 #define WDATASETTIMESERIES_H
34 #include "../common/WLimits.h"
35 #include "../common/WProperties.h"
36 #include "../common/WTransferable.h"
37 #include "WDataSetScalar.h"
58 typedef std::pair< std::shared_ptr< WDataSetScalar const >,
float >
TimeSlice;
66 std::string
const getName()
const;
88 WDataSetTimeSeries( std::vector< std::shared_ptr< WDataSetScalar const > > datasets, std::vector< float > times );
150 std::shared_ptr< WDataSetScalar const >
calcDataSetAtTime(
float time, std::string
const& name )
const;
160 template<
typename Data_T >
204 template<
typename Data_T >
259 template<
typename Data_T >
262 static const float inf = std::numeric_limits< float >::infinity();
263 WAssert( success,
"" );
269 throw WException( std::string(
"The provided time is not in the interval of this time series." ) );
273 if( lb == time || ub == time )
278 WAssert( lb != -inf && ub != inf,
"" );
281 WAssert( f && g,
"" );
282 float ml = ( ub - time ) / ( ub - lb );
283 float mu = ( time - lb ) / ( ub - lb );
288 template<
typename Data_T >
291 static const float inf = std::numeric_limits< float >::infinity();
292 WAssert( lb != -inf && ub != inf,
"" );
295 WAssert( f && g,
"" );
296 std::shared_ptr< WValueSet< Data_T > > vf = std::dynamic_pointer_cast< WValueSet< Data_T > >( f->getValueSet() );
297 std::shared_ptr< WValueSet< Data_T > > vg = std::dynamic_pointer_cast< WValueSet< Data_T > >( g->getValueSet() );
298 WAssert( vf && vg,
"" );
299 std::shared_ptr< std::vector< Data_T > > values(
new std::vector< Data_T >( vf->size() ) );
300 float ml = ( ub - time ) / ( ub - lb );
301 float mu = ( time - lb ) / ( ub - lb );
302 for( std::size_t k = 0; k < values->size(); ++k )
304 ( *values )[ k ] = ml * vf->getScalar( k ) + mu * vg->getScalar( k );
This data set type contains scalars as values.
double interpolate(const WPosition &pos, bool *success) const
Interpolate the value for the valueset at the given position.
Unit tests the time series class.
A compare functor for time slices.
bool operator()(TimeSlice const &t0, TimeSlice const &t1)
Compares the time of two time slices.
A dataset that stores a time series.
float getLBTimeSlice(float time) const
Find the largest time slice position that is smaller than or equal to time, or return -inf,...
static std::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
std::pair< std::shared_ptr< WDataSetScalar const >, float > TimeSlice
a time slice
std::vector< TimeSlice > m_dataSets
the datasets that compose the time series
float getMinTime() const
Get the first point of time in the time series.
float getMaxTime() const
Get the last point of time in the time series.
WDataSetTimeSeries()
Standard constructor.
float findNearestTimeSlice(float time) const
Find the nearest time slice for a given time.
std::shared_ptr< WDataSetScalar const > getDataSetPtrAtTimeSlice(float time) const
Get a pointer to the dataset at a given time or a NULL-pointer, if there was no dataset given for tha...
double getMaxValue()
Get the largest value in all datasets.
virtual ~WDataSetTimeSeries()
Destructor.
double getMinValue()
Get the smallest value in all datasets.
Data_T interpolate(WVector3d const &pos, float time, bool *success) const
Interpolate a value for a single point in space and time.
std::shared_ptr< WValueSetBase > calcInterpolatedValueSet(float lb, float ub, float time) const
Interpolate a valueset from two neighboring slices.
double m_minValue
the smallest value
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
WDataSetTimeSeries This
a conveniance typedef
std::shared_ptr< WDataSetScalar const > calcDataSetAtTime(float time, std::string const &name) const
Calculates a new dataset with values interpolated between the two nearest time slices.
std::string const getName() const
Returns a name.
std::string const getDescription() const
Returns a description.
double m_maxValue
the largest value
bool isTimeSlice(float time) const
Check if there exists a predefined dataset at the given point in time, i.e.
float getUBTimeSlice(float time) const
Find the smallest time slice position that is larger than time, or return inf, if there is no such ti...
Base class for all data set types.
Base Class for all value set types.
bool isNaN(T value)
Determines if a number is considered as NaN (aka Not a Number) or not.
An object that knows an appropriate dataType flag for the typename T.