Skip to content

Commit

Permalink
Add solar correlation.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigurd-Borge committed Sep 6, 2024
1 parent 6e77698 commit aaee9b9
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 8 deletions.
14 changes: 12 additions & 2 deletions src/antares/model/solar.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@
# SPDX-License-Identifier: MPL-2.0
#
# This file is part of the Antares project.
from pathlib import Path
from typing import Any, Optional


from antares.tools.ini_tool import IniFile, IniFileTypes
from antares.tools.time_series_tool import TimeSeries


class Solar(TimeSeries):
pass
def __init__(
self,
*,
study_path: Optional[Path] = None,
**kwargs: Any,
) -> None:
super().__init__(**kwargs)
if study_path is not None:
self.correlation = IniFile(study_path, IniFileTypes.SOLAR_CORRELATION_INI)
2 changes: 1 addition & 1 deletion src/antares/service/api_services/area_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def create_solar(self, area: Area, series: Optional[pd.DataFrame]) -> Solar:
series = series if series is not None else pd.DataFrame([])
series_path = f"input/solar/series/solar_{area.id}"
self._upload_series(area, series, series_path)
return Solar(series)
return Solar(time_series=series)

def create_misc_gen(self, area: Area, series: Optional[pd.DataFrame]) -> MiscGen:
series = series if series is not None else pd.DataFrame([])
Expand Down
2 changes: 1 addition & 1 deletion src/antares/service/local_services/area_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def create_reserves(self, area: Area, series: Optional[pd.DataFrame]) -> Reserve
def create_solar(self, area: Area, series: Optional[pd.DataFrame]) -> Solar:
series = series if series is not None else pd.DataFrame([])
local_file = TimeSeriesFile(TimeSeriesFileType.SOLAR, self.config.study_path, area.id, series)
return Solar(series, local_file)
return Solar(time_series=series, local_file=local_file, study_path=self.config.study_path)

def create_misc_gen(self, area: Area, series: Optional[pd.DataFrame]) -> MiscGen:
series = series if series is not None else pd.DataFrame([])
Expand Down
1 change: 1 addition & 0 deletions src/antares/tools/ini_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class IniFileTypes(Enum):
HYDRO_INI = "input/hydro/hydro.ini"
LINK_PROPERTIES_INI = "input/links/{area_name}/properties.ini"
RENEWABLES_LIST_INI = "input/renewables/clusters/{area_name}/list.ini"
SOLAR_CORRELATION_INI = "input/solar/prepro/correlation.ini"
ST_STORAGE_LIST_INI = "input/st-storage/clusters/{area_name}/list.ini"
THERMAL_AREAS_INI = "input/thermal/areas.ini"
THERMAL_LIST_INI = "input/thermal/clusters/{area_name}/list.ini"
Expand Down
17 changes: 13 additions & 4 deletions src/antares/tools/time_series_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@

class TimeSeriesFileType(Enum):
"""
The relative paths to different timeseries files used in the generation of an Antares study, starting from the
base folder of the study.
DTO for storing the paths to Antares time series files.
Files where the path contains {area_id} have to be used with .format(area_id=<area_id>) where <area_id> is the id
in question to access the correct path.
This DTO contains the relative paths to different timeseries files used in the generation of an Antares study,
starting from the base folder of the study.
Files where the path contains {area_id} have to be used with .format(area_id=<area_id>) where <area_id> is replaced
with the area's id to access the correct path.
Example:
TimeSeriesFileType.SOLAR.value.format(area_id="test_area")
"""

MISC_GEN = "input/misc-gen/miscgen-{area_id}.txt"
Expand Down Expand Up @@ -87,6 +92,10 @@ def _write_file(self) -> None:
class TimeSeries:
"""
A time series for use in Antares
Args:
time_series: Pandas DataFrame containing the time series.
local_file: TimeSeriesFile to store the time series if the study is local.
"""

def __init__(
Expand Down
6 changes: 6 additions & 0 deletions tests/antares/services/local_services/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
from antares.model.area import Area
from antares.model.hydro import HydroProperties
from antares.model.renewable import RenewableClusterProperties, TimeSeriesInterpretation, RenewableClusterGroup
from antares.model.solar import Solar
from antares.model.st_storage import STStorageProperties, STStorageGroup
from antares.model.study import Study, create_study_local
from antares.model.thermal import (
Expand Down Expand Up @@ -210,3 +211,8 @@ def actual_hydro_ini(local_study_with_hydro) -> IniFile:
@pytest.fixture
def area_fr(local_study_with_hydro) -> Area:
return local_study_with_hydro.get_areas()["fr"]


@pytest.fixture
def fr_solar(area_fr) -> Solar:
return area_fr.create_solar(None)
9 changes: 9 additions & 0 deletions tests/antares/services/local_services/test_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,12 @@ def test_can_create_solar_ts_file_with_time_series(self, area_fr):
# Then
assert actual_time_series.equals(expected_time_series)
assert actual_time_series_string == expected_time_series_string

def test_correlation_ini_exists(self, area_fr, fr_solar):
# Given
expected_ini_path = area_fr._area_service.config.study_path / "input/solar/prepro/correlation.ini"

# Then
assert expected_ini_path.exists()
assert expected_ini_path.is_file()
assert expected_ini_path == fr_solar.correlation.ini_path

0 comments on commit aaee9b9

Please sign in to comment.