OpenWalnut  1.4.0
Classes | Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends
WDataSetTimeSeries Class Reference

A dataset that stores a time series. More...

#include <WDataSetTimeSeries.h>

+ Inheritance diagram for WDataSetTimeSeries:

List of all members.

Classes

class  TimeSliceCompare
 A compare functor for time slices. More...

Public Member Functions

std::string const getName () const
 Returns a name.
std::string const getDescription () const
 Returns a description.
 WDataSetTimeSeries (std::vector< boost::shared_ptr< WDataSetScalar const > > datasets, std::vector< float > times)
 Construct time series from multiple 3D datasets.
virtual ~WDataSetTimeSeries ()
 Destructor.
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.
bool isTimeSlice (float time) const
 Check if there exists a predefined dataset at the given point in time, i.e.
float findNearestTimeSlice (float time) const
 Find the nearest time slice for a given time.
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 that point in 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.
template<typename Data_T >
Data_T interpolate (WVector3d const &pos, float time, bool *success) const
 Interpolate a value for a single point in space and time.
double getMinValue ()
 Get the smallest value in all datasets.
double getMaxValue ()
 Get the largest value in all datasets.

Static Public Member Functions

static boost::shared_ptr
< WPrototyped
getPrototype ()
 Returns a prototype instantiated with the true type of the deriving class.

Private Types

typedef WDataSetTimeSeries This
 a conveniance typedef
typedef std::pair
< boost::shared_ptr
< WDataSetScalar const >
, float > 
TimeSlice
 a time slice

Private Member Functions

float getLBTimeSlice (float time) const
 Find the largest time slice position that is smaller than or equal to time, or return -inf, if there is no such time slice.
float getUBTimeSlice (float time) const
 Find the smallest time slice position that is larger than time, or return inf, if there is no such time slice.
template<typename Data_T >
boost::shared_ptr< WValueSetBasecalcInterpolatedValueSet (float lb, float ub, float time) const
 Interpolate a valueset from two neighboring slices.
 WDataSetTimeSeries ()
 Standard constructor.

Private Attributes

std::vector< TimeSlicem_dataSets
 the datasets that compose the time series
double m_minValue
 the smallest value
double m_maxValue
 the largest value

Static Private Attributes

static boost::shared_ptr
< WPrototyped
m_prototype = boost::shared_ptr< WPrototyped >()
 The prototype as singleton.

Friends

class WDataSetTimeSeriesTest
 the test is a friend

Detailed Description

A dataset that stores a time series.

Notes:
Only works for scalar datasets at the moment!
Notes:
this is only a temporary solution

Definition at line 51 of file WDataSetTimeSeries.h.


Member Typedef Documentation

a conveniance typedef

Definition at line 57 of file WDataSetTimeSeries.h.

typedef std::pair< boost::shared_ptr< WDataSetScalar const >, float > WDataSetTimeSeries::TimeSlice [private]

a time slice

Definition at line 60 of file WDataSetTimeSeries.h.


Constructor & Destructor Documentation

WDataSetTimeSeries::WDataSetTimeSeries ( std::vector< boost::shared_ptr< WDataSetScalar const > >  datasets,
std::vector< float >  times 
)

Construct time series from multiple 3D datasets.

They do not have to be sorted by time.

Parameters:
datasetsA list of datasets to add.
timesA list of times for the datasets.

Definition at line 37 of file WDataSetTimeSeries.cpp.

References wlimits::isNaN(), m_dataSets, m_maxValue, and m_minValue.

Destructor.

Definition at line 78 of file WDataSetTimeSeries.cpp.

Standard constructor.

Definition at line 229 of file WDataSetTimeSeries.cpp.

Referenced by getPrototype().


Member Function Documentation

boost::shared_ptr< WDataSetScalar const > WDataSetTimeSeries::calcDataSetAtTime ( float  time,
std::string const &  name 
) const

Calculates a new dataset with values interpolated between the two nearest time slices.

if the time is not in the interval [getMinTime(),getMaxTime()], a NULL-pointer will be returned.

Parameters:
timeThe time.
nameThe name of the new dataset.
Returns:
A new interpolated dataset.

Definition at line 130 of file WDataSetTimeSeries.cpp.

References getDataSetPtrAtTimeSlice(), getLBTimeSlice(), getMaxTime(), getMinTime(), getUBTimeSlice(), wlimits::isNaN(), and m_dataSets.

Referenced by WDataSetTimeSeriesTest::testInterpolatedDataSets().

template<typename Data_T >
boost::shared_ptr< WValueSetBase > WDataSetTimeSeries::calcInterpolatedValueSet ( float  lb,
float  ub,
float  time 
) const [private]

Interpolate a valueset from two neighboring slices.

Parameters:
lbTime of one slice.
ubTime of the other slice.
timeThe actual time of the interpolated slice.
Returns:
A valueset with linearly interpolated values.

Definition at line 291 of file WDataSetTimeSeries.h.

References getDataSetPtrAtTimeSlice().

float WDataSetTimeSeries::findNearestTimeSlice ( float  time) const

Find the nearest time slice for a given time.

If there are two nearest time slices, the smaller one will be returned.

Parameters:
timeThe time.
Returns:
The nearest time slice.

Definition at line 108 of file WDataSetTimeSeries.cpp.

References getLBTimeSlice(), getMaxTime(), getUBTimeSlice(), and wlimits::isNaN().

Referenced by WDataSetTimeSeriesTest::testGetNearestTimeSlice().

