dnv-solarfarmer 0.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. dnv_solarfarmer-0.2.0/LICENSE +13 -0
  2. dnv_solarfarmer-0.2.0/MANIFEST.in +5 -0
  3. dnv_solarfarmer-0.2.0/PKG-INFO +183 -0
  4. dnv_solarfarmer-0.2.0/README.md +142 -0
  5. dnv_solarfarmer-0.2.0/dnv_solarfarmer.egg-info/PKG-INFO +183 -0
  6. dnv_solarfarmer-0.2.0/dnv_solarfarmer.egg-info/SOURCES.txt +71 -0
  7. dnv_solarfarmer-0.2.0/dnv_solarfarmer.egg-info/dependency_links.txt +1 -0
  8. dnv_solarfarmer-0.2.0/dnv_solarfarmer.egg-info/requires.txt +13 -0
  9. dnv_solarfarmer-0.2.0/dnv_solarfarmer.egg-info/top_level.txt +1 -0
  10. dnv_solarfarmer-0.2.0/docs/404.md +36 -0
  11. dnv_solarfarmer-0.2.0/docs/api.md +258 -0
  12. dnv_solarfarmer-0.2.0/docs/faq.md +57 -0
  13. dnv_solarfarmer-0.2.0/docs/getting-started/end-to-end-examples.md +128 -0
  14. dnv_solarfarmer-0.2.0/docs/getting-started/index.md +118 -0
  15. dnv_solarfarmer-0.2.0/docs/getting-started/quick-start-examples.md +505 -0
  16. dnv_solarfarmer-0.2.0/docs/getting-started/workflow-1-existing-api-files.md +325 -0
  17. dnv_solarfarmer-0.2.0/docs/getting-started/workflow-2-pvplant-builder.md +340 -0
  18. dnv_solarfarmer-0.2.0/docs/getting-started/workflow-3-plantbuilder-advanced.md +423 -0
  19. dnv_solarfarmer-0.2.0/docs/index.md +73 -0
  20. dnv_solarfarmer-0.2.0/docs/license.md +20 -0
  21. dnv_solarfarmer-0.2.0/mkdocs.yml +106 -0
  22. dnv_solarfarmer-0.2.0/pyproject.toml +123 -0
  23. dnv_solarfarmer-0.2.0/setup.cfg +4 -0
  24. dnv_solarfarmer-0.2.0/solarfarmer/__init__.py +133 -0
  25. dnv_solarfarmer-0.2.0/solarfarmer/__version__.py +85 -0
  26. dnv_solarfarmer-0.2.0/solarfarmer/api.py +554 -0
  27. dnv_solarfarmer-0.2.0/solarfarmer/config.py +55 -0
  28. dnv_solarfarmer-0.2.0/solarfarmer/endpoint_about.py +54 -0
  29. dnv_solarfarmer-0.2.0/solarfarmer/endpoint_modelchains.py +848 -0
  30. dnv_solarfarmer-0.2.0/solarfarmer/endpoint_modelchains_utils.py +729 -0
  31. dnv_solarfarmer-0.2.0/solarfarmer/endpoint_service.py +43 -0
  32. dnv_solarfarmer-0.2.0/solarfarmer/endpoint_terminate_async.py +56 -0
  33. dnv_solarfarmer-0.2.0/solarfarmer/logging.py +113 -0
  34. dnv_solarfarmer-0.2.0/solarfarmer/models/__init__.py +67 -0
  35. dnv_solarfarmer-0.2.0/solarfarmer/models/_base.py +14 -0
  36. dnv_solarfarmer-0.2.0/solarfarmer/models/auxiliary_losses.py +37 -0
  37. dnv_solarfarmer-0.2.0/solarfarmer/models/energy_calculation_inputs.py +83 -0
  38. dnv_solarfarmer-0.2.0/solarfarmer/models/energy_calculation_options.py +207 -0
  39. dnv_solarfarmer-0.2.0/solarfarmer/models/energy_calculation_results.py +1973 -0
  40. dnv_solarfarmer-0.2.0/solarfarmer/models/enums.py +101 -0
  41. dnv_solarfarmer-0.2.0/solarfarmer/models/inverter.py +38 -0
  42. dnv_solarfarmer-0.2.0/solarfarmer/models/layout.py +81 -0
  43. dnv_solarfarmer-0.2.0/solarfarmer/models/location.py +21 -0
  44. dnv_solarfarmer-0.2.0/solarfarmer/models/model_chain_response.py +202 -0
  45. dnv_solarfarmer-0.2.0/solarfarmer/models/monthly_albedo.py +60 -0
  46. dnv_solarfarmer-0.2.0/solarfarmer/models/mounting_type_specification.py +101 -0
  47. dnv_solarfarmer-0.2.0/solarfarmer/models/ond_supplements.py +32 -0
  48. dnv_solarfarmer-0.2.0/solarfarmer/models/pan_supplements.py +46 -0
  49. dnv_solarfarmer-0.2.0/solarfarmer/models/pv_plant.py +61 -0
  50. dnv_solarfarmer-0.2.0/solarfarmer/models/pvsystem/__init__.py +11 -0
  51. dnv_solarfarmer-0.2.0/solarfarmer/models/pvsystem/plant_defaults.py +91 -0
  52. dnv_solarfarmer-0.2.0/solarfarmer/models/pvsystem/plant_utils.py +187 -0
  53. dnv_solarfarmer-0.2.0/solarfarmer/models/pvsystem/pvsystem.py +1894 -0
  54. dnv_solarfarmer-0.2.0/solarfarmer/models/pvsystem/validation.py +29 -0
  55. dnv_solarfarmer-0.2.0/solarfarmer/models/tracker_system.py +36 -0
  56. dnv_solarfarmer-0.2.0/solarfarmer/models/transformer.py +30 -0
  57. dnv_solarfarmer-0.2.0/solarfarmer/models/transformer_specification.py +49 -0
  58. dnv_solarfarmer-0.2.0/solarfarmer/weather.py +498 -0
  59. dnv_solarfarmer-0.2.0/tests/test_api.py +448 -0
  60. dnv_solarfarmer-0.2.0/tests/test_construct_plant.py +211 -0
  61. dnv_solarfarmer-0.2.0/tests/test_endpoint_about.py +116 -0
  62. dnv_solarfarmer-0.2.0/tests/test_endpoint_modelchain.py +642 -0
  63. dnv_solarfarmer-0.2.0/tests/test_endpoint_modelchains_utils.py +780 -0
  64. dnv_solarfarmer-0.2.0/tests/test_endpoint_service.py +80 -0
  65. dnv_solarfarmer-0.2.0/tests/test_endpoint_terminate_async.py +97 -0
  66. dnv_solarfarmer-0.2.0/tests/test_energy_calculation_results.py +778 -0
  67. dnv_solarfarmer-0.2.0/tests/test_logging.py +75 -0
  68. dnv_solarfarmer-0.2.0/tests/test_model_chain_response.py +155 -0
  69. dnv_solarfarmer-0.2.0/tests/test_plant_utils.py +167 -0
  70. dnv_solarfarmer-0.2.0/tests/test_pvsystem.py +700 -0
  71. dnv_solarfarmer-0.2.0/tests/test_validation_message.py +72 -0
  72. dnv_solarfarmer-0.2.0/tests/test_version.py +15 -0
  73. dnv_solarfarmer-0.2.0/tests/test_weather.py +312 -0
