1 // -*- C++ -*- 2 /** 3 * @brief The class TimeSeries implements values indexed by time 4 * 5 * Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca 6 * 7 * This library is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU Lesser General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTCULAR PURPOSE. See the 15 * GNU Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public License 18 * along with this library. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 #ifndef OPENTURNS_TIMESERIES_HXX 22 #define OPENTURNS_TIMESERIES_HXX 23 24 #include <stdint.h> // for uint64_t 25 #include <cmath> // for nearbyint 26 27 #include "openturns/Point.hxx" 28 #include "openturns/Description.hxx" 29 #include "openturns/Indices.hxx" 30 #include "openturns/PersistentCollection.hxx" 31 #include "openturns/Collection.hxx" 32 #include "openturns/Sample.hxx" 33 #include "openturns/Graph.hxx" 34 #include "openturns/RegularGrid.hxx" 35 #include "openturns/FieldImplementation.hxx" 36 #include "openturns/Field.hxx" 37 38 BEGIN_NAMESPACE_OPENTURNS 39 40 /** 41 * @class TimeSeries 42 */ 43 44 class OT_API TimeSeries 45 : public FieldImplementation 46 { 47 CLASSNAME 48 49 public: 50 51 /** 52 * Default constructor 53 */ 54 TimeSeries(); 55 56 /** Standard constructor */ 57 TimeSeries(const UnsignedInteger n, 58 const UnsignedInteger dim); 59 60 /** Constructor from a TimeGrid and a dimension */ 61 TimeSeries(const RegularGrid & tg, 62 const UnsignedInteger dim); 63 64 /** Constructor from a TimeGrid and a sample */ 65 TimeSeries(const RegularGrid & tg, 66 const Sample & sample); 67 68 /** Constructor from a Field */ 69 TimeSeries(const Field & field); 70 71 #ifndef SWIG 72 /** Constructor from a collection of Point */ 73 TimeSeries(const Collection<Point> & coll); 74 #endif 75 76 /** Virtual constructor */ 77 TimeSeries * clone() const override; 78 79 /** 80 * String converter 81 * This method shows human readable information on the 82 * internal state of an TimeSeries. It is used when streaming 83 * the TimeSeries or for user information. 84 */ 85 String __repr__() const override; 86 String __str__(const String & offset = "") const override; 87 88 Bool operator ==(const TimeSeries & other) const; 89 90 /** Append an element to the collection */ 91 TimeSeries & add(const Point & point); 92 93 /** Append a sample to the collection */ 94 TimeSeries & add(const Sample & sample); 95 96 /** Append another time series to the collection. The time grids must match (one follows the other) */ 97 TimeSeries & add(const TimeSeries & continuer); 98 99 /** Method save() stores the object through the StorageManager */ 100 void save(Advocate & adv) const override; 101 102 /** Method load() reloads the object from the StorageManager */ 103 void load(Advocate & adv) override; 104 105 private: 106 107 /** The start time of the time series */ 108 Scalar start_; 109 110 /** The interval of the underlying regular time grid */ 111 Scalar timeStep_; 112 113 /** The number of timestamps of the underlying regular time grid */ 114 UnsignedInteger n_; 115 116 }; /* class TimeSeries */ 117 118 END_NAMESPACE_OPENTURNS 119 120 #endif /* OPENTURNS_TIMESERIES_HXX */ 121