boost::shared_ptr< WDataSetScalar const > WDataSetTimeSeries::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 that point in time.

Notes:
You need to provide the exact time.
Parameters:
timeThe time.
Returns:
A pointer to the appropriate dataset or a NULL-pointer.

Definition at line 120 of file WDataSetTimeSeries.cpp.

References m_dataSets.

Referenced by calcDataSetAtTime(), calcInterpolatedValueSet(), interpolate(), and WDataSetTimeSeriesTest::testGetDataSetPtrAtTimeSlice().

std::string const WDataSetTimeSeries::getDescription ( ) const [virtual]

Returns a description.

Returns:
A description.

Reimplemented from WDataSet.

Definition at line 87 of file WDataSetTimeSeries.cpp.

float WDataSetTimeSeries::getLBTimeSlice ( float  time) const [private]

Find the largest time slice position that is smaller than or equal to time, or return -inf, if there is no such time slice.

Parameters:
timeThe time.
Returns:
The largest time slice that is smaller than or equal to time or -inf.

Definition at line 202 of file WDataSetTimeSeries.cpp.

References m_dataSets.

Referenced by calcDataSetAtTime(), findNearestTimeSlice(), interpolate(), and WDataSetTimeSeriesTest::testLBTime().

float WDataSetTimeSeries::getMaxTime ( ) const [inline]

Get the last point of time in the time series.

Returns:
The last point of time.

Definition at line 316 of file WDataSetTimeSeries.h.

References m_dataSets.

Referenced by calcDataSetAtTime(), findNearestTimeSlice(), interpolate(), and WDataSetTimeSeriesTest::testTimeMinMax().

Get the largest value in all datasets.

Returns:
The largest value.

Definition at line 239 of file WDataSetTimeSeries.cpp.

References m_maxValue.

float WDataSetTimeSeries::getMinTime ( ) const [inline]

Get the first point of time in the time series.

Returns:
The first point of time.

Definition at line 311 of file WDataSetTimeSeries.h.

References m_dataSets.

Referenced by calcDataSetAtTime(), interpolate(), and WDataSetTimeSeriesTest::testTimeMinMax().

Get the smallest value in all datasets.

Returns:
The smallest value.

Definition at line 234 of file WDataSetTimeSeries.cpp.

References m_minValue.

std::string const WDataSetTimeSeries::getName ( ) const [virtual]

Returns a name.

Returns:
A name.

Reimplemented from WDataSet.

Definition at line 82 of file WDataSetTimeSeries.cpp.

boost::shared_ptr< WPrototyped > WDataSetTimeSeries::getPrototype ( ) [static]

Returns a prototype instantiated with the true type of the deriving class.

Returns:
the prototype.

Reimplemented from WDataSet.

Definition at line 92 of file WDataSetTimeSeries.cpp.

References m_prototype, and WDataSetTimeSeries().

float WDataSetTimeSeries::getUBTimeSlice ( float  time) const [private]

Find the smallest time slice position that is larger than time, or return inf, if there is no such time slice.

Parameters:
timeThe time.
Returns:
The largest time slice that is smaller than time or inf.

Definition at line 218 of file WDataSetTimeSeries.cpp.

References m_dataSets.

Referenced by calcDataSetAtTime(), findNearestTimeSlice(), interpolate(), and WDataSetTimeSeriesTest::testUBTime().

template<typename Data_T >
Data_T WDataSetTimeSeries::interpolate ( WVector3d const &  pos,
float  time,
bool *  success 
) const

Interpolate a value for a single point in space and time.

Parameters:
posThe spatial location.
timeThe temporal location.
[out]successA flag indicating if the position was in the dataset.
Returns:
The value at the given location.

Definition at line 262 of file WDataSetTimeSeries.h.

References getDataSetPtrAtTimeSlice(), getLBTimeSlice(), getMaxTime(), getMinTime(), getUBTimeSlice(), WDataSetScalar::interpolate(), and wlimits::isNaN().

Referenced by WDataSetTimeSeriesTest::testInterpolate().

bool WDataSetTimeSeries::isTimeSlice ( float  time) const

Check if there exists a predefined dataset at the given point in time, i.e.

no interpolation has to be done to access data at that point in time.

If the time is not in the represented interval [getMinTime(),getMaxTime()], it will return false.

Parameters:
timeThe point in time to test.
Returns:
true, iff the time is one of those that were given in the constructor.

Definition at line 102 of file WDataSetTimeSeries.cpp.

References m_dataSets.

Referenced by WDataSetTimeSeriesTest::testIsTimeSlice().


Friends And Related Function Documentation

friend class WDataSetTimeSeriesTest [friend]

the test is a friend

Definition at line 54 of file WDataSetTimeSeries.h.


Member Data Documentation

std::vector< TimeSlice > WDataSetTimeSeries::m_dataSets [private]

the largest value

Definition at line 258 of file WDataSetTimeSeries.h.

Referenced by getMaxValue(), and WDataSetTimeSeries().

the smallest value

Definition at line 255 of file WDataSetTimeSeries.h.

Referenced by getMinValue(), and WDataSetTimeSeries().

boost::shared_ptr< WPrototyped > WDataSetTimeSeries::m_prototype = boost::shared_ptr< WPrototyped >() [static, private]

The prototype as singleton.

Reimplemented from WDataSet.

Definition at line 252 of file WDataSetTimeSeries.h.

Referenced by getPrototype().


The documentation for this class was generated from the following files: