-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(thermals): correct TS Generator matrix index for thermal clusters (…
- Loading branch information
1 parent
9c4a7c0
commit b153bc3
Showing
3 changed files
with
111 additions
and
34 deletions.
There are no files selected for viewing
12 changes: 11 additions & 1 deletion
12
...study/storage/rawstudy/model/filesystem/root/input/thermal/prepro/area/thermal/thermal.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 |
---|---|---|
@@ -1,12 +1,22 @@ | ||
from antarest.study.storage.rawstudy.model.filesystem.folder_node import FolderNode | ||
from antarest.study.storage.rawstudy.model.filesystem.inode import TREE | ||
from antarest.study.storage.rawstudy.model.filesystem.matrix.input_series_matrix import InputSeriesMatrix | ||
from antarest.study.storage.rawstudy.model.filesystem.matrix.matrix import MatrixFrequency | ||
|
||
|
||
class InputThermalPreproAreaThermal(FolderNode): | ||
""" | ||
Folder containing thermal cluster data: `input/thermal/prepro/{area_id}/{cluster_id}`. | ||
This folder contains the following files: | ||
- `data.txt` (matrix): TS Generator matrix (daily) | ||
- `modulation.txt` (matrix): Modulation matrix (hourly) | ||
""" | ||
|
||
def build(self) -> TREE: | ||
children: TREE = { | ||
"data": InputSeriesMatrix(self.context, self.config.next_file("data.txt")), | ||
"data": InputSeriesMatrix(self.context, self.config.next_file("data.txt"), freq=MatrixFrequency.DAILY), | ||
"modulation": InputSeriesMatrix(self.context, self.config.next_file("modulation.txt")), | ||
} | ||
return children |
100 changes: 100 additions & 0 deletions
100
tests/integration/studies_blueprint/test_study_matrix_index.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,100 @@ | ||
from starlette.testclient import TestClient | ||
|
||
|
||
class TestStudyMatrixIndex: | ||
""" | ||
The goal of this test is to check that the API allows to retrieve | ||
information about the data matrices of a study. | ||
The values are used byt the frontend to display the time series | ||
with the right time column. | ||
""" | ||
|
||
def test_get_study_matrix_index( | ||
self, | ||
client: TestClient, | ||
user_access_token: str, | ||
study_id: str, | ||
) -> None: | ||
user_access_token = {"Authorization": f"Bearer {user_access_token}"} | ||
|
||
# Check the matrix index for Thermal clusters | ||
# =========================================== | ||
|
||
# Check the Common matrix index | ||
res = client.get( | ||
f"/v1/studies/{study_id}/matrixindex", | ||
headers=user_access_token, | ||
params={"path": "input/thermal/prepro/fr/01_solar/modulation"}, | ||
) | ||
assert res.status_code == 200, res.json() | ||
actual = res.json() | ||
# We expect to have an "hourly" time series with 8760 hours | ||
expected = { | ||
"first_week_size": 7, | ||
"level": "hourly", | ||
"start_date": "2001-01-01 00:00:00", | ||
"steps": 8760, | ||
} | ||
assert actual == expected | ||
|
||
# Check the TS Generator matrix index | ||
res = client.get( | ||
f"/v1/studies/{study_id}/matrixindex", | ||
headers=user_access_token, | ||
params={"path": "input/thermal/prepro/fr/01_solar/data"}, | ||
) | ||
assert res.status_code == 200, res.json() | ||
actual = res.json() | ||
# We expect to have a "daily" time series with 365 days | ||
expected = { | ||
"first_week_size": 7, | ||
"level": "daily", | ||
"start_date": "2001-01-01 00:00:00", | ||
"steps": 365, | ||
} | ||
assert actual == expected | ||
|
||
# Check the time series | ||
res = client.get( | ||
f"/v1/studies/{study_id}/matrixindex", | ||
headers=user_access_token, | ||
params={"path": "input/thermal/series/fr/01_solar/series"}, | ||
) | ||
assert res.status_code == 200, res.json() | ||
actual = res.json() | ||
# We expect to have an "hourly" time series with 8760 hours | ||
expected = { | ||
"first_week_size": 7, | ||
"level": "hourly", | ||
"start_date": "2001-01-01 00:00:00", | ||
"steps": 8760, | ||
} | ||
assert actual == expected | ||
|
||
# Check the default matrix index | ||
# ============================== | ||
|
||
res = client.get(f"/v1/studies/{study_id}/matrixindex", headers=user_access_token) | ||
assert res.status_code == 200 | ||
actual = res.json() | ||
expected = { | ||
"first_week_size": 7, | ||
"start_date": "2001-01-01 00:00:00", | ||
"steps": 8760, | ||
"level": "hourly", | ||
} | ||
assert actual == expected | ||
|
||
# Check the matrix index of a daily time series stored in the output folder | ||
# ========================================================================= | ||
|
||
res = client.get( | ||
f"/v1/studies/{study_id}/matrixindex", | ||
headers=user_access_token, | ||
params={"path": "output/20201014-1427eco/economy/mc-all/areas/es/details-daily"}, | ||
) | ||
assert res.status_code == 200 | ||
actual = res.json() | ||
expected = {"first_week_size": 7, "start_date": "2001-01-01 00:00:00", "steps": 7, "level": "daily"} | ||
assert actual == expected |
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