|
1 | | -from unittest.mock import Mock |
2 | | - |
3 | 1 | import pandas as pd |
4 | 2 | import pytest |
5 | 3 | from pandas.testing import assert_frame_equal, assert_series_equal |
6 | 4 |
|
7 | | -from prereise.gather.griddata.hifld import const |
8 | 5 | from prereise.gather.griddata.hifld.data_process.transmission import ( |
9 | 6 | add_b2bs_to_dc_lines, |
10 | 7 | add_lines_impedances_ratings, |
|
13 | 10 | augment_line_voltages, |
14 | 11 | create_buses, |
15 | 12 | create_transformers, |
16 | | - estimate_branch_impedance, |
17 | | - estimate_branch_rating, |
18 | 13 | filter_islands_and_connect_with_mst, |
19 | 14 | map_lines_to_substations_using_coords, |
20 | 15 | split_lines_to_ac_and_dc, |
@@ -222,66 +217,6 @@ def test_create_transformers(): |
222 | 217 | assert_frame_equal(transformers, expected_transformers) |
223 | 218 |
|
224 | 219 |
|
225 | | -def test_estimate_branch_impedance_lines(): |
226 | | - resistance = 0.01 |
227 | | - reactance = 0.1 |
228 | | - fake_lines = [Mock(series_impedance=(resistance + 1j * reactance))] * 3 |
229 | | - branch = pd.DataFrame( |
230 | | - {"VOLTAGE": [69, 70, 345], "type": ["Line"] * 3, "line_object": fake_lines} |
231 | | - ) |
232 | | - x = estimate_branch_impedance(branch.iloc[0], pd.Series()) |
233 | | - assert x == reactance / (69**2 / const.s_base) |
234 | | - x = estimate_branch_impedance(branch.iloc[1], pd.Series()) |
235 | | - assert x == reactance / (70**2 / const.s_base) |
236 | | - x = estimate_branch_impedance(branch.iloc[2], pd.Series()) |
237 | | - assert x == reactance / (345**2 / const.s_base) |
238 | | - |
239 | | - |
240 | | -def test_estimate_branch_impedance_transformers(): |
241 | | - transformers = pd.DataFrame( |
242 | | - {"from_bus_id": [0, 1, 2], "to_bus_id": [1, 2, 3], "type": ["Transformer"] * 3} |
243 | | - ) |
244 | | - bus_voltages = pd.Series([69, 230, 350, 500]) |
245 | | - x = estimate_branch_impedance(transformers.iloc[0], bus_voltages) |
246 | | - assert x == const.transformer_reactance[(69, 230)] |
247 | | - x = estimate_branch_impedance(transformers.iloc[1], bus_voltages) |
248 | | - assert x == const.transformer_reactance[(230, 345)] |
249 | | - x = estimate_branch_impedance(transformers.iloc[2], bus_voltages) |
250 | | - assert x == const.transformer_reactance[(345, 500)] |
251 | | - |
252 | | - |
253 | | -def test_estimate_branch_rating_lines(): |
254 | | - fake_ratings = pd.Series([10, 20, 30, 40]) |
255 | | - fake_thermal_ratings = pd.Series([100, 200, 300, 400]) |
256 | | - fake_lines = [Mock(power_rating=i) for i in fake_ratings] |
257 | | - branch = pd.DataFrame( |
258 | | - { |
259 | | - "VOLTAGE": [69, 140, 345, 499], |
260 | | - "type": ["Line"] * 4, |
261 | | - "line_object": fake_lines, |
262 | | - } |
263 | | - ) |
264 | | - assert_series_equal( |
265 | | - fake_ratings, |
266 | | - branch.apply(estimate_branch_rating, args=[None, fake_thermal_ratings], axis=1), |
267 | | - ) |
268 | | - |
269 | | - |
270 | | -def test_estimate_branch_rating_transformers(): |
271 | | - thermal_ratings = pd.Series([100, 550, 1655, 2585], index=[69, 230, 345, 500]) |
272 | | - transformers = pd.DataFrame( |
273 | | - {"from_bus_id": [0, 1, 2], "to_bus_id": [1, 2, 3], "type": ["Transformer"] * 3} |
274 | | - ) |
275 | | - bus_voltages = pd.Series([69, 230, 350, 500]) |
276 | | - |
277 | | - rating = estimate_branch_rating(transformers.iloc[0], bus_voltages, thermal_ratings) |
278 | | - assert rating == const.transformer_rating |
279 | | - rating = estimate_branch_rating(transformers.iloc[1], bus_voltages, thermal_ratings) |
280 | | - assert rating == const.transformer_rating * 3 |
281 | | - rating = estimate_branch_rating(transformers.iloc[2], bus_voltages, thermal_ratings) |
282 | | - assert rating == const.transformer_rating * 4 |
283 | | - |
284 | | - |
285 | 220 | def test_filter_islands_and_connect_with_mst(): |
286 | 221 | lines = pd.DataFrame( |
287 | 222 | { |
|
0 commit comments