25 #ifndef WDATASETTIMESERIES_H
26 #define WDATASETTIMESERIES_H
33 #include <boost/enable_shared_from_this.hpp>
34 #include <boost/shared_ptr.hpp>
36 #include "../common/WLimits.h"
37 #include "../common/WProperties.h"
38 #include "../common/WTransferable.h"
39 #include "WDataSetScalar.h"
60 typedef std::pair< boost::shared_ptr< WDataSetScalar const >,
float >
TimeSlice;
68 std::string
const getName()
const;
90 WDataSetTimeSeries( std::vector< boost::shared_ptr< WDataSetScalar const > > datasets, std::vector< float > times );
152 boost::shared_ptr< WDataSetScalar const >
calcDataSetAtTime(
float time, std::string
const& name )
const;
162 template<
typename Data_T >
206 template<
typename Data_T >
227 bool operator() ( TimeSlice
const& t0, TimeSlice
const& t1 );
236 bool operator() (
float const& t0, TimeSlice
const& t1 );
245 bool operator() ( TimeSlice
const& t0,
float const& t1 );
261 template<
typename Data_T >
264 static const float inf = std::numeric_limits< float >::infinity();
265 WAssert( success,
"" );
271 throw WException( std::string(
"The provided time is not in the interval of this time series." ) );
275 if( lb == time || ub == time )
280 WAssert( lb != -inf && ub != inf,
"" );
283 WAssert( f && g,
"" );
284 float ml = ( ub - time ) / ( ub - lb );
285 float mu = ( time - lb ) / ( ub - lb );
290 template<
typename Data_T >
293 static const float inf = std::numeric_limits< float >::infinity();
294 WAssert( lb != -inf && ub != inf,
"" );
297 WAssert( f && g,
"" );
298 boost::shared_ptr< WValueSet< Data_T > > vf = boost::dynamic_pointer_cast<
WValueSet< Data_T > >( f->getValueSet() );
299 boost::shared_ptr< WValueSet< Data_T > > vg = boost::dynamic_pointer_cast<
WValueSet< Data_T > >( g->getValueSet() );
300 WAssert( vf && vg,
"" );
301 boost::shared_ptr< std::vector< Data_T > > values(
new std::vector< Data_T >( vf->size() ) );
302 float ml = ( ub - time ) / ( ub - lb );
303 float mu = ( time - lb ) / ( ub - lb );
304 for( std::size_t k = 0; k < values->size(); ++k )
306 ( *values )[ k ] = ml * vf->getScalar( k ) + mu * vg->getScalar( k );
321 #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.