-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move forecast csv test to test folder (#209)
* Move forecast_csv test to test folder * Remove TestGenerateForecast from forecast_csv * Remove duplicate data in test_generate_forecast.py * Remove extraneous files. --------- Co-authored-by: Peter Dudfield <[email protected]>
- Loading branch information
1 parent
bf39f33
commit 9085d97
Showing
2 changed files
with
87 additions
and
58 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
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,55 @@ | ||
import os | ||
import pandas as pd | ||
from datetime import datetime, timedelta | ||
import quartz_solar_forecast.forecast as forecast | ||
from quartz_solar_forecast.utils.forecast_csv import write_out_forecasts | ||
from quartz_solar_forecast.pydantic_models import PVSite | ||
|
||
def test_generate_forecast(monkeypatch): | ||
site_name = "TestCase" | ||
latitude = 51.75 | ||
longitude = -1.25 | ||
capacity_kwp = 1.25 | ||
start_datetime = "2024-03-10 00:00:00" | ||
end_datetime = "2024-03-11 00:00:00" | ||
init_time_freq = 6 | ||
output_dir = os.path.join(os.getcwd(), "csv_forecasts") | ||
output_file_name = ( | ||
f"forecast_{site_name}_{start_datetime[:10]}_{end_datetime[:10]}.csv" | ||
) | ||
output_file_path = os.path.join(output_dir, output_file_name) | ||
|
||
def mock_forecast( | ||
site: PVSite, | ||
model: str = "gb", | ||
ts: datetime | str = None, | ||
nwp_source: str = "icon", | ||
): | ||
return pd.DataFrame( | ||
{ | ||
"datetime": [ | ||
datetime(2024, 3, 10, 0, 0) + timedelta(hours=6 * i) | ||
for i in range(4) | ||
], | ||
"power_kw": [0.1, 0.5, 0.8, 0.6], | ||
"forecast_init_time": [datetime(2024, 3, 10, 0, 0)] * 4, | ||
} | ||
) | ||
|
||
monkeypatch.setattr(forecast, "run_forecast", mock_forecast) | ||
|
||
if not os.path.exists(output_dir): | ||
os.makedirs(output_dir) | ||
|
||
write_out_forecasts( | ||
init_time_freq, | ||
start_datetime, | ||
end_datetime, | ||
site_name, | ||
latitude, | ||
longitude, | ||
capacity_kwp, | ||
) | ||
|
||
assert os.path.exists(output_file_path) | ||
os.remove(output_file_path) |