From 45d90d5b9eed2447e0561c3cf1b7ba20aa4b91e4 Mon Sep 17 00:00:00 2001 From: Guillaume PIERRE Date: Thu, 6 Feb 2025 15:30:53 +0100 Subject: [PATCH] Upgrade hydro from v8.8 to v9.2 : save hourly power time series according to value of parameter hydro-pmax We save hourly power time series only if hydro-pmax == hourly --- src/libs/antares/study/area/list.cpp | 11 ++++++++--- .../include/antares/study/parts/hydro/series.h | 4 +++- src/libs/antares/study/parts/hydro/series.cpp | 16 +++++++++++----- src/libs/antares/study/study.importprepro.cpp | 2 +- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/libs/antares/study/area/list.cpp b/src/libs/antares/study/area/list.cpp index 881a555017..80307b08cf 100644 --- a/src/libs/antares/study/area/list.cpp +++ b/src/libs/antares/study/area/list.cpp @@ -192,7 +192,9 @@ static bool AreaListSaveThermalDataToFile(const AreaList& list, const AnyString& return ini.save(filename); } -static bool AreaListSaveToFolderSingleArea(const Area& area, const AnyString& folder) +static bool AreaListSaveToFolderSingleArea(const Area& area, + const AnyString& folder, + Parameters::Compatibility::HydroPmax& hydroPmax) { bool ret = true; Clob buffer; @@ -274,7 +276,7 @@ static bool AreaListSaveToFolderSingleArea(const Area& area, const AnyString& fo if (area.hydro.series) // Series { buffer.clear() << folder << SEP << "input" << SEP << "hydro" << SEP << "series"; - ret = area.hydro.series->saveToFolder(area.id, buffer) && ret; + ret = area.hydro.series->saveToFolder(area.id, buffer, hydroPmax) && ret; } } @@ -763,7 +765,10 @@ bool AreaList::saveToFolder(const AnyString& folder) const { logs.info() << "Exporting the area " << (area.index + 1) << '/' << areas.size() << ": " << area.name; - ret = AreaListSaveToFolderSingleArea(area, folder) && ret; + ret = AreaListSaveToFolderSingleArea(area, + folder, + pStudy.parameters.compatibility.hydroPmax) + && ret; }); // Hydro diff --git a/src/libs/antares/study/include/antares/study/parts/hydro/series.h b/src/libs/antares/study/include/antares/study/parts/hydro/series.h index c3b587c0de..2a4997d923 100644 --- a/src/libs/antares/study/include/antares/study/parts/hydro/series.h +++ b/src/libs/antares/study/include/antares/study/parts/hydro/series.h @@ -91,7 +91,9 @@ class DataSeriesHydro ** \param folder The target folder ** \return A non-zero value if the operation succeeded, 0 otherwise */ - bool saveToFolder(const AreaName& areaID, const AnyString& folder) const; + bool saveToFolder(const AreaName& areaID, + const AnyString& folder, + Parameters::Compatibility::HydroPmax& hydroPmax) const; //@} TimeSeriesNumbers timeseriesNumbers; diff --git a/src/libs/antares/study/parts/hydro/series.cpp b/src/libs/antares/study/parts/hydro/series.cpp index 2ae774fbdf..30b25b6ea0 100644 --- a/src/libs/antares/study/parts/hydro/series.cpp +++ b/src/libs/antares/study/parts/hydro/series.cpp @@ -191,7 +191,9 @@ void DataSeriesHydro::buildHourlyMaxPowerFromDailyTS( ConvertDailyTSintoHourlyTS(DailyMaxPumpPower, maxHourlyPumpPower.timeSeries[0]); } -bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& folder) const +bool DataSeriesHydro::saveToFolder(const AreaName& areaID, + const AnyString& folder, + Parameters::Compatibility::HydroPmax& hydroPmax) const { String buffer; buffer.clear() << folder << SEP << areaID; @@ -207,10 +209,14 @@ bool DataSeriesHydro::saveToFolder(const AreaName& areaID, const AnyString& fold ret = storage.timeSeries.saveToCSVFile(buffer, 0) && ret; buffer.clear() << folder << SEP << areaID << SEP << "mingen.txt"; ret = mingen.timeSeries.saveToCSVFile(buffer, 0) && ret; - buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyGenPower.txt"; - ret = maxHourlyGenPower.timeSeries.saveToCSVFile(buffer, 0) && ret; - buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyPumpPower.txt"; - ret = maxHourlyPumpPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + + if (hydroPmax == Parameters::Compatibility::HydroPmax::Hourly) + { + buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyGenPower.txt"; + ret = maxHourlyGenPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + buffer.clear() << folder << SEP << areaID << SEP << "maxHourlyPumpPower.txt"; + ret = maxHourlyPumpPower.timeSeries.saveToCSVFile(buffer, 0) && ret; + } return ret; } diff --git a/src/libs/antares/study/study.importprepro.cpp b/src/libs/antares/study/study.importprepro.cpp index 3cf520c5eb..5ec2299038 100644 --- a/src/libs/antares/study/study.importprepro.cpp +++ b/src/libs/antares/study/study.importprepro.cpp @@ -82,7 +82,7 @@ bool Study::importTimeseriesIntoInput() { logs.info() << "Importing hydro timeseries : " << areaName; buffer.clear() << folderInput << SEP << "hydro" << SEP << "series"; - ret = area->hydro.series->saveToFolder(area->id, buffer) && ret; + ret = area->hydro.series->saveToFolder(area->id, buffer, parameters.compatibility.hydroPmax) && ret; ++progression; } }