This commit is contained in:
Павел Сорокин 2024-12-01 18:53:00 +04:00
parent a229d96eda
commit 325fe7c6f5

View File

@ -138,8 +138,8 @@ def get_wind_speed_and_direction(prediction, batch: Batch, lat: float, lon: floa
u_values = prediction.atmos_vars["u"][:, :, :, lat_idx, lon_idx]
v_values = prediction.atmos_vars["v"][:, :, :, lat_idx, lon_idx]
wind_speed=[]
wind_direction=[]
wind_speeds=[]
wind_directions=[]
for i in range(u_values.numel()):
u_scalar = u_values.view(-1)[i].item() # Разворачиваем тензор в одномерный и берем элемент
v_scalar = v_values.view(-1)[i].item()
@ -154,10 +154,10 @@ def get_wind_speed_and_direction(prediction, batch: Batch, lat: float, lon: floa
wind_dir = metpy.calc.wind_direction(u_with_units, v_with_units)
wind_speed = metpy.calc.wind_speed(u_with_units, v_with_units)
wind_speed.append(wind_speed.magnitude.item())
wind_direction.append(wind_dir.magnitude.item())
wind_speeds.append(wind_speed.magnitude.item())
wind_directions.append(wind_dir.magnitude.item())
return wind_speed,wind_direction
return wind_speeds,wind_directions
def wind_direction_to_text(wind_dir_deg):