Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions src/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,15 +343,10 @@ def set_location(location):


def forecast_to_json(forecast_data, decimal):
"""
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you removed the docstring?

Takes forecast_data from forecast() as input
and returns it in JSON format
"""
# Formatting into JSON
forecasts = []
for i in range(len(forecast_data["date"])):
forecast = {
"date": str(forecast_data["date"][i].date()),
for i, d in enumerate(forecast_data["date"]):
forecasts.append({
"date": str(d.date()),
"surf height": round(
float(forecast_data["wave_height_max"][i]), decimal
),
Expand All @@ -370,23 +365,29 @@ def forecast_to_json(forecast_data, decimal):
"temperature_2m_min": round(
float(forecast_data["temperature_2m_min"][i]), decimal
),
"rain_sum": round(float(forecast_data["rain_sum"][i]), decimal),
"rain_sum": round(
float(forecast_data["rain_sum"][i]), decimal
),
"daily_precipitation_probability": round(
float(forecast_data["precipitation_probability_max"][i]),
decimal,
float(
forecast_data["precipitation_probability_max"][i]
),
decimal
),
"wind_speed_max": round(
float(forecast_data["wind_speed_10m_max"][i]), decimal
),
"wind_direction_10m_dominant": round(
float(forecast_data["wind_direction_10m_dominant"][i]), decimal
float(
forecast_data["wind_direction_10m_dominant"][i]
),
decimal
),
}
forecasts.append(forecast)

})
return forecasts



def surf_summary(surf_data):
"""
Outputs a simple summary of the surf data.
Expand Down