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

@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: pyconvexity
3
+ Version: 0.1.0
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/convexity-js
8
+ Project-URL: Repository, https://github.com/bayesian-energy/convexity-js
9
+ Project-URL: Issues, https://github.com/bayesian-energy/convexity-js/issues
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Science/Research
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Requires-Python: >=3.9
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: pandas>=1.5.0
22
+ Requires-Dist: numpy>=1.21.0
23
+ Requires-Dist: pyarrow>=10.0.0
24
+ Provides-Extra: pypsa
25
+ Requires-Dist: pypsa>=0.25.0; extra == "pypsa"
26
+ Requires-Dist: networkx; extra == "pypsa"
27
+ Requires-Dist: scipy; extra == "pypsa"
28
+ Requires-Dist: xarray; extra == "pypsa"
29
+ Provides-Extra: excel
30
+ Requires-Dist: openpyxl>=3.0.0; extra == "excel"
31
+ Requires-Dist: xlsxwriter>=3.0.0; extra == "excel"
32
+ Provides-Extra: netcdf
33
+ Requires-Dist: netcdf4>=1.6.0; extra == "netcdf"
34
+ Requires-Dist: xarray>=2022.3.0; extra == "netcdf"
35
+ Provides-Extra: dev
36
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
37
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
38
+ Requires-Dist: black>=22.0.0; extra == "dev"
39
+ Requires-Dist: isort>=5.10.0; extra == "dev"
40
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
41
+ Requires-Dist: pre-commit>=2.20.0; extra == "dev"
42
+ Provides-Extra: all
43
+ Requires-Dist: pyconvexity[excel,netcdf,pypsa]; extra == "all"
44
+
45
+ # PyConvexity
46
+
47
+ **Energy system modeling library for optimization and analysis.**
48
+
49
+ PyConvexity provides the core functionality of the [Convexity](https://github.com/bayesian-energy/convexity-js) desktop application as a reusable, pip-installable Python library.
50
+
51
+ ## Installation
52
+
53
+ ```bash
54
+ pip install pyconvexity
55
+ ```
56
+
57
+ ## Quick Start
58
+
59
+ ```python
60
+ import pyconvexity as px
61
+
62
+ # Create a new energy system model database
63
+ px.create_database_with_schema("my_model.db")
64
+
65
+ # Create a network
66
+ with px.database_context("my_model.db") as conn:
67
+ network_req = px.CreateNetworkRequest(
68
+ name="My Energy Network",
69
+ description="Example renewable energy system",
70
+ start_time="2024-01-01 00:00:00",
71
+ end_time="2024-01-02 00:00:00",
72
+ time_resolution="H"
73
+ )
74
+ network_id = px.create_network(conn, network_req)
75
+
76
+ # Create carriers (energy types)
77
+ ac_carrier = px.create_carrier(conn, network_id, "AC")
78
+
79
+ # Create components
80
+ bus_id = px.create_component(
81
+ conn, network_id, "BUS", "Main Bus",
82
+ latitude=40.7128, longitude=-74.0060,
83
+ carrier_id=ac_carrier
84
+ )
85
+
86
+ # Set component attributes
87
+ px.set_static_attribute(conn, bus_id, "v_nom", px.StaticValue(230.0))
88
+
89
+ conn.commit()
90
+
91
+ print(f"✅ Created network {network_id} with bus {bus_id}")
92
+ ```
93
+
94
+ ## Features
95
+
96
+ - **Database Management**: SQLite-based energy system model storage
97
+ - **Component Modeling**: Buses, generators, loads, lines, storage, etc.
98
+ - **Time Series Support**: Efficient storage and retrieval of temporal data
99
+ - **Validation**: Built-in validation rules for energy system components
100
+ - **PyPSA Integration**: Compatible with PyPSA energy system modeling
101
+ - **Type Safety**: Full type hints and data validation
102
+
103
+ ## Core Concepts
104
+
105
+ ### Networks
106
+ Energy system models organized as networks with time periods and carriers.
107
+
108
+ ### Components
109
+ Physical and virtual elements: buses, generators, loads, transmission lines, storage units, etc.
110
+
111
+ ### Attributes
112
+ Component properties that can be static values or time series data.
113
+
114
+ ### Scenarios
115
+ Different parameter sets for the same network topology.
116
+
117
+ ## Documentation
118
+
119
+ - **Full Documentation**: [Convexity Documentation](https://github.com/bayesian-energy/convexity-js)
120
+ - **API Reference**: See docstrings in the code
121
+ - **Examples**: Check the `examples/` directory
122
+
123
+ ## Development
124
+
125
+ PyConvexity is developed as part of the [Convexity](https://github.com/bayesian-energy/convexity-js) project by [Bayesian Energy](https://bayesianenergy.com).
126
+
127
+ ## License
128
+
129
+ MIT License - see [LICENSE](https://github.com/bayesian-energy/convexity-js/blob/main/LICENSE) file for details.
130
+
131
+ ## Related Projects
132
+
133
+ - **[Convexity](https://github.com/bayesian-energy/convexity-js)**: Desktop application for energy system modeling
134
+ - **[PyPSA](https://pypsa.org/)**: Python for Power System Analysis
135
+ - **[Linopy](https://linopy.readthedocs.io/)**: Linear optimization with Python
@@ -0,0 +1,91 @@
1
+ # PyConvexity
2
+
3
+ **Energy system modeling library for optimization and analysis.**
4
+
5
+ PyConvexity provides the core functionality of the [Convexity](https://github.com/bayesian-energy/convexity-js) desktop application as a reusable, pip-installable Python library.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pip install pyconvexity
11
+ ```
12
+
13
+ ## Quick Start
14
+
15
+ ```python
16
+ import pyconvexity as px
17
+
18
+ # Create a new energy system model database
19
+ px.create_database_with_schema("my_model.db")
20
+
21
+ # Create a network
22
+ with px.database_context("my_model.db") as conn:
23
+ network_req = px.CreateNetworkRequest(
24
+ name="My Energy Network",
25
+ description="Example renewable energy system",
26
+ start_time="2024-01-01 00:00:00",
27
+ end_time="2024-01-02 00:00:00",
28
+ time_resolution="H"
29
+ )
30
+ network_id = px.create_network(conn, network_req)
31
+
32
+ # Create carriers (energy types)
33
+ ac_carrier = px.create_carrier(conn, network_id, "AC")
34
+
35
+ # Create components
36
+ bus_id = px.create_component(
37
+ conn, network_id, "BUS", "Main Bus",
38
+ latitude=40.7128, longitude=-74.0060,
39
+ carrier_id=ac_carrier
40
+ )
41
+
42
+ # Set component attributes
43
+ px.set_static_attribute(conn, bus_id, "v_nom", px.StaticValue(230.0))
44
+
45
+ conn.commit()
46
+
47
+ print(f"✅ Created network {network_id} with bus {bus_id}")
48
+ ```
49
+
50
+ ## Features
51
+
52
+ - **Database Management**: SQLite-based energy system model storage
53
+ - **Component Modeling**: Buses, generators, loads, lines, storage, etc.
54
+ - **Time Series Support**: Efficient storage and retrieval of temporal data
55
+ - **Validation**: Built-in validation rules for energy system components
56
+ - **PyPSA Integration**: Compatible with PyPSA energy system modeling
57
+ - **Type Safety**: Full type hints and data validation
58
+
59
+ ## Core Concepts
60
+
61
+ ### Networks
62
+ Energy system models organized as networks with time periods and carriers.
63
+
64
+ ### Components
65
+ Physical and virtual elements: buses, generators, loads, transmission lines, storage units, etc.
66
+
67
+ ### Attributes
68
+ Component properties that can be static values or time series data.
69
+
70
+ ### Scenarios
71
+ Different parameter sets for the same network topology.
72
+
73
+ ## Documentation
74
+
75
+ - **Full Documentation**: [Convexity Documentation](https://github.com/bayesian-energy/convexity-js)
76
+ - **API Reference**: See docstrings in the code
77
+ - **Examples**: Check the `examples/` directory
78
+
79
+ ## Development
80
+
81
+ PyConvexity is developed as part of the [Convexity](https://github.com/bayesian-energy/convexity-js) project by [Bayesian Energy](https://bayesianenergy.com).
82
+
83
+ ## License
84
+
85
+ MIT License - see [LICENSE](https://github.com/bayesian-energy/convexity-js/blob/main/LICENSE) file for details.
86
+
87
+ ## Related Projects
88
+
89
+ - **[Convexity](https://github.com/bayesian-energy/convexity-js)**: Desktop application for energy system modeling
90
+ - **[PyPSA](https://pypsa.org/)**: Python for Power System Analysis
91
+ - **[Linopy](https://linopy.readthedocs.io/)**: Linear optimization with Python
@@ -0,0 +1,89 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pyconvexity"
7
+ version = "0.1.0"
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
+ dev = [
48
+ "pytest>=7.0.0",
49
+ "pytest-cov>=4.0.0",
50
+ "black>=22.0.0",
51
+ "isort>=5.10.0",
52
+ "mypy>=1.0.0",
53
+ "pre-commit>=2.20.0",
54
+ ]
55
+ all = [
56
+ "pyconvexity[pypsa,excel,netcdf]",
57
+ ]
58
+
59
+ [project.urls]
60
+ Homepage = "https://github.com/bayesian-energy/convexity-js"
61
+ Repository = "https://github.com/bayesian-energy/convexity-js"
62
+ Issues = "https://github.com/bayesian-energy/convexity-js/issues"
63
+
64
+ [tool.setuptools.packages.find]
65
+ where = ["src"]
66
+
67
+
68
+ [tool.setuptools.package-data]
69
+ pyconvexity = ["data/**/*", "schema/**/*"]
70
+
71
+ [tool.black]
72
+ line-length = 100
73
+ target-version = ['py39']
74
+
75
+ [tool.isort]
76
+ profile = "black"
77
+ line_length = 100
78
+
79
+ [tool.mypy]
80
+ python_version = "3.9"
81
+ warn_return_any = true
82
+ warn_unused_configs = true
83
+ disallow_untyped_defs = true
84
+
85
+ [tool.pytest.ini_options]
86
+ testpaths = ["tests"]
87
+ python_files = ["test_*.py"]
88
+ python_classes = ["Test*"]
89
+ python_functions = ["test_*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,120 @@
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
+ TimeseriesPoint,
25
+ Component,
26
+ Network,
27
+ CreateNetworkRequest,
28
+ CreateComponentRequest,
29
+ )
30
+
31
+ from pyconvexity.core.database import (
32
+ create_database_with_schema,
33
+ database_context,
34
+ open_connection,
35
+ validate_database,
36
+ )
37
+
38
+ # Import main API functions
39
+ from pyconvexity.models import (
40
+ # Component operations
41
+ get_component, create_component, update_component, delete_component,
42
+ list_components_by_type, list_component_attributes,
43
+
44
+ # Attribute operations
45
+ set_static_attribute, set_timeseries_attribute, get_attribute, delete_attribute,
46
+
47
+ # Network operations
48
+ create_network, get_network_info, get_network_time_periods, list_networks,
49
+ create_carrier, list_carriers, get_network_config, set_network_config,
50
+ get_master_scenario_id, resolve_scenario_id,
51
+ )
52
+
53
+ from pyconvexity.validation import (
54
+ get_validation_rule, list_validation_rules, validate_timeseries_alignment
55
+ )
56
+
57
+ # High-level API functions
58
+ __all__ = [
59
+ # Version info
60
+ "__version__",
61
+ "__author__",
62
+
63
+ # Core types
64
+ "StaticValue",
65
+ "TimeseriesPoint",
66
+ "Component",
67
+ "Network",
68
+ "CreateNetworkRequest",
69
+ "CreateComponentRequest",
70
+
71
+ # Database operations
72
+ "create_database_with_schema",
73
+ "database_context",
74
+ "open_connection",
75
+ "validate_database",
76
+
77
+ # Exceptions
78
+ "PyConvexityError",
79
+ "DatabaseError",
80
+ "ValidationError",
81
+ "ComponentNotFound",
82
+ "AttributeNotFound",
83
+
84
+ # Component operations
85
+ "get_component", "create_component", "update_component", "delete_component",
86
+ "list_components_by_type", "list_component_attributes",
87
+
88
+ # Attribute operations
89
+ "set_static_attribute", "set_timeseries_attribute", "get_attribute", "delete_attribute",
90
+
91
+ # Network operations
92
+ "create_network", "get_network_info", "get_network_time_periods", "list_networks",
93
+ "create_carrier", "list_carriers", "get_network_config", "set_network_config",
94
+ "get_master_scenario_id", "resolve_scenario_id",
95
+
96
+ # Validation
97
+ "get_validation_rule", "list_validation_rules", "validate_timeseries_alignment",
98
+ ]
99
+
100
+ # Optional imports with graceful fallbacks
101
+ try:
102
+ from pyconvexity.solvers.pypsa import PyPSASolver
103
+ __all__.append("PyPSASolver")
104
+ except ImportError:
105
+ # PyPSA not available
106
+ pass
107
+
108
+ try:
109
+ from pyconvexity.io.excel import ExcelImporter, ExcelExporter
110
+ __all__.extend(["ExcelImporter", "ExcelExporter"])
111
+ except ImportError:
112
+ # Excel dependencies not available
113
+ pass
114
+
115
+ try:
116
+ from pyconvexity.io.netcdf import NetCDFImporter, NetCDFExporter
117
+ __all__.extend(["NetCDFImporter", "NetCDFExporter"])
118
+ except ImportError:
119
+ # NetCDF dependencies not available
120
+ pass
@@ -0,0 +1,2 @@
1
+ # This file is automatically updated by GitHub Actions during release
2
+ __version__ = "0.1.0" # Default version for local development
@@ -0,0 +1,64 @@
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
+ TimeseriesPoint,
20
+ AttributeValue,
21
+ ValidationRule,
22
+ Component,
23
+ Network,
24
+ TimePeriod,
25
+ TimeseriesValidationResult,
26
+ CreateComponentRequest,
27
+ CreateNetworkRequest,
28
+ )
29
+
30
+ from pyconvexity.core.database import (
31
+ DatabaseContext,
32
+ open_connection,
33
+ validate_database,
34
+ create_database_with_schema,
35
+ )
36
+
37
+ __all__ = [
38
+ # Errors
39
+ "PyConvexityError",
40
+ "DatabaseError",
41
+ "ValidationError",
42
+ "ComponentNotFound",
43
+ "AttributeNotFound",
44
+ "InvalidDataType",
45
+ "TimeseriesError",
46
+
47
+ # Types
48
+ "StaticValue",
49
+ "TimeseriesPoint",
50
+ "AttributeValue",
51
+ "ValidationRule",
52
+ "Component",
53
+ "Network",
54
+ "TimePeriod",
55
+ "TimeseriesValidationResult",
56
+ "CreateComponentRequest",
57
+ "CreateNetworkRequest",
58
+
59
+ # Database
60
+ "DatabaseContext",
61
+ "open_connection",
62
+ "validate_database",
63
+ "create_database_with_schema",
64
+ ]