floris_design #7
@ -1,3 +1,4 @@
|
||||
import math
|
||||
import os.path
|
||||
import sys
|
||||
import uuid
|
||||
@ -54,13 +55,23 @@ class FlorisULSTU(FlorisModel):
|
||||
super().set(**kwargs)
|
||||
|
||||
def visualisation(self):
|
||||
wind_dirs = self.core.flow_field.wind_directions
|
||||
wind_speeds = self.core.flow_field.wind_speeds
|
||||
|
||||
experiment_counts = len(wind_dirs)
|
||||
near_square = math.ceil(math.sqrt(experiment_counts))
|
||||
fig, axarr = plt.subplots(near_square, near_square, figsize=(15,8))
|
||||
axarr = axarr.flatten()
|
||||
|
||||
for experiment_count in range(experiment_counts):
|
||||
self.reset_operation()
|
||||
|
||||
self.set(wind_speeds=[wind_speeds[0]], wind_directions=[wind_dirs[0]], turbulence_intensities=[0.05])
|
||||
ax = axarr[experiment_count]
|
||||
horizontal_plane = self.calculate_horizontal_plane(height=90.0)
|
||||
visualize_cut_plane(
|
||||
horizontal_plane,
|
||||
ax=ax,
|
||||
title=f"Wind flow day {experiment_count + 1}",
|
||||
)
|
||||
|
||||
# plot_turbine_labels(self, axarr[0, 0])
|
||||
|
@ -17,7 +17,7 @@ class OpenMeteoClient:
|
||||
params = {
|
||||
"latitude": latitude,
|
||||
"longitude": longitude,
|
||||
"hourly": ["wind_speed_10m", "wind_direction_10m"],
|
||||
"daily": ["wind_speed_10m_max", "wind_direction_10m_dominant"],
|
||||
"timezone": self.timezone,
|
||||
"start_date": start_date,
|
||||
"end_date": end_date
|
||||
@ -27,13 +27,13 @@ class OpenMeteoClient:
|
||||
|
||||
def process_response(self, response):
|
||||
# Process hourly data
|
||||
hourly = response.Hourly()
|
||||
hourly_wind_speed_10m = hourly.Variables(0).ValuesAsNumpy()
|
||||
hourly_wind_direction_10m = hourly.Variables(1).ValuesAsNumpy()
|
||||
daily = response.Daily()
|
||||
daily_wind_speed_10m = daily.Variables(0).ValuesAsNumpy()
|
||||
daily_wind_direction_10m = daily.Variables(1).ValuesAsNumpy()
|
||||
|
||||
return hourly_wind_speed_10m.tolist(), hourly_wind_direction_10m.tolist()
|
||||
return daily_wind_speed_10m.tolist(), daily_wind_direction_10m.tolist()
|
||||
|
||||
def get_weather_info(self, latitude, longitude, start_date, end_date):
|
||||
def get_weather_info(self, start_date, end_date, latitude=54.35119762746125, longitude=48.389356992149345):
|
||||
responses = self.fetch_weather_data(latitude, longitude, start_date, end_date)
|
||||
response = responses[0]
|
||||
self.process_response(response)
|
||||
|
@ -1,5 +1,4 @@
|
||||
from datetime import date
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from fastapi import Query
|
||||
|
||||
@ -19,4 +18,4 @@ class SFlorisInputParams(BaseModel):
|
||||
|
||||
class SFlorisOutputData(BaseModel):
|
||||
file_name: str
|
||||
data: list[float]
|
||||
data: object
|
@ -14,6 +14,7 @@ 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"
|
||||
|
||||
router = APIRouter(
|
||||
@ -36,13 +37,9 @@ async def get_windmill_data(
|
||||
|
||||
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])
|
||||
climate_info = client.get_weather_info(data.date_start, data.date_end)
|
||||
wind_speeds = climate_info[0]
|
||||
wind_directions = climate_info[1]
|
||||
|
||||
fmodel.set(
|
||||
layout_x=data.layout_x,
|
||||
@ -54,12 +51,12 @@ async def get_windmill_data(
|
||||
|
||||
fmodel.run()
|
||||
|
||||
data = fmodel.get_turbine_powers()[0].tolist()
|
||||
res = fmodel.get_turbine_powers().tolist()
|
||||
file_name = fmodel.visualisation()
|
||||
|
||||
return SFlorisOutputData(
|
||||
file_name=file_name,
|
||||
data=data
|
||||
data=res
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user