Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mzy2240 committed May 21, 2022
2 parents 032d5e8 + eb3ed53 commit 54fa349
Show file tree
Hide file tree
Showing 31 changed files with 121 additions and 51 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ The ESA team works hard to ensure ESA is well tested, and we strive for
testing coverage data for ESA, using `coverage
<https://pypi.org/project/coverage/>`__.

.. table:: ESA's testing coverage as of 2022-02-20 (Git commit: 2b5a8ff)
.. table:: ESA's testing coverage as of 2022-05-20 (Git commit: bbb3f12)
:widths: auto
:align: left

Expand All @@ -86,7 +86,7 @@ testing coverage data for ESA, using `coverage
+=================+===================+=================+=================+====================+
| esa/__init__.py | 2 | 0 | 2 | 100 |
+-----------------+-------------------+-----------------+-----------------+--------------------+
| esa/saw.py | 824 | 0 | 824 | 100 |
| esa/saw.py | 848 | 0 | 848 | 100 |
+-----------------+-------------------+-----------------+-----------------+--------------------+

License
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.6
1.2.7
4 changes: 2 additions & 2 deletions docs/doctrees/environment.pickle
Git LFS file not shown
4 changes: 2 additions & 2 deletions docs/doctrees/esa.doctree
Git LFS file not shown
2 changes: 1 addition & 1 deletion docs/doctrees/overview.doctree
Git LFS file not shown
4 changes: 2 additions & 2 deletions docs/doctrees/welcome.doctree
Git LFS file not shown
2 changes: 1 addition & 1 deletion docs/html/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 437d8a7d4ff36783090e9c4c30038663
config: 5bbb22a6f84fd03f028d7b14f41d5375
tags: 645f666f9bcd5a90fca523b33c5a78b7
2 changes: 1 addition & 1 deletion docs/html/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '1.2.6',
VERSION: '1.2.7',
LANGUAGE: 'None',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
2 changes: 1 addition & 1 deletion docs/html/common_issues.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>Common Issues &#8212; ESA 1.2.6 documentation</title>
<title>Common Issues &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down
17 changes: 11 additions & 6 deletions docs/html/esa.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>esa API Documentation &#8212; ESA 1.2.6 documentation</title>
<title>esa API Documentation &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down Expand Up @@ -1288,12 +1288,17 @@

<dl class="py method">
<dt class="sig sig-object py" id="esa.saw.SAW.get_lodf_matrix">
<span class="sig-name descname"><span class="pre">get_lodf_matrix</span></span><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#esa.saw.SAW.get_lodf_matrix" title="Permalink to this definition"></a></dt>
<dd><p>Obtain LODF matrix in numpy array format.
By default, it obtains the lodf matrix directly from PW.</p>
<span class="sig-name descname"><span class="pre">get_lodf_matrix</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">precision</span></span><span class="p"><span class="pre">:</span></span> <span class="n"><span class="pre">int</span></span> <span class="o"><span class="pre">=</span></span> <span class="default_value"><span class="pre">3</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#esa.saw.SAW.get_lodf_matrix" title="Permalink to this definition"></a></dt>
<dd><p>Obtain LODF matrix in numpy array or scipy sparse matrix.
By default, it obtains the lodf matrix directly from PW. If size
is larger than 1000, then precision will be applied to filter out
small values and the result will be returned in scipy sparse matrix.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><p>LODF matrix</p>
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>precision</strong> – number of decimal to keep.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p>LODF matrix</p>
</dd>
</dl>
</dd></dl>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/genindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Index &#8212; ESA 1.2.6 documentation</title>
<title>Index &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>Easy SimAuto (ESA) Documentation &#8212; ESA 1.2.6 documentation</title>
<title>Easy SimAuto (ESA) Documentation &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/installation.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>Installing ESA &#8212; ESA 1.2.6 documentation</title>
<title>Installing ESA &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down
Binary file modified docs/html/objects.inv
Binary file not shown.
8 changes: 4 additions & 4 deletions docs/html/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>ESA Overview &#8212; ESA 1.2.6 documentation</title>
<title>ESA Overview &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down Expand Up @@ -133,7 +133,7 @@ <h2>Testing Coverage<a class="headerlink" href="#testing-coverage" title="Permal
<p>The ESA team strives to write good tests with 100% coverage. The table
below provides the latest test coverage data for ESA.</p>
<table class="colwidths-auto docutils align-left" id="id3">
<caption><span class="caption-text">ESA’s testing coverage as of 2022-02-20 (Git commit: 2b5a8ff)</span><a class="headerlink" href="#id3" title="Permalink to this table"></a></caption>
<caption><span class="caption-text">ESA’s testing coverage as of 2022-05-20 (Git commit: bbb3f12)</span><a class="headerlink" href="#id3" title="Permalink to this table"></a></caption>
<thead>
<tr class="row-odd"><th class="head"><p>Name</p></th>
<th class="head"><p>Num. Statements</p></th>
Expand All @@ -150,9 +150,9 @@ <h2>Testing Coverage<a class="headerlink" href="#testing-coverage" title="Permal
<td><p>100</p></td>
</tr>
<tr class="row-odd"><td><p>esa/saw.py</p></td>
<td><p>824</p></td>
<td><p>848</p></td>
<td><p>0</p></td>
<td><p>824</p></td>
<td><p>848</p></td>
<td><p>100</p></td>
</tr>
</tbody>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/py-modindex.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Python Module Index &#8212; ESA 1.2.6 documentation</title>
<title>Python Module Index &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/quick_start.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>Quick Start &#8212; ESA 1.2.6 documentation</title>
<title>Quick Start &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/search.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Search &#8212; ESA 1.2.6 documentation</title>
<title>Search &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />

Expand Down
2 changes: 1 addition & 1 deletion docs/html/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/html/snippets.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>Examples &#8212; ESA 1.2.6 documentation</title>
<title>Examples &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down
10 changes: 9 additions & 1 deletion docs/html/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />

<title>Welcome! &#8212; ESA 1.2.6 documentation</title>
<title>Welcome! &#8212; ESA 1.2.7 documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css" />
<link rel="stylesheet" type="text/css" href="_static/alabaster.css" />
<script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
Expand Down Expand Up @@ -357,6 +357,14 @@ <h3>Credits and Thanks<a class="headerlink" href="#credits-and-thanks" title="Pe
<p>Changes made with each ESA release are listed here. Please note that
versions prior to 1.0.0 are not listed here, but are still available on
<a class="reference external" href="https://pypi.org/project/esa/#history">PyPi</a>.</p>
<section id="version-1-2-7">
<h3>Version 1.2.7<a class="headerlink" href="#version-1-2-7" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>Officially support PW23</p></li>
<li><p>Support obtaining LODF matrix from large case (&gt;1000)</p></li>
<li><p>Fix the self-loop issue when generating inter-substation level graph model</p></li>
</ul>
</section>
<section id="version-1-2-6">
<h3>Version 1.2.6<a class="headerlink" href="#version-1-2-6" title="Permalink to this headline"></a></h3>
<ul class="simple">
Expand Down
4 changes: 2 additions & 2 deletions docs/rst/coverage.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. table:: ESA's testing coverage as of 2022-02-20 (Git commit: 2b5a8ff)
.. table:: ESA's testing coverage as of 2022-05-20 (Git commit: bbb3f12)
:widths: auto
:align: left

Expand All @@ -7,5 +7,5 @@
+=================+===================+=================+=================+====================+
| esa/__init__.py | 2 | 0 | 2 | 100 |
+-----------------+-------------------+-----------------+-----------------+--------------------+
| esa/saw.py | 824 | 0 | 824 | 100 |
| esa/saw.py | 848 | 0 | 848 | 100 |
+-----------------+-------------------+-----------------+-----------------+--------------------+
8 changes: 8 additions & 0 deletions docs/rst/welcome/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ Changes made with each ESA release are listed here. Please note that
versions prior to 1.0.0 are not listed here, but are still available on
`PyPi <https://pypi.org/project/esa/#history>`__.

