Welcome to SolarFarmer API¶
A Python SDK that wraps the DNV SolarFarmer API to run cloud-based energy calculations and manage API payloads.
New to SolarFarmer? Discover it here!
Embed SolarFarmer's API into your workflow. Typical use-cases of the package include:
- Build SolarFarmer API JSON payloads for 2D energy calculations
- Run 2D and 3D energy calculations from existing API payload files
- Manage and visualize simulation results
- Iterate over API payloads to explore design variations and optimization scenarios
Install¶
Install from PyPI using your favorite package manager, for example:
pip install dnv-solarfarmer
Tip
For full functionality install all: pip install "dnv-solarfarmer[all]"
Note
This package is periodically updated to remain compatible with the latest SolarFarmer API releases.
Getting Started¶
Warning
A commercial API key is required to run calculations with SolarFarmer's cloud energy yield engine.
Start by acquiring your SolarFarmer web API token. For more details, see the SolarFarmer web API introduction page.
Once you have your API key, provide it to the SDK using either the SF_API_KEY environment variable or pass it directly as the api_key argument when calling the energy calculation function or other endpoints.
Choose your workflow: load existing API files, build plant configurations from scratch, or integrate custom data models to run the SolarFarmer energy calculation in the cloud. For example,
Calling the energy calculation model with all the API inputs in a folder:
import solarfarmer as sf
# API key (optional, it could be an environment variable 'SF_API_KEY')
api_key = "Your SolarFarmer API key here"
project_id = "my_project"
# One folder with all the calculation inputs (JSON, PAN, OND, met data)
folder_with_inputs = r"C:\user_name\data\inputs_solarFarmer_api_call"
# Make the call to the API
results = sf.run_energy_calculation(inputs_folder_path=folder_with_inputs,
project_id=project_id,
api_key=api_key)
Tip
The package comes with sample files for both the 2D and 3D energy calculations, which are used in the tutorials.
Alternatively, you can get additional sample files from the API step-by-step tutorials or export your own from SolarFarmer's desktop application.
Contributing & License¶
Suggestions and code contributions are welcome on GitHub. This repository is licensed under the Apache License, Version 2.0 (see LICENSE).
For technical support, contact solarfarmer@dnv.com.