Data Module¶
The Data.TEracsData
class is the main way of loading up data from
an ERACS file for use in a study. The main method to use is
Data.TEracsData.Load()
which takes a string to the full file path and
name of the file to load. Once loaded, the data may be viewed and modified
using the appropriate properties exposed by the Data.TEracsData
class such as Collection.TEracsDataCollection.Busbars
which is
an inherited property from the parent class.
API¶
Import Data for access to all data-loading classes exposed by the ERACS Python Interface. An instance of the TEracsData class can be used to load and save data using multiple file formats (XML, CSV, etc.).
-
class
TEracsData
¶ This class should be used to load up an ERACS network ready to be passed to a calculation module
- Inherits
-
property
FaultCapability
¶ Fault Capability, determined by synchronous machines, transformer windings, transmission lines and cables in the network.
- Type
int.
- Writable
False.
-
property
EracsVersion
¶ Returns a string version of ERACS used to export the loaded data.
- Example
EracsVersion => “3.11.0”
- Returns
A string of the ERACS version.
-
GetDataFromTypecode
(ATypecode)¶ Return the appropriate data list using the typecode given.
- Parameters
ATypecode (int) – The typecode for desired element data.
- Returns
A TEracsDataList for the specific type specified.
- Raises
TEracsArgumentError – If the typecode is unknown.
-
GetDataItem
(ATypecode, ASeqnum)¶ Looks for the specified item from the appropriate data list using the typecode and sequence number provided, returns it as a Dictionary. A full list of available typecodes can be viewed here.
- Parameters
ATypecode (int) – Must be an integer, typecode of element
ASeqnum (int) – Must be an integer, sequence number of specific element
- Returns
Dictionary for desired data item
- Raises
TEracsArgumentError – If no item exists with given typecode and sequence number.
-
CloseSwitch
(ASwitchID)¶ Close the specified switch.
- Parameters
ASwitchID (int) – Index of the switch to close.
-
OpenSwitch
(ASwitchID)¶ Open the specified switch.
- Parameters
ASwitchID (int) – Index of the switch to open.
-
SetSwitchState
(ASwitchId, AState)¶ When a switch needs updating/changing use this method. Each element dictionary has an internal connection indicator key, and therefore changing the state of the switch directly in the Switches list will have no effect.
- Parameters
ASwitchId (int) – ID of the switch to change the state of.
AState (int) – The state to change the switch to. (0 = open, 1 = closed)
- Doctest
>>> data = TEracsData() >>> data.Switches.append( ... {'id': 'sw1', 'swstate': 1, 'pid': 'cab1', 'ptypecode': 3, 'busbar1': 'bus1'} ... ) >>> data.Switches[0]['swstate'] 1
>>> data.OpenSwitch('sw1') >>> data.Switches[0]['swstate'] 0
>>> data.CloseSwitch('sw1') >>> data.Switches[0]['swstate'] 1
-
Load
(AFilePathAndName, ATrySameName=True)¶ Load the data from a supported format (XML or CSV).
- Parameters
AFilePathAndName (str) – The full path and name of file to load.
- Returns
True if the file was successfully loaded.
- Raises
TEracsArgumentError – If the file has an unknown extension.
-
Save
(AFilePathAndName)¶ Save the data into a supported format (XML, CSV, JSON, SVG, HTML)
- Parameters
AFilePathAndName (str) – The full path and name of file to save.
- Returns
True if the file was successfully saved.
- Raises
TEracsArgumentError – If the file has an unknown extension.
-
OpenInBrowserAsSvg
()¶ Open the data in a web browser as SVG.
-
OpenInBrowserAsHtml
()¶ Open the data in a web browser as HTML.
-
class
TEracsDataConverter
¶ This class simplifies access to certain DLLs for data conversion.
-
XmlToJson
(AFile, ASource)¶ Converts XML data to JSON
- Parameters
AFile (str) – The full path and name of Destination file.
ASource (str) – The full path and name of Source XML file.
- Raises
TEracsArgumentError – If either arguments are of the incorrect type or source points to a non-existent file.
TEracsDllError – If the DLL is not found or loaded properly.
-
NameplateXmlToClassicXml
(ATx, AKeyname)¶ Converts a transformer which uses the classic transformer format into a nameplate format (newer).
- Parameters
ATx (element) – Transformer XML element in the classic format.
- Returns
An XML element for the new nameplate transformer.
- Raises
TEracsDllError – If the DLL is not found or loaded properly, or if it fails to return back a converted transformer.
-