Skip to main content

Python API fetching Solarpanels forecast information.

About

With this python library you can request data from Open-Meteo and see what your solar panels may produce in the coming days.

Installation

pip install open-meteo-solar-forecast

Data

This library returns a lot of different data, based on the API:

Energy

  • Total Estimated Energy Production - today/tomorrow (kWh)
  • Estimated Energy Production - This Hour (kWh)
  • Estimated Energy Production - Next Hour (kWh)
  • Estimated Energy Production - Remaining today (kWh)
  • Estimate.wh_period_15m: exact modeled energy in Wh for each 15-minute interval, keyed by its timezone-aware interval-start timestamp. It is derived from the interval-average modeled power after array combination and inverter clipping. Estimate.watts is instantaneous modeled power and is not an equivalent source for interval energy.

Power

  • Highest Power Peak Time - Today (datetime)
  • Highest Power Peak Time - Tomorrow (datetime)
  • Estimated Power Production - Now (W)
  • Estimated Power Production - Next Hour (W)
  • Estimated Power Production - In +6 Hours (W)
  • Estimated Power Production - In +12 Hours (W)
  • Estimated Power Production - In +24 Hours (W)

API Info

  • Timezone
  • Rate limit
  • Account type
  • Rate remaining

Validation

  • API key (bool)
  • Plane (bool)

Example

import asyncio

from open_meteo_solar_forecast import OpenMeteoSolarForecast


