Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
killian-scalian committed Feb 25, 2025
1 parent ff14b32 commit 6111cbe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/antares/craft/service/local_services/services/area.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,8 @@ def create_renewable_cluster(
list_ini = IniFile(self.config.study_path, InitializationFilesTypes.RENEWABLES_LIST_INI, area_id=area_id)
list_ini.add_section({renewable_name: new_section_content})
list_ini.write_ini_file()

if series:
write_timeseries(self.config.study_path, series, TimeSeriesFileType.RENEWABLE_DATA_SERIES, area_id)
if isinstance(series, pd.DataFrame) and not series.empty:
write_timeseries(self.config.study_path, series, TimeSeriesFileType.RENEWABLE_DATA_SERIES, area_id, cluster_id=transform_name_to_id(renewable_name))

return RenewableCluster(self.renewable_service, area_id, renewable_name, properties)

Expand Down
11 changes: 9 additions & 2 deletions src/antares/craft/tools/matrix_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ def read_timeseries(
return _time_series


def write_timeseries(study_path: Path, series: pd.DataFrame, ts_file_type: TimeSeriesFileType, area_id: str) -> None:
file_path = study_path.joinpath(ts_file_type.value.format(area_id=area_id))
def write_timeseries(study_path: Path, series: pd.DataFrame, ts_file_type: TimeSeriesFileType, area_id: str, cluster_id: Optional[str] = None, second_area_id: Optional[str] = None) -> None:
if second_area_id:
file_path = study_path.joinpath(ts_file_type.value.format(area_id=area_id, second_area_id=second_area_id))
elif cluster_id:
file_path = study_path.joinpath(ts_file_type.value.format(area_id=area_id, cluster_id=cluster_id))
else:
file_path = study_path.joinpath(ts_file_type.value.format(area_id=area_id))
if not file_path.parent.is_dir():
file_path.parent.mkdir(parents=True)
series.to_csv(file_path, sep="\t", header=False, index=False, encoding="utf-8")

0 comments on commit 6111cbe

Please sign in to comment.