Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
series.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_H__
22#define __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_H__
23
24#include <map>
25#include <optional>
26#include <string>
27
28#include <antares/array/matrix.h>
29
30namespace Antares::Data
31{
39class TimeSeries;
40
42{
43public:
44 void registerSeries(const TimeSeries* s, std::string label);
45 // Return a description of the error in case of inconsistent number of columns, std::nullopt
46 // otherwis
47 std::optional<std::string> checkSeriesNumberOfColumnsConsistency() const;
48
49 uint32_t operator[](uint y) const;
50 uint32_t& operator[](uint y);
51
52 void clear();
53 void reset(uint h);
54
55 uint height() const;
56
57 void saveToBuffer(std::string& data) const;
58
59private:
60 Matrix<uint32_t> tsNumbers;
61 std::map<std::string, const TimeSeries*> series;
62};
63
65{
66public:
67 using TS = Matrix<double>;
68
69 explicit TimeSeries(TimeSeriesNumbers& tsNumbers);
77 bool loadFromFile(const std::filesystem::path& path, const bool average);
86 int saveToFolder(const std::string& areaID,
87 const std::string& folder,
88 const std::string& prefix) const;
89
90 int saveToFile(const std::string& filename, bool saveEvenIfAllZero) const;
91
92 double getCoefficient(uint32_t year, uint32_t timestep) const;
93 const double* getColumn(uint32_t year) const;
94 uint32_t getSeriesIndex(uint32_t year) const;
95
98 double* operator[](uint32_t index);
99
100 void reset();
101 void reset(uint32_t width, uint32_t height);
102 uint32_t numberOfColumns() const;
103 void unloadFromMemory() const;
104 void roundAllEntries();
105 void resize(uint32_t timeSeriesCount, uint32_t timestepCount);
106 void fill(double value);
107 void averageTimeseries();
108
109 bool forceReload(bool reload = false) const;
110 void markAsModified() const;
111
112 TS timeSeries;
113 TimeSeriesNumbers& timeseriesNumbers;
114
115 static const std::vector<double> emptyColumn;
116};
117
118} // namespace Antares::Data
119#endif /* __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_H__ */
Definition series.h:42
This class is used to represent the generic time series.
Definition series.h:65
bool loadFromFile(const std::filesystem::path &path, const bool average)
Load series from a file.
Definition series.cpp:114
static const std::vector< double > emptyColumn
used in getColumn if timeSeries empty
Definition series.h:115
double * operator[](uint32_t index)
overload operator to return a column Unlike getColumn() it uses direct indexing and not timeseriesNum...
Definition series.cpp:165
int saveToFolder(const std::string &areaID, const std::string &folder, const std::string &prefix) const
Save time series to a file.
Definition series.cpp:130
A n-by-n matrix.
Definition jit.h:30