async def main() -> None:
    """Show example on how to use the library."""
    async with OpenMeteoSolarForecast(
        latitude=52.16,
        longitude=4.47,
        declination=20,
        azimuth=10,
        dc_kwp=2.160,
		use_horizon=True,
		partial_shading=True,
        horizon_map=((0,30),(360,30),
		max_snowcover_depth_cm=5.0,
    ) as forecast:
        estimate = await forecast.estimate()
        print(estimate)


if __name__ == "__main__":
    asyncio.run(main())
Parameter value type Description
base_url str The base URL of the API (optional)
api_key str Your API key (optional)
declination int | list[int] | tuple[int, ...] The tilt of the solar panels (required)
azimuth int | list[int] | tuple[int, ...] The direction the solar panels are facing, using the Open-Meteo convention: 0 = south, -90 = east, 90 = west, ±180 = north. To convert a compass bearing (0 = north, 90 = east, 180 = south, 270 = west), subtract 180. (required)
dc_kwp float | list[float] | tuple[float, ...] The size of the solar panels in kWp (required)
tracking str | list[str] | tuple[str, ...] Solar tracker type: "none", "azimuth", "tilt" or "dual" (optional, default = "none")
use_horizon bool | list[bool] | tuple[bool, ...] Whether to use horizon shading (optional, default = False)
partial_shading bool | list[bool] | tuple[bool, ...] Whether to use interpret horizon shading as partial [experimental] (optional, default = False)
horizon_map tuple of 2-tuples | list[tuple of 2-tuples] Map of the horizon* (required if use_horizon = True)
max_snowcover_depth_cm float | list[float] | tuple[float, ...] Critical snow coverage (cm) resulting in zero panel power [experimental] (required, default = 0.0 turns this off)

Multiple PV arrays

To calculate a combined forecast from multiple arrays, pass per-array values as lists or tuples for the required parameters (latitude, longitude, declination, azimuth, and dc_kwp).

async with OpenMeteoSolarForecast(
    latitude=[52.16, 52.16],
    longitude=[4.47, 4.47],
    declination=[20, 35],
    azimuth=[-90, 90],  # east and west (0 = south, -90 = east, 90 = west)
    dc_kwp=[2.4, 1.8],
    # Optional per-array values can also be lists/tuples
    efficiency_factor=[0.95, 0.97],
    use_horizon=[False, True],
    horizon_map=[
        ((0, 0), (360, 0)),
        ((0, 20), (180, 10), (360, 20)),
    max_snowcover_depth_cm=[5.0,5.0],
    ],
) as forecast:
    estimate = await forecast.estimate()

Scalar values are still supported and are automatically applied to all arrays when mixed with list/tuple inputs.

The horizon map is a tuple of 2-tuples, where each 2-tuple consists of (azimuth,elevation). Azimuth is the compass direction in degrees (0° = north, 180° = south). The horizon map has to cover the whole range of azimuths that the sun travels through over the year (recommendation: plot the horizon from 0 to 360°). Elevation is the associated angle in degrees of any object (hill, tree, ...) casting a shadow on the modules. The elevation angle has to be in the range 0° (flat, ideal horizon) to 90° (in the sky directly over the modules). The map has to be monotonic on the azimuth axis, however this is not checked by the script! Elevation values in between are interpolated along the azimuth axis, thus non-monotonic values will give wrong results. The horizon map can also be passed from a text file, see the included example estimate_horizon.py.

If partial_shading is disabled and a shadow is detected on the module, only the diffuse irradiation will be used to calculate the power output. This is useful if the shading is predominantly from far-away objects, which can be treated as shading the whole module at once or not. If partial_shading is enabled and a shadow is detected on the module, the shadow is treated as partial. This is useful if the shading arises from close-by objects, which cast 'hard' contoured shadows on the module. In this case, an experimental calculation is used taking into account the 'sunniness' of the conditions. This is done via the ratio of diffuse and direct irradiation. A large share of diffuse irradiation (cloudy day) will let the module run as homogeneously shaded at diffuse power. A small share of diffuse irradiation (sunny) day will reduce the diffuse power even more, since hard partial shadows can shut down the module completely.

If tracking is set to a value other than "none", the irradiance is calculated for a panel that follows the sun on the given axis. "azimuth" models a vertical-axis (east-west) tracker and ignores the azimuth parameter, "tilt" models a tilt-axis tracker and ignores the declination parameter, and "dual" models a dual-axis tracker and ignores both. Like the other per-array parameters, it can be passed as a list/tuple for multiple arrays.

If max_snowcover_depth_cm is set to a value > 0, this value will be interpreted as the snow cover depth (in centimeters) that results in zero power from the module. In between, a linear interpolation over the forecast snow cover depth is applied. (A value of 0 turns this feature completely off.)

Contributing

Would you like to contribute to the development of this project? Then read the prepared contribution guidelines and go ahead!

Thank you for being involved! :heart_eyes:

Setting up development environment

This Python project uses uv as its dependency manager.

You need at least:

  • Python 3.11+
  • uv

Install all packages, including all development requirements:

uv sync

uv creates a virtual environment in .venv where it installs all necessary packages. Run commands inside it with:

uv run python

License

MIT License

Copyright (c) 2021-2024 Klaas Schoute
Copyright (c) 2024 Rany

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_meteo_solar_forecast-0.1.30.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_meteo_solar_forecast-0.1.30-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file open_meteo_solar_forecast-0.1.30.tar.gz.

File metadata

  • Download URL: open_meteo_solar_forecast-0.1.30.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for open_meteo_solar_forecast-0.1.30.tar.gz
Algorithm Hash digest
SHA256 47e991bf8216e636f9b2a2de2c586bc35444557c9541359d8167cf9c5c06a239
MD5 a034f70d24f94eafef1560c6e217d3eb
BLAKE2b-256 179fb1efb912c3515e18c17995ce27849aec0b07d3a2368d8273a817af131af5

See more details on using hashes here.

File details

Details for the file open_meteo_solar_forecast-0.1.30-py3-none-any.whl.

File metadata

  • Download URL: open_meteo_solar_forecast-0.1.30-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for open_meteo_solar_forecast-0.1.30-py3-none-any.whl
Algorithm Hash digest
SHA256 7348569c247be8afca8e1f581481ef4f9e586d60e16853329fa07fd9248be68c
MD5 d7cbec9ffd6a6fb5c1a5c352d41d5963
BLAKE2b-256 38017f81d6f156801c999663bbdf38bd9968f8741d1b33f2e215f54632a7f486

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.32

2 files

0.1.31

2 files

This release

0.1.30 This release

2 files

0.1.29

2 files

0.1.27

2 files

0.1.23

2 files

0.1.22

2 files

0.1.21

2 files

0.1.20

2 files

0.1.19

2 files

0.1.18

2 files

0.1.17

2 files

0.1.16

2 files

0.1.15

2 files

0.1.14

2 files

0.1.13

2 files

0.1.12

2 files

0.1.11

2 files

0.1.10

2 files

0.1.9

2 files

0.1.8

2 files

0.1.7

2 files

0.1.6

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page