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.

Files changed (42) hide show
  1. pyconvexity/__init__.py +226 -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/data/README.md +101 -0
  8. pyconvexity/data/__init__.py +17 -0
  9. pyconvexity/data/loaders/__init__.py +3 -0
  10. pyconvexity/data/loaders/cache.py +213 -0
  11. pyconvexity/data/schema/01_core_schema.sql +420 -0
  12. pyconvexity/data/schema/02_data_metadata.sql +120 -0
  13. pyconvexity/data/schema/03_validation_data.sql +506 -0
  14. pyconvexity/data/sources/__init__.py +5 -0
  15. pyconvexity/data/sources/gem.py +442 -0
  16. pyconvexity/io/__init__.py +26 -0
  17. pyconvexity/io/excel_exporter.py +1226 -0
  18. pyconvexity/io/excel_importer.py +1381 -0
  19. pyconvexity/io/netcdf_exporter.py +197 -0
  20. pyconvexity/io/netcdf_importer.py +1833 -0
  21. pyconvexity/models/__init__.py +195 -0
  22. pyconvexity/models/attributes.py +730 -0
  23. pyconvexity/models/carriers.py +159 -0
  24. pyconvexity/models/components.py +611 -0
  25. pyconvexity/models/network.py +503 -0
  26. pyconvexity/models/results.py +148 -0
  27. pyconvexity/models/scenarios.py +234 -0
  28. pyconvexity/solvers/__init__.py +29 -0
  29. pyconvexity/solvers/pypsa/__init__.py +24 -0
  30. pyconvexity/solvers/pypsa/api.py +460 -0
  31. pyconvexity/solvers/pypsa/batch_loader.py +307 -0
  32. pyconvexity/solvers/pypsa/builder.py +675 -0
  33. pyconvexity/solvers/pypsa/constraints.py +405 -0
  34. pyconvexity/solvers/pypsa/solver.py +1509 -0
  35. pyconvexity/solvers/pypsa/storage.py +2048 -0
  36. pyconvexity/timeseries.py +330 -0
  37. pyconvexity/validation/__init__.py +25 -0
  38. pyconvexity/validation/rules.py +312 -0
  39. pyconvexity-0.4.3.dist-info/METADATA +47 -0
  40. pyconvexity-0.4.3.dist-info/RECORD +42 -0
  41. pyconvexity-0.4.3.dist-info/WHEEL +5 -0
  42. pyconvexity-0.4.3.dist-info/top_level.txt +1 -0
@@ -0,0 +1,120 @@
1
+ -- ============================================================================
2
+ -- DATA STORAGE AND METADATA SCHEMA
3
+ -- Essential tables for data storage and solve results
4
+ -- Version 3.1.0 - Simplified for single-network-per-file
5
+ -- ============================================================================
6
+
7
+ -- ============================================================================
8
+ -- GENERIC DATA STORAGE
9
+ -- ============================================================================
10
+
11
+ -- Generic data store for arbitrary network-level data
12
+ CREATE TABLE network_data_store (
13
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
14
+ category TEXT NOT NULL, -- 'config', 'results', 'statistics', 'scripts', etc.
15
+ name TEXT NOT NULL,
16
+ data_format TEXT DEFAULT 'json', -- 'json', 'csv', 'binary', 'text'
17
+ data BLOB NOT NULL,
18
+ metadata TEXT, -- JSON metadata
19
+ checksum TEXT,
20
+
21
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
22
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
23
+
24
+ CONSTRAINT uq_datastore_category_name
25
+ UNIQUE (category, name),
26
+ CONSTRAINT valid_data_format
27
+ CHECK (data_format IN ('json', 'csv', 'binary', 'text', 'yaml', 'toml'))
28
+ );
29
+
30
+ CREATE INDEX idx_datastore_category ON network_data_store(category);
31
+
32
+ -- ============================================================================
33
+ -- DOCUMENTATION AND NOTES
34
+ -- ============================================================================
35
+
36
+ -- Network-level notes
37
+ CREATE TABLE network_notes (
38
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
39
+ title TEXT NOT NULL,
40
+ content TEXT,
41
+ tags TEXT, -- JSON array
42
+ note_type TEXT DEFAULT 'note',
43
+ priority INTEGER DEFAULT 0,
44
+
45
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
46
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
47
+
48
+ CONSTRAINT valid_note_type
49
+ CHECK (note_type IN ('note', 'todo', 'warning', 'info', 'doc'))
50
+ );
51
+
52
+ -- Component-specific notes
53
+ CREATE TABLE component_notes (
54
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
55
+ component_id INTEGER NOT NULL,
56
+ title TEXT NOT NULL,
57
+ content TEXT,
58
+ tags TEXT,
59
+ note_type TEXT DEFAULT 'note',
60
+ priority INTEGER DEFAULT 0,
61
+
62
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
63
+ updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
64
+
65
+ CONSTRAINT fk_component_notes_component
66
+ FOREIGN KEY (component_id) REFERENCES components(id) ON DELETE CASCADE,
67
+ CONSTRAINT valid_component_note_type
68
+ CHECK (note_type IN ('note', 'todo', 'warning', 'info', 'doc'))
69
+ );
70
+
71
+ CREATE INDEX idx_component_notes_component ON component_notes(component_id);
72
+
73
+ -- ============================================================================
74
+ -- SOLVE RESULTS AND STATISTICS
75
+ -- ============================================================================
76
+
77
+ -- Network solve results - stores solver outputs per scenario
78
+ CREATE TABLE network_solve_results (
79
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
80
+ scenario_id INTEGER, -- NULL for base network, non-NULL for scenario
81
+
82
+ -- Solve metadata
83
+ solved_at DATETIME DEFAULT CURRENT_TIMESTAMP,
84
+ solver_name TEXT NOT NULL,
85
+ solve_type TEXT NOT NULL,
86
+ solve_status TEXT NOT NULL,
87
+ objective_value REAL,
88
+ solve_time_seconds REAL,
89
+
90
+ -- Results stored as JSON
91
+ results_json TEXT NOT NULL,
92
+ metadata_json TEXT,
93
+
94
+ -- Only one result per scenario (including NULL for base network)
95
+ UNIQUE (scenario_id),
96
+
97
+ FOREIGN KEY (scenario_id) REFERENCES scenarios(id) ON DELETE CASCADE
98
+ );
99
+
100
+ CREATE INDEX idx_solve_results_scenario ON network_solve_results(scenario_id);
101
+
102
+ -- Year-based solve results for capacity expansion analysis
103
+ CREATE TABLE network_solve_results_by_year (
104
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
105
+ scenario_id INTEGER, -- NULL for base network
106
+ year INTEGER NOT NULL,
107
+
108
+ results_json TEXT NOT NULL,
109
+ metadata_json TEXT,
110
+
111
+ created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
112
+
113
+ CONSTRAINT fk_solve_results_year_scenario
114
+ FOREIGN KEY (scenario_id) REFERENCES scenarios(id) ON DELETE CASCADE,
115
+ CONSTRAINT uq_solve_results_year_unique
116
+ UNIQUE (scenario_id, year),
117
+ CONSTRAINT valid_year CHECK (year >= 1900 AND year <= 2100)
118
+ );
119
+
120
+ CREATE INDEX idx_solve_results_year_scenario ON network_solve_results_by_year(scenario_id);