dtocean-economics
The DTOcean Economics Module provides functions to assess and compare the economic performance of arrays designed by DTOcean. It generates metrics such as the levelised cost of energy (LCOE). The module can accept multiple operational expenditure and energy production records to generate statistical analysis.
Part of the DTOcean suite of tools.
Installation
pip install dtocean-economics
Usage
An example of calculating the LCOE from a bill of materials, and two different operational expenditure (OPEX) and energy histories.
Create the bill of materials first (in Euro):
>>> import pandas as pd
>>> bom_dict = {'phase': ["One", "One", "One", "Two", "Two", "Two"],
... 'unitary_cost': [0.0, 100000.0, 100000.0, 1, 1, 1],
... 'project_year': [0, 1, 2, 0, 1, 2],
... 'quantity': [1, 1, 1, 1, 10, 20]}
>>> bom_df = pd.DataFrame(bom_dict, columns=["phase",
... "project_year",
... "quantity",
... "unitary_cost"])
>>> bom_df
phase project_year quantity unitary_cost
0 One 0 1 0.0
1 One 1 1 100000.0
2 One 2 1 100000.0
3 Two 0 1 1.0
4 Two 1 10 1.0
5 Two 2 20 1.0
Now build two independent OPEX records (in Euro):
>>> opex_dict = {'project_year': [0, 1, 2, 3, 4, 5],
... 'cost 0': [0.0, 100000.0, 100000.0, 1, 1, 1],
... 'cost 1': [0.0, 100000.0, 0, 1, 1, 100000.0]}
>>> opex_df = pd.DataFrame(opex_dict, columns=["project_year",
... "cost 0",
... "cost 1"])
>>> opex_df
project_year cost 0 cost 1
0 0 0.0 0.0
1 1 100000.0 100000.0
2 2 100000.0 0.0
3 3 1.0 1.0
4 4 1.0 1.0
5 5 1.0 100000.0
And the related energy production records (in Wh):
>>> energy_dict = {'project_year': [0, 1, 2, 3, 4, 5],
... 'energy 0': [0, 1e6, 2e6, 0, 10e6, 20e6],
... 'energy 1': [0, 1e6, 32e6, 0, 0, 20e6]}
>>> energy_df = pd.DataFrame(energy_dict, columns=["project_year",
... "energy 0",
... "energy 1"])
>>> energy_df
project_year energy 0 energy 1
0 0 0.0 0.0
1 1 1000000.0 1000000.0
2 2 2000000.0 32000000.0
3 3 0.0 0.0
4 4 10000000.0 0.0
5 5 20000000.0 20000000.0
Process the inputs to calculate the discounted values:
>>> from dtocean_economics import add_costs_to_bom, get_discounted_values
>>> discount_rate = 1 / 5
>>> add_costs_to_bom(bom_df, discount_rate)
>>> bom_df
phase project_year quantity unitary_cost costs discounted_costs
0 One 0 1 0.0 0.0 0.000000
1 One 1 1 100000.0 100000.0 83333.333333
2 One 2 1 100000.0 100000.0 69444.444444
3 Two 0 1 1.0 1.0 1.000000
4 Two 1 10 1.0 10.0 8.333333
5 Two 2 20 1.0 20.0 13.888889
>>> discounted_opex = get_discounted_values(opex_df, discount_rate)
>>> discounted_opex
0 152779.240612
1 123522.151492
dtype: float64
>>> discounted_energy = get_discounted_values(energy_df, discount_rate)
>>> discounted_energy
0 1.508230e+07
1 3.109311e+07
dtype: float64
Now calculate the mean of the LCOE (in Euro/kWh):
>>> discounted_capex = bom_df['discounted_costs'].sum()
>>> discounted_costs = discounted_opex + discounted_capex
>>> lcoe = discounted_costs / discounted_energy * 1000
>>> lcoe
0 20.260845
1 8.886958
dtype: float64
>>> float(lcoe.mean())
14.573901960338254
Development
Development of dtocean-economics uses the Poetry dependency manager. Poetry must be installed and available on the command line.
To install:
poetry install
Tests
A test suite is provided with the source code that uses pytest.
Install the testing dependencies:
poetry install --with test
Additional tests are available for the plugins to dtocean-core. Enable these
tests by installing the test-extras group:
poetry install --with test --with test-extras
Run the tests:
poetry run pytest
Code quality can also be audited using the ruff and pyright tools. Install the dependencies:
poetry install --with audit
Run the audit:
poetry run ruff
poetry run pyright src
The above tests can be run across all compatible Python versions using tox and tox-uv. To install:
poetry install --with test --with test-extras --with audit --with tox
To run the tests:
poetry run tox
Contributing
Please see the dtocean GitHub repository for contributing guidelines.
Credits
This package was initially created as part of the EU DTOcean project by:
It is now maintained by Mathew Topper at Data Only Greater.
License
Metadata
Release files for dtocean-economics 4.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dtocean_economics-4.0.1.tar.gz | 27.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dtocean_economics-4.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 57.4 kB
Release files / dtocean_economics-4.0.1.tar.gz
| Download URL | dtocean_economics-4.0.1.tar.gz |
|---|---|
| Size | 27.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
041feb0993cb082139c84e896f6479a5606ed6421b2d058d8962cb03f66071e1
|
|
BLAKE2b-256 checksum How to use checksums |
9a459fc4d93fe7baae399ce80fe60b3306a62fcde96e189c8b3dfb644a4336a4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency logRelease files / dtocean_economics-4.0.1-py3-none-any.whl
| Download URL | dtocean_economics-4.0.1-py3-none-any.whl |
|---|---|
| Size | 29.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
31c453b2373fe8ce76d3f59d8160759fde195929337e7d33c443b30f005104f5
|
|
BLAKE2b-256 checksum How to use checksums |
3c2490f8f90c199ae766d811e629da0cb9421585a09ef5336a0d7108f725330e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 21, 2026.
Transparency log