pyconvexity 0.5.1.post1__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.
Potentially problematic release.
This version of pyconvexity might be problematic. Click here for more details.
- pyconvexity-0.5.1.post1/PKG-INFO +148 -0
- pyconvexity-0.5.1.post1/README.md +100 -0
- pyconvexity-0.5.1.post1/pyproject.toml +93 -0
- pyconvexity-0.5.1.post1/setup.cfg +4 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/__init__.py +250 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/_version.py +1 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/core/__init__.py +60 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/core/database.py +485 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/core/errors.py +106 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/core/types.py +400 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/dashboard.py +265 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/README.md +101 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/__init__.py +17 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/loaders/__init__.py +3 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/loaders/cache.py +213 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/schema/01_core_schema.sql +420 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/schema/02_data_metadata.sql +120 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/schema/03_validation_data.sql +507 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/sources/__init__.py +5 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/data/sources/gem.py +442 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/io/__init__.py +26 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/io/excel_exporter.py +1226 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/io/excel_importer.py +1381 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/io/netcdf_exporter.py +191 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/io/netcdf_importer.py +1802 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/models/__init__.py +195 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/models/attributes.py +730 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/models/carriers.py +159 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/models/components.py +611 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/models/network.py +503 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/models/results.py +148 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/models/scenarios.py +234 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/__init__.py +29 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/__init__.py +30 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/api.py +446 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/batch_loader.py +296 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/builder.py +655 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/clearing_price.py +678 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/constraints.py +405 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/solver.py +1091 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/solvers/pypsa/storage.py +2082 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/timeseries.py +330 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/transformations/__init__.py +15 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/transformations/api.py +93 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/transformations/time_axis.py +736 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/validation/__init__.py +25 -0
- pyconvexity-0.5.1.post1/src/pyconvexity/validation/rules.py +312 -0
- pyconvexity-0.5.1.post1/src/pyconvexity.egg-info/PKG-INFO +148 -0
- pyconvexity-0.5.1.post1/src/pyconvexity.egg-info/SOURCES.txt +51 -0
- pyconvexity-0.5.1.post1/src/pyconvexity.egg-info/dependency_links.txt +1 -0
- pyconvexity-0.5.1.post1/src/pyconvexity.egg-info/requires.txt +32 -0
- pyconvexity-0.5.1.post1/src/pyconvexity.egg-info/top_level.txt +1 -0
- pyconvexity-0.5.1.post1/tests/test_core_types.py +112 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pyconvexity
|
|
3
|
+
Version: 0.5.1.post1
|
|
4
|
+
Summary: Python library for energy system modeling and optimization with PyPSA
|
|
5
|
+
Author-email: Convexity Team <info@convexity.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/bayesian-energy/pyconvexity
|
|
8
|
+
Project-URL: Repository, https://github.com/bayesian-energy/pyconvexity
|
|
9
|
+
Project-URL: Issues, https://github.com/bayesian-energy/pyconvexity/issues
|
|
10
|
+
Project-URL: Documentation, https://pyconvexity.readthedocs.io
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: pandas>=1.5.0
|
|
23
|
+
Requires-Dist: numpy>=1.21.0
|
|
24
|
+
Requires-Dist: pyarrow>=10.0.0
|
|
25
|
+
Provides-Extra: pypsa
|
|
26
|
+
Requires-Dist: pypsa>=0.25.0; extra == "pypsa"
|
|
27
|
+
Requires-Dist: networkx; extra == "pypsa"
|
|
28
|
+
Requires-Dist: scipy; extra == "pypsa"
|
|
29
|
+
Requires-Dist: xarray; extra == "pypsa"
|
|
30
|
+
Provides-Extra: excel
|
|
31
|
+
Requires-Dist: openpyxl>=3.0.0; extra == "excel"
|
|
32
|
+
Requires-Dist: xlsxwriter>=3.0.0; extra == "excel"
|
|
33
|
+
Provides-Extra: netcdf
|
|
34
|
+
Requires-Dist: netcdf4>=1.6.0; extra == "netcdf"
|
|
35
|
+
Requires-Dist: xarray>=2022.3.0; extra == "netcdf"
|
|
36
|
+
Provides-Extra: data
|
|
37
|
+
Requires-Dist: country-converter>=1.0.0; extra == "data"
|
|
38
|
+
Requires-Dist: pyyaml>=6.0.0; extra == "data"
|
|
39
|
+
Provides-Extra: dev
|
|
40
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
41
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
42
|
+
Requires-Dist: black>=22.0.0; extra == "dev"
|
|
43
|
+
Requires-Dist: isort>=5.10.0; extra == "dev"
|
|
44
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
45
|
+
Requires-Dist: pre-commit>=2.20.0; extra == "dev"
|
|
46
|
+
Provides-Extra: all
|
|
47
|
+
Requires-Dist: pyconvexity[data,excel,netcdf,pypsa]; extra == "all"
|
|
48
|
+
|
|
49
|
+
# pyconvexity
|
|
50
|
+
|
|
51
|
+
Python library for energy system modeling and optimization with PyPSA.
|
|
52
|
+
|
|
53
|
+
[](https://badge.fury.io/py/pyconvexity)
|
|
54
|
+
[](https://www.python.org/downloads/)
|
|
55
|
+
[](https://opensource.org/licenses/MIT)
|
|
56
|
+
|
|
57
|
+
## Overview
|
|
58
|
+
|
|
59
|
+
pyconvexity is the Python library that powers [Convexity](https://bayesian.energy/convexity), providing programmatic access to energy system modeling and optimization. It stores models in SQLite databases and integrates with PyPSA for solving.
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install pyconvexity
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
With optional dependencies:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pip install pyconvexity[pypsa] # PyPSA solver integration
|
|
71
|
+
pip install pyconvexity[excel] # Excel import/export
|
|
72
|
+
pip install pyconvexity[all] # All optional dependencies
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Quick Start
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import pyconvexity as px
|
|
79
|
+
|
|
80
|
+
# Create a new model database
|
|
81
|
+
px.create_database_with_schema("my_model.db")
|
|
82
|
+
|
|
83
|
+
# Create a network
|
|
84
|
+
with px.database_context("my_model.db") as conn:
|
|
85
|
+
network_req = px.CreateNetworkRequest(
|
|
86
|
+
name="My Network",
|
|
87
|
+
start_time="2024-01-01 00:00:00",
|
|
88
|
+
end_time="2024-01-01 23:00:00",
|
|
89
|
+
time_resolution="PT1H",
|
|
90
|
+
)
|
|
91
|
+
px.create_network(conn, network_req)
|
|
92
|
+
|
|
93
|
+
# Create components
|
|
94
|
+
carrier_id = px.create_carrier(conn, name="AC")
|
|
95
|
+
bus_id = px.create_component(conn, "BUS", "Main Bus", carrier_id=carrier_id)
|
|
96
|
+
|
|
97
|
+
conn.commit()
|
|
98
|
+
|
|
99
|
+
# Solve the network
|
|
100
|
+
result = px.solve_network("my_model.db", solver_name="highs")
|
|
101
|
+
print(f"Success: {result['success']}, Objective: {result['objective_value']}")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Documentation
|
|
105
|
+
|
|
106
|
+
Full documentation is available at: **[docs.bayesian.energy](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/)**
|
|
107
|
+
|
|
108
|
+
- [API Reference](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/api/api-reference)
|
|
109
|
+
- [Examples & Tutorials](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/examples/example-1/)
|
|
110
|
+
|
|
111
|
+
## Development
|
|
112
|
+
|
|
113
|
+
### Setup
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
git clone https://github.com/bayesian-energy/pyconvexity.git
|
|
117
|
+
cd pyconvexity
|
|
118
|
+
pip install -e ".[dev,all]"
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Running Tests
|
|
122
|
+
|
|
123
|
+
```bash
|
|
124
|
+
pytest
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Documentation Deployment
|
|
128
|
+
|
|
129
|
+
API documentation is auto-generated and synced to [bayesian-docs](https://github.com/bayesian-energy/bayesian-docs).
|
|
130
|
+
|
|
131
|
+
**Generate API docs locally:**
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
python scripts/generate_api_docs.py --output-dir api-docs
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**How it works:**
|
|
138
|
+
1. On push to `main` or release, the `sync-docs.yml` workflow runs
|
|
139
|
+
2. It generates API markdown from Python docstrings
|
|
140
|
+
3. Commits the generated docs to the `bayesian-docs` repository
|
|
141
|
+
|
|
142
|
+
**Setup for maintainers:**
|
|
143
|
+
- Add `DOCS_DEPLOY_TOKEN` secret to the repo (personal access token with `repo` scope for bayesian-docs)
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
148
|
+
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# pyconvexity
|
|
2
|
+
|
|
3
|
+
Python library for energy system modeling and optimization with PyPSA.
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/py/pyconvexity)
|
|
6
|
+
[](https://www.python.org/downloads/)
|
|
7
|
+
[](https://opensource.org/licenses/MIT)
|
|
8
|
+
|
|
9
|
+
## Overview
|
|
10
|
+
|
|
11
|
+
pyconvexity is the Python library that powers [Convexity](https://bayesian.energy/convexity), providing programmatic access to energy system modeling and optimization. It stores models in SQLite databases and integrates with PyPSA for solving.
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pip install pyconvexity
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
With optional dependencies:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pip install pyconvexity[pypsa] # PyPSA solver integration
|
|
23
|
+
pip install pyconvexity[excel] # Excel import/export
|
|
24
|
+
pip install pyconvexity[all] # All optional dependencies
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
import pyconvexity as px
|
|
31
|
+
|
|
32
|
+
# Create a new model database
|
|
33
|
+
px.create_database_with_schema("my_model.db")
|
|
34
|
+
|
|
35
|
+
# Create a network
|
|
36
|
+
with px.database_context("my_model.db") as conn:
|
|
37
|
+
network_req = px.CreateNetworkRequest(
|
|
38
|
+
name="My Network",
|
|
39
|
+
start_time="2024-01-01 00:00:00",
|
|
40
|
+
end_time="2024-01-01 23:00:00",
|
|
41
|
+
time_resolution="PT1H",
|
|
42
|
+
)
|
|
43
|
+
px.create_network(conn, network_req)
|
|
44
|
+
|
|
45
|
+
# Create components
|
|
46
|
+
carrier_id = px.create_carrier(conn, name="AC")
|
|
47
|
+
bus_id = px.create_component(conn, "BUS", "Main Bus", carrier_id=carrier_id)
|
|
48
|
+
|
|
49
|
+
conn.commit()
|
|
50
|
+
|
|
51
|
+
# Solve the network
|
|
52
|
+
result = px.solve_network("my_model.db", solver_name="highs")
|
|
53
|
+
print(f"Success: {result['success']}, Objective: {result['objective_value']}")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Documentation
|
|
57
|
+
|
|
58
|
+
Full documentation is available at: **[docs.bayesian.energy](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/)**
|
|
59
|
+
|
|
60
|
+
- [API Reference](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/api/api-reference)
|
|
61
|
+
- [Examples & Tutorials](https://docs.bayesian.energy/convexity/user-guide/advanced-features/pyconvexity/examples/example-1/)
|
|
62
|
+
|
|
63
|
+
## Development
|
|
64
|
+
|
|
65
|
+
### Setup
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
git clone https://github.com/bayesian-energy/pyconvexity.git
|
|
69
|
+
cd pyconvexity
|
|
70
|
+
pip install -e ".[dev,all]"
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Running Tests
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
pytest
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### Documentation Deployment
|
|
80
|
+
|
|
81
|
+
API documentation is auto-generated and synced to [bayesian-docs](https://github.com/bayesian-energy/bayesian-docs).
|
|
82
|
+
|
|
83
|
+
**Generate API docs locally:**
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
python scripts/generate_api_docs.py --output-dir api-docs
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
**How it works:**
|
|
90
|
+
1. On push to `main` or release, the `sync-docs.yml` workflow runs
|
|
91
|
+
2. It generates API markdown from Python docstrings
|
|
92
|
+
3. Commits the generated docs to the `bayesian-docs` repository
|
|
93
|
+
|
|
94
|
+
**Setup for maintainers:**
|
|
95
|
+
- Add `DOCS_DEPLOY_TOKEN` secret to the repo (personal access token with `repo` scope for bayesian-docs)
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
100
|
+
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "pyconvexity"
|
|
7
|
+
version = "0.5.1.post1"
|
|
8
|
+
description = "Python library for energy system modeling and optimization with PyPSA"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
authors = [
|
|
12
|
+
{name = "Convexity Team", email = "info@convexity.com"}
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Scientific/Engineering",
|
|
24
|
+
]
|
|
25
|
+
requires-python = ">=3.9"
|
|
26
|
+
dependencies = [
|
|
27
|
+
"pandas>=1.5.0",
|
|
28
|
+
"numpy>=1.21.0",
|
|
29
|
+
"pyarrow>=10.0.0",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
[project.optional-dependencies]
|
|
33
|
+
pypsa = [
|
|
34
|
+
"pypsa>=0.25.0",
|
|
35
|
+
"networkx",
|
|
36
|
+
"scipy",
|
|
37
|
+
"xarray",
|
|
38
|
+
]
|
|
39
|
+
excel = [
|
|
40
|
+
"openpyxl>=3.0.0",
|
|
41
|
+
"xlsxwriter>=3.0.0",
|
|
42
|
+
]
|
|
43
|
+
netcdf = [
|
|
44
|
+
"netcdf4>=1.6.0",
|
|
45
|
+
"xarray>=2022.3.0",
|
|
46
|
+
]
|
|
47
|
+
data = [
|
|
48
|
+
"country-converter>=1.0.0",
|
|
49
|
+
"pyyaml>=6.0.0",
|
|
50
|
+
]
|
|
51
|
+
dev = [
|
|
52
|
+
"pytest>=7.0.0",
|
|
53
|
+
"pytest-cov>=4.0.0",
|
|
54
|
+
"black>=22.0.0",
|
|
55
|
+
"isort>=5.10.0",
|
|
56
|
+
"mypy>=1.0.0",
|
|
57
|
+
"pre-commit>=2.20.0",
|
|
58
|
+
]
|
|
59
|
+
all = [
|
|
60
|
+
"pyconvexity[pypsa,excel,netcdf,data]",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[project.urls]
|
|
64
|
+
Homepage = "https://github.com/bayesian-energy/pyconvexity"
|
|
65
|
+
Repository = "https://github.com/bayesian-energy/pyconvexity"
|
|
66
|
+
Issues = "https://github.com/bayesian-energy/pyconvexity/issues"
|
|
67
|
+
Documentation = "https://pyconvexity.readthedocs.io"
|
|
68
|
+
|
|
69
|
+
[tool.setuptools.packages.find]
|
|
70
|
+
where = ["src"]
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
[tool.setuptools.package-data]
|
|
74
|
+
pyconvexity = ["data/**/*"]
|
|
75
|
+
|
|
76
|
+
[tool.black]
|
|
77
|
+
target-version = ['py39']
|
|
78
|
+
|
|
79
|
+
[tool.isort]
|
|
80
|
+
profile = "black"
|
|
81
|
+
line_length = 88
|
|
82
|
+
|
|
83
|
+
[tool.mypy]
|
|
84
|
+
python_version = "0.5.1.post1"
|
|
85
|
+
warn_return_any = true
|
|
86
|
+
warn_unused_configs = true
|
|
87
|
+
disallow_untyped_defs = true
|
|
88
|
+
|
|
89
|
+
[tool.pytest.ini_options]
|
|
90
|
+
testpaths = ["tests"]
|
|
91
|
+
python_files = ["test_*.py"]
|
|
92
|
+
python_classes = ["Test*"]
|
|
93
|
+
python_functions = ["test_*"]
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"""
|
|
2
|
+
PyConvexity - Python library for energy system modeling and optimization.
|
|
3
|
+
|
|
4
|
+
This library provides the core functionality of the Convexity desktop application
|
|
5
|
+
as a reusable, pip-installable package for building and solving energy system models.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
# Version information
|
|
9
|
+
from pyconvexity._version import __version__
|
|
10
|
+
|
|
11
|
+
__author__ = "Convexity Team"
|
|
12
|
+
|
|
13
|
+
# Core imports - always available
|
|
14
|
+
from pyconvexity.core.errors import (
|
|
15
|
+
PyConvexityError,
|
|
16
|
+
DatabaseError,
|
|
17
|
+
ValidationError,
|
|
18
|
+
ComponentNotFound,
|
|
19
|
+
AttributeNotFound,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
from pyconvexity.core.types import (
|
|
23
|
+
StaticValue,
|
|
24
|
+
Timeseries,
|
|
25
|
+
TimeseriesMetadata,
|
|
26
|
+
Component,
|
|
27
|
+
Network,
|
|
28
|
+
CreateNetworkRequest,
|
|
29
|
+
CreateComponentRequest,
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
from pyconvexity.core.database import (
|
|
33
|
+
create_database_with_schema,
|
|
34
|
+
database_context,
|
|
35
|
+
open_connection,
|
|
36
|
+
validate_database,
|
|
37
|
+
# Database maintenance functions
|
|
38
|
+
vacuum_database,
|
|
39
|
+
analyze_database,
|
|
40
|
+
optimize_database,
|
|
41
|
+
get_database_size_info,
|
|
42
|
+
should_optimize_database,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
# Import main API functions
|
|
46
|
+
from pyconvexity.models import (
|
|
47
|
+
# Component operations
|
|
48
|
+
get_component,
|
|
49
|
+
create_component,
|
|
50
|
+
update_component,
|
|
51
|
+
delete_component,
|
|
52
|
+
list_components_by_type,
|
|
53
|
+
list_component_attributes,
|
|
54
|
+
# Attribute operations
|
|
55
|
+
set_static_attribute,
|
|
56
|
+
set_timeseries_attribute,
|
|
57
|
+
get_attribute,
|
|
58
|
+
delete_attribute,
|
|
59
|
+
# Actual value operations
|
|
60
|
+
set_actual_static_value,
|
|
61
|
+
set_actual_timeseries_value,
|
|
62
|
+
get_actual_value,
|
|
63
|
+
clear_actual_value,
|
|
64
|
+
get_actual_scenario_id,
|
|
65
|
+
get_or_create_actual_scenario,
|
|
66
|
+
has_actual_value,
|
|
67
|
+
# Network operations
|
|
68
|
+
create_network,
|
|
69
|
+
get_network_info,
|
|
70
|
+
get_network_time_periods,
|
|
71
|
+
list_networks,
|
|
72
|
+
create_carrier,
|
|
73
|
+
list_carriers,
|
|
74
|
+
get_network_config,
|
|
75
|
+
set_network_config,
|
|
76
|
+
# Scenario operations
|
|
77
|
+
create_scenario,
|
|
78
|
+
list_scenarios,
|
|
79
|
+
get_scenario,
|
|
80
|
+
delete_scenario,
|
|
81
|
+
)
|
|
82
|
+
|
|
83
|
+
from pyconvexity.validation import (
|
|
84
|
+
get_validation_rule,
|
|
85
|
+
list_validation_rules,
|
|
86
|
+
validate_timeseries_alignment,
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# High-level timeseries API - recommended for new code
|
|
90
|
+
from pyconvexity.timeseries import (
|
|
91
|
+
get_timeseries,
|
|
92
|
+
set_timeseries,
|
|
93
|
+
get_timeseries_metadata,
|
|
94
|
+
get_multiple_timeseries,
|
|
95
|
+
timeseries_to_numpy,
|
|
96
|
+
numpy_to_timeseries,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
# Dashboard configuration for Convexity app
|
|
100
|
+
from pyconvexity.dashboard import (
|
|
101
|
+
DashboardConfig,
|
|
102
|
+
set_dashboard_config,
|
|
103
|
+
get_dashboard_config,
|
|
104
|
+
clear_dashboard_config,
|
|
105
|
+
auto_layout,
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
# High-level API functions
|
|
109
|
+
__all__ = [
|
|
110
|
+
# Version info
|
|
111
|
+
"__version__",
|
|
112
|
+
"__author__",
|
|
113
|
+
# Core types
|
|
114
|
+
"StaticValue",
|
|
115
|
+
"Timeseries",
|
|
116
|
+
"TimeseriesMetadata",
|
|
117
|
+
"Component",
|
|
118
|
+
"Network",
|
|
119
|
+
"CreateNetworkRequest",
|
|
120
|
+
"CreateComponentRequest",
|
|
121
|
+
# Database operations
|
|
122
|
+
"create_database_with_schema",
|
|
123
|
+
"database_context",
|
|
124
|
+
"open_connection",
|
|
125
|
+
"validate_database",
|
|
126
|
+
# Database maintenance
|
|
127
|
+
"vacuum_database",
|
|
128
|
+
"analyze_database",
|
|
129
|
+
"optimize_database",
|
|
130
|
+
"get_database_size_info",
|
|
131
|
+
"should_optimize_database",
|
|
132
|
+
# Exceptions
|
|
133
|
+
"PyConvexityError",
|
|
134
|
+
"DatabaseError",
|
|
135
|
+
"ValidationError",
|
|
136
|
+
"ComponentNotFound",
|
|
137
|
+
"AttributeNotFound",
|
|
138
|
+
# Component operations
|
|
139
|
+
"get_component",
|
|
140
|
+
"create_component",
|
|
141
|
+
"update_component",
|
|
142
|
+
"delete_component",
|
|
143
|
+
"list_components_by_type",
|
|
144
|
+
"list_component_attributes",
|
|
145
|
+
# Attribute operations
|
|
146
|
+
"set_static_attribute",
|
|
147
|
+
"set_timeseries_attribute",
|
|
148
|
+
"get_attribute",
|
|
149
|
+
"delete_attribute",
|
|
150
|
+
# Actual value operations
|
|
151
|
+
"set_actual_static_value",
|
|
152
|
+
"set_actual_timeseries_value",
|
|
153
|
+
"get_actual_value",
|
|
154
|
+
"clear_actual_value",
|
|
155
|
+
"get_actual_scenario_id",
|
|
156
|
+
"get_or_create_actual_scenario",
|
|
157
|
+
"has_actual_value",
|
|
158
|
+
# Network operations
|
|
159
|
+
"create_network",
|
|
160
|
+
"get_network_info",
|
|
161
|
+
"get_network_time_periods",
|
|
162
|
+
"list_networks",
|
|
163
|
+
"create_carrier",
|
|
164
|
+
"list_carriers",
|
|
165
|
+
"get_network_config",
|
|
166
|
+
"set_network_config",
|
|
167
|
+
# Scenario operations
|
|
168
|
+
"create_scenario",
|
|
169
|
+
"list_scenarios",
|
|
170
|
+
"get_scenario",
|
|
171
|
+
"delete_scenario",
|
|
172
|
+
# Validation
|
|
173
|
+
"get_validation_rule",
|
|
174
|
+
"list_validation_rules",
|
|
175
|
+
"validate_timeseries_alignment",
|
|
176
|
+
# High-level timeseries API
|
|
177
|
+
"get_timeseries",
|
|
178
|
+
"set_timeseries",
|
|
179
|
+
"get_timeseries_metadata",
|
|
180
|
+
"get_multiple_timeseries",
|
|
181
|
+
"timeseries_to_numpy",
|
|
182
|
+
"numpy_to_timeseries",
|
|
183
|
+
# Dashboard configuration
|
|
184
|
+
"DashboardConfig",
|
|
185
|
+
"set_dashboard_config",
|
|
186
|
+
"get_dashboard_config",
|
|
187
|
+
"clear_dashboard_config",
|
|
188
|
+
"auto_layout",
|
|
189
|
+
]
|
|
190
|
+
|
|
191
|
+
# Data module imports
|
|
192
|
+
try:
|
|
193
|
+
from pyconvexity import data
|
|
194
|
+
|
|
195
|
+
__all__.append("data")
|
|
196
|
+
except ImportError:
|
|
197
|
+
# Data dependencies not available
|
|
198
|
+
pass
|
|
199
|
+
|
|
200
|
+
# Optional imports with graceful fallbacks
|
|
201
|
+
try:
|
|
202
|
+
from pyconvexity.solvers.pypsa import (
|
|
203
|
+
solve_network,
|
|
204
|
+
build_pypsa_network,
|
|
205
|
+
solve_pypsa_network,
|
|
206
|
+
load_network_components,
|
|
207
|
+
apply_constraints,
|
|
208
|
+
store_solve_results,
|
|
209
|
+
)
|
|
210
|
+
|
|
211
|
+
__all__.extend(
|
|
212
|
+
[
|
|
213
|
+
"solve_network",
|
|
214
|
+
"build_pypsa_network",
|
|
215
|
+
"solve_pypsa_network",
|
|
216
|
+
"load_network_components",
|
|
217
|
+
"apply_constraints",
|
|
218
|
+
"store_solve_results",
|
|
219
|
+
]
|
|
220
|
+
)
|
|
221
|
+
except ImportError:
|
|
222
|
+
# PyPSA not available
|
|
223
|
+
pass
|
|
224
|
+
|
|
225
|
+
# Excel I/O functionality
|
|
226
|
+
try:
|
|
227
|
+
from pyconvexity.io import ExcelModelExporter, ExcelModelImporter
|
|
228
|
+
|
|
229
|
+
__all__.extend(["ExcelModelExporter", "ExcelModelImporter"])
|
|
230
|
+
except ImportError:
|
|
231
|
+
# Excel dependencies not available
|
|
232
|
+
pass
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
try:
|
|
236
|
+
from pyconvexity.io import NetCDFModelExporter, NetCDFModelImporter
|
|
237
|
+
|
|
238
|
+
__all__.extend(["NetCDFModelExporter", "NetCDFModelImporter"])
|
|
239
|
+
except ImportError:
|
|
240
|
+
# NetCDF dependencies not available
|
|
241
|
+
pass
|
|
242
|
+
|
|
243
|
+
# Transformation operations
|
|
244
|
+
try:
|
|
245
|
+
from pyconvexity.transformations import modify_time_axis
|
|
246
|
+
|
|
247
|
+
__all__.append("modify_time_axis")
|
|
248
|
+
except ImportError:
|
|
249
|
+
# Transformation dependencies (pandas, numpy) not available
|
|
250
|
+
pass
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.5.1.post1"
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Core module for PyConvexity.
|
|
3
|
+
|
|
4
|
+
Contains fundamental types, database operations, and error handling.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from pyconvexity.core.errors import (
|
|
8
|
+
PyConvexityError,
|
|
9
|
+
DatabaseError,
|
|
10
|
+
ValidationError,
|
|
11
|
+
ComponentNotFound,
|
|
12
|
+
AttributeNotFound,
|
|
13
|
+
InvalidDataType,
|
|
14
|
+
TimeseriesError,
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
from pyconvexity.core.types import (
|
|
18
|
+
StaticValue,
|
|
19
|
+
AttributeValue,
|
|
20
|
+
ValidationRule,
|
|
21
|
+
Component,
|
|
22
|
+
Network,
|
|
23
|
+
TimePeriod,
|
|
24
|
+
TimeseriesValidationResult,
|
|
25
|
+
CreateComponentRequest,
|
|
26
|
+
CreateNetworkRequest,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
from pyconvexity.core.database import (
|
|
30
|
+
DatabaseContext,
|
|
31
|
+
open_connection,
|
|
32
|
+
validate_database,
|
|
33
|
+
create_database_with_schema,
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
__all__ = [
|
|
37
|
+
# Errors
|
|
38
|
+
"PyConvexityError",
|
|
39
|
+
"DatabaseError",
|
|
40
|
+
"ValidationError",
|
|
41
|
+
"ComponentNotFound",
|
|
42
|
+
"AttributeNotFound",
|
|
43
|
+
"InvalidDataType",
|
|
44
|
+
"TimeseriesError",
|
|
45
|
+
# Types
|
|
46
|
+
"StaticValue",
|
|
47
|
+
"AttributeValue",
|
|
48
|
+
"ValidationRule",
|
|
49
|
+
"Component",
|
|
50
|
+
"Network",
|
|
51
|
+
"TimePeriod",
|
|
52
|
+
"TimeseriesValidationResult",
|
|
53
|
+
"CreateComponentRequest",
|
|
54
|
+
"CreateNetworkRequest",
|
|
55
|
+
# Database
|
|
56
|
+
"DatabaseContext",
|
|
57
|
+
"open_connection",
|
|
58
|
+
"validate_database",
|
|
59
|
+
"create_database_with_schema",
|
|
60
|
+
]
|