-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(local): implement
thermal_ts_generation
(#112)
- Loading branch information
1 parent
92ca409
commit 8b616b4
Showing
7 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
antares-timeseries-generation==0.1.7 | ||
|
||
absl-py~=1.4.0 | ||
click~=8.1.7 | ||
configparser~=5.0.2 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
tests/antares/services/local_services/test_thermal_ts_generation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# Copyright (c) 2024, RTE (https://www.rte-france.com) | ||
# | ||
# See AUTHORS.txt | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
# | ||
# SPDX-License-Identifier: MPL-2.0 | ||
# | ||
# This file is part of the Antares project. | ||
import pytest | ||
|
||
import re | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
from antares.craft.model.thermal import ThermalClusterPropertiesUpdate | ||
|
||
|
||
class TestThermalTsGeneration: | ||
def set_up_matrices(self, local_study_w_thermals): | ||
prepro_data_matrix = np.zeros((365, 6)) | ||
prepro_data_matrix[:, :2] = 1 | ||
|
||
prepro_modulation_matrix = np.ones((8760, 4)) | ||
prepro_modulation_matrix[:, 3] = 0 | ||
|
||
cluster_1 = local_study_w_thermals.get_areas()["fr"].get_thermals()["test thermal cluster"] | ||
cluster_2 = local_study_w_thermals.get_areas()["fr"].get_thermals()["thermal_fr_2"] | ||
cluster_3 = local_study_w_thermals.get_areas()["it"].get_thermals()["thermal_it"] | ||
for cluster in [cluster_1, cluster_2, cluster_3]: | ||
cluster.update_prepro_data_matrix(pd.DataFrame(prepro_data_matrix)) | ||
cluster.update_prepro_modulation_matrix(pd.DataFrame(prepro_modulation_matrix)) | ||
|
||
def test_nominal_case(self, local_study_w_thermals): | ||
self.set_up_matrices(local_study_w_thermals) | ||
# Change nominal capacity | ||
cluster_1 = local_study_w_thermals.get_areas()["fr"].get_thermals()["test thermal cluster"] | ||
cluster_2 = local_study_w_thermals.get_areas()["fr"].get_thermals()["thermal_fr_2"] | ||
cluster_3 = local_study_w_thermals.get_areas()["it"].get_thermals()["thermal_it"] | ||
for k, cluster in enumerate([cluster_1, cluster_2, cluster_3]): | ||
new_properties = ThermalClusterPropertiesUpdate(nominal_capacity=100 * (k + 1)) | ||
cluster.update_properties(new_properties) | ||
# Generate new TS | ||
local_study_w_thermals.generate_thermal_timeseries(4) | ||
# Checks TS generated | ||
for k, cluster in enumerate([cluster_1, cluster_2, cluster_3]): | ||
series = cluster.get_series_matrix() | ||
expected_series = pd.DataFrame(np.full((8760, 4), (k + 1) * 100)) | ||
assert series.equals(expected_series) | ||
|
||
def test_error_case(self, local_study_w_thermals): | ||
self.set_up_matrices(local_study_w_thermals) | ||
with pytest.raises( | ||
ValueError, | ||
match=re.escape("Area fr, cluster test thermal cluster: Nominal power must be strictly positive, got 0."), | ||
): | ||
local_study_w_thermals.generate_thermal_timeseries(4) |