te::st::TimeSeries Class Reference

A class to represent time series. More...

#include <TimeSeries.h>

Public Member Functions

void add (te::dt::DateTime *time, te::dt::AbstractData *value)
 It adds an observation (time and attribute value) into the time series. More...
 
void add (te::dt::DateTime *time, double value)
 It adds an observation (time and attribute value as double) into the time series. More...
 
void add (te::dt::DateTime *time, int value)
 It adds an observation (time and attribute value as integer) into the time series. More...
 
void add (te::dt::DateTime *time, const std::string &value)
 It adds an observation (time and attribute value as string) into the time series. More...
 
void add (const TimeSeriesObservation &item)
 It adds an observation (time and attribute value) into the time series. More...
 
TimeSeriesclone () const
 It returns a clone of this time series. More...
 
double getDouble (te::dt::DateTime *t) const
 It returns the value as a double associated to a given date and time. More...
 
std::string getId () const
 It returns the time series identifier. More...
 
int getInt (te::dt::DateTime *t) const
 It returns the value as an integer associated to a given date and time. More...
 
AbstractTimeSeriesInterpgetInterpolator () const
 It returns the interpolator associated to the time series. More...
 
te::gm::GeometrygetLocation () const
 It returns the time series location. More...
 
const TimeSeriesObservationSetgetObservations () const
 It returns the time series observations. More...
 
std::string getString (te::dt::DateTime *t) const
 It returns the value as a string associated to a given date and time. More...
 
std::unique_ptr< te::dt::DateTimePeriodgetTemporalExtent () const
 It returns the temporal extent or range of the time series. More...
 
std::unique_ptr< te::dt::AbstractDatagetValue (te::dt::DateTime *t) const
 It returns the value associated to a given date and time. More...
 
void getValueExtent (double &minValue, double &maxValue)
 It returns the minimal and maximun values of the time series. More...
 
void getValueExtent (int &minValue, int &maxValue)
 It returns the minimal and maximun values of the time series. More...
 
void getValueExtent (std::string &minValue, std::string &maxValue)
 It returns the minimal and maximun values of the time series. More...
 
TimeSeriesoperator= (const TimeSeries &other)
 Copy assignment operator. More...
 
void setId (const std::string &id)
 It sets the time series identifier. More...
 
void setInterpolator (AbstractTimeSeriesInterp *interp)
 It sets the interpolator associated to the time series. More...
 
void setLocation (te::gm::Geometry *geom)
 It sets the time series location. More...
 
std::size_t size () const
 It returns the size of the time series observation set. More...
 
virtual ~TimeSeries ()
 It returns time series subsets that satisfy the given relations. More...
 
TimeSeries Constructors
 TimeSeries ()
 Empty constructor. More...
 
 TimeSeries (const std::string &id)
 Empty constructor. More...
 
 TimeSeries (AbstractTimeSeriesInterp *interp, const std::string &id)
 Empty constructor. More...
 
 TimeSeries (AbstractTimeSeriesInterp *interp, const std::string &id, te::gm::Geometry *geom)
 Empty constructor. More...
 
 TimeSeries (const TimeSeriesObservationSet &obs, AbstractTimeSeriesInterp *interp, const std::string &id, te::gm::Geometry *geom)
 Constructor. More...
 
 TimeSeries (const TimeSeriesPatch &patch, AbstractTimeSeriesInterp *interp, const std::string &id, te::gm::Geometry *geom)
 It constructs a time series from a patch. More...
 
 TimeSeries (const TimeSeries &ts)
 Copy constructor. More...
 
TimeSeries Iterator

An example of use:

TimeSeriesIterator it = tj.begin(); while(it!=tj.end()) { DateTime* t = it.getTime(); double v = it.getDouble(); //or getValue() or getInt()...
++it; }

TimeSeriesIterator begin () const
 It returns an iterator that points to the first observation of the time series. More...
 
TimeSeriesIterator end () const
 It returns an iterator that points to the end of the time series. More...
 
TimeSeriesIterator at (te::dt::DateTime *t) const
 It returns an iterator that points to an observation at a given time. More...
 
Time Series Patch

These methods return patches of a time series, as TimeSeriesPatch objects, that satisfy given restrictions. A TimeSeriesPatch object contains only pointers to the initial and final observations that delimit a patch of a TimeSeries. The end() method of a TimeSeriesPatch object returns an iterator that points to the position AFTER the last required observation.

Example of use:

