diff --git a/src/solver/simulation/include/antares/solver/simulation/solver.hxx b/src/solver/simulation/include/antares/solver/simulation/solver.hxx index 7a4417c29ed..f20157e059b 100644 --- a/src/solver/simulation/include/antares/solver/simulation/solver.hxx +++ b/src/solver/simulation/include/antares/solver/simulation/solver.hxx @@ -491,9 +491,16 @@ void ISimulation::regenerateTimeSeries(uint year) if (refreshTSonCurrentYear) { auto clusters = getAllClustersToGen(study.areas, pData.haveToRefreshTSThermal); - fs::path savePath = fs::path(study.folderOutput.to()) / "ts-generator" - / "thermal" / "mc-" / std::to_string(year); - generateThermalTimeSeries(study, clusters, study.runtime->random[Data::seedTsGenThermal], savePath); + generateThermalTimeSeries(study, clusters, study.runtime->random[Data::seedTsGenThermal]); + + bool archive = study.parameters.timeSeriesToArchive & Data::timeSeriesThermal; + bool doWeWrite = archive && !study.parameters.noOutput; + if (doWeWrite) + { + fs::path savePath = fs::path(study.folderOutput.to()) / "ts-generator" + / "thermal" / "mc-" / std::to_string(year); + writeThermalTimeSeries(clusters, savePath); + } // apply the spinning if we generated some in memory clusters for (auto* cluster: clusters) diff --git a/src/solver/ts-generator/availability.cpp b/src/solver/ts-generator/availability.cpp index 959197de65e..6223ce2b071 100644 --- a/src/solver/ts-generator/availability.cpp +++ b/src/solver/ts-generator/availability.cpp @@ -612,8 +612,7 @@ void writeTStoDisk(const Matrix<>& series, bool generateThermalTimeSeries(Data::Study& study, const std::vector& clusters, - MersenneTwister& thermalRandom, - const fs::path& savePath) + MersenneTwister& thermalRandom) { logs.info(); logs.info() << "Generating the thermal time-series"; @@ -629,14 +628,12 @@ bool generateThermalTimeSeries(Data::Study& study, generator.run(tsGenerationData); } - bool archive = study.parameters.timeSeriesToArchive & Data::timeSeriesThermal; - bool doWeWrite = archive && !study.parameters.noOutput; - if (! doWeWrite) - { - logs.info() << "Study parameters forbid writing thermal TS."; - return true; - } + return true; +} +void writeThermalTimeSeries(const std::vector& clusters, + const fs::path& savePath) +{ for (auto* cluster: clusters) { auto areaName = cluster->parentArea->id.to(); @@ -645,8 +642,6 @@ bool generateThermalTimeSeries(Data::Study& study, writeTStoDisk(cluster->series.timeSeries, filePath); } - - return true; } // gp : we should try to add const identifiers before args here diff --git a/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h b/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h index ef60d6a9d43..15b7522b43b 100644 --- a/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h +++ b/src/solver/ts-generator/include/antares/solver/ts-generator/generator.h @@ -109,8 +109,10 @@ bool GenerateTimeSeries(Data::Study& study, uint year, IResultWriter& writer); bool generateThermalTimeSeries(Data::Study& study, const std::vector& clusters, - MersenneTwister& thermalRandom, - const fs::path& savePath); + MersenneTwister& thermalRandom); + +void writeThermalTimeSeries(const std::vector& clusters, + const fs::path& savePath); bool generateLinkTimeSeries(std::vector& links, StudyParamsForLinkTS&, diff --git a/src/tools/ts-generator/main.cpp b/src/tools/ts-generator/main.cpp index 3550f1720de..caffb0e6a0b 100644 --- a/src/tools/ts-generator/main.cpp +++ b/src/tools/ts-generator/main.cpp @@ -79,21 +79,12 @@ int main(int argc, char* argv[]) // ============ THERMAL : Getting data for generating time-series ========= auto study = std::make_shared(true); Data::StudyLoadOptions studyOptions; - studyOptions.prepareOutput = true; - if (!study->loadFromFolder(settings.studyFolder, studyOptions)) { logs.error() << "Invalid study given to the generator"; return 1; } - // Forces the writing of generated TS into the study's output sub-folder - study->parameters.timeSeriesToArchive |= Antares::Data::timeSeriesThermal; - - auto thermalSavePath = fs::path(settings.studyFolder) / "output" / FormattedTime("%Y%m%d-%H%M"); - thermalSavePath /= "ts-generator"; - thermalSavePath /= "thermal"; - std::vector clusters; if (settings.allThermal) { @@ -105,7 +96,6 @@ int main(int argc, char* argv[]) } // ======================================================================== - LinksTSgenerator linksTSgenerator(settings); linksTSgenerator.extractData(); @@ -115,8 +105,13 @@ int main(int argc, char* argv[]) bool ret = TSGenerator::generateThermalTimeSeries(*study, clusters, - thermalRandom, - thermalSavePath); + thermalRandom); + + auto thermalSavePath = fs::path(settings.studyFolder) / "output" / FormattedTime("%Y%m%d-%H%M"); + thermalSavePath /= "ts-generator"; + thermalSavePath /= "thermal"; + + writeThermalTimeSeries(clusters, thermalSavePath); ret = linksTSgenerator.generate() && ret;