|
49 | 49 | "\n",
|
50 | 50 | "from power_grid_model import LoadGenType, ComponentType, DatasetType, ComponentAttributeFilterOptions\n",
|
51 | 51 | "from power_grid_model import PowerGridModel, CalculationMethod, CalculationType\n",
|
52 |
| - "from power_grid_model import initialize_array, power_grid_meta_data" |
| 52 | + "from power_grid_model import initialize_array, attribute_dtype" |
53 | 53 | ]
|
54 | 54 | },
|
55 | 55 | {
|
|
127 | 127 | "\n",
|
128 | 128 | "A columnar data format better integrates with most databases. In addition, it may bring memory and, in some cases, even computational performance improvements, because unused attribute columns can be omitted.\n",
|
129 | 129 | "\n",
|
130 |
| - "Make sure to provide the correct `dtype` to the numpy arrays, exposed for each dataset type, component and attribute via the `power_grid_meta_data` object." |
| 130 | + "Make sure to provide the correct `dtype` to the numpy arrays, exposed for each dataset type, component and attribute via the helper function `attribute_dtype` function." |
131 | 131 | ]
|
132 | 132 | },
|
133 | 133 | {
|
|
137 | 137 | "metadata": {},
|
138 | 138 | "outputs": [],
|
139 | 139 | "source": [
|
140 |
| - "source_attribute_dtypes = power_grid_meta_data[DatasetType.input][ComponentType.source].dtype\n", |
141 | 140 | "source_columns = {\n",
|
142 |
| - " \"id\": np.array([10], dtype=source_attribute_dtypes[\"id\"]),\n", |
143 |
| - " \"node\": np.array([1], dtype=source_attribute_dtypes[\"node\"]),\n", |
144 |
| - " \"status\": np.array([1], dtype=source_attribute_dtypes[\"status\"]),\n", |
145 |
| - " \"u_ref\": np.array([1.0], dtype=source_attribute_dtypes[\"u_ref\"]),\n", |
| 141 | + " \"id\": np.array([10], dtype=attribute_dtype(DatasetType.input, ComponentType.source, \"id\")),\n", |
| 142 | + " \"node\": np.array([1], dtype=attribute_dtype(DatasetType.input, ComponentType.source, \"node\")),\n", |
| 143 | + " \"status\": np.array([1], dtype=attribute_dtype(DatasetType.input, ComponentType.source, \"status\")),\n", |
| 144 | + " \"u_ref\": np.array([1.0], dtype=attribute_dtype(DatasetType.input, ComponentType.source, \"u_ref\")),\n", |
146 | 145 | " # We're not creating columns for u_ref_angle, sk, ... Instead, the default values are used. This saves us memory.\n",
|
147 | 146 | "}\n",
|
148 | 147 | "\n",
|
|
674 | 673 | "metadata": {},
|
675 | 674 | "outputs": [],
|
676 | 675 | "source": [
|
677 |
| - "line_update_dtype = power_grid_meta_data[DatasetType.update][ComponentType.line].dtype\n", |
678 | 676 | "columnar_update_line = {\n",
|
679 |
| - " \"id\": np.array([3], dtype=line_update_dtype[\"id\"]), # change line ID 3\n", |
680 |
| - " \"from_status\": np.array([0], dtype=line_update_dtype[\"from_status\"]), # switch off at from side\n", |
| 677 | + " \"id\": np.array([3], dtype=attribute_dtype(DatasetType.update, ComponentType.line, \"id\")), # change line ID 3\n", |
| 678 | + " \"from_status\": np.array(\n", |
| 679 | + " [0], dtype=attribute_dtype(DatasetType.update, ComponentType.line, \"from_status\")\n", |
| 680 | + " ), # switch off at from side\n", |
681 | 681 | "}\n",
|
682 | 682 | "# leave to-side swiching status the same, no need to specify\n",
|
683 | 683 | "\n",
|
|
699 | 699 | "metadata": {},
|
700 | 700 | "outputs": [],
|
701 | 701 | "source": [
|
702 |
| - "line_update_dtype = power_grid_meta_data[DatasetType.update][ComponentType.line].dtype\n", |
703 | 702 | "columnar_no_ID_update_line = {\n",
|
704 | 703 | " # Update IDs are not specified\n",
|
705 | 704 | " \"from_status\": np.array(\n",
|
706 |
| - " [0, 1, 1], dtype=line_update_dtype[\"from_status\"]\n", |
| 705 | + " [0, 1, 1], dtype=attribute_dtype(DatasetType.update, ComponentType.line, \"from_status\")\n", |
707 | 706 | " ), # The update for the whole column needs to be specified\n",
|
708 | 707 | "}\n",
|
709 | 708 | "# leave to-side swiching status the same, no need to specify\n",
|
|
1404 | 1403 | "output_type": "stream",
|
1405 | 1404 | "text": [
|
1406 | 1405 | "Node data with invalid results\n",
|
1407 |
| - "[[0.99940117 0.99268579 0.99452137]\n", |
1408 |
| - " [0.99934769 0.98622639 0.98935286]\n", |
1409 |
| - " [0.99928838 0.97965401 0.98409554]\n", |
1410 |
| - " [0. 0. 0. ]\n", |
1411 |
| - " [0.99915138 0.96614948 0.97329879]\n", |
1412 |
| - " [0.99907317 0.95920586 0.96775071]\n", |
1413 |
| - " [0.9989881 0.95212621 0.96209647]\n", |
1414 |
| - " [0. 0. 0. ]\n", |
1415 |
| - " [0.99879613 0.93753005 0.95044796]\n", |
1416 |
| - " [0.9986885 0.92999747 0.94444167]]\n", |
| 1406 | + "[[9.99401170e-001 9.92685785e-001 9.94521366e-001]\n", |
| 1407 | + " [9.99347687e-001 9.86226389e-001 9.89352855e-001]\n", |
| 1408 | + " [9.99288384e-001 9.79654011e-001 9.84095542e-001]\n", |
| 1409 | + " [3.94357132e+180 2.87518198e+161 2.04418455e+214]\n", |
| 1410 | + " [9.99151380e-001 9.66149483e-001 9.73298790e-001]\n", |
| 1411 | + " [9.99073166e-001 9.59205860e-001 9.67750710e-001]\n", |
| 1412 | + " [9.98988099e-001 9.52126208e-001 9.62096474e-001]\n", |
| 1413 | + " [0.00000000e+000 0.00000000e+000 0.00000000e+000]\n", |
| 1414 | + " [9.98796126e-001 9.37530046e-001 9.50447962e-001]\n", |
| 1415 | + " [9.98688504e-001 9.29997471e-001 9.44441670e-001]]\n", |
1417 | 1416 | "Node data with only valid results\n",
|
1418 | 1417 | "[[0.99940117 0.99268579 0.99452137]\n",
|
1419 | 1418 | " [0.99934769 0.98622639 0.98935286]\n",
|
|
1456 | 1455 | ],
|
1457 | 1456 | "metadata": {
|
1458 | 1457 | "kernelspec": {
|
1459 |
| - "display_name": "venv", |
| 1458 | + "display_name": ".venv", |
1460 | 1459 | "language": "python",
|
1461 | 1460 | "name": "python3"
|
1462 | 1461 | },
|
|
0 commit comments