Skip to content

Commit bca5acf

Browse files
Update pre commit (#100)
* code: set default data path * code: set default data path * code: changes to data_accessor * code: add unit test for ensure_path_exists * code: update data_accessor.md * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * code: pre-commit * code: add missing data_path docstring * update pyupgrade * update pyupgrade * code: update pre-commit and solve new issues * update REUSE.toml --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent bae79b9 commit bca5acf

7 files changed

Lines changed: 10 additions & 10 deletions

File tree

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,4 @@ repos:
7272
rev: v0.2.22 # Use the latest release tag
7373
hooks:
7474
- id: rumdl
75-
args: ["--fix", "--disable=MD006, MD013, MD024, MD030, MD033, MD041"]
75+
args: ["--fix", "--disable=MD013, MD024, MD030, MD033, MD041"]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ A Python package to manage techno-economic assumptions for energy system models.
1818
It provides a structured way to store, retrieve, and manipulate data related to various technologies used in energy systems,
1919
including unit-ful parameters, currency conversions, inflation adjustment, and temporal modelling.
2020

21-
The package currently includes a pre-parsed dataset from the DEA's Technology Catalogue focusing on energy storage technologies and a dedicated parser (see [here](docs/examples/dea_storage.md)). In the future it will include other common public data sources such NREL's ATB.
21+
The package currently includes a pre-parsed dataset from the DEA's Technology Catalogue focusing on energy storage technologies and a dedicated parser (see [DEA parser documentation](docs/examples/dea_storage_v10.md)). In the future it will include other common public data sources such NREL's ATB.
2222

2323
The goal of this package is to make energy system modelling easier and more efficient,
2424
automating common tasks and transformations to reduce errors and allowing for easier data exchange between models.
@@ -75,7 +75,7 @@ uv sync --group dev --group docs
7575

7676
## Usage
7777

78-
Detailed usage instructions and examples can be found in the available documentation. To build the documentation locally, follow the steps outlined [here](docs/contributing/instructions.md#building-the-documentation-locally).
78+
Detailed usage instructions and examples can be found in the available documentation. To build the documentation locally, follow the [contributing instructions](docs/contributing/instructions.md#building-the-documentation-locally).
7979

8080
## Maintainers
8181

docs/examples/dea_storage_v10.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The Danish Energy Agency (DEA) data parser demonstrates a full data-cleaning and
1616

1717
## Dataset Description
1818

19-
The original dataset is available at this [link](https://ens.dk/media/6589/download). A full description of the dataset is available at this [link](https://ens.dk/media/6588/download). The raw source file is included in the repository at `src/technologydata/parsers/raw/Technology_datasheet_for_energy_storage.xlsx`.
19+
The original dataset is available from the [Danish Energy Agency website](https://ens.dk/media/6589/download). A full description of the dataset is available in the [DEA documentation](https://ens.dk/media/6588/download). The raw source file is included in the repository at `src/technologydata/parsers/raw/Technology_datasheet_for_energy_storage.xlsx`.
2020

2121
The dataset is in Excel format, and it includes, under the data sheet `alldata_flat`, a flat table of technology parameters for a range of energy storage technologies. Columns include `Technology`, `ws`, `par` (parameter name), `val` (value), `unit`, `year`, `est` (case/estimate), `priceyear`, plus metadata columns such as `cat`, `ref`, `note`. Rows are individual parameter records (parameter value + unit + context) for technologies and estimation cases.
2222

@@ -40,7 +40,7 @@ Function `_extract_year()` extracts the first sequence of digits from the `year`
4040

4141
Function `_clean_parameter_string()` removes leading hyphens, removes text inside square brackets (units/notes), collapses extra spaces and lower-cases the parameter name. It is applied to the `par` column.
4242

43-
Function `_standardize_units()` is applied to columns `par` and `unit`. It completes missing units based on parameter name (e.g., `energy storage capacity for one unit` is mapped to the unit `MWh`) via a parameter-to-unit map. Moreover, it replaces known incorrect unit strings as `⁰C` -> `C` or `m2` to `meter**2`. The unit substitutions are driven by the `pint` documentation available at this [link](https://github.com/hgrecco/pint/blob/master/pint/default_en.txt).
43+
Function `_standardize_units()` is applied to columns `par` and `unit`. It completes missing units based on parameter name (e.g., `energy storage capacity for one unit` is mapped to the unit `MWh`) via a parameter-to-unit map. Moreover, it replaces known incorrect unit strings as `⁰C` -> `C` or `m2` to `meter**2`. The unit substitutions are driven by the [pint default units definition](https://github.com/hgrecco/pint/blob/master/pint/default_en.txt).
4444

4545
Function `Commons.update_unit_with_currency_year(unit, priceyear)`, if present, appends `priceyear` information to currency units. This is because `technologydata` follows the currency pattern `\b(?P<cu_iso3>[A-Z]{3})_(?P<year>\d{4})\b`, as for example `EUR_2021`.
4646

docs/examples/manual_input_usa_v0134.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ The Manual Input USA data parser demonstrates a data-cleaning and transformation
1616

1717
## Dataset Description
1818

19-
The original dataset is a manually curated CSV file containing USA-specific technology parameters available at this [link](https://github.com/PyPSA/technology-data/blob/v0.13.4/inputs/US/manual_input_usa.csv). The raw source file is included in the repository at `src/technologydata/parsers/raw/manual_input_usa.csv`.
19+
The original dataset is a manually curated CSV file containing USA-specific technology parameters available from the [PyPSA technology-data repository](https://github.com/PyPSA/technology-data/blob/v0.13.4/inputs/US/manual_input_usa.csv). The raw source file is included in the repository at `src/technologydata/parsers/raw/manual_input_usa.csv`.
2020

2121
The dataset is in CSV format and includes a flat table of technology parameters for various energy technologies relevant to the USA context. Columns include `technology`, `parameter`, `year`, `value`, `unit`, `currency_year`, `source`, `further_description`, `financial_case`, and `scenario`. Rows are individual parameter records (parameter value + unit + context) for technologies with different scenarios and financial cases.
2222

docs/user_guide/parameter.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The `Parameter` class in `technologydata` encapsulates a value, its unit, proven
66

77
## Features
88

9-
- **Value and Units**: Stores a numerical value (`magnitude`) and its associated units (`units`). Units are handled using `pint` and support custom currency units (e.g., `USD_2020/kW`). The default `pint` units definition file is available [here](https://github.com/hgrecco/pint/blob/master/pint/default_en.txt) for reference. Be mindful of false unit-friends, e.g. `t = metric_ton = tonne != ton = US_ton`
9+
- **Value and Units**: Stores a numerical value (`magnitude`) and its associated units (`units`). Units are handled using `pint` and support custom currency units (e.g., `USD_2020/kW`). The [pint default units definition](https://github.com/hgrecco/pint/blob/master/pint/default_en.txt) file is available for reference. Be mindful of false unit-friends, e.g. `t = metric_ton = tonne != ton = US_ton`
1010
- **Currency Unit Convention**: Currency units must follow the pattern `XYZ_YYYY`, where `XYZ` is the 3-letter [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code (e.g., `USD`, `EUR`, `CNY`) and `YYYY` is the 4-digit year (e.g., `USD_2020`). This allows for both currency and inflation adjustments.
1111
- **Carrier and Heating Value**: Optionally specify an energy carrier (e.g., `H2`) and a heating value type (`LHV` or `HHV`).
1212
- **Provenance and Notes**: Track the origin of the data and any additional notes.

src/technologydata/parsers/data_accessor.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55
"""Provide a class to access data from a data source."""
66

7+
import enum
78
import logging
89
import pathlib
910
import re
1011
import sys
11-
from enum import Enum
1212
from typing import Annotated
1313

1414
import pydantic
@@ -24,7 +24,7 @@
2424
logger = logging.getLogger(__name__)
2525

2626

27-
class DataSourceName(str, Enum):
27+
class DataSourceName(enum.StrEnum):
2828
"""An enumeration of available data sources."""
2929

3030
DEA_ENERGY_STORAGE = "dea_energy_storage"

src/technologydata/utils/commons.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
all_currency_codes = set(get_iso3_to_currency_codes().values())
2020

2121

22-
class DateFormatEnum(str, enum.Enum):
22+
class DateFormatEnum(enum.StrEnum):
2323
"""
2424
Enum for date formats used in different sources.
2525

0 commit comments

Comments
 (0)