31 #include "../common/WAssert.h"
32 #include "../common/WLimits.h"
33 #include "WDataSetTimeSeries.h"
39 std::vector< float > times )
42 WAssert( !datasets.empty(),
"" );
43 WAssert( datasets.size() == times.size(),
"" );
44 std::vector< std::shared_ptr< WDataSetScalar const > >::iterator dit;
45 std::vector< float >::iterator tit;
46 std::shared_ptr< WGridRegular3D > g = std::dynamic_pointer_cast< WGridRegular3D >( datasets.front()->getGrid() );
48 dataType d = datasets.front()->getValueSet()->getDataType();
51 for( dit = datasets.begin(), tit = times.begin(); dit != datasets.end() && tit != times.end(); ++dit, ++tit )
54 WAssert( g == std::dynamic_pointer_cast< WGridRegular3D >( ( *dit )->getGrid() ),
"" );
56 WAssert( d == ( *dit )->getValueSet()->getDataType(),
"" );
57 WAssert( ( *dit )->getValueSet()->dimension() == 1,
"" );
58 WAssert( ( *dit )->getValueSet()->order() == 0,
"" );
70 for( std::size_t k = 1; k <
m_dataSets.size(); ++k )
74 throw WException( std::string(
"There are multiple time slices at the same point in time!" ) );
85 return std::string(
"WDataSetTimeSeries" );
90 return std::string(
"A time series." );
106 return f !=
m_dataSets.end() && f->second == time;
118 return time - lb <= ub - time ? lb : ub;
124 if( f !=
m_dataSets.end() && f->second == time )
128 return std::shared_ptr< WDataSetScalar const >();
136 return std::shared_ptr< WDataSetScalar const >();
140 if( lb == time || ub == time )
146 std::shared_ptr< WValueSetBase > vs;
147 switch(
m_dataSets.front().first->getValueSet()->getDataType() )
150 vs = calcInterpolatedValueSet< uint8_t >( lb, ub, time );
153 vs = calcInterpolatedValueSet< int8_t >( lb, ub, time );
156 vs = calcInterpolatedValueSet< uint16_t >( lb, ub, time );
159 vs = calcInterpolatedValueSet< int16_t >( lb, ub, time );
162 vs = calcInterpolatedValueSet< uint32_t >( lb, ub, time );
164 case W_DT_SIGNED_INT:
165 vs = calcInterpolatedValueSet< int32_t >( lb, ub, time );
168 vs = calcInterpolatedValueSet< uint64_t >( lb, ub, time );
171 vs = calcInterpolatedValueSet< int64_t >( lb, ub, time );
174 vs = calcInterpolatedValueSet< float >( lb, ub, time );
177 vs = calcInterpolatedValueSet< double >( lb, ub, time );
180 throw WException( std::string(
"Unsupported datatype in WDataSetTimeSeries::calcDataSetAtTime()" ) );
184 ds->setFilename( name );
190 return t0.second < t1.second;
195 return t0 < t1.second;
200 return t0.second < t1;
206 float t = -std::numeric_limits< float >::infinity();
207 if( f !=
m_dataSets.end() && f->second == time )
222 float t = std::numeric_limits< float >::infinity();
This data set type contains scalars as values.
A compare functor for time slices.
bool operator()(TimeSlice const &t0, TimeSlice const &t1)
Compares the time of two time slices.
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.
double m_minValue
the smallest value
static std::shared_ptr< WPrototyped > getPrototype()
Returns a prototype instantiated with the true type of the deriving class.
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...
dataType
Data types and number values taken from the nifti1.h, at this point it's unknown if it makes sense to...
bool isNaN(T value)
Determines if a number is considered as NaN (aka Not a Number) or not.