diff --git a/server/requirements.txt b/server/requirements.txt index 3097f7c..ad67f03 100644 --- a/server/requirements.txt +++ b/server/requirements.txt @@ -31,3 +31,4 @@ typing_extensions==4.12.2 uvicorn==0.30.6 watchfiles==0.24.0 websockets==13.1 +PyMySQL=1.1.1 diff --git a/server/src/data/schemas.py b/server/src/data/schemas.py index 3388350..6558a9d 100644 --- a/server/src/data/schemas.py +++ b/server/src/data/schemas.py @@ -1,3 +1,5 @@ +from datetime import date + from pydantic import BaseModel, Field from fastapi import Query @@ -9,9 +11,10 @@ class SWeatherInfo(BaseModel): class SFlorisInputParams(BaseModel): - weather_id: int layout_x: list[float] = Field(Query([])) layout_y: list[float] = Field(Query([])) + date_start: date + date_end: date class SFlorisOutputData(BaseModel): diff --git a/server/src/routers/floris_router.py b/server/src/routers/floris_router.py index 7bbca30..ddccce5 100644 --- a/server/src/routers/floris_router.py +++ b/server/src/routers/floris_router.py @@ -12,6 +12,7 @@ from data.schemas import SFlorisInputParams, SFlorisOutputData, SWeatherInfo sys.path.append(str(Path(__file__).parent.parent.parent)) from floris_module.src import FlorisULSTU +from floris_module.src.OpenMeteoClient import OpenMeteoClient FLORIS_IMAGES_PATH = Path(__file__).parent.parent.parent / "public" / "floris" @@ -31,15 +32,26 @@ async def get_windmill_data( detail="Length of layout x and y must be the same", ) - atmosphere_param: SWeatherInfo = WeatherRepository().get_by_id(data.weather_id) - fmodel = FlorisULSTU() + + client = OpenMeteoClient() + + wind_directions = list() + wind_speeds = list() + + for i in range(len(data.layout_x)): + i_result = client.get_weather_info(data.layout_x[i], data.layout_y[i], data.date_start, data.date_end) + wind_speeds.extend(i_result[0]) + wind_directions.extend(i_result[1]) + fmodel.set( layout_x=data.layout_x, layout_y=data.layout_y, - wind_directions=[atmosphere_param.WindDir], - wind_speeds=[atmosphere_param.WindSpeed], + wind_directions=wind_directions, + wind_speeds=wind_speeds, + turbulence_intensities=[0.1] * len(wind_directions) ) + fmodel.run() data = fmodel.get_turbine_powers()[0].tolist()