-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add transmission to substation track selection #217
Conversation
26a3c66
to
cfe96df
Compare
Yes, I believe they are all independent. We don't have to merge this PR now, we can go over it once we have the whole chain and we want to compare both tracks. |
cfe96df
to
17c1d05
Compare
17c1d05
to
8e7a8c5
Compare
8e7a8c5
to
0621ea9
Compare
Running the latest code, I'm getting an error: >>> from prereise.gather.griddata.hifld.data_process.transmission import build_transmission
>>> lines, substations = build_transmission(method="line2sub", kwargs={"rounding": 2})
dropping 6892 substations of 70857 total due to LINES parameter equal to 0
filter substations based on lines
---------------------------------
initial number of substations: 63965
substations with same location after rounding: 13769
initial number of lines: 71554
zero distance lines after rounding: 11589
there are 1117 lines with two substations missing
there are 1848 lines with one substation missing
there are 2042 unique orphan endpoint
there are 7622 substations unconnected
finding closest neighbor to unconnected lines
100%|██████████████████████████████████████| 2965/2965 [02:07<00:00, 23.31it/s]
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\DanielOlsen\repos\bes\PreREISE\prereise\gather\griddata\hifld\data_process\transmission.py", line 511, in build_transmission
lines, substations = assign_substations_to_lines(
File "C:\Users\DanielOlsen\repos\bes\PreREISE\prereise\gather\griddata\hifld\data_process\transmission.py", line 167, in assign_substations_to_lines
line2sub.loc[i, f"OTHER_{endpoint}_SUB"] = list(
File "C:\Python39\lib\site-packages\pandas\core\indexing.py", line 723, in __setitem__
iloc._setitem_with_indexer(indexer, value, self.name)
File "C:\Python39\lib\site-packages\pandas\core\indexing.py", line 1730, in _setitem_with_indexer
self._setitem_with_indexer_split_path(indexer, value, name)
File "C:\Python39\lib\site-packages\pandas\core\indexing.py", line 1785, in _setitem_with_indexer_split_path
raise ValueError(
ValueError: Must have equal len keys and value when setting with an iterable Maybe this is because of something upstream? |
It works for me:
|
Using your exact same call (passing kwargs={"rounding": 2}), it still works for me:
|
@rouille, there must be something funny about my environment, when I spin up a docker container and |
Oh this is strange: Using Python 3.9.6 on Windows and Pandas 1.2.5, 1.3.1, or 1.3.2 (latest), I get the error shown. If I downgrade to Pandas 1.1.5 (as specified in the Pipfile), it works properly. This seems potentially related to Pandas Issue#32372. If I change l.167 from |
0621ea9
to
d3539b6
Compare
Done |
d3539b6
to
68e9f79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've gone through the code and the logic makes sense. Running the two methods with default parameters yields 71,554 lines for the new method, compared to 67,389 lines for the old method. If we trust the line coordinates more than the substation names, this method seems to avoid tossing lines unnecessarily, while only making fairly reasonable assumptions.
A test or two would be nice, but since this new functionality is not being activated by default yet, I don't think that should hold up enabling us to play around with the new method.
4e710cd
to
3d4da0e
Compare
3d4da0e
to
94a4dca
Compare
94a4dca
to
ddb6e7a
Compare
91e5c11
to
0528d6f
Compare
0528d6f
to
dc287d4
Compare
Pull Request doc
Purpose
Select HIFLD substations based on HIFLD lines
What the code is doing
map_lines_to_substations_using_coords
: create a data frame mapping lines to substations base on coordinatesassign_substations_to_lines
: updatelines
andsubstations
data frames. In particular:lines
data frame (name of selectedsubstations
are used)build_transmission
: the function has been updated to use the above method to get the lines/substations tupleTesting
How did you test this change (unit/functional testing, manual testing, etc.)?
Where to look
All the code is in the
transmission
moduleUsage Example/Visuals
Time estimate
30min