Change to meteo api for getting wind info
This commit is contained in:
parent
078b076f20
commit
71e23c7caa
@ -31,3 +31,4 @@ typing_extensions==4.12.2
|
|||||||
uvicorn==0.30.6
|
uvicorn==0.30.6
|
||||||
watchfiles==0.24.0
|
watchfiles==0.24.0
|
||||||
websockets==13.1
|
websockets==13.1
|
||||||
|
PyMySQL=1.1.1
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from datetime import date
|
||||||
|
|
||||||
from pydantic import BaseModel, Field
|
from pydantic import BaseModel, Field
|
||||||
from fastapi import Query
|
from fastapi import Query
|
||||||
|
|
||||||
@ -9,9 +11,10 @@ class SWeatherInfo(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class SFlorisInputParams(BaseModel):
|
class SFlorisInputParams(BaseModel):
|
||||||
weather_id: int
|
|
||||||
layout_x: list[float] = Field(Query([]))
|
layout_x: list[float] = Field(Query([]))
|
||||||
layout_y: list[float] = Field(Query([]))
|
layout_y: list[float] = Field(Query([]))
|
||||||
|
date_start: date
|
||||||
|
date_end: date
|
||||||
|
|
||||||
|
|
||||||
class SFlorisOutputData(BaseModel):
|
class SFlorisOutputData(BaseModel):
|
||||||
|
@ -12,6 +12,7 @@ from data.schemas import SFlorisInputParams, SFlorisOutputData, SWeatherInfo
|
|||||||
|
|
||||||
sys.path.append(str(Path(__file__).parent.parent.parent))
|
sys.path.append(str(Path(__file__).parent.parent.parent))
|
||||||
from floris_module.src import FlorisULSTU
|
from floris_module.src import FlorisULSTU
|
||||||
|
from floris_module.src.OpenMeteoClient import OpenMeteoClient
|
||||||
|
|
||||||
FLORIS_IMAGES_PATH = Path(__file__).parent.parent.parent / "public" / "floris"
|
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",
|
detail="Length of layout x and y must be the same",
|
||||||
)
|
)
|
||||||
|
|
||||||
atmosphere_param: SWeatherInfo = WeatherRepository().get_by_id(data.weather_id)
|
|
||||||
|
|
||||||
fmodel = FlorisULSTU()
|
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(
|
fmodel.set(
|
||||||
layout_x=data.layout_x,
|
layout_x=data.layout_x,
|
||||||
layout_y=data.layout_y,
|
layout_y=data.layout_y,
|
||||||
wind_directions=[atmosphere_param.WindDir],
|
wind_directions=wind_directions,
|
||||||
wind_speeds=[atmosphere_param.WindSpeed],
|
wind_speeds=wind_speeds,
|
||||||
|
turbulence_intensities=[0.1] * len(wind_directions)
|
||||||
)
|
)
|
||||||
|
|
||||||
fmodel.run()
|
fmodel.run()
|
||||||
|
|
||||||
data = fmodel.get_turbine_powers()[0].tolist()
|
data = fmodel.get_turbine_powers()[0].tolist()
|
||||||
|
Loading…
Reference in New Issue
Block a user