power-grid-model-io 1.2.95__py3-none-any.whl → 1.2.97__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 power-grid-model-io might be problematic. Click here for more details.
- power_grid_model_io/converters/pandapower_converter.py +30 -9
- power_grid_model_io/converters/pgm_json_converter.py +7 -4
- power_grid_model_io/converters/tabular_converter.py +3 -1
- {power_grid_model_io-1.2.95.dist-info → power_grid_model_io-1.2.97.dist-info}/METADATA +18 -18
- {power_grid_model_io-1.2.95.dist-info → power_grid_model_io-1.2.97.dist-info}/RECORD +8 -8
- {power_grid_model_io-1.2.95.dist-info → power_grid_model_io-1.2.97.dist-info}/WHEEL +1 -1
- {power_grid_model_io-1.2.95.dist-info → power_grid_model_io-1.2.97.dist-info}/LICENSE +0 -0
- {power_grid_model_io-1.2.95.dist-info → power_grid_model_io-1.2.97.dist-info}/top_level.txt +0 -0
|
@@ -12,7 +12,15 @@ from typing import Dict, List, MutableMapping, Optional, Tuple, Type, Union
|
|
|
12
12
|
import numpy as np
|
|
13
13
|
import pandas as pd
|
|
14
14
|
import structlog
|
|
15
|
-
from power_grid_model import
|
|
15
|
+
from power_grid_model import (
|
|
16
|
+
Branch3Side,
|
|
17
|
+
BranchSide,
|
|
18
|
+
DatasetType,
|
|
19
|
+
LoadGenType,
|
|
20
|
+
WindingType,
|
|
21
|
+
initialize_array,
|
|
22
|
+
power_grid_meta_data,
|
|
23
|
+
)
|
|
16
24
|
from power_grid_model.data_types import Dataset, SingleDataset
|
|
17
25
|
|
|
18
26
|
from power_grid_model_io.converters.base_converter import BaseConverter
|
|
@@ -113,10 +121,10 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
|
|
|
113
121
|
self._extra_info_to_pgm_input_data(extra_info)
|
|
114
122
|
|
|
115
123
|
# Convert
|
|
116
|
-
def pgm_output_dtype_checker(check_type: str) -> bool:
|
|
124
|
+
def pgm_output_dtype_checker(check_type: DatasetType | str) -> bool:
|
|
117
125
|
return all(
|
|
118
126
|
(
|
|
119
|
-
comp_array.dtype == power_grid_meta_data[check_type][component]
|
|
127
|
+
comp_array.dtype == power_grid_meta_data[DatasetType[check_type]][component]
|
|
120
128
|
for component, comp_array in self.pgm_output_data.items()
|
|
121
129
|
)
|
|
122
130
|
)
|
|
@@ -248,7 +256,10 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
|
|
|
248
256
|
nan = np.iinfo(dtype).min
|
|
249
257
|
all_other_cols = ["i_n"]
|
|
250
258
|
for component, data in self.pgm_output_data.items():
|
|
251
|
-
input_cols = power_grid_meta_data[
|
|
259
|
+
input_cols = power_grid_meta_data[DatasetType.input][component].dtype.names
|
|
260
|
+
if input_cols is None:
|
|
261
|
+
input_cols = tuple()
|
|
262
|
+
|
|
252
263
|
node_cols = [col for col in input_cols if is_node_ref(col)]
|
|
253
264
|
other_cols = [col for col in input_cols if col in all_other_cols]
|
|
254
265
|
if not node_cols + other_cols:
|
|
@@ -747,8 +758,12 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
|
|
|
747
758
|
pgm_transformers["sn"] = sn_mva * parallel * 1e6
|
|
748
759
|
pgm_transformers["uk"] = vk_percent * 1e-2
|
|
749
760
|
pgm_transformers["pk"] = vkr_percent * sn_mva * parallel * (1e6 * 1e-2)
|
|
750
|
-
pgm_transformers["i0"] = i_no_load * 1e-2
|
|
751
761
|
pgm_transformers["p0"] = pfe * parallel * 1e3
|
|
762
|
+
pgm_transformers["i0"] = i_no_load * 1e-2
|
|
763
|
+
i0_min_threshold = pgm_transformers["p0"] / pgm_transformers["sn"]
|
|
764
|
+
if any(np.less(pgm_transformers["i0"], i0_min_threshold)):
|
|
765
|
+
logger.warning("Minimum value of i0_percent is clipped to p0/sn")
|
|
766
|
+
pgm_transformers["i0"] = np.clip(pgm_transformers["i0"], a_min=i0_min_threshold, a_max=None)
|
|
752
767
|
pgm_transformers["clock"] = clocks
|
|
753
768
|
pgm_transformers["winding_from"] = winding_types["winding_from"]
|
|
754
769
|
pgm_transformers["winding_to"] = winding_types["winding_to"]
|
|
@@ -875,8 +890,12 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
|
|
|
875
890
|
pgm_3wtransformers["pk_13"] = vkr_lv_percent * np.minimum(sn_hv_mva, sn_lv_mva) * (1e-2 * 1e6)
|
|
876
891
|
pgm_3wtransformers["pk_23"] = vkr_mv_percent * np.minimum(sn_mv_mva, sn_lv_mva) * (1e-2 * 1e6)
|
|
877
892
|
|
|
878
|
-
pgm_3wtransformers["i0"] = self._get_pp_attr("trafo3w", "i0_percent", expected_type="f8") * 1e-2
|
|
879
893
|
pgm_3wtransformers["p0"] = self._get_pp_attr("trafo3w", "pfe_kw", expected_type="f8") * 1e3
|
|
894
|
+
pgm_3wtransformers["i0"] = self._get_pp_attr("trafo3w", "i0_percent", expected_type="f8") * 1e-2
|
|
895
|
+
i0_min_threshold = pgm_3wtransformers["p0"] / pgm_3wtransformers["sn_1"]
|
|
896
|
+
if any(np.less(pgm_3wtransformers["i0"], i0_min_threshold)):
|
|
897
|
+
logger.warning("Minimum value of i0_percent is clipped to p0/sn_1")
|
|
898
|
+
pgm_3wtransformers["i0"] = np.clip(pgm_3wtransformers["i0"], a_min=i0_min_threshold, a_max=None)
|
|
880
899
|
pgm_3wtransformers["clock_12"] = clocks_12
|
|
881
900
|
pgm_3wtransformers["clock_13"] = clocks_13
|
|
882
901
|
pgm_3wtransformers["winding_1"] = winding_types["winding_1"]
|
|
@@ -1594,9 +1613,11 @@ class PandaPowerConverter(BaseConverter[PandaPowerData]):
|
|
|
1594
1613
|
# Combine all branch bus, current and et in one dataframe
|
|
1595
1614
|
all_i_df = pd.concat(
|
|
1596
1615
|
[
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1616
|
+
(
|
|
1617
|
+
join_currents(table, bus_name, i_name)
|
|
1618
|
+
if not rest_switches_absent[table]
|
|
1619
|
+
else pd.DataFrame(columns=["bus", "element", "et", "i_ka"])
|
|
1620
|
+
)
|
|
1600
1621
|
for table, attr_names in switch_attrs.items()
|
|
1601
1622
|
for bus_name, i_name in attr_names.items()
|
|
1602
1623
|
]
|
|
@@ -151,9 +151,12 @@ class PgmJsonConverter(BaseConverter[StructuredData]):
|
|
|
151
151
|
|
|
152
152
|
# If an attribute doesn't exist, it is added to the extra_info lookup table
|
|
153
153
|
elif extra_info is not None:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
obj_id = obj["id"]
|
|
155
|
+
if not isinstance(obj_id, int):
|
|
156
|
+
raise ValueError(f"Invalid 'id' value for {component} {data_type} data")
|
|
157
|
+
if obj_id not in extra_info:
|
|
158
|
+
extra_info[obj_id] = {}
|
|
159
|
+
extra_info[obj_id][attribute] = value
|
|
157
160
|
return array
|
|
158
161
|
|
|
159
162
|
def _serialize_data(self, data: Dataset, extra_info: Optional[ExtraInfo]) -> StructuredData:
|
|
@@ -271,7 +274,7 @@ class PgmJsonConverter(BaseConverter[StructuredData]):
|
|
|
271
274
|
self._extract_extra_component_info(component, entry, reserialized_data, extra_info)
|
|
272
275
|
|
|
273
276
|
def _extract_extra_component_info(
|
|
274
|
-
self, component: str, attributes: Dict[str, Any], reserialized_data:
|
|
277
|
+
self, component: str, attributes: Dict[str, Any], reserialized_data: SinglePythonDataset, extra_info: ExtraInfo
|
|
275
278
|
):
|
|
276
279
|
entry_id = attributes["id"]
|
|
277
280
|
reserialized_entry = self._get_first_by(reserialized_data[component], "id", entry_id)
|
|
@@ -180,6 +180,8 @@ class TabularConverter(BaseConverter[TabularData]):
|
|
|
180
180
|
|
|
181
181
|
if "filters" in attributes:
|
|
182
182
|
table_mask = self._parse_table_filters(data=data, table=table, filtering_functions=attributes["filters"])
|
|
183
|
+
if table_mask is not None and not table_mask.any():
|
|
184
|
+
return None
|
|
183
185
|
else:
|
|
184
186
|
table_mask = None
|
|
185
187
|
|
|
@@ -219,7 +221,7 @@ class TabularConverter(BaseConverter[TabularData]):
|
|
|
219
221
|
for filtering_fn in filtering_functions:
|
|
220
222
|
for fn_name, kwargs in filtering_fn.items():
|
|
221
223
|
fn_ptr = get_function(fn_name)
|
|
222
|
-
table_mask &= data[table].apply(fn_ptr, axis=1, **kwargs).values
|
|
224
|
+
table_mask &= cast(pd.DataFrame, data[table]).apply(fn_ptr, axis=1, **kwargs).values
|
|
223
225
|
return table_mask
|
|
224
226
|
|
|
225
227
|
# pylint: disable = too-many-arguments
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: power-grid-model-io
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.97
|
|
4
4
|
Summary: Power Grid Model Input/Output
|
|
5
5
|
Author-email: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
6
6
|
License: MPL-2.0
|
|
@@ -21,31 +21,31 @@ Classifier: Topic :: Scientific/Engineering :: Physics
|
|
|
21
21
|
Requires-Python: >=3.10
|
|
22
22
|
Description-Content-Type: text/markdown
|
|
23
23
|
License-File: LICENSE
|
|
24
|
-
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: numpy>=1.20
|
|
25
25
|
Requires-Dist: openpyxl
|
|
26
26
|
Requires-Dist: pandas
|
|
27
|
-
Requires-Dist: power-grid-model
|
|
27
|
+
Requires-Dist: power-grid-model>=1.8
|
|
28
28
|
Requires-Dist: pyyaml
|
|
29
29
|
Requires-Dist: structlog
|
|
30
30
|
Requires-Dist: tqdm
|
|
31
31
|
Provides-Extra: dev
|
|
32
|
-
Requires-Dist: pandapower
|
|
33
|
-
Requires-Dist: pre-commit
|
|
34
|
-
Requires-Dist: pylint
|
|
35
|
-
Requires-Dist: pytest
|
|
36
|
-
Requires-Dist: pytest-cov
|
|
37
|
-
Requires-Dist: pydantic
|
|
38
|
-
Requires-Dist: numba
|
|
32
|
+
Requires-Dist: pandapower>2.11.1; extra == "dev"
|
|
33
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
34
|
+
Requires-Dist: pylint; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest; extra == "dev"
|
|
36
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
37
|
+
Requires-Dist: pydantic>2; extra == "dev"
|
|
38
|
+
Requires-Dist: numba; extra == "dev"
|
|
39
39
|
Provides-Extra: doc
|
|
40
|
-
Requires-Dist: sphinx
|
|
41
|
-
Requires-Dist: myst-nb
|
|
42
|
-
Requires-Dist: sphinx-rtd-theme
|
|
43
|
-
Requires-Dist: readthedocs-sphinx-search
|
|
44
|
-
Requires-Dist: sphinx-hoverxref
|
|
45
|
-
Requires-Dist: numpydoc
|
|
40
|
+
Requires-Dist: sphinx; extra == "doc"
|
|
41
|
+
Requires-Dist: myst-nb; extra == "doc"
|
|
42
|
+
Requires-Dist: sphinx-rtd-theme; extra == "doc"
|
|
43
|
+
Requires-Dist: readthedocs-sphinx-search; extra == "doc"
|
|
44
|
+
Requires-Dist: sphinx-hoverxref; extra == "doc"
|
|
45
|
+
Requires-Dist: numpydoc; extra == "doc"
|
|
46
46
|
Provides-Extra: examples
|
|
47
|
-
Requires-Dist: pandapower
|
|
48
|
-
Requires-Dist: pyarrow
|
|
47
|
+
Requires-Dist: pandapower>2.11.1; extra == "examples"
|
|
48
|
+
Requires-Dist: pyarrow; extra == "examples"
|
|
49
49
|
|
|
50
50
|
<!--
|
|
51
51
|
SPDX-FileCopyrightText: Contributors to the Power Grid Model project <powergridmodel@lfenergy.org>
|
|
@@ -8,9 +8,9 @@ power_grid_model_io/config/excel/vision_en_9_7.yaml,sha256=yXClnsAxy2cIey6fW6pcm
|
|
|
8
8
|
power_grid_model_io/config/excel/vision_nl.yaml,sha256=hALPcS4RjPYxNodnC5-FTCE7djnLVSAtnsayeOhUuRY,21333
|
|
9
9
|
power_grid_model_io/converters/__init__.py,sha256=kmbjFW6kVr30fmHb6mAoD7DQAqmbrsOuF1ewd8b0Q3M,408
|
|
10
10
|
power_grid_model_io/converters/base_converter.py,sha256=TICEXyG7PtimAUvhAmpSoZUqwa0shiDdwbWpiM2Ur7o,6048
|
|
11
|
-
power_grid_model_io/converters/pandapower_converter.py,sha256=
|
|
12
|
-
power_grid_model_io/converters/pgm_json_converter.py,sha256=
|
|
13
|
-
power_grid_model_io/converters/tabular_converter.py,sha256=
|
|
11
|
+
power_grid_model_io/converters/pandapower_converter.py,sha256=ycjnKAJcn8E6Eor9uCmzbvdKleLZlzvgR2syQY9X9NQ,114803
|
|
12
|
+
power_grid_model_io/converters/pgm_json_converter.py,sha256=GdesepDPVl1oX_F35Dtjz6kzrkiGfvQA55rBzWJYhA4,13343
|
|
13
|
+
power_grid_model_io/converters/tabular_converter.py,sha256=piBO5lgB_qDhkrYSDMy7PvZ6Fo1dhcdUp0tl0taayHY,33565
|
|
14
14
|
power_grid_model_io/converters/vision_excel_converter.py,sha256=aGEoOh8Y-ZK1O5oSZQCrW_-0MHlBg1RjiJyQjLs91pY,4155
|
|
15
15
|
power_grid_model_io/data_stores/__init__.py,sha256=qwbj1j-Aa_yRB-E3j35pEVtF3mgH8CVIXAnog5mOry0,138
|
|
16
16
|
power_grid_model_io/data_stores/base_data_store.py,sha256=DJfLtRwvx_tXKnpjtBdfbMqPjWc324Eo5WeKTXjWXqc,1706
|
|
@@ -41,8 +41,8 @@ power_grid_model_io/utils/modules.py,sha256=a4IdozSL-sOZcmIQON_aQS7-cpnCyt-3p7zs
|
|
|
41
41
|
power_grid_model_io/utils/parsing.py,sha256=XB1QSHnslIieFJBKFXZCtiydqpOqQBiX_CXDbItXgAQ,4522
|
|
42
42
|
power_grid_model_io/utils/uuid_excel_cvtr.py,sha256=H1iWhW_nluJBUJ3hK-Gc0xJjGnH5e35WrBz_fA3YXZs,7626
|
|
43
43
|
power_grid_model_io/utils/zip.py,sha256=VXHX4xWPPZbhOlZUAbMDy3MgQFzK6_l7sRvGXihNUY4,3875
|
|
44
|
-
power_grid_model_io-1.2.
|
|
45
|
-
power_grid_model_io-1.2.
|
|
46
|
-
power_grid_model_io-1.2.
|
|
47
|
-
power_grid_model_io-1.2.
|
|
48
|
-
power_grid_model_io-1.2.
|
|
44
|
+
power_grid_model_io-1.2.97.dist-info/LICENSE,sha256=7Pm2fWFFHHUG5lDHed1vl5CjzxObIXQglnYsEdtjo_k,14907
|
|
45
|
+
power_grid_model_io-1.2.97.dist-info/METADATA,sha256=tGMO4lJ0t1-D_LreiuBHmwp9aLcctS3NZx-V8zbmucA,8019
|
|
46
|
+
power_grid_model_io-1.2.97.dist-info/WHEEL,sha256=Mdi9PDNwEZptOjTlUcAth7XJDFtKrHYaQMPulZeBCiQ,91
|
|
47
|
+
power_grid_model_io-1.2.97.dist-info/top_level.txt,sha256=7sq9VveemMm2R0RgTBa4tH8y_xF4_1hxbufmX9OjCTo,20
|
|
48
|
+
power_grid_model_io-1.2.97.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|