-
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: separate interconnections via network topology #240
Conversation
1a865f3
to
65a3947
Compare
non_dropped_lines = lines.loc[labels != "dropped"] | ||
for id, line in dropped_lines.iterrows(): | ||
non_dropped_sub = ( # noqa: F841 | ||
line.SUB_1_ID if line.SUB_2_ID in seams_substations else line.SUB_2_ID |
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.
So it is guaranteed there are no lines with both ends in seams substations, right?
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.
It is not guaranteed, in fact it does happen in our data set! The path of connection from the Eastern interconnect to the Oklaunion B2B station appears to go from a full-Eastern substation through another intermediate mixed-interconnect substation first before getting to the B2B substation, so both the B2B substation and the 'intermediate' are considered to be 'part of the seam', since both have buses in both interconnects, and the line that connects the two has both ends 'on the seam'. With the input data we have right now, the interconnects still do end up getting separated properly, but there's definitely potential for this sort of edge case to bite us with different input data. This would also preclude your other refactor idea of always looking to the substation at the 'other end' to determine which interconnect a line should connect to within a dropped substation.
new_substations["NAME"] = [ | ||
substations.loc[sub_id, "NAME"] + f"_{i}" for i in new_sub_interconnects | ||
] |
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.
Keeping track of this using NAME
field is nice, not sure whether it is more straight forward to inferring this using id
directly, i.e. xxxx_1
and xxxx_2
where xxxx
is the old sub id and the numbers are interconnect rankings. It is not necessarily to have consecutive numbers sub_ids right? We might need them to be integers though.
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.
We might need them to be integers though
: I think you might be right, I'm not sure how much downstream code is implicitly expecting integers vs. just some sort of unique index.
for line_id, line in sub_dropped_lines.iterrows(): | ||
for new_sub_id, sub in new_substations.iterrows(): | ||
if line["interconnect"] == sub["NAME"].split("_")[1]: | ||
if line["SUB_1_ID"] == sub_id: | ||
lines.loc[line_id, "SUB_1_ID"] = new_sub_id | ||
if line["SUB_2_ID"] == sub_id: | ||
lines.loc[line_id, "SUB_2_ID"] = new_sub_id |
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.
Not sure whether this could be simplified if we give an interconnect tag to substations first.
Thanks for making all the wild ideas happen. Although I'm aware of the full story line via offline discussions, I still found the logic brain burning when reading through the code. Here is my two cents popping up upon review, not sure whether that would be clearer:
In this way, we don't need to label lines with interconnects but substations only. In the end, we could have a sanity check to see whether all lines with both ends locating into the same interconnection. It is very likely I missed something. If that breaks anywhere of the critical logic flow, just forget it and never mind:) |
@BainanXia I like your plan of splitting |
It's just an alternative way to achieve the same thing. I was thinking all we need is to tag every node with interconnections rather than edges via assumptions + neighbors. Specifically, if one node has neighbors with multiple interconnection tags (dropped nodes), we make copies and tag each copy with one interconnect among the set. |
B2B facility information has been added, as well as a function to add these B2B lines to the DC line table by looking at the now-separated substations. Therefore, this should now fulfill all remaining requirements of #233. |
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 can reproduce your test and see that the B2B where added to the dclines.
5896d9c
to
37d1681
Compare
37d1681
to
14f8980
Compare
…nnects feat: separate interconnections via network topology
…nnects feat: separate interconnections via network topology
…nnects feat: separate interconnections via network topology
…nnects feat: separate interconnections via network topology
…nnects feat: separate interconnections via network topology
…nnects feat: separate interconnections via network topology
…nnects feat: separate interconnections via network topology
…nnects feat: separate interconnections via network topology
Pull Request doc
Purpose
IN SERVICE
orNOT AVAILABLE
. AlthoughNOT AVAILABLE
substations are only about 5% of the total, they're about 20% of the substations within Texas and New Mexico, which causes lines to get mapped to faraway substations which are sometimes in other interconnections.interconnect
attribute of lines and substations, given input on where to split the substations and how to re-join them.Closes #233.
What the code is doing
add_interconnects_by_connected_components
that:interconnect
labels for lines, identify which interconnects are present within substations that get split, and create new pseudo-substations for each interconnect within a substation, and re-connect lines as necessary. New pseudo-substations get added, and substations which got split are removed.Testing
Tested manually:
Validation:
Usage Example/Visuals
Here are the transmission lines for the states required to define the interconnections, colored by interconnect, with tiny yellow stars at the location of the dropped substations:

Time estimate
30-60 minutes for the current code/logic. I'm also going to add some tests and try to factor out some of the for loops that were added for convenience but could probably be equivalently done in a cleaner way, although the elapsed time for these steps is quite short so it doesn't need too much optimization.