forecast
forecast
#
Generate potential future capture sessions.
Candidate sessions for the scheduler to choose from: times lays out the
slots, and the rest add the conditions each slot would be captured under,
composed with the cg.Array() broadcasting pattern.
Available Functions
times(resolution, span, start): Generate datetime slots at a fixed resolution.times_of_day(hours, start): Generate today's remaining slots at specific hours.solar_position(location, time): Compute solar altitude/azimuth (vectorized).hourly_weather(location, days): Fetch hourly weather from Open-Meteo (free, no API key).fetch_past_weather(location, when): Fetch historical weather from Meteostat station observations.nearest_weather(weather, times): Find the nearest weather entry for each timestamp.locations_area(bounds, resolution_meters): Grid of locations inside a polygon.locations_perimeter(bounds, resolution_meters): Locations along a polygon's edges.
Example
from datetime import timedelta
import capturegraph as cg
import capturegraph.scheduling as cgsh
# Generate potential sessions for the next 24 hours
potential = cg.Array()
potential.date = cgsh.forecast.times(span=timedelta(hours=24))
potential.location = my_location
# Add solar angles
potential.solar_angle = cgsh.forecast.solar_position(my_location, potential.date)
# Add weather forecasts
weather_data = cgsh.forecast.hourly_weather(my_location, days=3)
potential.weather = cgsh.forecast.nearest_weather(weather_data, potential.date)