25 #ifndef WDATASETTIMESERIES_H
26 #define WDATASETTIMESERIES_H
34 #include <boost/enable_shared_from_this.hpp>
37 #include <boost/shared_ptr.hpp>
40 #include "../common/WLimits.h"
41 #include "../common/WProperties.h"
42 #include "../common/WTransferable.h"
43 #include "WDataSetScalar.h"
64 typedef std::pair< boost::shared_ptr< WDataSetScalar const >,
float >
TimeSlice;
72 std::string
const getName()
const;
94 WDataSetTimeSeries( std::vector< boost::shared_ptr< WDataSetScalar const > > datasets, std::vector< float > times );
156 boost::shared_ptr< WDataSetScalar const >
calcDataSetAtTime(
float time, std::string
const& name )
const;
166 template<
typename Data_T >
210 template<
typename Data_T >
231 bool operator() ( TimeSlice
const& t0, TimeSlice
const& t1 );
240 bool operator() (
float const& t0, TimeSlice
const& t1 );
249 bool operator() ( TimeSlice
const& t0,
float const& t1 );
265 template<
typename Data_T >
268 static const float inf = std::numeric_limits< float >::infinity();
269 WAssert( success,
"" );
275 throw WException( std::string(
"The provided time is not in the interval of this time series." ) );
279 if( lb == time || ub == time )
284 WAssert( lb != -inf && ub != inf,
"" );
287 WAssert( f && g,
"" );
288 float ml = ( ub - time ) / ( ub - lb );
289 float mu = ( time - lb ) / ( ub - lb );
294 template<
typename Data_T >
297 static const float inf = std::numeric_limits< float >::infinity();
298 WAssert( lb != -inf && ub != inf,
"" );
301 WAssert( f && g,
"" );
302 boost::shared_ptr< WValueSet< Data_T > > vf = boost::dynamic_pointer_cast<
WValueSet< Data_T > >( f->getValueSet() );
303 boost::shared_ptr< WValueSet< Data_T > > vg = boost::dynamic_pointer_cast<
WValueSet< Data_T > >( g->getValueSet() );
304 WAssert( vf && vg,
"" );
305 boost::shared_ptr< std::vector< Data_T > > values(
new std::vector< Data_T >( vf->size() ) );
306 float ml = ( ub - time ) / ( ub - lb );
307 float mu = ( time - lb ) / ( ub - lb );
308 for( std::size_t k = 0; k < values->size(); ++k )
310 ( *values )[ k ] = ml * vf->getScalar( k ) + mu * vg->getScalar( k );
325 #endif // WDATASETTIMESERIES_H
double m_maxValue
the largest value
std::string const getName() const
Returns a name.
A dataset that stores a time series.
boost::shared_ptr< WValueSetBase > calcInterpolatedValueSet(float lb, float ub, float time) const
Interpolate a valueset from two neighboring slices.
std::pair< boost::shared_ptr< WDataSetScalar const >, float > TimeSlice
a time slice
Base class for all data set types.
double interpolate(const WPosition &pos, bool *success) const
Interpolate the value fo the valueset at the given position.
double m_minValue
the smallest value
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...
static boost::shared_ptr< WPrototyped > m_prototype
The prototype as singleton.
virtual ~WDataSetTimeSeries()
Destructor.
float getLBTimeSlice(float time) const
Find the largest time slice position that is smaller than or equal to time, or return -inf...
std::string const getDescription() const
Returns a description.
boost::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...
An object that knows an appropriate dataType flag for the typename T.
double getMaxValue()
Get the largest value in all datasets.
static boost::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
double getMinValue()
Get the smallest value in all datasets.
bool operator()(TimeSlice const &t0, TimeSlice const &t1)
Compares the time of two time slices.
float findNearestTimeSlice(float time) const
Find the nearest time slice for a given time.
Unit tests the time series class.
A compare functor for time slices.
bool isNaN(T value)
Determines if a number is considered as NaN (aka Not a Number) or not.
WDataSetTimeSeries This
a conveniance typedef
WDataSetTimeSeries()
Standard constructor.
Base Class for all value set types.
bool isTimeSlice(float time) const
Check if there exists a predefined dataset at the given point in time, i.e.
std::vector< TimeSlice > m_dataSets
the datasets that compose the time series
This data set type contains scalars as values.
float getMaxTime() const
Get the last point of time in the time series.
Data_T interpolate(WVector3d const &pos, float time, bool *success) const
Interpolate a value for a single point in space and time.
boost::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.
float getMinTime() const
Get the first point of time in the time series.