Skip to content

Commit

Permalink
Apply pre-commmit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wperkins authored and actions-user committed Dec 28, 2023
1 parent 29b1498 commit a68de7c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 1 addition & 0 deletions scripts/contingency_native_psse.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Outage(enum.Enum):
# Contingency
# -------------------------------------------------------------


@dataclass
class Contingency:
num: int
Expand Down
18 changes: 10 additions & 8 deletions scripts/contingency_psse_native.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
# -------------------------------------------------------------
# file: contingency_psse_pti.py
#
# A hack script to convert PSS/E contingencies to ExaGO NATIVE
# A hack script to convert PSS/E contingencies to ExaGO NATIVE
# -------------------------------------------------------------
# -------------------------------------------------------------

import sys, os
import sys
import os
from optparse import OptionParser
from pyparsing import *
import enum
Expand All @@ -16,12 +17,14 @@
# -------------------------------------------------------------
program = os.path.basename(sys.argv[0])


class Outage(enum.Enum):
GEN = 1
BR = 2
TR = 3
LOAD = 4


Name = Word(printables)

intid = Word(nums)
Expand All @@ -37,24 +40,24 @@ class Outage(enum.Enum):
Unit = Keyword("UNIT", caseless=True)

LineOutage = (
Open.suppress() + Branch.suppress() +
Open.suppress() + Branch.suppress() +
From.suppress() + Bus.suppress() + intid.setName("from_bus") +
To.suppress() + Bus.suppress() + intid.setName("to_bus") +
Circuit.suppress() + intid.setName("circuit")
).setParseAction(lambda t: (Outage.BR, t[0:]) )
).setParseAction(lambda t: (Outage.BR, t[0:]))

GenOutage = (
Remove.suppress() + Unit.suppress() +
intid.setName("gen") +
From.suppress() + Bus.suppress() + intid.setName("bus")
).setParseAction(lambda t: (Outage.GEN, t[0:]) )
).setParseAction(lambda t: (Outage.GEN, t[0:]))

Contingency = (
Keyword("CONTINGENCY", caseless=True).suppress() +
Name +
OneOrMore( LineOutage | GenOutage ) +
OneOrMore(LineOutage | GenOutage) +
Keyword("END", caseless=True).suppress()
).setParseAction(lambda t: { t[0] : t[1:] })
).setParseAction(lambda t: {t[0]: t[1:]})

ContingencyList = OneOrMore(Contingency)

Expand Down Expand Up @@ -109,4 +112,3 @@ class Outage(enum.Enum):
output.write("%d,%d,0,0," %
(int(typ.value), int(dat[1])))
output.write("'1 ',1,0,0.01\n")

0 comments on commit a68de7c

Please sign in to comment.