@@ -0,0 +1,13 @@
1
+ Copyright [2026] [DNV AS]
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ include LICENSE
2
+ include README.md
3
+ include mkdocs.yml
4
+ recursive-include docs *.md
5
+ recursive-include examples *.py
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: dnv-solarfarmer
3
+ Version: 0.2.0
4
+ Summary: Python SDK for SolarFarmer, a bankable solar PV design and energy yield assessment tool by DNV.
5
+ Author-email: DNV <solarfarmer@dnv.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://www.dnv.com/software/services/solarfarmer/
8
+ Project-URL: Repository, https://github.com/dnv-opensource/solarfarmer-python-sdk
9
+ Project-URL: Issues, https://github.com/dnv-opensource/solarfarmer-python-sdk/issues
10
+ Keywords: solar,pv,photovoltaic,solarfarmer,dnv,sdk,api
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: License :: OSI Approved :: Apache Software License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Topic :: Software Development
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: pydantic>=2.0
30
+ Requires-Dist: requests>=2.28
31
+ Requires-Dist: tabulate>=0.9.0
32
+ Provides-Extra: notebooks
33
+ Requires-Dist: ipykernel<8,>=6.29; extra == "notebooks"
34
+ Requires-Dist: jupyterlab<6,>=4.0; extra == "notebooks"
35
+ Requires-Dist: notebook<9,>=7.0; extra == "notebooks"
36
+ Provides-Extra: all
37
+ Requires-Dist: dnv-solarfarmer[notebooks]; extra == "all"
38
+ Requires-Dist: pandas>=2.0; extra == "all"
39
+ Requires-Dist: matplotlib>=3.5; extra == "all"
40
+ Dynamic: license-file
41
+
42
+ # SolarFarmer Python SDK
43
+
44
+ [![PyPI version](https://img.shields.io/pypi/v/dnv-solarfarmer)](https://pypi.org/project/dnv-solarfarmer/)
45
+ [![Python versions](https://img.shields.io/pypi/pyversions/dnv-solarfarmer)](https://pypi.org/project/dnv-solarfarmer/)
46
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
47
+ [![CI](https://github.com/dnv-opensource/solarfarmer-python-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/dnv-opensource/solarfarmer-python-sdk/actions/workflows/test.yml)
48
+ [![Documentation](https://img.shields.io/badge/docs-online-teal)](https://dnv-opensource.github.io/solarfarmer-python-sdk/)
49
+
50
+ The official Python SDK for [SolarFarmer](https://www.dnv.com/software/services/solarfarmer/), a bankable solar PV design and energy yield assessment software from DNV. This SDK provides a typed Python interface that simplifies calling SolarFarmer APIs: build payloads, run 2D and 3D energy calculations, and process results programmatically.
51
+
52
+ ## Key Features
53
+
54
+ - **Data models that mirror the API schema.** Pydantic classes with field validation catch payload errors locally before the API call. Field descriptions and type hints improve discoverability.
55
+ - **Two plant-building paths.** Full control via `EnergyCalculationInputs` and component classes, or quick screening via `PVSystem` from high-level specs (DC and AC capacities, tilt, GCR)
56
+ - **Structured results.** `CalculationResults` gives direct access to annual/monthly metrics, loss trees, and time series without parsing raw JSON.
57
+ - **Automatic endpoint handling.** One function call runs 2D or 3D calculations. The SDK selects the right endpoint, polls async jobs, and supports cancellation via `terminate_calculation()`.
58
+
59
+ ## Requirements
60
+
61
+ - Python >= 3.10 (tested on 3.10, 3.11, 3.12, 3.13)
62
+ - A SolarFarmer API key (commercial licence required; see [API Key](#api-key))
63
+
64
+ ## Installation
65
+
66
+ Install from PyPI:
67
+
68
+ ```bash
69
+ pip install dnv-solarfarmer
70
+ ```
71
+
72
+ The package is imported as `solarfarmer` regardless of the distribution name:
73
+
74
+ ```python
75
+ import solarfarmer as sf
76
+ ```
77
+
78
+ Install with optional extras:
79
+
80
+ ```bash
81
+ pip install "dnv-solarfarmer[notebooks]" # JupyterLab and notebook support
82
+ pip install "dnv-solarfarmer[all]" # full installation including pandas and matplotlib
83
+ ```
84
+
85
+ For development and documentation extras (managed as dependency groups, requires `uv`):
86
+
87
+ ```bash
88
+ uv sync --group dev # linting and testing tools (for contributors)
89
+ uv sync --group docs # documentation build tools
90
+ ```
91
+
92
+ Install from source:
93
+
94
+ ```bash
95
+ git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
96
+ cd solarfarmer-python-sdk
97
+ pip install -e .
98
+ ```
99
+
100
+ ## API Key
101
+
102
+ A SolarFarmer API key is required to run energy calculations. Obtain one from the [SolarFarmer portal](https://solarfarmer.dnv.com/). For setup instructions, see the [API key documentation](https://mysoftware.dnv.com/download/public/renewables/solarfarmer/manuals/latest/WebApi/Introduction/ApiKey.html).
103
+
104
+ Set your key as an environment variable (recommended):
105
+
106
+ ```bash
107
+ export SF_API_KEY="your_api_key_here"
108
+ ```
109
+
110
+ Alternatively, pass it directly as the `api_key` parameter to any function that calls the API.
111
+
112
+ ## Configuration
113
+
114
+ | Environment Variable | Default | Description |
115
+ |---|---|---|
116
+ | `SF_API_KEY` | *(none; required for calculations)* | API authentication token |
117
+ | `SF_API_URL` | `https://solarfarmer.dnv.com/latest/api` | Override the base API URL for custom deployments |
118
+
119
+ ## Optional Dependencies
120
+
121
+ The core SDK (`pydantic`, `requests`, `tabulate`) does not depend on `pandas`.
122
+ Install the `all` extra for DataFrame-based features:
123
+
124
+ ```bash
125
+ pip install "dnv-solarfarmer[all]"
126
+ ```
127
+
128
+ This unlocks `sf.from_dataframe()` and `sf.from_pvlib()` for writing weather files from DataFrames, and enables `CalculationResults` to parse timeseries outputs into DataFrames. Without pandas, those functions raise `ImportError` or return `None`. All other SDK features work without it.
129
+
130
+ ## Getting Started
131
+
132
+ The SDK supports three workflows for different use cases:
133
+
134
+ | Workflow | Best for | Entry point |
135
+ |---|---|---|
136
+ | 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=...)` |
137
+ | 2. PVSystem builder | Quick screening from high-level specs (capacity, tilt, equipment files). The design is approximate: string sizing and inverter count are inferred, so DC/AC capacity may not match the target exactly. | `plant = sf.PVSystem(...)` then `plant.run_energy_calculation()` |
138
+ | 3. Custom integration | Developers mapping internal databases or proprietary formats to the SolarFarmer API | `params = sf.EnergyCalculationInputs(...)` then `sf.run_energy_calculation(plant_builder=params)` |
139
+
140
+ See the [Getting Started guide](https://dnv-opensource.github.io/solarfarmer-python-sdk/getting-started/) for full per-workflow walkthroughs, and the [example notebooks](https://dnv-opensource.github.io/solarfarmer-python-sdk/notebooks/Example_EnergyCalculations/) for runnable end-to-end examples.
141
+
142
+ ## Documentation
143
+
144
+ Full documentation (API reference, workflow guides, notebook tutorials):
145
+
146
+ **https://dnv-opensource.github.io/solarfarmer-python-sdk/**
147
+
148
+ To build and serve the documentation locally:
149
+
150
+ ```bash
151
+ uv sync --group docs
152
+ zensical serve -o # build, serve, and open in browser (port 8000)
153
+ zensical serve -o -a localhost:8080 # use a different port
154
+ ```
155
+
156
+ `zensical serve` builds the docs and starts a local server in one step. The `-o` flag opens the page automatically in your default browser.
157
+
158
+ ## Contributing
159
+
160
+ Fork the repository, create a branch, and submit a pull request to `main`. To set up a development environment:
161
+
162
+ ```bash
163
+ git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
164
+ cd solarfarmer-python-sdk
165
+ pip install -e .
166
+ uv sync --group dev
167
+ ```
168
+
169
+ - **Linting and formatting:** `ruff check solarfarmer/ tests/` and `ruff format solarfarmer/ tests/`
170
+ - **Tests:** `pytest tests/ -v`
171
+
172
+ All contributions should include tests for new functionality. For feature proposals or questions, contact [solarfarmer@dnv.com](mailto:solarfarmer@dnv.com). See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
173
+
174
+ ## Getting Technical Support
175
+
176
+ - **SDK documentation:** https://dnv-opensource.github.io/solarfarmer-python-sdk/
177
+ - **SolarFarmer API documentation:** https://mysoftware.dnv.com/download/public/renewables/solarfarmer/manuals/latest/WebApi/Introduction/introduction.html
178
+ - **Issue tracker:** https://github.com/dnv-opensource/solarfarmer-python-sdk/issues
179
+ - **Email:** [solarfarmer@dnv.com](mailto:solarfarmer@dnv.com)
180
+
181
+ ## License
182
+
183
+ Apache License, Version 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,142 @@
1
+ # SolarFarmer Python SDK
2
+
3
+ [![PyPI version](https://img.shields.io/pypi/v/dnv-solarfarmer)](https://pypi.org/project/dnv-solarfarmer/)
4
+ [![Python versions](https://img.shields.io/pypi/pyversions/dnv-solarfarmer)](https://pypi.org/project/dnv-solarfarmer/)
5
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
6
+ [![CI](https://github.com/dnv-opensource/solarfarmer-python-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/dnv-opensource/solarfarmer-python-sdk/actions/workflows/test.yml)
7
+ [![Documentation](https://img.shields.io/badge/docs-online-teal)](https://dnv-opensource.github.io/solarfarmer-python-sdk/)
8
+
9
+ The official Python SDK for [SolarFarmer](https://www.dnv.com/software/services/solarfarmer/), a bankable solar PV design and energy yield assessment software from DNV. This SDK provides a typed Python interface that simplifies calling SolarFarmer APIs: build payloads, run 2D and 3D energy calculations, and process results programmatically.
10
+
11
+ ## Key Features
12
+
13
+ - **Data models that mirror the API schema.** Pydantic classes with field validation catch payload errors locally before the API call. Field descriptions and type hints improve discoverability.
14
+ - **Two plant-building paths.** Full control via `EnergyCalculationInputs` and component classes, or quick screening via `PVSystem` from high-level specs (DC and AC capacities, tilt, GCR)
15
+ - **Structured results.** `CalculationResults` gives direct access to annual/monthly metrics, loss trees, and time series without parsing raw JSON.
16
+ - **Automatic endpoint handling.** One function call runs 2D or 3D calculations. The SDK selects the right endpoint, polls async jobs, and supports cancellation via `terminate_calculation()`.
17
+
18
+ ## Requirements
19
+
20
+ - Python >= 3.10 (tested on 3.10, 3.11, 3.12, 3.13)
21
+ - A SolarFarmer API key (commercial licence required; see [API Key](#api-key))
22
+
23
+ ## Installation
24
+
25
+ Install from PyPI:
26
+
27
+ ```bash
28
+ pip install dnv-solarfarmer
29
+ ```
30
+
31
+ The package is imported as `solarfarmer` regardless of the distribution name:
32
+
33
+ ```python
34
+ import solarfarmer as sf
35
+ ```
36
+
37
+ Install with optional extras:
38
+
39
+ ```bash
40
+ pip install "dnv-solarfarmer[notebooks]" # JupyterLab and notebook support
41
+ pip install "dnv-solarfarmer[all]" # full installation including pandas and matplotlib
42
+ ```
43
+
44
+ For development and documentation extras (managed as dependency groups, requires `uv`):
45
+
46
+ ```bash
47
+ uv sync --group dev # linting and testing tools (for contributors)
48
+ uv sync --group docs # documentation build tools
49
+ ```
50
+
51
+ Install from source:
52
+
53
+ ```bash
54
+ git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
55
+ cd solarfarmer-python-sdk
56
+ pip install -e .
57
+ ```
58
+
59
+ ## API Key
60
+
61
+ A SolarFarmer API key is required to run energy calculations. Obtain one from the [SolarFarmer portal](https://solarfarmer.dnv.com/). For setup instructions, see the [API key documentation](https://mysoftware.dnv.com/download/public/renewables/solarfarmer/manuals/latest/WebApi/Introduction/ApiKey.html).
62
+
63
+ Set your key as an environment variable (recommended):
64
+
65
+ ```bash
66
+ export SF_API_KEY="your_api_key_here"
67
+ ```
68
+
69
+ Alternatively, pass it directly as the `api_key` parameter to any function that calls the API.
70
+
71
+ ## Configuration
72
+
73
+ | Environment Variable | Default | Description |
74
+ |---|---|---|
75
+ | `SF_API_KEY` | *(none; required for calculations)* | API authentication token |
76
+ | `SF_API_URL` | `https://solarfarmer.dnv.com/latest/api` | Override the base API URL for custom deployments |
77
+
78
+ ## Optional Dependencies
79
+
80
+ The core SDK (`pydantic`, `requests`, `tabulate`) does not depend on `pandas`.
81
+ Install the `all` extra for DataFrame-based features:
82
+
83
+ ```bash
84
+ pip install "dnv-solarfarmer[all]"
85
+ ```
86
+
87
+ This unlocks `sf.from_dataframe()` and `sf.from_pvlib()` for writing weather files from DataFrames, and enables `CalculationResults` to parse timeseries outputs into DataFrames. Without pandas, those functions raise `ImportError` or return `None`. All other SDK features work without it.
88
+
89
+ ## Getting Started
90
+
91
+ The SDK supports three workflows for different use cases:
92
+
93
+ | Workflow | Best for | Entry point |
94
+ |---|---|---|
95
+ | 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=...)` |
96
+ | 2. PVSystem builder | Quick screening from high-level specs (capacity, tilt, equipment files). The design is approximate: string sizing and inverter count are inferred, so DC/AC capacity may not match the target exactly. | `plant = sf.PVSystem(...)` then `plant.run_energy_calculation()` |
97
+ | 3. Custom integration | Developers mapping internal databases or proprietary formats to the SolarFarmer API | `params = sf.EnergyCalculationInputs(...)` then `sf.run_energy_calculation(plant_builder=params)` |
98
+
99
+ See the [Getting Started guide](https://dnv-opensource.github.io/solarfarmer-python-sdk/getting-started/) for full per-workflow walkthroughs, and the [example notebooks](https://dnv-opensource.github.io/solarfarmer-python-sdk/notebooks/Example_EnergyCalculations/) for runnable end-to-end examples.
100
+
101
+ ## Documentation
102
+
103
+ Full documentation (API reference, workflow guides, notebook tutorials):
104
+
105
+ **https://dnv-opensource.github.io/solarfarmer-python-sdk/**
106
+
107
+ To build and serve the documentation locally:
108
+
109
+ ```bash
110
+ uv sync --group docs
111
+ zensical serve -o # build, serve, and open in browser (port 8000)
112
+ zensical serve -o -a localhost:8080 # use a different port
113
+ ```
114
+
115
+ `zensical serve` builds the docs and starts a local server in one step. The `-o` flag opens the page automatically in your default browser.
116
+
117
+ ## Contributing
118
+
119
+ Fork the repository, create a branch, and submit a pull request to `main`. To set up a development environment:
120
+
121
+ ```bash
122
+ git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
123
+ cd solarfarmer-python-sdk
124
+ pip install -e .
125
+ uv sync --group dev
126
+ ```
127
+
128
+ - **Linting and formatting:** `ruff check solarfarmer/ tests/` and `ruff format solarfarmer/ tests/`
129
+ - **Tests:** `pytest tests/ -v`
130
+
131
+ All contributions should include tests for new functionality. For feature proposals or questions, contact [solarfarmer@dnv.com](mailto:solarfarmer@dnv.com). See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
132
+
133
+ ## Getting Technical Support
134
+
135
+ - **SDK documentation:** https://dnv-opensource.github.io/solarfarmer-python-sdk/
136
+ - **SolarFarmer API documentation:** https://mysoftware.dnv.com/download/public/renewables/solarfarmer/manuals/latest/WebApi/Introduction/introduction.html
137
+ - **Issue tracker:** https://github.com/dnv-opensource/solarfarmer-python-sdk/issues
138
+ - **Email:** [solarfarmer@dnv.com](mailto:solarfarmer@dnv.com)
139
+
140
+ ## License
141
+
142
+ Apache License, Version 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,183 @@
1
+ Metadata-Version: 2.4
2
+ Name: dnv-solarfarmer
3
+ Version: 0.2.0
4
+ Summary: Python SDK for SolarFarmer, a bankable solar PV design and energy yield assessment tool by DNV.
5
+ Author-email: DNV <solarfarmer@dnv.com>
6
+ License: Apache-2.0
7
+ Project-URL: Homepage, https://www.dnv.com/software/services/solarfarmer/
8
+ Project-URL: Repository, https://github.com/dnv-opensource/solarfarmer-python-sdk
9
+ Project-URL: Issues, https://github.com/dnv-opensource/solarfarmer-python-sdk/issues
10
+ Keywords: solar,pv,photovoltaic,solarfarmer,dnv,sdk,api
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: License :: OSI Approved :: Apache Software License
20
+ Classifier: Operating System :: OS Independent
21
+ Classifier: Topic :: Scientific/Engineering :: Physics
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Classifier: Topic :: Software Development :: Libraries
24
+ Classifier: Topic :: Software Development
25
+ Classifier: Topic :: Scientific/Engineering
26
+ Requires-Python: >=3.10
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Requires-Dist: pydantic>=2.0
30
+ Requires-Dist: requests>=2.28
31
+ Requires-Dist: tabulate>=0.9.0
32
+ Provides-Extra: notebooks
33
+ Requires-Dist: ipykernel<8,>=6.29; extra == "notebooks"
34
+ Requires-Dist: jupyterlab<6,>=4.0; extra == "notebooks"
35
+ Requires-Dist: notebook<9,>=7.0; extra == "notebooks"
36
+ Provides-Extra: all
37
+ Requires-Dist: dnv-solarfarmer[notebooks]; extra == "all"
38
+ Requires-Dist: pandas>=2.0; extra == "all"
39
+ Requires-Dist: matplotlib>=3.5; extra == "all"
40
+ Dynamic: license-file
41
+
42
+ # SolarFarmer Python SDK
43
+
44
+ [![PyPI version](https://img.shields.io/pypi/v/dnv-solarfarmer)](https://pypi.org/project/dnv-solarfarmer/)
45
+ [![Python versions](https://img.shields.io/pypi/pyversions/dnv-solarfarmer)](https://pypi.org/project/dnv-solarfarmer/)
46
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](LICENSE)
47
+ [![CI](https://github.com/dnv-opensource/solarfarmer-python-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/dnv-opensource/solarfarmer-python-sdk/actions/workflows/test.yml)
48
+ [![Documentation](https://img.shields.io/badge/docs-online-teal)](https://dnv-opensource.github.io/solarfarmer-python-sdk/)
49
+
50
+ The official Python SDK for [SolarFarmer](https://www.dnv.com/software/services/solarfarmer/), a bankable solar PV design and energy yield assessment software from DNV. This SDK provides a typed Python interface that simplifies calling SolarFarmer APIs: build payloads, run 2D and 3D energy calculations, and process results programmatically.
51
+
52
+ ## Key Features
53
+
54
+ - **Data models that mirror the API schema.** Pydantic classes with field validation catch payload errors locally before the API call. Field descriptions and type hints improve discoverability.
55
+ - **Two plant-building paths.** Full control via `EnergyCalculationInputs` and component classes, or quick screening via `PVSystem` from high-level specs (DC and AC capacities, tilt, GCR)
56
+ - **Structured results.** `CalculationResults` gives direct access to annual/monthly metrics, loss trees, and time series without parsing raw JSON.
57
+ - **Automatic endpoint handling.** One function call runs 2D or 3D calculations. The SDK selects the right endpoint, polls async jobs, and supports cancellation via `terminate_calculation()`.
58
+
59
+ ## Requirements
60
+
61
+ - Python >= 3.10 (tested on 3.10, 3.11, 3.12, 3.13)
62
+ - A SolarFarmer API key (commercial licence required; see [API Key](#api-key))
63
+
64
+ ## Installation
65
+
66
+ Install from PyPI:
67
+
68
+ ```bash
69
+ pip install dnv-solarfarmer
70
+ ```
71
+
72
+ The package is imported as `solarfarmer` regardless of the distribution name:
73
+
74
+ ```python
75
+ import solarfarmer as sf
76
+ ```
77
+
78
+ Install with optional extras:
79
+
80
+ ```bash
81
+ pip install "dnv-solarfarmer[notebooks]" # JupyterLab and notebook support
82
+ pip install "dnv-solarfarmer[all]" # full installation including pandas and matplotlib
83
+ ```
84
+
85
+ For development and documentation extras (managed as dependency groups, requires `uv`):
86
+
87
+ ```bash
88
+ uv sync --group dev # linting and testing tools (for contributors)
89
+ uv sync --group docs # documentation build tools
90
+ ```
91
+
92
+ Install from source:
93
+
94
+ ```bash
95
+ git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
96
+ cd solarfarmer-python-sdk
97
+ pip install -e .
98
+ ```
99
+
100
+ ## API Key
101
+
102
+ A SolarFarmer API key is required to run energy calculations. Obtain one from the [SolarFarmer portal](https://solarfarmer.dnv.com/). For setup instructions, see the [API key documentation](https://mysoftware.dnv.com/download/public/renewables/solarfarmer/manuals/latest/WebApi/Introduction/ApiKey.html).
103
+
104
+ Set your key as an environment variable (recommended):
105
+
106
+ ```bash
107
+ export SF_API_KEY="your_api_key_here"
108
+ ```
109
+
110
+ Alternatively, pass it directly as the `api_key` parameter to any function that calls the API.
111
+
112
+ ## Configuration
113
+
114
+ | Environment Variable | Default | Description |
115
+ |---|---|---|
116
+ | `SF_API_KEY` | *(none; required for calculations)* | API authentication token |
117
+ | `SF_API_URL` | `https://solarfarmer.dnv.com/latest/api` | Override the base API URL for custom deployments |
118
+
119
+ ## Optional Dependencies
120
+
121
+ The core SDK (`pydantic`, `requests`, `tabulate`) does not depend on `pandas`.
122
+ Install the `all` extra for DataFrame-based features:
123
+
124
+ ```bash
125
+ pip install "dnv-solarfarmer[all]"
126
+ ```
127
+
128
+ This unlocks `sf.from_dataframe()` and `sf.from_pvlib()` for writing weather files from DataFrames, and enables `CalculationResults` to parse timeseries outputs into DataFrames. Without pandas, those functions raise `ImportError` or return `None`. All other SDK features work without it.
129
+
130
+ ## Getting Started
131
+
132
+ The SDK supports three workflows for different use cases:
133
+
134
+ | Workflow | Best for | Entry point |
135
+ |---|---|---|
136
+ | 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=...)` |
137
+ | 2. PVSystem builder | Quick screening from high-level specs (capacity, tilt, equipment files). The design is approximate: string sizing and inverter count are inferred, so DC/AC capacity may not match the target exactly. | `plant = sf.PVSystem(...)` then `plant.run_energy_calculation()` |
138
+ | 3. Custom integration | Developers mapping internal databases or proprietary formats to the SolarFarmer API | `params = sf.EnergyCalculationInputs(...)` then `sf.run_energy_calculation(plant_builder=params)` |
139
+
140
+ See the [Getting Started guide](https://dnv-opensource.github.io/solarfarmer-python-sdk/getting-started/) for full per-workflow walkthroughs, and the [example notebooks](https://dnv-opensource.github.io/solarfarmer-python-sdk/notebooks/Example_EnergyCalculations/) for runnable end-to-end examples.
141
+
142
+ ## Documentation
143
+
144
+ Full documentation (API reference, workflow guides, notebook tutorials):
145
+
146
+ **https://dnv-opensource.github.io/solarfarmer-python-sdk/**
147
+
148
+ To build and serve the documentation locally:
149
+
150
+ ```bash
151
+ uv sync --group docs
152
+ zensical serve -o # build, serve, and open in browser (port 8000)
153
+ zensical serve -o -a localhost:8080 # use a different port
154
+ ```
155
+
156
+ `zensical serve` builds the docs and starts a local server in one step. The `-o` flag opens the page automatically in your default browser.
157
+
158
+ ## Contributing
159
+
160
+ Fork the repository, create a branch, and submit a pull request to `main`. To set up a development environment:
161
+
162
+ ```bash
163
+ git clone https://github.com/dnv-opensource/solarfarmer-python-sdk
164
+ cd solarfarmer-python-sdk
165
+ pip install -e .
166
+ uv sync --group dev
167
+ ```
168
+
169
+ - **Linting and formatting:** `ruff check solarfarmer/ tests/` and `ruff format solarfarmer/ tests/`
170
+ - **Tests:** `pytest tests/ -v`
171
+
172
+ All contributions should include tests for new functionality. For feature proposals or questions, contact [solarfarmer@dnv.com](mailto:solarfarmer@dnv.com). See [CONTRIBUTING.md](CONTRIBUTING.md) for full guidelines.
173
+
174
+ ## Getting Technical Support
175
+
176
+ - **SDK documentation:** https://dnv-opensource.github.io/solarfarmer-python-sdk/
177
+ - **SolarFarmer API documentation:** https://mysoftware.dnv.com/download/public/renewables/solarfarmer/manuals/latest/WebApi/Introduction/introduction.html
178
+ - **Issue tracker:** https://github.com/dnv-opensource/solarfarmer-python-sdk/issues
179
+ - **Email:** [solarfarmer@dnv.com](mailto:solarfarmer@dnv.com)
180
+
181
+ ## License
182
+
183
+ Apache License, Version 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,71 @@
1
+ LICENSE
2
+ MANIFEST.in
3
+ README.md
4
+ mkdocs.yml
5
+ pyproject.toml
6
+ dnv_solarfarmer.egg-info/PKG-INFO
7
+ dnv_solarfarmer.egg-info/SOURCES.txt
8
+ dnv_solarfarmer.egg-info/dependency_links.txt
9
+ dnv_solarfarmer.egg-info/requires.txt
10
+ dnv_solarfarmer.egg-info/top_level.txt
11
+ docs/404.md
12
+ docs/api.md
13
+ docs/faq.md
14
+ docs/index.md
15
+ docs/license.md
16
+ docs/getting-started/end-to-end-examples.md
17
+ docs/getting-started/index.md
18
+ docs/getting-started/quick-start-examples.md
19
+ docs/getting-started/workflow-1-existing-api-files.md
20
+ docs/getting-started/workflow-2-pvplant-builder.md
21
+ docs/getting-started/workflow-3-plantbuilder-advanced.md
22
+ solarfarmer/__init__.py
23
+ solarfarmer/__version__.py
24
+ solarfarmer/api.py
25
+ solarfarmer/config.py
26
+ solarfarmer/endpoint_about.py
27
+ solarfarmer/endpoint_modelchains.py
28
+ solarfarmer/endpoint_modelchains_utils.py
29
+ solarfarmer/endpoint_service.py
30
+ solarfarmer/endpoint_terminate_async.py
31
+ solarfarmer/logging.py
32
+ solarfarmer/weather.py
33
+ solarfarmer/models/__init__.py
34
+ solarfarmer/models/_base.py
35
+ solarfarmer/models/auxiliary_losses.py
36
+ solarfarmer/models/energy_calculation_inputs.py
37
+ solarfarmer/models/energy_calculation_options.py
38
+ solarfarmer/models/energy_calculation_results.py
39
+ solarfarmer/models/enums.py
40
+ solarfarmer/models/inverter.py
41
+ solarfarmer/models/layout.py
42
+ solarfarmer/models/location.py
43
+ solarfarmer/models/model_chain_response.py
44
+ solarfarmer/models/monthly_albedo.py
45
+ solarfarmer/models/mounting_type_specification.py
46
+ solarfarmer/models/ond_supplements.py
47
+ solarfarmer/models/pan_supplements.py
48
+ solarfarmer/models/pv_plant.py
49
+ solarfarmer/models/tracker_system.py
50
+ solarfarmer/models/transformer.py
51
+ solarfarmer/models/transformer_specification.py
52
+ solarfarmer/models/pvsystem/__init__.py
53
+ solarfarmer/models/pvsystem/plant_defaults.py
54
+ solarfarmer/models/pvsystem/plant_utils.py
55
+ solarfarmer/models/pvsystem/pvsystem.py
56
+ solarfarmer/models/pvsystem/validation.py
57
+ tests/test_api.py
58
+ tests/test_construct_plant.py
59
+ tests/test_endpoint_about.py
60
+ tests/test_endpoint_modelchain.py
61
+ tests/test_endpoint_modelchains_utils.py
62
+ tests/test_endpoint_service.py
63
+ tests/test_endpoint_terminate_async.py
64
+ tests/test_energy_calculation_results.py
65
+ tests/test_logging.py
66
+ tests/test_model_chain_response.py
67
+ tests/test_plant_utils.py
68
+ tests/test_pvsystem.py
69
+ tests/test_validation_message.py
70
+ tests/test_version.py
71
+ tests/test_weather.py
@@ -0,0 +1,13 @@
1
+ pydantic>=2.0
2
+ requests>=2.28
3
+ tabulate>=0.9.0
4
+
5
+ [all]
6
+ dnv-solarfarmer[notebooks]
7
+ pandas>=2.0
8
+ matplotlib>=3.5
9
+
10
+ [notebooks]
11
+ ipykernel<8,>=6.29
12
+ jupyterlab<6,>=4.0
13
+ notebook<9,>=7.0
@@ -0,0 +1 @@
1
+ solarfarmer
@@ -0,0 +1,36 @@
1
+ # 404 - Page Not Found
2
+
3
+ The page you're looking for cannot be found.
4
+
5
+ ## Quick Links
6
+
7
+ **[← Back to Home](index.md)** | **[Getting Started](getting-started/index.md)** | **[API Reference](api.md)**
8
+
9
+ ## Find What You Need
10
+
11
+ ### Popular Pages
12
+
13
+ - [Quick Start Examples](getting-started/quick-start-examples.md)
14
+ - [Workflow 1: Load Existing API Files](getting-started/workflow-1-existing-api-files.md)
15
+ - [Workflow 2: Design Plants with PVSystem](getting-started/workflow-2-pvplant-builder.md)
16
+ - [Workflow 3: Advanced Integration](getting-started/workflow-3-plantbuilder-advanced.md)
17
+ - [End-to-End Examples](getting-started/end-to-end-examples.md)
18
+
19
+ ### Example Notebooks
20
+
21
+ Browse our [Jupyter notebook examples](getting-started/index.md) for hands-on tutorials covering:
22
+
23
+ - Using the About and Service Endpoints
24
+ - Running 2D and 3D Calculations
25
+ - Creating Plants with PVSystem
26
+ - Terminating Asynchronous Calculations
27
+
28
+ ## Need Help?
29
+
30
+ **Search** - Use the search bar above to find documentation
31
+
32
+ **Report Issues** - [GitHub Issues](https://github.com/dnv-opensource/solarfarmer-api-python-sdk/issues)
33
+
34
+ **Contact** - [solarfarmer@dnv.com](mailto:solarfarmer@dnv.com)
35
+
36
+ **Community** - Follow on [LinkedIn](https://www.linkedin.com/feed/hashtag/solarfarmer/)