Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move data validation to specialized functions [ANT-1213] #2149

Merged
merged 24 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/libs/antares/study/area/list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ static bool AreaListLoadFromFolderSingleArea(Study& study,
// if changes are required, please update reloadXCastData()
buffer.clear() << study.folderInput << SEP << "hydro" << SEP << "prepro";
ret = area.hydro.prepro->loadFromFolder(study, area.id, buffer.c_str()) && ret;
ret = area.hydro.prepro->validate(area.id) && ret;
}

auto* hydroSeries = area.hydro.series;
Expand Down Expand Up @@ -1160,6 +1161,7 @@ bool AreaList::loadFromFolder(const StudyLoadOptions& options)
logs.info() << "Loading global hydro data...";
buffer.clear() << pStudy.folderInput << SEP << "hydro";
ret = PartHydro::LoadFromFolder(pStudy, buffer) && ret;
ret = PartHydro::validate(pStudy) && ret;
}

// Thermal data, specific to areas
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class PartHydro
pumpMod,
};

public:
/*!
** \brief Load data for hydro container from a folder
**
Expand All @@ -61,6 +60,13 @@ class PartHydro
*/
static bool LoadFromFolder(Study& study, const AnyString& folder);

/*!
** \brief Check and validate the loaded datas
**
** \return A non-zero value if the operation succeeded, 0 otherwise
*/
static bool validate(Study& study);

/*!
** \brief Save data from several containers to a folder (except data for the prepro and
*time-series)
Expand All @@ -71,7 +77,6 @@ class PartHydro
*/
static bool SaveToFolder(const AreaList& areas, const AnyString& folder);

public:
/*!
** \brief Default Constructor
*/
Expand Down Expand Up @@ -100,7 +105,6 @@ class PartHydro

bool CheckDailyMaxEnergy(const AnyString& areaName);

public:
//! Inter-daily breakdown (previously called Smoothing Factor or alpha)
double interDailyBreakdown;
//! Intra-daily modulation
Expand Down Expand Up @@ -161,6 +165,10 @@ class PartHydro
Matrix<double, double> dailyNbHoursAtGenPmax;
Matrix<double, double> dailyNbHoursAtPumpPmax;

private:
static bool checkReservoirLevels(const Study& study);
static bool checkProperties(Study& study);

}; // class PartHydro

// Interpolates a water value from a table according to a level and a day.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ class PreproHydro
** \param folder The source folder (ex: `input/hydro/prepro`)
** \return A non-zero value if the operation succeeded, 0 otherwise
*/
bool loadFromFolder(Study& s, const AreaName& areaID, const char folder[]);
bool loadFromFolder(Study& s, const AreaName& areaID, const std::string& folder);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible (or usefull) to use std::filesystem::path for folder ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will be done in another PR


bool validate(const std::string& areaID);
/*!
** \brief Save hydro settings for the prepro into a folder
**
Expand Down
Loading
Loading