pyconvexity 0.4.8__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.

Files changed (44) hide show
  1. pyconvexity/__init__.py +241 -0
  2. pyconvexity/_version.py +1 -0
  3. pyconvexity/core/__init__.py +60 -0
  4. pyconvexity/core/database.py +485 -0
  5. pyconvexity/core/errors.py +106 -0
  6. pyconvexity/core/types.py +400 -0
  7. pyconvexity/dashboard.py +265 -0
  8. pyconvexity/data/README.md +101 -0
  9. pyconvexity/data/__init__.py +17 -0
  10. pyconvexity/data/loaders/__init__.py +3 -0
  11. pyconvexity/data/loaders/cache.py +213 -0
  12. pyconvexity/data/schema/01_core_schema.sql +420 -0
  13. pyconvexity/data/schema/02_data_metadata.sql +120 -0
  14. pyconvexity/data/schema/03_validation_data.sql +507 -0
  15. pyconvexity/data/sources/__init__.py +5 -0
  16. pyconvexity/data/sources/gem.py +442 -0
  17. pyconvexity/io/__init__.py +26 -0
  18. pyconvexity/io/excel_exporter.py +1226 -0
  19. pyconvexity/io/excel_importer.py +1381 -0
  20. pyconvexity/io/netcdf_exporter.py +191 -0
  21. pyconvexity/io/netcdf_importer.py +1802 -0
  22. pyconvexity/models/__init__.py +195 -0
  23. pyconvexity/models/attributes.py +730 -0
  24. pyconvexity/models/carriers.py +159 -0
  25. pyconvexity/models/components.py +611 -0
  26. pyconvexity/models/network.py +503 -0
  27. pyconvexity/models/results.py +148 -0
  28. pyconvexity/models/scenarios.py +234 -0
  29. pyconvexity/solvers/__init__.py +29 -0
  30. pyconvexity/solvers/pypsa/__init__.py +30 -0
  31. pyconvexity/solvers/pypsa/api.py +446 -0
  32. pyconvexity/solvers/pypsa/batch_loader.py +296 -0
  33. pyconvexity/solvers/pypsa/builder.py +655 -0
  34. pyconvexity/solvers/pypsa/clearing_price.py +678 -0
  35. pyconvexity/solvers/pypsa/constraints.py +405 -0
  36. pyconvexity/solvers/pypsa/solver.py +1442 -0
  37. pyconvexity/solvers/pypsa/storage.py +2096 -0
  38. pyconvexity/timeseries.py +330 -0
  39. pyconvexity/validation/__init__.py +25 -0
  40. pyconvexity/validation/rules.py +312 -0
  41. pyconvexity-0.4.8.dist-info/METADATA +148 -0
  42. pyconvexity-0.4.8.dist-info/RECORD +44 -0
  43. pyconvexity-0.4.8.dist-info/WHEEL +5 -0
  44. pyconvexity-0.4.8.dist-info/top_level.txt +1 -0
@@ -0,0 +1,241 @@
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
@@ -0,0 +1 @@
1
+ __version__ = "0.4.8"
@@ -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
+ ]