TimeSeriesPatch patch = tj->getTimeSeries(period, "DURING"); TimeSeriesIterator it = patch.begin(); while(it!=patch.end()) { DateTime* t = it.getTime(); double v = it.getDouble(); //or getInt() or get Value() ++it; }

Other option is to create a new TimeSeries from the returned patch:

TimeSeriesPatch patch = tj->getTimeSeries(period, "DURING"); TimeSeries tsnew(patch);

TimeSeriesPatch getPatch (const te::dt::DateTime &dt, te::dt::TemporalRelation r=te::dt::DURING) const
 It returns a time series subset that satisfies a given temporal relation. More...
 
void getPatches (const double &v, te::dt::BasicRelation r, std::vector< TimeSeriesPatch > &result) const
 It returns time series subsets that satisfy a given relation. More...
 
void getPatches (const double &v, te::dt::BasicRelation r, const te::dt::DateTime &dt, te::dt::TemporalRelation tr, std::vector< TimeSeriesPatch > &result) const
 It returns time series subsets that satisfy a given relation. More...
 

Private Member Functions

void getResultOrderedByTime (const double &v, te::dt::BasicRelation r, std::map< te::dt::DateTime *, te::dt::AbstractData *, te::dt::CompareDateTime > &result) const
 It returns the result of a basic relation ordered by time. More...
 

Private Attributes

std::string m_id
 The time series identification. More...
 
AbstractTimeSeriesInterpm_interpolator
 The interpolator used to estimate values at non-observed times. More...
 
std::unique_ptr< te::gm::Geometrym_location
 The time series location. More...
 
TimeSeriesObservationSet m_observations
 The time series observations. More...
 

Detailed Description

A class to represent time series.

A time series represents a variation of a property over time, where this property is of a textual or numerical type (T -> A). It is composed of a set of observations and of an interpolator able to estimate values in non-observed times.

See also
ObservationSet AbstractInterpolator

Definition at line 66 of file TimeSeries.h.

Constructor & Destructor Documentation

◆ TimeSeries() [1/7]

te::st::TimeSeries::TimeSeries ( )

Empty constructor.

It constructs an empty time series. The user does not indicate the interpolator associated to it. Internally, it uses a default interpolator that is NearestValueAtTimeInterp.

◆ TimeSeries() [2/7]

te::st::TimeSeries::TimeSeries ( const std::string &  id)

Empty constructor.

It constructs an empty time series. The user does not indicate the interpolator associated to it. Internally, it uses a default interpolator that is NearestValueAtTimeInterp.

Parameters
idThe time series id

◆ TimeSeries() [3/7]

te::st::TimeSeries::TimeSeries ( AbstractTimeSeriesInterp interp,
const std::string &  id 
)

Empty constructor.

It constructs an empty trajectory.

Parameters
idThe time series id.
interpThe interpolator associated to the time series.

◆ TimeSeries() [4/7]

te::st::TimeSeries::TimeSeries ( AbstractTimeSeriesInterp interp,
const std::string &  id,
te::gm::Geometry geom 
)

Empty constructor.

It constructs an empty trajectory.

Parameters
interpThe interpolator associated to the time series.
idThe time series id.
geomThe time series location.
Note
It will take the ownership of the given geometry.

◆ TimeSeries() [5/7]

te::st::TimeSeries::TimeSeries ( const TimeSeriesObservationSet obs,
AbstractTimeSeriesInterp interp,
const std::string &  id,
te::gm::Geometry geom 
)

Constructor.

Parameters
obsThe time series observations.
interpThe interpolator associated to the time series.
idThe time series id.
geomThe time series location.
Note
It will take the ownership of the given geometry.

◆ TimeSeries() [6/7]

te::st::TimeSeries::TimeSeries ( const TimeSeriesPatch patch,
AbstractTimeSeriesInterp interp,
const std::string &  id,
te::gm::Geometry geom 
)

It constructs a time series from a patch.

Parameters
patchThe given patch.
interpThe interpolator
idThe time series id
geomThe time series location

◆ TimeSeries() [7/7]

te::st::TimeSeries::TimeSeries ( const TimeSeries ts)

Copy constructor.

Note
The built time series will share the internal pointers of "ts".
The caller has to use the method "clone" to have a deep copy.

◆ ~TimeSeries()

virtual te::st::TimeSeries::~TimeSeries ( )
virtual

It returns time series subsets that satisfy the given relations.

The possible basic relations are: LESS (1); MORE (2); EQUAL (4); LESS | EQUAL (5); MORE | EQUAL (6).

The possible temporal relations are: AFTER (2); AFTER | EQUALS (10); 3. BEFORE (1); 4. BEFORE | EQUALS (9); DURING (4); EQUALS (8) .

Parameters
v1A given first value.
r1A given relation associated to the first value.
v2A given second value.
r2A given relation associated to the second value.
dtA given date and time.
trA given temporal relation.
resultThe returned patches.
Note
When the temporal relation is DURING, dt must be a time period.

Virtual destructor.

Member Function Documentation

◆ add() [1/5]

void te::st::TimeSeries::add ( te::dt::DateTime time,
te::dt::AbstractData value 
)

It adds an observation (time and attribute value) into the time series.

Parameters
timeA pointer to the time.
dataA pointer to the attribute value.
Note
The caller will take the ownership of the returned pointer.

◆ add() [2/5]

void te::st::TimeSeries::add ( te::dt::DateTime time,
double  value 
)

It adds an observation (time and attribute value as double) into the time series.

Parameters
timeA pointer to the time.
dataA pointer to the attribute value as a double.
Note
The caller will take the ownership of the given pointer.

◆ add() [3/5]

void te::st::TimeSeries::add ( te::dt::DateTime time,
int  value 
)

It adds an observation (time and attribute value as integer) into the time series.

Parameters
timeA pointer to the time.
dataA pointer to the attribute value as a integer.
Note
The caller will take the ownership of the given pointer.

◆ add() [4/5]

void te::st::TimeSeries::add ( te::dt::DateTime time,
const std::string &  value 
)

It adds an observation (time and attribute value as string) into the time series.

Parameters
timeA pointer to the time.
dataA pointer to the attribute value as a string.
Note
The caller will take the ownership of the given pointer.

◆ add() [5/5]

void te::st::TimeSeries::add ( const TimeSeriesObservation item)

It adds an observation (time and attribute value) into the time series.

Parameters
itemA time series item.

◆ at()

TimeSeriesIterator te::st::TimeSeries::at ( te::dt::DateTime t) const

It returns an iterator that points to an observation at a given time.

If there is no observation at this given time, the returned iterator points to the end of the trajectory.

Returns
The time series iterator.
Note
This does not take the ownership of the given pointer.

◆ begin()

TimeSeriesIterator te::st::TimeSeries::begin ( ) const

It returns an iterator that points to the first observation of the time series.

Returns
The time series iterator.

◆ clone()

TimeSeries* te::st::TimeSeries::clone ( ) const

It returns a clone of this time series.

Returns
A new time series.
Note
The caller will take the ownership of the returned pointer.

◆ end()

TimeSeriesIterator te::st::TimeSeries::end ( ) const

It returns an iterator that points to the end of the time series.

Returns
The time series iterator.

◆ getDouble()

double te::st::TimeSeries::getDouble ( te::dt::DateTime t) const

It returns the value as a double associated to a given date and time.

If there is no value associated to the given date and time, it will use internally its interpolation function.

Parameters
tA date and time.
Returns
The value associated to the given date and time.

◆ getId()

std::string te::st::TimeSeries::getId ( ) const

It returns the time series identifier.

Returns
The time series identifier.

◆ getInt()

int te::st::TimeSeries::getInt ( te::dt::DateTime t) const

It returns the value as an integer associated to a given date and time.

If there is no value associated to the given date and time, it will use internally its interpolation function.

Parameters
tA date and time.
Returns
The value associated to the given date and time.

◆ getInterpolator()

AbstractTimeSeriesInterp* te::st::TimeSeries::getInterpolator ( ) const

It returns the interpolator associated to the time series.

Returns
A pointer the interpolator associated to the time series.
Note
The caller will NOT take the ownership of the returned pointer.
The AbstractTimeSeriesInterp points to a singleton.

◆ getLocation()

te::gm::Geometry* te::st::TimeSeries::getLocation ( ) const

It returns the time series location.

Returns
A pointer to the time series location.
Note
The caller will NOT take the ownership of the returned pointer.

◆ getObservations()

const TimeSeriesObservationSet& te::st::TimeSeries::getObservations ( ) const

It returns the time series observations.

Returns
A reference to the time series observations.

◆ getPatch()

TimeSeriesPatch te::st::TimeSeries::getPatch ( const te::dt::DateTime dt,
te::dt::TemporalRelation  r = te::dt::DURING 
) const

It returns a time series subset that satisfies a given temporal relation.

The possible temporal relations are: AFTER (2); AFTER | EQUALS (10); 3. BEFORE (1); 4. BEFORE | EQUALS (9); DURING (4); EQUALS (8)

Parameters
dtA given date and time.
rA given temporal relation.
Returns
A patch of the time series.
Note
When the temporal relation is DURING, dt must be a time period.

◆ getPatches() [1/2]

void te::st::TimeSeries::getPatches ( const double &  v,
te::dt::BasicRelation  r,
std::vector< TimeSeriesPatch > &  result 
) const

It returns time series subsets that satisfy a given relation.

The possible basic relation is: LESS (1); MORE (2); EQUAL (4); LESS | EQUAL (5); MORE | EQUAL (6).

Parameters
vA given value.
rA given basic relation.
resultThe returned patches.

◆ getPatches() [2/2]

void te::st::TimeSeries::getPatches ( const double &  v,
te::dt::BasicRelation  r,
const te::dt::DateTime dt,
te::dt::TemporalRelation  tr,
std::vector< TimeSeriesPatch > &  result 
) const

It returns time series subsets that satisfy a given relation.

The possible basic relation is: LESS (1); MORE (2); EQUAL (4); LESS | EQUAL (5); MORE | EQUAL (6).

Parameters
v1A given first value.
r1A given relation associated to the first value.
v2A given second value.
r2A given relation associated to the second value.
resultThe returned patches.

It returns time series subsets that satisfy a the given relations.

The possible basic relations are: LESS (1); MORE (2); EQUAL (4); LESS | EQUAL (5); MORE | EQUAL (6).
The possible temporal relations are: AFTER (2); AFTER | EQUALS (10); 3. BEFORE (1); 4. BEFORE | EQUALS (9); DURING (4); EQUALS (8) .

Parameters
vA given value.
rA basic relation.
dtA given date and time.
trA given temporal relation.
resultThe returned patches.
Note
When the temporal relation is DURING, dt must be a time period.

◆ getResultOrderedByTime()

void te::st::TimeSeries::getResultOrderedByTime ( const double &  v,
te::dt::BasicRelation  r,
std::map< te::dt::DateTime *, te::dt::AbstractData *, te::dt::CompareDateTime > &  result 
) const
private

It returns the result of a basic relation ordered by time.

◆ getString()

std::string te::st::TimeSeries::getString ( te::dt::DateTime t) const

It returns the value as a string associated to a given date and time.

If there is no value associated to the given date and time, it will use internally its interpolation function.

Parameters
tA date and time.
Returns
The value associated to the given date and time.

◆ getTemporalExtent()

std::unique_ptr<te::dt::DateTimePeriod> te::st::TimeSeries::getTemporalExtent ( ) const

It returns the temporal extent or range of the time series.

Returns
The temporal extent or range of the time series.
Note
The caller will take the ownership of the output pointer.

◆ getValue()

std::unique_ptr<te::dt::AbstractData> te::st::TimeSeries::getValue ( te::dt::DateTime t) const

It returns the value associated to a given date and time.

If there is no value associated to the given date and time, it will use internally its interpolation function.

Parameters
tA date and time.
Returns
A pointer to the value associated to the given date and time.
Note
The caller will take the ownership of the returned pointer.

◆ getValueExtent() [1/3]

void te::st::TimeSeries::getValueExtent ( double &  minValue,
double &  maxValue 
)

It returns the minimal and maximun values of the time series.

Parameters
minValueThe minumun value of the time series.
maxValueThe maximun value of the time series.

◆ getValueExtent() [2/3]

void te::st::TimeSeries::getValueExtent ( int &  minValue,
int &  maxValue 
)

It returns the minimal and maximun values of the time series.

Parameters
minValueThe minumun value of the time series.
maxValueThe maximun value of the time series.

◆ getValueExtent() [3/3]

void te::st::TimeSeries::getValueExtent ( std::string &  minValue,
std::string &  maxValue 
)

It returns the minimal and maximun values of the time series.

Parameters
minValueThe minumun value of the time series.
maxValueThe maximun value of the time series.

◆ operator=()

TimeSeries& te::st::TimeSeries::operator= ( const TimeSeries other)

Copy assignment operator.

Note
They will share the internal pointers.
The caller has to use the method "clone" to have a deep copy.

◆ setId()

void te::st::TimeSeries::setId ( const std::string &  id)

It sets the time series identifier.

Parameters
idThe time series identifier.

◆ setInterpolator()

void te::st::TimeSeries::setInterpolator ( AbstractTimeSeriesInterp interp)

It sets the interpolator associated to the time series.

Parameters
interpA interpolator which is able to estimate values at non-observed times.
Note
It will NOT take the ownership of the input pointer.
The AbstractTimeSeriesInterp points to a singleton.

◆ setLocation()

void te::st::TimeSeries::setLocation ( te::gm::Geometry geom)

It sets the time series location.

Parameters
geomThe time series location.
Note
It will take the ownership of the given pointer.

◆ size()

std::size_t te::st::TimeSeries::size ( ) const

It returns the size of the time series observation set.

Returns
The observation set size of the time series.

Member Data Documentation

◆ m_id

std::string te::st::TimeSeries::m_id
private

The time series identification.

Definition at line 534 of file TimeSeries.h.

◆ m_interpolator

AbstractTimeSeriesInterp* te::st::TimeSeries::m_interpolator
private

The interpolator used to estimate values at non-observed times.

Definition at line 532 of file TimeSeries.h.

◆ m_location

std::unique_ptr<te::gm::Geometry> te::st::TimeSeries::m_location
private

The time series location.

Definition at line 533 of file TimeSeries.h.

◆ m_observations

TimeSeriesObservationSet te::st::TimeSeries::m_observations
private

The time series observations.

Definition at line 531 of file TimeSeries.h.


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