SDK for SolarFarmer software, bankable solar PV calculation engine developed by DNV.
Project description
SolarFarmer Python SDK
The official Python SDK for DNV SolarFarmer, a bankable solar PV calculation engine. Use it to build validated API payloads, run cloud-based 2D and 3D energy calculations, and analyse simulation results — all from Python.
Key Features
- API-faithful data models that closely mirror the SolarFarmer API schema, with serialization conveniences (snake_case Python fields serialized to the correct camelCase JSON automatically) to reduce integration friction
- Two plant-building approaches: a bottom-up route using
EnergyCalculationInputs,PVPlant, and component classes (Inverter,Layout,Transformer, etc.) for full control over the plant topology; and aPVSystemconvenience class that accepts high-level parameters (capacity, tilt, GCR, equipment files) and constructs the payload automatically, suited to indicative simulations where exhaustive detail is not required CalculationResultsencapsulation — the API response is wrapped in aCalculationResultsobject that provides structured access to annual and monthly energy metrics, loss trees, PVsyst-format time-series, and detailed time-series output without manual JSON parsing- ModelChain and ModelChainAsync endpoint support — the SDK dispatches to the synchronous
ModelChainendpoint or the asynchronousModelChainAsyncendpoint as appropriate, and handles polling automatically for long-running jobs - Async job management — poll, monitor, and terminate async calculations via
terminate_calculation()
Requirements
- Python >= 3.10 (tested on 3.10, 3.11, 3.12, 3.13)
- A SolarFarmer API key (commercial licence required) — see API Key
Installation
Install from PyPI:
pip install dnv-solarfarmer
The package is imported as solarfarmer regardless of the distribution name:
import solarfarmer as sf
Install with optional extras:
pip install "dnv-solarfarmer[notebooks]" # JupyterLab and notebook support
pip install "dnv-solarfarmer[all]" # full installation including pandas and matplotlib
pip install "dnv-solarfarmer[dev]" # linting and testing tools (for contributors)
Install from source:
git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
cd solarfarmer-python-sdk
pip install -e .
API Key
A SolarFarmer API key is required to run energy calculations. Obtain one from the SolarFarmer portal. For setup instructions, see the API key documentation.
Set your key as an environment variable (recommended):
export SF_API_KEY="your_api_key_here"
Alternatively, pass it directly as the api_key parameter to any function that calls the API.
Configuration
| Environment Variable | Default | Description |
|---|---|---|
SF_API_KEY |
(none — required for calculations) | API authentication token |
SF_API_URL |
https://solarfarmer.dnv.com/latest/api |
Override the base API URL for custom deployments |
Getting Started
The SDK is built around three workflows suited to different use cases:
| Workflow | Best for | Primary entry point |
|---|---|---|
| 1. Load existing files | Users with pre-built API payloads from the SolarFarmer desktop app or a previous export | sf.run_energy_calculation(inputs_folder_path=...) |
| 2. PVSystem builder | Solar engineers designing new plants programmatically with automatic payload generation | sf.PVSystem(...) then plant.run_energy_calculation() |
| 3. Custom integration | Developers mapping internal databases or proprietary formats to the SolarFarmer API | sf.EnergyCalculationInputs(location=..., pv_plant=..., ...) |
See the Getting Started guide for full per-workflow walkthroughs, and the example notebooks for runnable end-to-end examples.
Documentation
Full documentation including API reference, workflow guides, and notebook tutorials:
https://dnv-opensource.github.io/solarfarmer-python-sdk/
To build and serve the documentation locally:
pip install "dnv-solarfarmer[docs]"
zensical serve -o # build, serve, and open in browser (port 8000)
zensical serve -o -a localhost:8080 # use a different port
zensical serve builds the docs and starts a local server in one step. The -o flag opens the page automatically in your default browser.
Contributing
Fork the repository, create a branch, and submit a pull request to main. To set up a development environment:
git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
cd solarfarmer-python-sdk
pip install -e ".[dev]"
- Linting and formatting:
ruff check solarfarmer/ tests/andruff format solarfarmer/ tests/ - Tests:
pytest tests/ -v
All contributions should include tests for new functionality. For feature proposals or questions, contact solarfarmer@dnv.com. See CONTRIBUTING.md for full guidelines.
Getting Technical Support
- SDK documentation: https://dnv-opensource.github.io/solarfarmer-python-sdk/
- SolarFarmer API documentation: https://mysoftware.dnv.com/download/public/renewables/solarfarmer/manuals/latest/WebApi/Introduction/introduction.html
- Issue tracker: https://github.com/dnv-opensource/solarfarmer-python-sdk/issues
- Email: solarfarmer@dnv.com
License
Apache License, Version 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dnv_solarfarmer-0.2.0rc1.tar.gz.
File metadata
- Download URL: dnv_solarfarmer-0.2.0rc1.tar.gz
- Upload date:
- Size: 121.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70dfc60d28fb505e319e8542136a15fe2b480798453296898cae5880a24e2615
|
|
| MD5 |
1ec182e6015398c8f309560614283fcc
|
|
| BLAKE2b-256 |
92d3dad939ba362cb3890e60786e39c2340e4e21e19f9c3bea01ae36aa8a8264
|
Provenance
The following attestation bundles were made for dnv_solarfarmer-0.2.0rc1.tar.gz:
Publisher:
release.yml on dnv-opensource/solarfarmer-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dnv_solarfarmer-0.2.0rc1.tar.gz -
Subject digest:
70dfc60d28fb505e319e8542136a15fe2b480798453296898cae5880a24e2615 - Sigstore transparency entry: 1175475275
- Sigstore integration time:
-
Permalink:
dnv-opensource/solarfarmer-python-sdk@ba5ca982cb204156bae4b291718973d25008dff5 -
Branch / Tag:
refs/tags/v0.2.0rc1 - Owner: https://github.com/dnv-opensource
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ba5ca982cb204156bae4b291718973d25008dff5 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dnv_solarfarmer-0.2.0rc1-py3-none-any.whl.
File metadata
- Download URL: dnv_solarfarmer-0.2.0rc1-py3-none-any.whl
- Upload date:
- Size: 83.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
450caeaa2f0b89116cce1b2e14c541fe66e1d63e9dea3b1fb62f654de36ee272
|
|
| MD5 |
db30a8528b79405f99b553434888ff5a
|
|
| BLAKE2b-256 |
bf546f6e4ae2091aaeabb6e2d15f45545e124963f9729cb5d7fae786ee0a917c
|
Provenance
The following attestation bundles were made for dnv_solarfarmer-0.2.0rc1-py3-none-any.whl:
Publisher:
release.yml on dnv-opensource/solarfarmer-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dnv_solarfarmer-0.2.0rc1-py3-none-any.whl -
Subject digest:
450caeaa2f0b89116cce1b2e14c541fe66e1d63e9dea3b1fb62f654de36ee272 - Sigstore transparency entry: 1175475289
- Sigstore integration time:
-
Permalink:
dnv-opensource/solarfarmer-python-sdk@ba5ca982cb204156bae4b291718973d25008dff5 -
Branch / Tag:
refs/tags/v0.2.0rc1 - Owner: https://github.com/dnv-opensource
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ba5ca982cb204156bae4b291718973d25008dff5 -
Trigger Event:
push
-
Statement type: