technologydata 0.1.0__tar.gz → 0.2.1__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 (106) hide show
  1. {technologydata-0.1.0 → technologydata-0.2.1}/CITATIONS.cff +1 -1
  2. {technologydata-0.1.0 → technologydata-0.2.1}/MANIFEST.in +3 -2
  3. {technologydata-0.1.0 → technologydata-0.2.1}/PKG-INFO +1 -1
  4. {technologydata-0.1.0 → technologydata-0.2.1}/REUSE.toml +3 -4
  5. {technologydata-0.1.0 → technologydata-0.2.1}/docs/examples/dea_storage.md +8 -8
  6. technologydata-0.2.1/docs/examples/manual_input_usa.md +78 -0
  7. {technologydata-0.1.0 → technologydata-0.2.1}/docs/index.md +1 -0
  8. {technologydata-0.1.0 → technologydata-0.2.1}/mkdocs.yaml +1 -0
  9. technologydata-0.2.1/src/technologydata/parsers/commons.py +136 -0
  10. {technologydata-0.1.0/src/technologydata/package_data → technologydata-0.2.1/src/technologydata/parsers}/dea_energy_storage/dea_energy_storage.py +23 -56
  11. technologydata-0.2.1/src/technologydata/parsers/manual_input_usa/manual_input_usa.py +256 -0
  12. technologydata-0.2.1/src/technologydata/parsers/manual_input_usa/sources.json +12 -0
  13. technologydata-0.2.1/src/technologydata/parsers/manual_input_usa/technologies.json +4149 -0
  14. technologydata-0.2.1/src/technologydata/parsers/raw/manual_input_usa.csv +287 -0
  15. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/utils/carriers.txt +2 -0
  16. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata.egg-info/PKG-INFO +1 -1
  17. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata.egg-info/SOURCES.txt +11 -4
  18. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_dea_energy_storage.py +1 -1
  19. technologydata-0.2.1/test/test_parser_commons.py +28 -0
  20. {technologydata-0.1.0 → technologydata-0.2.1}/.codespell.ignore +0 -0
  21. {technologydata-0.1.0 → technologydata-0.2.1}/.github/instructions/copilot-instructions.md +0 -0
  22. {technologydata-0.1.0 → technologydata-0.2.1}/.github/workflows/ci.yaml +0 -0
  23. {technologydata-0.1.0 → technologydata-0.2.1}/.github/workflows/release.yml +0 -0
  24. {technologydata-0.1.0 → technologydata-0.2.1}/.gitignore +0 -0
  25. {technologydata-0.1.0 → technologydata-0.2.1}/.pre-commit-config.yaml +0 -0
  26. {technologydata-0.1.0 → technologydata-0.2.1}/.readthedocs.yaml +0 -0
  27. {technologydata-0.1.0 → technologydata-0.2.1}/CONTRIBUTING.md +0 -0
  28. {technologydata-0.1.0 → technologydata-0.2.1}/LICENSE +0 -0
  29. {technologydata-0.1.0 → technologydata-0.2.1}/LICENSES/CC-BY-4.0.txt +0 -0
  30. {technologydata-0.1.0 → technologydata-0.2.1}/LICENSES/MIT.txt +0 -0
  31. {technologydata-0.1.0 → technologydata-0.2.1}/README.md +0 -0
  32. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/commons/commons.md +0 -0
  33. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/commons/dateformatenum.md +0 -0
  34. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/commons/fileextensionenum.md +0 -0
  35. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/datapackage.md +0 -0
  36. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/parameter.md +0 -0
  37. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/source.md +0 -0
  38. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/source_collection.md +0 -0
  39. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/technology.md +0 -0
  40. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/technology_collection.md +0 -0
  41. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/units/customundefineduniterror.md +0 -0
  42. {technologydata-0.1.0 → technologydata-0.2.1}/docs/api/units/specialunitregistry.md +0 -0
  43. {technologydata-0.1.0 → technologydata-0.2.1}/docs/assets/extensions/dynamic_inspect.py +0 -0
  44. {technologydata-0.1.0 → technologydata-0.2.1}/docs/assets/javascripts/matjax.js +0 -0
  45. {technologydata-0.1.0 → technologydata-0.2.1}/docs/assets/javascripts/readthedocs.js +0 -0
  46. {technologydata-0.1.0 → technologydata-0.2.1}/docs/assets/logo/technology_data_logo.png +0 -0
  47. {technologydata-0.1.0 → technologydata-0.2.1}/docs/assets/overrides/hooks/shortcodes.py +0 -0
  48. {technologydata-0.1.0 → technologydata-0.2.1}/docs/assets/stylesheets/extra.css +0 -0
  49. {technologydata-0.1.0 → technologydata-0.2.1}/docs/contributing/CODE_OF_CONDUCT.md +0 -0
  50. {technologydata-0.1.0 → technologydata-0.2.1}/docs/contributing/contributors.md +0 -0
  51. {technologydata-0.1.0 → technologydata-0.2.1}/docs/contributing/instructions.md +0 -0
  52. {technologydata-0.1.0 → technologydata-0.2.1}/docs/home/citing.md +0 -0
  53. {technologydata-0.1.0 → technologydata-0.2.1}/docs/home/contacts.md +0 -0
  54. {technologydata-0.1.0 → technologydata-0.2.1}/docs/home/faq.md +0 -0
  55. {technologydata-0.1.0 → technologydata-0.2.1}/docs/home/installation.md +0 -0
  56. {technologydata-0.1.0 → technologydata-0.2.1}/docs/home/license.md +0 -0
  57. {technologydata-0.1.0 → technologydata-0.2.1}/docs/home/release-notes.md +0 -0
  58. {technologydata-0.1.0 → technologydata-0.2.1}/docs/home/users.md +0 -0
  59. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/class-diagram.puml +0 -0
  60. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/datapackage.md +0 -0
  61. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/design.md +0 -0
  62. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/models.md +0 -0
  63. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/parameter.md +0 -0
  64. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/source.md +0 -0
  65. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/source_collection.md +0 -0
  66. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/technology.md +0 -0
  67. {technologydata-0.1.0 → technologydata-0.2.1}/docs/user_guide/technology_collection.md +0 -0
  68. {technologydata-0.1.0 → technologydata-0.2.1}/pyproject.toml +0 -0
  69. {technologydata-0.1.0 → technologydata-0.2.1}/setup.cfg +0 -0
  70. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/__init__.py +0 -0
  71. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/constants/__init__.py +0 -0
  72. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/constants/energy_density.py +0 -0
  73. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/datapackage.py +0 -0
  74. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/parameter.py +0 -0
  75. {technologydata-0.1.0/src/technologydata/package_data → technologydata-0.2.1/src/technologydata/parsers}/dea_energy_storage/sources.json +0 -0
  76. {technologydata-0.1.0/src/technologydata/package_data → technologydata-0.2.1/src/technologydata/parsers}/dea_energy_storage/technologies.json +0 -0
  77. {technologydata-0.1.0/src/technologydata/package_data → technologydata-0.2.1/src/technologydata/parsers}/raw/Technology_datasheet_for_energy_storage.xlsx +0 -0
  78. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/source.py +0 -0
  79. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/source_collection.py +0 -0
  80. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/technologies/__init__.py +0 -0
  81. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/technologies/growth_models.py +0 -0
  82. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/technology.py +0 -0
  83. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/technology_collection.py +0 -0
  84. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/utils/__init__.py +0 -0
  85. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/utils/commons.py +0 -0
  86. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/utils/heating_values.txt +0 -0
  87. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata/utils/units.py +0 -0
  88. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata.egg-info/dependency_links.txt +0 -0
  89. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata.egg-info/requires.txt +0 -0
  90. {technologydata-0.1.0 → technologydata-0.2.1}/src/technologydata.egg-info/top_level.txt +0 -0
  91. {technologydata-0.1.0 → technologydata-0.2.1}/test/conftest.py +0 -0
  92. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_commons.py +0 -0
  93. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_data/currency_conversion/WB_CNY_2020/parameters.csv +0 -0
  94. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_data/currency_conversion/WB_EUR_2020/parameters.csv +0 -0
  95. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_data/currency_conversion/WB_USD_2020/parameters.csv +0 -0
  96. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_data/solar_photovoltaics_example/sources.json +0 -0
  97. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_data/solar_photovoltaics_example/technologies.json +0 -0
  98. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_datapackage.py +0 -0
  99. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_growth_models.py +0 -0
  100. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_parameter.py +0 -0
  101. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_source.py +0 -0
  102. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_source_collection.py +0 -0
  103. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_technology.py +0 -0
  104. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_technology_collection.py +0 -0
  105. {technologydata-0.1.0 → technologydata-0.2.1}/test/test_units.py +0 -0
  106. {technologydata-0.1.0 → technologydata-0.2.1}/uv.lock +0 -0
@@ -6,7 +6,7 @@ cff-version: 1.2.0
6
6
  message: "If you use this package, we suggest the following way of citing it."
7
7
  title: "technologydata: Data for Energy Systems Models"
8
8
  repository: https://github.com/open-energy-transition/technology-data
9
- version: 0.1.0 # Don't touch, will be updated by the release script
9
+ version: 0.2.1 # Don't touch, will be updated by the release script
10
10
  license: MIT
11
11
  authors:
12
12
  - family-names: Hampp
@@ -1,6 +1,7 @@
1
1
  include src/technologydata/utils/*.txt
2
- include src/technologydata/package_data/dea_energy_storage/*.json
3
- include src/technologydata/package_data/raw/*
2
+ include src/technologydata/parsers/dea_energy_storage/*.json
3
+ include src/technologydata/parsers/manual_input_usa/*.json
4
+ include src/technologydata/parsers/raw/*
4
5
  include test/test_data/currency_conversion/WB_CNY_2020/*
5
6
  include test/test_data/currency_conversion/WB_EUR_2020/*
6
7
  include test/test_data/currency_conversion/WB_USD_2020/*
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: technologydata
3
- Version: 0.1.0
3
+ Version: 0.2.1
4
4
  Summary: Package for providing common data assumptions for energy system modelling on techno-economics and macro-economics.
5
5
  Author-email: Contributors to technologydata <johannes.hampp@openenergytransition.org>, Contributors to technologydata <fabrizio.finozzi.business@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/open-energy-transition/technology-data
@@ -8,22 +8,21 @@ path = ["uv.lock", "*.yaml", "docs/**", "*.md", "*.in"]
8
8
  SPDX-FileCopyrightText = "technologydata contributors"
9
9
  SPDX-License-Identifier = "MIT"
10
10
 
11
-
12
11
  [[annotations]]
13
- path = ["test/test_data/**",]
12
+ path = ["test/test_data/**"]
14
13
  SPDX-FileCopyrightText = "technologydata contributors"
15
14
  SPDX-License-Identifier = "CC-BY-4.0"
16
15
 
17
16
  [[annotations]]
18
17
  path = [
19
- "src/technologydata/package_data/dea_energy_storage/*.json", "src/technologydata/package_data/schemas/*.json"
18
+ "src/technologydata/parsers/dea_energy_storage/*.json", "src/technologydata/parsers/schemas/*.json", "src/technologydata/parsers/raw/manual_input_usa.csv", "src/technologydata/parsers/manual_input_usa/*.json",
20
19
  ]
21
20
  SPDX-FileCopyrightText = "technologydata contributors"
22
21
  SPDX-License-Identifier = "CC-BY-4.0"
23
22
 
24
23
  [[annotations]]
25
24
  path = [
26
- "src/technologydata/package_data/raw/Technology_datasheet_for_energy_storage.xlsx"
25
+ "src/technologydata/parsers/raw/Technology_datasheet_for_energy_storage.xlsx"
27
26
  ]
28
27
  SPDX-FileCopyrightText = "The Danish Energy Agency"
29
28
  SPDX-License-Identifier = "CC-BY-4.0"
@@ -2,11 +2,11 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The Danish Energy Agency (DEA) data parser `dea_energy_storage.py` demonstrates a full data-cleaning and transformation pipeline for converting raw tabular data into the `technologydata` schema files `technologies.json` and `sources.json`. The parser is implemented in `src/technologydata/package_data/dea_energy_storage/dea_energy_storage.py`.
5
+ The Danish Energy Agency (DEA) data parser `dea_energy_storage.py` demonstrates a full data-cleaning and transformation pipeline for converting raw tabular data into the `technologydata` schema files `technologies.json` and `sources.json`. The parser is implemented in `src/technologydata/parsers/dea_energy_storage/dea_energy_storage.py`.
6
6
 
7
7
  ## Dataset Description
8
8
 
9
- 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/package_data/raw/Technology_datasheet_for_energy_storage.xlsx`.
9
+ 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`.
10
10
 
11
11
  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.
12
12
 
@@ -25,7 +25,7 @@ Function `parse_input_arguments()` defines and parses the command-line arguments
25
25
 
26
26
  ### Read the raw data
27
27
 
28
- The script reads the raw data available at `src/technologydata/package_data/raw/Technology_datasheet_for_energy_storage.xlsx`, under sheet `alldata_flat`, in a `pandas` dataframe. It uses `pandas.read_excel(..., engine=calamine, dtype=str)`. All entries are handled as strings initially.
28
+ The script reads the raw data available at `src/technologydata/parsers/raw/Technology_datasheet_for_energy_storage.xlsx`, under sheet `alldata_flat`, in a `pandas` dataframe. It uses `pandas.read_excel(..., engine=calamine, dtype=str)`. All entries are handled as strings initially.
29
29
 
30
30
  ### Data cleaning, validation and dealing with missing/null values
31
31
 
@@ -64,7 +64,7 @@ Function `build_technology_collection()`:
64
64
  - for each group, builds a dictionary of `Parameter` objects (each with `magnitude`, `units`, `sources`, `provenance`).
65
65
  - creates a `Technology` object for each group, with `name` = `ws`, `detailed_technology` = `Technology`, `year`=`year`, `region` = `EU`, `case` = `est` and collects them into a `TechnologyCollection` object.
66
66
  - writes the `TechnologyCollection` object to a `technologies.json`.
67
- - if `--export_schema` is used, schema files produced during export are moved to the sub-folder `src/technologydata/package_data/schemas`.
67
+ - if `--export_schema` is used, schema files produced during export are moved to the sub-folder `src/technologydata/parsers/schemas`.
68
68
 
69
69
  ## Running the parser
70
70
 
@@ -72,13 +72,13 @@ Function `build_technology_collection()`:
72
72
 
73
73
  From repository root:
74
74
 
75
- - Basic run: `python src/technologydata/package_data/dea_energy_storage/dea_energy_storage.py`
75
+ - Basic run: `python src/technologydata/parsers/dea_energy_storage/dea_energy_storage.py`
76
76
  - Example with options: `--num_digits 3 --store_source --filter_params --export_schema`
77
77
 
78
78
  ### Outputs
79
79
 
80
80
  The parser generates the following outputs:
81
81
 
82
- - `src/technologydata/package_data/dea_energy_storage/technologies.json`.
83
- - `src/technologydata/package_data/dea_energy_storage/sources.json`.
84
- - Optional schema files moved to `src/technologydata/package_data/schemas` when `--export_schema` is used.
82
+ - `src/technologydata/parsers/dea_energy_storage/technologies.json`.
83
+ - `src/technologydata/parsers/dea_energy_storage/sources.json`.
84
+ - Optional schema files moved to `src/technologydata/parsers/schemas` when `--export_schema` is used.
@@ -0,0 +1,78 @@
1
+ # Manual Input USA Parser Documentation
2
+
3
+ ## Overview
4
+
5
+ The Manual Input USA data parser `manual_input_usa.py` demonstrates a data-cleaning and transformation pipeline for converting manually curated, USA-specific tabular data into the `technologydata` schema files `technologies.json` and `sources.json`. The parser is implemented in `src/technologydata/parsers/manual_input_usa/manual_input_usa.py`.
6
+
7
+ ## Dataset Description
8
+
9
+ 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`.
10
+
11
+ 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.
12
+
13
+ ## Parser description
14
+
15
+ The parser is articulated in the following steps.
16
+
17
+ ### Command line argument parsing
18
+
19
+ Function `CommonsParser.parse_input_arguments()` defines and parses the command-line arguments:
20
+
21
+ - `--num_digits` (int, default 4) — number of decimals used when rounding numeric values. The default value is 4.
22
+ - `--store_source` (boolean flag) — whether to store the source on the Wayback Machine. The default value is `false`.
23
+
24
+ ### Read the raw data
25
+
26
+ The script reads the raw data available at `src/technologydata/parsers/raw/manual_input_usa.csv` in a `pandas` dataframe. It uses `pandas.read_csv(..., dtype=str, na_values="None")`. All entries are handled as strings initially except for the `value` column which is converted to float.
27
+
28
+ ### Data cleaning, validation and dealing with missing/null values
29
+
30
+ The data cleaning and validation happens with the following steps.
31
+
32
+ Function `extract_units_carriers_heating_value()` extracts standardized units, carriers, and heating values from input unit strings. This function maps complex unit representations to simplified unit, carrier, and heating value combinations using a predefined dictionary of special patterns. Examples include:
33
+
34
+ - `USD_2022/MW_FT` → unit: `USD_2022/MW`, carrier: `1/FT`, heating_value: `1/LHV`
35
+ - `MWh_H2/MWh_FT` → unit: `MWh/MWh`, carrier: `H2/FT`, heating_value: `LHV`
36
+ - `MWh_el/MWh_FT` → unit: `MWh/MWh`, carrier: `el/FT`, heating_value: `LHV`
37
+ - `t_CO2/MWh_FT` → unit: `t/MWh`, carrier: `CO2/FT`, heating_value: `LHV`
38
+ - `USD_2022/kWh_H2` → unit: `USD_2022/kWh`, carrier: `1/H2`, heating_value: `LHV`
39
+ - `USD_2023/t_CO2/h` → unit: `USD_2023/t/h`, carrier: `1/CO2`, heating_value: `None`
40
+ - `MWh_el/t_CO2` → unit: `MWh/t`, carrier: `el/CO2`, heating_value: `LHV`
41
+ - `MWh_th/t_CO2` → unit: `MWh/t`, carrier: `thermal/CO2`, heating_value: `LHV`
42
+
43
+ The parser also fills missing values in the `scenario` column with `"not_available"`.
44
+
45
+ The parser applies the following unit conversions:
46
+
47
+ - Convert `per unit` to `%` and multiply the corresponding `value` by 100.0, rounding to `num_digits` decimals.
48
+
49
+ Function `Commons.update_unit_with_currency_year(unit, currency_year)` appends `currency_year` information to currency units when present. This is because `technologydata` follows the currency pattern `\b(?P<cu_iso3>[A-Z]{3})_(?P<year>\d{4})\b`, as for example `USD_2022`.
50
+
51
+ ### Populate and export the source and technology collections
52
+
53
+ Function `build_technology_collection()`:
54
+
55
+ - if `store_source` is set, constructs a `Source` object for the manual input USA dataset, calls `ensure_in_wayback()` and writes `sources.json`; otherwise reads an existing `sources.json`.
56
+ - groups the cleaned DataFrame by `scenario`, `year`, `technology`.
57
+ - for each group, builds a dictionary of `Parameter` objects (each with `magnitude`, `sources`, and optionally `carrier`, `heating_value`, `units`, `note`).
58
+ - captures the `financial_case` value from rows within each group to combine with `scenario`.
59
+ - creates a `case` value by combining `scenario` and `financial_case` in the format `"{scenario} - {financial_case}"` when `financial_case` is present; otherwise uses `scenario` alone.
60
+ - creates a `Technology` object for each group, with `name` = `technology`, `detailed_technology` = `technology`, `year` = `year`, `region` = `USA`, `case` = combined case value, and collects them into a `TechnologyCollection` object.
61
+ - writes the `TechnologyCollection` object to a `technologies.json`.
62
+
63
+ ## Running the parser
64
+
65
+ ### Execution instructions
66
+
67
+ From repository root:
68
+
69
+ - Basic run: `python src/technologydata/parsers/manual_input_usa/manual_input_usa.py`
70
+ - Example with options: `--num_digits 3 --store_source`
71
+
72
+ ### Outputs
73
+
74
+ The parser generates the following outputs:
75
+
76
+ - `src/technologydata/parsers/manual_input_usa/technologies.json`.
77
+ - `src/technologydata/parsers/manual_input_usa/sources.json`.
78
+ - Optional schema files moved to `src/technologydata/parsers/schemas` when `--export_schema` is used.
@@ -2,6 +2,7 @@
2
2
  <img src="assets/logo/technology_data_logo.png" alt="technologydata Header Logo" width="400"/>
3
3
  </p>
4
4
 
5
+ [![PyPI version](https://img.shields.io/pypi/v/technologydata.svg)](https://pypi.python.org/pypi/technologydata)
5
6
  [![License](https://img.shields.io/pypi/l/pypsa.svg)](https://github.com/PyPSA/pypsa?tab=MIT-1-ov-file)
6
7
  [![Discord](https://img.shields.io/discord/911692131440148490?logo=discord)](https://discord.gg/T7YZbnVU)
7
8
 
@@ -32,6 +32,7 @@ nav:
32
32
 
33
33
  - Examples:
34
34
  - Danish Energy Agency Parser: examples/dea_storage.md
35
+ - Manual Input USA Parser: examples/manual_input_usa.md
35
36
 
36
37
  - API Reference:
37
38
  - Data Package: api/datapackage.md
@@ -0,0 +1,136 @@
1
+ # SPDX-FileCopyrightText: technologydata contributors
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+
5
+ """Classes for Commons methods for the data parsers."""
6
+
7
+ import argparse
8
+ from typing import Annotated, Any
9
+
10
+ import pydantic
11
+ from pydantic import BaseModel, ConfigDict
12
+
13
+
14
+ class ArgumentConfig(BaseModel):
15
+ """
16
+ Pydantic model for defining argument configurations.
17
+
18
+ Allows flexible configuration of command-line arguments with type checking
19
+ and validation.
20
+ """
21
+
22
+ name: Annotated[str, pydantic.Field(description="Name of the argument config")]
23
+ arg_type: Annotated[
24
+ type | None,
25
+ pydantic.Field(
26
+ description="The type to which the command-line argument should be converted."
27
+ ),
28
+ ] = None
29
+ default: Annotated[
30
+ Any | None, pydantic.Field(description="Default value of the argument config")
31
+ ] = None
32
+ help: Annotated[
33
+ str | None,
34
+ pydantic.Field(description="A brief description of what the argument does."),
35
+ ] = None
36
+ action: Annotated[
37
+ str | None,
38
+ pydantic.Field(
39
+ description="Specification of how the command-line arguments should be handled"
40
+ ),
41
+ ] = None
42
+ required: Annotated[
43
+ bool, pydantic.Field(description="Flag to check whether field is mondatory")
44
+ ] = False
45
+
46
+ # Allow extra fields for maximum flexibility
47
+ model_config = ConfigDict(extra="allow")
48
+
49
+
50
+ class CommonsParser:
51
+ """Commons methods for the data parsers."""
52
+
53
+ @staticmethod
54
+ @pydantic.validate_call
55
+ def parse_input_arguments(
56
+ additional_arguments: list[ArgumentConfig] | None = None,
57
+ description: str = "Flexible command line argument parser",
58
+ ) -> argparse.Namespace:
59
+ """
60
+ Parse command line arguments with robust configuration.
61
+
62
+ Parameters
63
+ ----------
64
+ additional_arguments : Optional[List[ArgumentConfig]]
65
+ A list of ArgumentConfig objects defining extra arguments.
66
+ description : str
67
+ Description for the argument parser. Defaults to a generic message.
68
+
69
+ Returns
70
+ -------
71
+ argparse.Namespace
72
+ Parsed command line arguments
73
+
74
+ Examples
75
+ --------
76
+ >>> extra_args = [
77
+ ... ArgumentConfig(
78
+ ... name="--input_file",
79
+ ... arg_type=str,
80
+ ... required=True,
81
+ ... help="Path to input CSV file"
82
+ ... ),
83
+ ... ArgumentConfig(
84
+ ... name="--verbose",
85
+ ... action="store_true",
86
+ ... help="Enable verbose output"
87
+ ... )
88
+ ... ]
89
+ >>> args = CommonsParser.parse_input_arguments(additional_arguments=extra_args)
90
+
91
+ """
92
+ # Create parser with provided or default description
93
+ parser = argparse.ArgumentParser(
94
+ description=description,
95
+ formatter_class=argparse.RawTextHelpFormatter,
96
+ )
97
+
98
+ # Default arguments
99
+ default_args = [
100
+ ArgumentConfig(
101
+ name="--num_digits",
102
+ arg_type=int,
103
+ default=4,
104
+ help="Number of significant digits to round the values.",
105
+ ),
106
+ ArgumentConfig(
107
+ name="--store_source",
108
+ action="store_true",
109
+ help="Store_source, store the source object on the wayback machine. Default: false",
110
+ ),
111
+ ]
112
+
113
+ # Combine default and additional arguments
114
+ all_arguments = default_args + (additional_arguments or [])
115
+
116
+ # Add arguments to parser (Option 1)
117
+ for arg_config in all_arguments:
118
+ # Convert Pydantic model to argparse-compatible dictionary
119
+ arg_dict = {
120
+ k: v
121
+ for k, v in arg_config.model_dump().items()
122
+ if v is not None and k != "name"
123
+ }
124
+
125
+ if arg_dict.get("arg_type") is not None:
126
+ arg_dict["type"] = arg_dict.pop("arg_type")
127
+
128
+ print("arg_dict", arg_dict)
129
+
130
+ # Add argument to parser
131
+ parser.add_argument(arg_config.name, **arg_dict)
132
+
133
+ # Parse arguments
134
+ args = parser.parse_args()
135
+
136
+ return args
@@ -7,19 +7,19 @@ Data parser for the DEA energy storage data set.
7
7
 
8
8
  How to run:
9
9
  From the repository root, execute:
10
- python src/technologydata/package_data/dea_energy_storage/dea_energy_storage.py
10
+ python src/technologydata/parsers/dea_energy_storage/dea_energy_storage.py
11
11
 
12
12
  Configuration options (command-line arguments):
13
13
  --num_digits <int> Number of significant digits to round the values. Default: 4
14
14
  --store_source Store the source object on the Wayback Machine. Default: False
15
15
  --filter_params Filter the parameters stored to technologies.json. Default: False
16
+ --export_schema Export the Source/TechnologyCollection schemas. Default: False
16
17
 
17
18
  Example:
18
- python src/technologydata/package_data/dea_energy_storage/dea_energy_storage.py --num_digits 3 --store_source --filter_params
19
+ python src/technologydata/parsers/dea_energy_storage/dea_energy_storage.py --num_digits 3 --store_source --filter_params
19
20
 
20
21
  """
21
22
 
22
- import argparse
23
23
  import logging
24
24
  import pathlib
25
25
  import re
@@ -36,6 +36,7 @@ from technologydata import (
36
36
  Technology,
37
37
  TechnologyCollection,
38
38
  )
39
+ from technologydata.parsers.commons import ArgumentConfig, CommonsParser
39
40
 
40
41
  path_cwd = pathlib.Path.cwd()
41
42
 
@@ -478,60 +479,26 @@ def build_technology_collection(
478
479
  return TechnologyCollection(technologies=list_techs)
479
480
 
480
481
 
481
- @pydantic.validate_call
482
- def parse_input_arguments() -> argparse.Namespace:
483
- """
484
- Parse command line arguments.
482
+ if __name__ == "__main__":
483
+ # Parse input arguments
485
484
 
486
- Returns
487
- -------
488
- argparse.Namespace
489
- Parsed command line arguments containing:
490
- - Number of significant digits
491
- - Store source flag
485
+ additional_input_args = [
486
+ ArgumentConfig(
487
+ name="--filter_params",
488
+ action="store_true",
489
+ help="filter_params. Filter the parameters stored to technologies.json. Default: false",
490
+ ),
491
+ ArgumentConfig(
492
+ name="--export_schema",
493
+ action="store_true",
494
+ help="export_schema. Export the Source/TechnologyCollection schemas. Default: false",
495
+ ),
496
+ ]
492
497
 
493
- """
494
- # Create the parser
495
- parser = argparse.ArgumentParser(
498
+ input_args = CommonsParser.parse_input_arguments(
499
+ additional_arguments=additional_input_args,
496
500
  description="Parse the DEA technology storage dataset",
497
- formatter_class=argparse.RawTextHelpFormatter,
498
- )
499
-
500
- # Define arguments
501
- parser.add_argument(
502
- "--num_digits",
503
- type=int,
504
- default=4,
505
- help="Name of significant digits to round the values. ",
506
501
  )
507
-
508
- parser.add_argument(
509
- "--store_source",
510
- action="store_true",
511
- help="store_source, store the source object on the wayback machine. Default: false",
512
- )
513
-
514
- parser.add_argument(
515
- "--filter_params",
516
- action="store_true",
517
- help="filter_params. Filter the parameters stored to technologies.json. Default: false",
518
- )
519
-
520
- parser.add_argument(
521
- "--export_schema",
522
- action="store_true",
523
- help="export_schema. Export the Source/TechnologyCollection schemas. Default: false",
524
- )
525
-
526
- # Parse arguments
527
- args = parser.parse_args()
528
-
529
- return args
530
-
531
-
532
- if __name__ == "__main__":
533
- # Parse input arguments
534
- input_args = parse_input_arguments()
535
502
  logger.info("Command line arguments parsed.")
536
503
 
537
504
  # Read the raw data
@@ -539,7 +506,7 @@ if __name__ == "__main__":
539
506
  path_cwd,
540
507
  "src",
541
508
  "technologydata",
542
- "package_data",
509
+ "parsers",
543
510
  "raw",
544
511
  "Technology_datasheet_for_energy_storage.xlsx",
545
512
  )
@@ -651,7 +618,7 @@ if __name__ == "__main__":
651
618
  path_cwd,
652
619
  "src",
653
620
  "technologydata",
654
- "package_data",
621
+ "parsers",
655
622
  "dea_energy_storage",
656
623
  )
657
624
  output_technologies_path = pathlib.Path(
@@ -676,7 +643,7 @@ if __name__ == "__main__":
676
643
  if input_args.export_schema:
677
644
  # Move schema files if they exist
678
645
  schema_folder = pathlib.Path(
679
- path_cwd, "src", "technologydata", "package_data", "schemas"
646
+ path_cwd, "src", "technologydata", "parsers", "schemas"
680
647
  )
681
648
  sources_schema = pathlib.Path(dea_storage_path, "sources.schema.json")
682
649
  technologies_schema = pathlib.Path(dea_storage_path, "technologies.schema.json")