Version 1.2.7
^^^^^^^^^^^^^

* Officially support PW23
* Support obtaining LODF matrix from large case (>1000)
* Fix the self-loop issue when generating inter-substation level graph model


Version 1.2.6
^^^^^^^^^^^^^

Expand Down
2 changes: 1 addition & 1 deletion esa/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
# Please keep the docstring above up to date with all the imports.
from .saw import SAW, PowerWorldError, COMError, CommandNotRespectedError,\
Error
__version__ = "1.2.6"
__version__ = "1.2.7"
52 changes: 41 additions & 11 deletions esa/saw.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@
import re
import datetime
import json
from toolz.itertoolz import partition_all

import numpy as np
from numpy.linalg import multi_dot, det, solve, inv
import numba as nb
import pandas as pd
from scipy.sparse import csr_matrix
from scipy.sparse import csr_matrix, coo_matrix, hstack
import networkx as nx
from tqdm import trange
import pythoncom
Expand Down Expand Up @@ -859,6 +860,8 @@ def to_graph(self, node: str = 'bus', geographic: bool = False,
create_using=graph_type,
edge_key="LineCircuit",
edge_attr=edge_attr)
if node == "substation":
graph.remove_edges_from(nx.selfloop_edges(graph))
if node_attr:
if isinstance(node_attr, (list, tuple)):
nf.extend(node_attr)
Expand All @@ -873,23 +876,50 @@ def to_graph(self, node: str = 'bus', geographic: bool = False,
raise e
return graph

def get_lodf_matrix(self):
"""Obtain LODF matrix in numpy array format.
By default, it obtains the lodf matrix directly from PW.
def get_lodf_matrix(self, precision: int = 3):
"""Obtain LODF matrix in numpy array or scipy sparse matrix.
By default, it obtains the lodf matrix directly from PW. If size
is larger than 1000, then precision will be applied to filter out
small values and the result will be returned in scipy sparse matrix.
:param precision: number of decimal to keep.
:returns: LODF matrix
"""
self.pw_order = True
count = self.ListOfDevices('branch').shape[0]
statement = "CalculateLODFMatrix(OUTAGES,ALL,ALL,YES,DC,ALL,YES)"
self.RunScriptCommand(statement)
count = self.ListOfDevices('branch').shape[0]
array = [f"LODFMult:{x}" for x in range(count)]
df = self.GetParametersMultipleElement('branch', array)
temp = df.to_numpy(dtype=float)/100
self.isl = np.any(temp >= 10, axis=1)
temp[self.isl, :] = 0
temp[self.isl, self.isl] = -1
self.lodf = temp
if count <= 1000:
df = self.GetParametersMultipleElement('branch', array)
temp = df.to_numpy(dtype=float)/100
self.isl = np.any(temp >= 10, axis=1)
temp[self.isl, :] = 0
temp[self.isl, self.isl] = -1
self.lodf = temp
else:
container = []
isl = None
for batch in partition_all(20, array):
df = self.GetParametersMultipleElement('branch', batch)
temp = df.to_numpy(dtype=float) / 100
temp = temp.round(precision)
if isl is None:
isl = np.any(temp >= 10, axis=1)
else:
isl = np.logical_or(isl, np.any(temp >= 10, axis=1))
temp[isl, :] = 0
temp = coo_matrix(temp)
temp.eliminate_zeros()
container.append(temp)
temp = hstack(container).tolil()
temp[isl, :] = 0
temp[isl, isl] = -1
temp = temp.tocsr()
temp.eliminate_zeros()
self.lodf = temp
self.isl = isl
return self.lodf, self.isl

def get_incidence_matrix(self):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
'Automation', 'Power Systems', 'Electric Power', 'Power',
'Easy SimAuto', 'ESA', 'Smart Grid', 'Numpy', 'Pandas'],
install_requires=['pandas >= 0.25', 'numpy >= 1.19.5, <1.22', 'scipy', 'pywin32',
'pypiwin32', 'networkx', 'tqdm', 'numba'],
'pypiwin32', 'toolz', 'networkx', 'tqdm', 'numba'],
python_requires='>=3.7',
# There are a couple tests that use networkx, and we use the magic
# of sphinx for documentation. Coverage is necessary to keep the
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/ieee_14/IEEE 14 bus_pws_version_23.PWB
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/cases/tx2000/tx2000_base_pws_version_23.PWB
Git LFS file not shown
4 changes: 2 additions & 2 deletions tests/cases/wscc_9/WSCC 9 bus.pwd
Git LFS file not shown
3 changes: 3 additions & 0 deletions tests/cases/wscc_9/WSCC 9 bus_pws_version_23.PWB
Git LFS file not shown
Loading

0 comments on commit 54fa349

Please sign in to comment.