eta_utility.connectors.forecast_solar module
This module provides a read-only REST API connector to the forecast.solar API.
You can obtain an estimate of solar production for a specific location, defined by latitude and longitude, and a specific plane orientation, defined by declination and azimuth, based on the installed module power.
Supported endpoints include: “Estimate”, “Historic”, and “Clearsky”:
Estimate Solar Production The estimate endpoint provides the forecast for today and the upcoming days, depending on the account model.
Historic Solar Production The historic endpoint calculates the average solar production for a given day based on historical weather data, excluding current weather conditions.
Clear Sky Solar Production The clearsky endpoint calculates the theoretically possible solar production assuming no cloud cover.
For more information, visit the forecast.solar API documentation.
- class eta_utility.connectors.forecast_solar.ForecastSolarConnection(url: str = 'https://api.forecast.solar', *, api_key: str = 'None', url_params: dict[str, Any] | None = None, query_params: dict[str, Any] | None = None, nodes: Nodes | None = None)[source]
Bases:
SeriesConnection
ForecastSolarConnection is a class to download and upload multiple features from and to the Forecast.Solar database as timeseries.
- Parameters:
url – URL of the server with scheme (https://).
usr – Not needed for Forecast.Solar.
pwd – Not needed for Forecast.Solar.
api_key – Token for API authentication.
nodes – Nodes to select in connection.
- read(nodes: Nodes | None = None) pd.DataFrame [source]
Return forecast data from the Forecast.Solar Database.
- Parameters:
nodes – List of nodes to read values from.
- Returns:
pandas.DataFrame containing the data read from the connection.
- write(values: Mapping[AnyNode, Any]) None [source]
Warning
Cannot read single values from the Forecast.Solar API. Use read_series instead
- Raises:
- subscribe(handler: SubscriptionHandler, nodes: Nodes | None = None, interval: TimeStep = 1) None [source]
Warning
Cannot read single values from the Forecast.Solar API. Use read_series instead
- Raises:
- read_series(from_time: datetime, to_time: datetime, nodes: Nodes | None = None, interval: TimeStep = 1, **kwargs: Any) pd.DataFrame [source]
Return a time series of forecast data from the Forecast.Solar Database.
- Parameters:
nodes – List of nodes to read values from.
from_time – Starting time to begin reading (included in output).
to_time – Time to stop reading at (not included in output).
interval – Interval between time steps. It is interpreted as seconds if given as integer.
kwargs – Other parameters (ignored by this connector).
- Returns:
Pandas DataFrame containing the data read from the connection.
- subscribe_series(handler: SubscriptionHandler, req_interval: TimeStep, offset: TimeStep | None = None, nodes: Nodes | None = None, interval: TimeStep = 1, data_interval: TimeStep = 1, **kwargs: Any) None [source]
Warning
Cannot read single values from the Forecast.Solar API. Use read_series instead
- Raises:
- close_sub() None [source]
Warning
Cannot read single values from the Forecast.Solar API. Use read_series instead
- Raises:
- timestr_from_datetime(dt: datetime) str [source]
Create an Forecast.Solar compatible time string.
- Parameters:
dt – Datetime object to convert to string.
- Returns:
Forecast.Solar compatible time string.
- classmethod route_valid(nodes: Nodes) bool [source]
Check if node routes make up a valid route, by using the Forecast.Solar API’s check endpoint.
- Parameters:
nodes – List of nodes to check.
- Returns:
Boolean if the nodes are on the same route.
- classmethod calculate_watt_hours_period(df: pandas.DataFrame, watts_column: str) pandas.DataFrame [source]
Calculates watt hours for each period based on the average watts provided. Assumes the DataFrame is indexed by timestamps.
- classmethod summarize_watt_hours_over_day(df: pandas.DataFrame) pandas.DataFrame [source]
Sums up watt hours over each day.
- classmethod get_dataframe_of_values(df: pandas.DataFrame, watts_column: str = 'watts') tuple[pandas.DataFrame, pandas.DataFrame] [source]
Process the original DataFrame to return a DataFrame with watt_hours_period, watt_hours (summarized over the day), and watt_hours_day.