pyconvexity 0.4.3__py3-none-any.whl
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/__init__.py +226 -0
- pyconvexity/_version.py +1 -0
- pyconvexity/core/__init__.py +60 -0
- pyconvexity/core/database.py +485 -0
- pyconvexity/core/errors.py +106 -0
- pyconvexity/core/types.py +400 -0
- pyconvexity/data/README.md +101 -0
- pyconvexity/data/__init__.py +17 -0
- pyconvexity/data/loaders/__init__.py +3 -0
- pyconvexity/data/loaders/cache.py +213 -0
- pyconvexity/data/schema/01_core_schema.sql +420 -0
- pyconvexity/data/schema/02_data_metadata.sql +120 -0
- pyconvexity/data/schema/03_validation_data.sql +506 -0
- pyconvexity/data/sources/__init__.py +5 -0
- pyconvexity/data/sources/gem.py +442 -0
- pyconvexity/io/__init__.py +26 -0
- pyconvexity/io/excel_exporter.py +1226 -0
- pyconvexity/io/excel_importer.py +1381 -0
- pyconvexity/io/netcdf_exporter.py +197 -0
- pyconvexity/io/netcdf_importer.py +1833 -0
- pyconvexity/models/__init__.py +195 -0
- pyconvexity/models/attributes.py +730 -0
- pyconvexity/models/carriers.py +159 -0
- pyconvexity/models/components.py +611 -0
- pyconvexity/models/network.py +503 -0
- pyconvexity/models/results.py +148 -0
- pyconvexity/models/scenarios.py +234 -0
- pyconvexity/solvers/__init__.py +29 -0
- pyconvexity/solvers/pypsa/__init__.py +24 -0
- pyconvexity/solvers/pypsa/api.py +460 -0
- pyconvexity/solvers/pypsa/batch_loader.py +307 -0
- pyconvexity/solvers/pypsa/builder.py +675 -0
- pyconvexity/solvers/pypsa/constraints.py +405 -0
- pyconvexity/solvers/pypsa/solver.py +1509 -0
- pyconvexity/solvers/pypsa/storage.py +2048 -0
- pyconvexity/timeseries.py +330 -0
- pyconvexity/validation/__init__.py +25 -0
- pyconvexity/validation/rules.py +312 -0
- pyconvexity-0.4.3.dist-info/METADATA +47 -0
- pyconvexity-0.4.3.dist-info/RECORD +42 -0
- pyconvexity-0.4.3.dist-info/WHEEL +5 -0
- pyconvexity-0.4.3.dist-info/top_level.txt +1 -0
pyconvexity/__init__.py
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
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
|
+
# High-level API functions
|
|
100
|
+
__all__ = [
|
|
101
|
+
# Version info
|
|
102
|
+
"__version__",
|
|
103
|
+
"__author__",
|
|
104
|
+
# Core types
|
|
105
|
+
"StaticValue",
|
|
106
|
+
"Timeseries",
|
|
107
|
+
"TimeseriesMetadata",
|
|
108
|
+
"Component",
|
|
109
|
+
"Network",
|
|
110
|
+
"CreateNetworkRequest",
|
|
111
|
+
"CreateComponentRequest",
|
|
112
|
+
# Database operations
|
|
113
|
+
"create_database_with_schema",
|
|
114
|
+
"database_context",
|
|
115
|
+
"open_connection",
|
|
116
|
+
"validate_database",
|
|
117
|
+
# Database maintenance
|
|
118
|
+
"vacuum_database",
|
|
119
|
+
"analyze_database",
|
|
120
|
+
"optimize_database",
|
|
121
|
+
"get_database_size_info",
|
|
122
|
+
"should_optimize_database",
|
|
123
|
+
# Exceptions
|
|
124
|
+
"PyConvexityError",
|
|
125
|
+
"DatabaseError",
|
|
126
|
+
"ValidationError",
|
|
127
|
+
"ComponentNotFound",
|
|
128
|
+
"AttributeNotFound",
|
|
129
|
+
# Component operations
|
|
130
|
+
"get_component",
|
|
131
|
+
"create_component",
|
|
132
|
+
"update_component",
|
|
133
|
+
"delete_component",
|
|
134
|
+
"list_components_by_type",
|
|
135
|
+
"list_component_attributes",
|
|
136
|
+
# Attribute operations
|
|
137
|
+
"set_static_attribute",
|
|
138
|
+
"set_timeseries_attribute",
|
|
139
|
+
"get_attribute",
|
|
140
|
+
"delete_attribute",
|
|
141
|
+
# Actual value operations
|
|
142
|
+
"set_actual_static_value",
|
|
143
|
+
"set_actual_timeseries_value",
|
|
144
|
+
"get_actual_value",
|
|
145
|
+
"clear_actual_value",
|
|
146
|
+
"get_actual_scenario_id",
|
|
147
|
+
"get_or_create_actual_scenario",
|
|
148
|
+
"has_actual_value",
|
|
149
|
+
# Network operations
|
|
150
|
+
"create_network",
|
|
151
|
+
"get_network_info",
|
|
152
|
+
"get_network_time_periods",
|
|
153
|
+
"list_networks",
|
|
154
|
+
"create_carrier",
|
|
155
|
+
"list_carriers",
|
|
156
|
+
"get_network_config",
|
|
157
|
+
"set_network_config",
|
|
158
|
+
# Scenario operations
|
|
159
|
+
"create_scenario",
|
|
160
|
+
"list_scenarios",
|
|
161
|
+
"get_scenario",
|
|
162
|
+
"delete_scenario",
|
|
163
|
+
# Validation
|
|
164
|
+
"get_validation_rule",
|
|
165
|
+
"list_validation_rules",
|
|
166
|
+
"validate_timeseries_alignment",
|
|
167
|
+
# High-level timeseries API
|
|
168
|
+
"get_timeseries",
|
|
169
|
+
"set_timeseries",
|
|
170
|
+
"get_timeseries_metadata",
|
|
171
|
+
"get_multiple_timeseries",
|
|
172
|
+
"timeseries_to_numpy",
|
|
173
|
+
"numpy_to_timeseries",
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
# Data module imports
|
|
177
|
+
try:
|
|
178
|
+
from pyconvexity import data
|
|
179
|
+
|
|
180
|
+
__all__.append("data")
|
|
181
|
+
except ImportError:
|
|
182
|
+
# Data dependencies not available
|
|
183
|
+
pass
|
|
184
|
+
|
|
185
|
+
# Optional imports with graceful fallbacks
|
|
186
|
+
try:
|
|
187
|
+
from pyconvexity.solvers.pypsa import (
|
|
188
|
+
solve_network,
|
|
189
|
+
build_pypsa_network,
|
|
190
|
+
solve_pypsa_network,
|
|
191
|
+
load_network_components,
|
|
192
|
+
apply_constraints,
|
|
193
|
+
store_solve_results,
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
__all__.extend(
|
|
197
|
+
[
|
|
198
|
+
"solve_network",
|
|
199
|
+
"build_pypsa_network",
|
|
200
|
+
"solve_pypsa_network",
|
|
201
|
+
"load_network_components",
|
|
202
|
+
"apply_constraints",
|
|
203
|
+
"store_solve_results",
|
|
204
|
+
]
|
|
205
|
+
)
|
|
206
|
+
except ImportError:
|
|
207
|
+
# PyPSA not available
|
|
208
|
+
pass
|
|
209
|
+
|
|
210
|
+
# Excel I/O functionality
|
|
211
|
+
try:
|
|
212
|
+
from pyconvexity.io import ExcelModelExporter, ExcelModelImporter
|
|
213
|
+
|
|
214
|
+
__all__.extend(["ExcelModelExporter", "ExcelModelImporter"])
|
|
215
|
+
except ImportError:
|
|
216
|
+
# Excel dependencies not available
|
|
217
|
+
pass
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
try:
|
|
221
|
+
from pyconvexity.io import NetCDFModelExporter, NetCDFModelImporter
|
|
222
|
+
|
|
223
|
+
__all__.extend(["NetCDFModelExporter", "NetCDFModelImporter"])
|
|
224
|
+
except ImportError:
|
|
225
|
+
# NetCDF dependencies not available
|
|
226
|
+
pass
|
pyconvexity/_version.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.4.3"
|
|
@@ -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
|
+
]
|