-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [DEV] Add classes TimeSeriesNumbers TimeSeries * [DEV] Add classes to cpp * [DEV] getTSNumber * [DEV] getCoeff getColumn * [FIX] Windows CI * [DEV] Use matrix<> instead of vector * [DEV] Add timeSeriesLoadFromFolder * [DEV] removed pointer from windseries add savetofolder add reset add typedef TSNumbers * [DEV] Wind compiling * [DEV] remove old wind series files * [FIX] crash * [FIX] getSeriesIndex * [DEV] load series * [DEV] remove load series files * [FIX] compile * [DEV] Comments * [DEV] revert reset() * [DEV] solar series * [DEV] remove solar series files * [FIX] Tests crashes * [DEV] Add static member emptyColumn * [DEV] remove useless if * Use generic class for load series (#1686) * [DEV] load series * [DEV] remove load series files * [FIX] compile * [DEV] Comments * [DEV] revert reset() * [DEV] Comments * [DEV] using TScoefficients * Refactor thermal & renewable series (#1693) * [DEV] Thermal series start * [FIX] getCoefficient() arg order * [DEV] Use Matrix<double> only * [DEV] Remove class DataSeriesCommon * [DEV] Add using TS * [skip ci] Add library series, move files to part/series * [DEV] Use library series * [DEV] Replace matrix<double> with TimeSeries::TS * [DEV] Remove template from class TimeSeriesConfigurer * [DEV] Clean valueAtTimeStep * [DEV] Comments and use series.reset() * Refactor hydro series (#1705) * [DEV] Removed hydro/series.hxx * [DEV] Use a ref for TSNumbers * [DEV] Use a ref for TSNumbers (#1706) * [DEV] Use TimeSeries for ror * [DEV] Modify operator[] behavior * [DEV] storage * [CI] Upgrade python to 3.12 * [DEV] mingen * [DEV] replace tsindex with year in hydro/management * [DEV] Remove getIndex from hydro series * [DEV] code smells * Make hydro ts count a private member (#1712) * Refactor max power TS checks : internalize count of generation time series (ror, storage, mingen) We should not be able to change a TS count without resizing the TS. This was allowed when because this count was a public data member. So we make it a private data member, and change it only when resizing the associated data. * Make hydro time series cont a private member --------- Co-authored-by: guilpier-code <[email protected]> * [FIX] Compile * [FIX] Code smells * [FIX] Code smells * [DEV] valueAtTimeStep uses year hour now * Unit tests for timeseries (#1713) * [DEV] Fix include path * [DEV] move folder series * [DEV] Use timestep instead of hour * [FIX] several comments for class series * [FIX] more comments * [FIX] try fix windows CI --------- Co-authored-by: guilpier-code <[email protected]>
- Loading branch information
1 parent
4e90b33
commit fb8b725
Showing
84 changed files
with
994 additions
and
1,706 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
add_library(series) | ||
add_library(Antares::series ALIAS series) | ||
|
||
set(SRC_STUDY_PART_SERIES | ||
include/antares/series/series.h | ||
series.cpp | ||
) | ||
target_sources(series PUBLIC ${SRC_STUDY_PART_SERIES}) | ||
|
||
target_link_libraries(series PUBLIC Antares::array) | ||
|
||
target_include_directories(series | ||
PUBLIC | ||
${CMAKE_CURRENT_SOURCE_DIR}/include | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
** Copyright 2007-2023 RTE | ||
** Authors: Antares_Simulator Team | ||
** | ||
** This file is part of Antares_Simulator. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** There are special exceptions to the terms and conditions of the | ||
** license as they are applied to this software. View the full text of | ||
** the exceptions in file COPYING.txt in the directory of this software | ||
** distribution | ||
** | ||
** Antares_Simulator is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions | ||
*/ | ||
#ifndef __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_H__ | ||
#define __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_H__ | ||
|
||
#include <antares/array/matrix.h> | ||
|
||
namespace Antares::Data | ||
{ | ||
|
||
class TimeSeries | ||
{ | ||
/*! | ||
** \brief This class is used to represent the generic time series | ||
** | ||
** The goal is to handle indexing with the time series numbers: getCoefficient() | ||
** and also providing a wrapper for all the Matrix<> functions such as resize() | ||
*/ | ||
|
||
public: | ||
using numbers = Matrix<uint32_t>; | ||
using TS = Matrix<double>; | ||
|
||
explicit TimeSeries(numbers& tsNumbers); | ||
/*! | ||
** \brief Load series from a file | ||
** | ||
** \param path path of the file | ||
** \param dataBuffer yuni dependency to use loadFromCSV | ||
** \param average used to average timeseries | ||
** \return A non-zero value if the operation succeeded, 0 otherwise | ||
*/ | ||
bool loadFromFile(const std::string& path, | ||
Matrix<>::BufferType dataBuffer, | ||
const bool average); | ||
/*! | ||
** \brief Save time series to a file | ||
** \ingroup windseries | ||
** | ||
** \param areaID The ID of the area associated to the data series | ||
** \param folder The target folder | ||
** \param prefix the prefix for the filename | ||
** \return A non-zero value if the operation succeeded, 0 otherwise | ||
*/ | ||
int saveToFolder(const AreaName& areaID, | ||
const std::string& folder, | ||
const std::string& prefix) const; | ||
|
||
double getCoefficient(uint32_t year, uint32_t timestep) const; | ||
const double* getColumn(uint32_t year) const; | ||
uint32_t getSeriesIndex(uint32_t year) const; | ||
|
||
double* operator[](uint32_t index); | ||
|
||
void reset(); | ||
void unloadFromMemory() const; | ||
void roundAllEntries(); | ||
void resize(uint32_t timeSeriesCount, uint32_t timestepCount); | ||
void averageTimeseries(); | ||
|
||
bool forceReload(bool reload = false) const; | ||
void markAsModified() const; | ||
uint64_t memoryUsage() const; | ||
|
||
TS timeSeries; | ||
numbers& timeseriesNumbers; | ||
|
||
static const double emptyColumn[HOURS_PER_YEAR]; | ||
}; | ||
|
||
} // namespace Antares::Data | ||
#endif /* __ANTARES_LIBS_STUDY_PARTS_COMMON_TIMESERIES_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* | ||
** Copyright 2007-2023 RTE | ||
** Authors: Antares_Simulator Team | ||
** | ||
** This file is part of Antares_Simulator. | ||
** | ||
** Antares_Simulator is free software: you can redistribute it and/or modify | ||
** it under the terms of the GNU General Public License as published by | ||
** the Free Software Foundation, either version 3 of the License, or | ||
** (at your option) any later version. | ||
** | ||
** There are special exceptions to the terms and conditions of the | ||
** license as they are applied to this software. View the full text of | ||
** the exceptions in file COPYING.txt in the directory of this software | ||
** distribution | ||
** | ||
** Antares_Simulator is distributed in the hope that it will be useful, | ||
** but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
** GNU General Public License for more details. | ||
** | ||
** You should have received a copy of the GNU General Public License | ||
** along with Antares_Simulator. If not, see <http://www.gnu.org/licenses/>. | ||
** | ||
** SPDX-License-Identifier: licenceRef-GPL3_WITH_RTE-Exceptions | ||
*/ | ||
|
||
#include <yuni/yuni.h> | ||
#include <yuni/io/file.h> | ||
#include <yuni/io/directory.h> | ||
#include "antares/series/series.h" | ||
|
||
using namespace Yuni; | ||
|
||
#define SEP IO::Separator | ||
|
||
|
||
namespace Antares::Data | ||
{ | ||
|
||
const double TimeSeries::emptyColumn[] = {0}; | ||
|
||
TimeSeries::TimeSeries(numbers& tsNumbers) : timeseriesNumbers(tsNumbers) | ||
{} | ||
|
||
bool TimeSeries::loadFromFile(const std::string& path, | ||
Matrix<>::BufferType dataBuffer, | ||
const bool average) | ||
{ | ||
bool ret = true; | ||
ret = timeSeries.loadFromCSVFile(path, 1, HOURS_PER_YEAR, &dataBuffer) && ret; | ||
|
||
if (average) | ||
timeSeries.averageTimeseries(); | ||
|
||
timeseriesNumbers.clear(); | ||
|
||
return ret; | ||
} | ||
|
||
int TimeSeries::saveToFolder(const AreaName& areaID, | ||
const std::string& folder, | ||
const std::string& prefix) const | ||
{ | ||
Clob buffer; | ||
buffer.clear() << folder << SEP << prefix << areaID << ".txt"; | ||
return timeSeries.saveToCSVFile(buffer, 0); | ||
} | ||
|
||
|
||
double TimeSeries::getCoefficient(uint32_t year, uint32_t timestep) const | ||
{ | ||
if (timeSeries.width == 0) | ||
return 0; | ||
return timeSeries[getSeriesIndex(year)][timestep]; | ||
} | ||
|
||
const double* TimeSeries::getColumn(uint32_t year) const | ||
{ | ||
if (timeSeries.width == 0) | ||
return emptyColumn; | ||
return timeSeries[getSeriesIndex(year)]; | ||
} | ||
|
||
uint32_t TimeSeries::getSeriesIndex(uint32_t year) const | ||
{ | ||
if (timeSeries.width == 1) | ||
return 0; | ||
else | ||
return timeseriesNumbers[0][year]; | ||
} | ||
|
||
double* TimeSeries::operator[](uint32_t index) | ||
{ | ||
if (timeSeries.width <= index) | ||
return nullptr; | ||
return timeSeries[index]; | ||
} | ||
|
||
void TimeSeries::reset() | ||
{ | ||
timeSeries.reset(1, HOURS_PER_YEAR); | ||
} | ||
|
||
void TimeSeries::resize(uint32_t timeSeriesCount, uint32_t timestepCount) | ||
{ | ||
timeSeries.resize(timeSeriesCount, timestepCount); | ||
} | ||
|
||
void TimeSeries::roundAllEntries() | ||
{ | ||
timeSeries.roundAllEntries(); | ||
} | ||
|
||
void TimeSeries::averageTimeseries() | ||
{ | ||
timeSeries.averageTimeseries(); | ||
} | ||
|
||
void TimeSeries::unloadFromMemory() const | ||
{ | ||
timeSeries.unloadFromMemory(); | ||
} | ||
|
||
bool TimeSeries::forceReload(bool reload) const | ||
{ | ||
return timeSeries.forceReload(reload); | ||
} | ||
|
||
void TimeSeries::markAsModified() const | ||
{ | ||
timeSeries.markAsModified(); | ||
} | ||
|
||
uint64_t TimeSeries::memoryUsage() const | ||
{ | ||
return timeSeries.memoryUsage(); | ||
} | ||
|
||
} // namespace Antares::Data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.