Economic assessment module for the DTOcean tools
Project description
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
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 dtocean_economics-4.0.0.tar.gz.
File metadata
- Download URL: dtocean_economics-4.0.0.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c5f9cb1809db79784fd8df65f2183c7abd8be25e9a8d1487b10c4945b54a072
|
|
| MD5 |
8827f9062e50ace20814dbf92af6690b
|
|
| BLAKE2b-256 |
71ad3472866e9e2442c2179e51a623946447578d1ab6775ba05b75c63831f239
|
Provenance
The following attestation bundles were made for dtocean_economics-4.0.0.tar.gz:
Publisher:
release.yml on DTOcean/dtocean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dtocean_economics-4.0.0.tar.gz -
Subject digest:
9c5f9cb1809db79784fd8df65f2183c7abd8be25e9a8d1487b10c4945b54a072 - Sigstore transparency entry: 1350492398
- Sigstore integration time:
-
Permalink:
DTOcean/dtocean@8df626cfa2a4b922d6163de1eff475bb8eb5f239 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DTOcean
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8df626cfa2a4b922d6163de1eff475bb8eb5f239 -
Trigger Event:
push
-
Statement type:
File details
Details for the file dtocean_economics-4.0.0-py3-none-any.whl.
File metadata
- Download URL: dtocean_economics-4.0.0-py3-none-any.whl
- Upload date:
- Size: 29.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d545cbe51fc109390755fe4aa2a02a5dc418a282b785d8f50a9812e9f2295133
|
|
| MD5 |
7dd60f2c18fa0745284e4dc3645f970f
|
|
| BLAKE2b-256 |
4e510e96c601f47de2dc2983298f0d8cb6a49a3fb447c9d75e96290212bd9814
|
Provenance
The following attestation bundles were made for dtocean_economics-4.0.0-py3-none-any.whl:
Publisher:
release.yml on DTOcean/dtocean
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
dtocean_economics-4.0.0-py3-none-any.whl -
Subject digest:
d545cbe51fc109390755fe4aa2a02a5dc418a282b785d8f50a9812e9f2295133 - Sigstore transparency entry: 1350492488
- Sigstore integration time:
-
Permalink:
DTOcean/dtocean@8df626cfa2a4b922d6163de1eff475bb8eb5f239 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DTOcean
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8df626cfa2a4b922d6163de1eff475bb8eb5f239 -
Trigger Event:
push
-
Statement type: