emthub 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- emthub-0.0.1/LICENSE.txt +28 -0
- emthub-0.0.1/PKG-INFO +65 -0
- emthub-0.0.1/README.md +39 -0
- emthub-0.0.1/setup.cfg +50 -0
- emthub-0.0.1/setup.py +3 -0
- emthub-0.0.1/src/emthub/ClearDB.py +26 -0
- emthub-0.0.1/src/emthub/CountClasses.py +96 -0
- emthub-0.0.1/src/emthub/EMTHubConfig.py +63 -0
- emthub-0.0.1/src/emthub/ListBES.py +45 -0
- emthub-0.0.1/src/emthub/ListFeeders.py +54 -0
- emthub-0.0.1/src/emthub/RawToXML.py +418 -0
- emthub-0.0.1/src/emthub/SPARQL_Dict.py +198 -0
- emthub-0.0.1/src/emthub/SummarizeDB.py +52 -0
- emthub-0.0.1/src/emthub/XMLtoCIM.py +1331 -0
- emthub-0.0.1/src/emthub/__init__.py +0 -0
- emthub-0.0.1/src/emthub/atpbes.py +55 -0
- emthub-0.0.1/src/emthub.egg-info/PKG-INFO +65 -0
- emthub-0.0.1/src/emthub.egg-info/SOURCES.txt +21 -0
- emthub-0.0.1/src/emthub.egg-info/dependency_links.txt +1 -0
- emthub-0.0.1/src/emthub.egg-info/not-zip-safe +1 -0
- emthub-0.0.1/src/emthub.egg-info/requires.txt +5 -0
- emthub-0.0.1/src/emthub.egg-info/top_level.txt +1 -0
emthub-0.0.1/LICENSE.txt
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
BSD 3-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Meltran, Inc
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
3. Neither the name of the copyright holder nor the names of its
|
|
16
|
+
contributors may be used to endorse or promote products derived from
|
|
17
|
+
this software without specific prior written permission.
|
|
18
|
+
|
|
19
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
20
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
21
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
22
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
23
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
24
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
25
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
26
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
27
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
28
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
emthub-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: emthub
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: EMTHub: Electromagnetic transient model-building and validation.
|
|
5
|
+
Home-page: https://github.com/temcdrm/EMTHub
|
|
6
|
+
Author: Tom McDermott
|
|
7
|
+
Author-email: tom@meltran.com
|
|
8
|
+
License: BSD
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/temcdrm/EMTHub/issues
|
|
10
|
+
Classifier: License :: OSI Approved :: BSD License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
13
|
+
Classifier: Development Status :: 3 - Alpha
|
|
14
|
+
Classifier: Environment :: Console
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: Intended Audience :: Education
|
|
17
|
+
Classifier: Intended Audience :: Science/Research
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.txt
|
|
21
|
+
Requires-Dist: SPARQLWrapper>=2.0.0
|
|
22
|
+
Requires-Dist: numpy>=1.23.0
|
|
23
|
+
Requires-Dist: pandas>=1.4.3
|
|
24
|
+
Requires-Dist: lxml>=4.9.0
|
|
25
|
+
Requires-Dist: scipy>=1.8.1
|
|
26
|
+
|
|
27
|
+
# EMTHub™
|
|
28
|
+
|
|
29
|
+
Software and data schemas for standards-based model building and
|
|
30
|
+
validation to perform electromagnetic transient (EMT) studies of electric
|
|
31
|
+
utility power systems. The focus is on inverter-based resources (IBR),
|
|
32
|
+
e.g., wind, solar, and storage, in electric utility systems.
|
|
33
|
+
|
|
34
|
+
Use the Green Code button to download.
|
|
35
|
+
|
|
36
|
+
- End users may now follow the two-step installation described in the next section.
|
|
37
|
+
- Developers may now use `git clone https://github.com/temcdrm/emthub.git` from a local directory.
|
|
38
|
+
|
|
39
|
+
## Users
|
|
40
|
+
|
|
41
|
+
The Blazegraph triple-store database is required, but unlike [CIMHub](https://github.com/GRIDAPPSD/CIMHub/tree/feature/SETO), Java, Docker, and OpenDSS are not required.
|
|
42
|
+
|
|
43
|
+
- Install Blazegraph 2.1.6 from [Blazegraph Releases](https://github.com/blazegraph/database/releases).
|
|
44
|
+
- Invoke `pip install emthub --upgrade`.
|
|
45
|
+
|
|
46
|
+
### Alternative Transients Program (ATP)
|
|
47
|
+
|
|
48
|
+
Some optional features of the software require a license to use ATP. See [ATP Web Site](https://atp-emtp.org/) for more information, and to apply for an ATP license.
|
|
49
|
+
|
|
50
|
+
## Developers
|
|
51
|
+
|
|
52
|
+
Install Blazegraph and clone this repository, then use `pip install -e .` to install the Python emthub package from your git clone.
|
|
53
|
+
|
|
54
|
+
To deploy the project on PyPi, staring in the directory of your git clone, where `setup.py` is located:
|
|
55
|
+
|
|
56
|
+
- Make sure that the version number in `setup.cfg` and `src\emthub\version.py` is new.
|
|
57
|
+
- Invoke `rd /s /q dist` on Windows (would be `rm -rf dist` on Linux or Mac OS X)
|
|
58
|
+
- `python -m build`
|
|
59
|
+
- `twine check dist/*` should not show any errors
|
|
60
|
+
- `twine upload -r testpypi dist/*` requires project credentials for pecblocks on test.pypi.org (Note: this will reject if version already exists, also note that testpypi is a separate register to pypi)
|
|
61
|
+
- `pip install -i https://test.pypi.org/simple/ emthub==0.0.1` for local testing of the deployable package, example version 0.0.1 (Note: consider doing this in a separate Python test environment)
|
|
62
|
+
- `twine upload dist/*` for final deployment
|
|
63
|
+
|
|
64
|
+
Copyright 2024, Meltran, Inc
|
|
65
|
+
|
emthub-0.0.1/README.md
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# EMTHub™
|
|
2
|
+
|
|
3
|
+
Software and data schemas for standards-based model building and
|
|
4
|
+
validation to perform electromagnetic transient (EMT) studies of electric
|
|
5
|
+
utility power systems. The focus is on inverter-based resources (IBR),
|
|
6
|
+
e.g., wind, solar, and storage, in electric utility systems.
|
|
7
|
+
|
|
8
|
+
Use the Green Code button to download.
|
|
9
|
+
|
|
10
|
+
- End users may now follow the two-step installation described in the next section.
|
|
11
|
+
- Developers may now use `git clone https://github.com/temcdrm/emthub.git` from a local directory.
|
|
12
|
+
|
|
13
|
+
## Users
|
|
14
|
+
|
|
15
|
+
The Blazegraph triple-store database is required, but unlike [CIMHub](https://github.com/GRIDAPPSD/CIMHub/tree/feature/SETO), Java, Docker, and OpenDSS are not required.
|
|
16
|
+
|
|
17
|
+
- Install Blazegraph 2.1.6 from [Blazegraph Releases](https://github.com/blazegraph/database/releases).
|
|
18
|
+
- Invoke `pip install emthub --upgrade`.
|
|
19
|
+
|
|
20
|
+
### Alternative Transients Program (ATP)
|
|
21
|
+
|
|
22
|
+
Some optional features of the software require a license to use ATP. See [ATP Web Site](https://atp-emtp.org/) for more information, and to apply for an ATP license.
|
|
23
|
+
|
|
24
|
+
## Developers
|
|
25
|
+
|
|
26
|
+
Install Blazegraph and clone this repository, then use `pip install -e .` to install the Python emthub package from your git clone.
|
|
27
|
+
|
|
28
|
+
To deploy the project on PyPi, staring in the directory of your git clone, where `setup.py` is located:
|
|
29
|
+
|
|
30
|
+
- Make sure that the version number in `setup.cfg` and `src\emthub\version.py` is new.
|
|
31
|
+
- Invoke `rd /s /q dist` on Windows (would be `rm -rf dist` on Linux or Mac OS X)
|
|
32
|
+
- `python -m build`
|
|
33
|
+
- `twine check dist/*` should not show any errors
|
|
34
|
+
- `twine upload -r testpypi dist/*` requires project credentials for pecblocks on test.pypi.org (Note: this will reject if version already exists, also note that testpypi is a separate register to pypi)
|
|
35
|
+
- `pip install -i https://test.pypi.org/simple/ emthub==0.0.1` for local testing of the deployable package, example version 0.0.1 (Note: consider doing this in a separate Python test environment)
|
|
36
|
+
- `twine upload dist/*` for final deployment
|
|
37
|
+
|
|
38
|
+
Copyright 2024, Meltran, Inc
|
|
39
|
+
|
emthub-0.0.1/setup.cfg
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[bdist_wheel]
|
|
2
|
+
universal = 1
|
|
3
|
+
|
|
4
|
+
[metadata]
|
|
5
|
+
name = emthub
|
|
6
|
+
version = 0.0.1
|
|
7
|
+
author = Tom McDermott
|
|
8
|
+
author_email = tom@meltran.com
|
|
9
|
+
description = EMTHub: Electromagnetic transient model-building and validation.
|
|
10
|
+
long_description = file: README.md
|
|
11
|
+
long_description_content_type = text/markdown
|
|
12
|
+
license_files = LICENSE.txt
|
|
13
|
+
license = BSD
|
|
14
|
+
url = https://github.com/temcdrm/EMTHub
|
|
15
|
+
project_urls =
|
|
16
|
+
Bug Tracker = https://github.com/temcdrm/EMTHub/issues
|
|
17
|
+
classifiers =
|
|
18
|
+
License :: OSI Approved :: BSD License
|
|
19
|
+
Operating System :: OS Independent
|
|
20
|
+
Programming Language :: Python :: 3.8
|
|
21
|
+
Development Status :: 3 - Alpha
|
|
22
|
+
Environment :: Console
|
|
23
|
+
Intended Audience :: Developers
|
|
24
|
+
Intended Audience :: Education
|
|
25
|
+
Intended Audience :: Science/Research
|
|
26
|
+
Topic :: Scientific/Engineering
|
|
27
|
+
|
|
28
|
+
[options]
|
|
29
|
+
zip_safe = False
|
|
30
|
+
include_package_data = True
|
|
31
|
+
package_dir =
|
|
32
|
+
= src
|
|
33
|
+
install_requires =
|
|
34
|
+
SPARQLWrapper>=2.0.0
|
|
35
|
+
numpy>=1.23.0
|
|
36
|
+
pandas>=1.4.3
|
|
37
|
+
lxml>=4.9.0
|
|
38
|
+
scipy>=1.8.1
|
|
39
|
+
|
|
40
|
+
[options.packages.find]
|
|
41
|
+
where = src_python
|
|
42
|
+
|
|
43
|
+
[options.package_data]
|
|
44
|
+
cimhub =
|
|
45
|
+
*.json
|
|
46
|
+
|
|
47
|
+
[egg_info]
|
|
48
|
+
tag_build =
|
|
49
|
+
tag_date = 0
|
|
50
|
+
|
emthub-0.0.1/setup.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Copyright (C) 2018-2023 Battelle Memorial Institute
|
|
2
|
+
# Copyright (C) 2024 Meltran, Inc
|
|
3
|
+
"""Clear the Blazegraph database.
|
|
4
|
+
"""
|
|
5
|
+
from SPARQLWrapper import SPARQLWrapper2
|
|
6
|
+
import re
|
|
7
|
+
import emthub.EMTHubConfig as EMTHubConfig
|
|
8
|
+
|
|
9
|
+
drop_all = """drop all
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
def clear_db (cfg_file=None):
|
|
13
|
+
""" Clear the database.
|
|
14
|
+
|
|
15
|
+
Blazegraph must already be started. If not already configured, cfg_file must be provided.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
cfg_file (str): configuration file for Blazegraph.
|
|
19
|
+
"""
|
|
20
|
+
if cfg_file is not None:
|
|
21
|
+
EMTHubConfig.ConfigFromJsonFile (cfg_file)
|
|
22
|
+
sparql = SPARQLWrapper2 (EMTHubConfig.blazegraph_url)
|
|
23
|
+
sparql.method = 'POST'
|
|
24
|
+
sparql.setQuery (drop_all)
|
|
25
|
+
ret = sparql.query()
|
|
26
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# Copyright (C) 2018-2023 Battelle Memorial Institute
|
|
2
|
+
# Copyright (C) 2024 Meltran, Inc
|
|
3
|
+
"""List and count the instances of classes found in a Blazegraph database.
|
|
4
|
+
"""
|
|
5
|
+
from SPARQLWrapper import SPARQLWrapper2
|
|
6
|
+
import os
|
|
7
|
+
import emthub.EMTHubConfig as EMTHubConfig
|
|
8
|
+
|
|
9
|
+
def clear_database (sparql):
|
|
10
|
+
sparql.method = 'POST'
|
|
11
|
+
sparql.setQuery(EMTHubConfig.prefix +
|
|
12
|
+
"""
|
|
13
|
+
DROP ALL
|
|
14
|
+
""")
|
|
15
|
+
return sparql.query()
|
|
16
|
+
|
|
17
|
+
def count_classes (sparql):
|
|
18
|
+
sparql.method = 'GET'
|
|
19
|
+
sparql.setQuery(EMTHubConfig.prefix +
|
|
20
|
+
"""
|
|
21
|
+
SELECT ?class (COUNT(?class) as ?cnt)
|
|
22
|
+
WHERE {
|
|
23
|
+
?s a ?rawclass .
|
|
24
|
+
bind(strafter(str(?rawclass),"#") as ?class)
|
|
25
|
+
} group by ?class order by ?class
|
|
26
|
+
""")
|
|
27
|
+
return sparql.query()
|
|
28
|
+
|
|
29
|
+
def count_platform_circuit_classes (cfg_file=None, xml_path = '../model_output_tests/'):
|
|
30
|
+
""" Counts the class instances found in CIMHub's distribution test feeders.
|
|
31
|
+
|
|
32
|
+
Blazegraph must already be started. If not already configured, cfg_file must be provided.
|
|
33
|
+
The test feeder CIM XML files, as exported from OpenDSS, must already exist in xml_path.
|
|
34
|
+
Use this function as a template for summarizing BES test cases.
|
|
35
|
+
Writes to console, and writes summary files to xml_path.
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
cfg_file (str): configuration file for Blazegraph.
|
|
39
|
+
xml_path (str): relative path for reading CIM XML and writing summary files.
|
|
40
|
+
"""
|
|
41
|
+
if cfg_file is not None:
|
|
42
|
+
EMTHubConfig.ConfigFromJsonFile (cfg_file)
|
|
43
|
+
|
|
44
|
+
sparql = SPARQLWrapper2(EMTHubConfig.blazegraph_url)
|
|
45
|
+
|
|
46
|
+
xml_files = {'ACEP_PSIL':{},
|
|
47
|
+
'EPRI_DPV_J1':{},
|
|
48
|
+
'IEEE123':{},
|
|
49
|
+
'IEEE123_PV':{},
|
|
50
|
+
'IEEE13':{},
|
|
51
|
+
'IEEE13_Assets':{},
|
|
52
|
+
'IEEE37':{},
|
|
53
|
+
'IEEE8500':{},
|
|
54
|
+
'IEEE8500_3subs':{},
|
|
55
|
+
'R2_12_47_2':{},
|
|
56
|
+
'Transactive':{}
|
|
57
|
+
}
|
|
58
|
+
all_classes = []
|
|
59
|
+
|
|
60
|
+
for fname in xml_files:
|
|
61
|
+
clear_database (sparql)
|
|
62
|
+
cmd = 'curl -D- -H "Content-Type: application/xml" --upload-file ' + xml_path + fname + '.xml' + ' -X POST ' + EMTHubConfig.blazegraph_url
|
|
63
|
+
os.system (cmd)
|
|
64
|
+
ret = count_classes (sparql)
|
|
65
|
+
for b in ret.bindings:
|
|
66
|
+
cls = b['class'].value
|
|
67
|
+
cnt = b['cnt'].value
|
|
68
|
+
xml_files[fname][cls] = cnt
|
|
69
|
+
if cls not in all_classes:
|
|
70
|
+
all_classes.append (cls)
|
|
71
|
+
|
|
72
|
+
csvfile = xml_path + 'class_counts.csv'
|
|
73
|
+
mdfile = xml_path + 'class_counts.md'
|
|
74
|
+
print ('Writing Class Summaries to {:s} and {:s}'.format (csvfile, mdfile))
|
|
75
|
+
fp1 = open (csvfile, 'w')
|
|
76
|
+
fp2 = open (mdfile, 'w')
|
|
77
|
+
|
|
78
|
+
print ('Class,' + ','.join(xml_files.keys()), file=fp1)
|
|
79
|
+
print ('| Class | ' + ' | '.join(xml_files.keys()) + ' |', file=fp2)
|
|
80
|
+
mdhdr = '| :--- |'
|
|
81
|
+
for fname in xml_files.keys():
|
|
82
|
+
mdhdr = mdhdr + ' :---: |'
|
|
83
|
+
print (mdhdr, file=fp2)
|
|
84
|
+
|
|
85
|
+
for cls in sorted (all_classes):
|
|
86
|
+
counts = []
|
|
87
|
+
for fname in xml_files.keys():
|
|
88
|
+
cnt = '0'
|
|
89
|
+
if cls in xml_files[fname]:
|
|
90
|
+
cnt = xml_files[fname][cls]
|
|
91
|
+
counts.append (cnt)
|
|
92
|
+
print (cls + ',' + ','.join(counts), file=fp1)
|
|
93
|
+
print ('| ' + cls + ' | ' + ' | '.join(counts) + ' |', file=fp2)
|
|
94
|
+
|
|
95
|
+
fp1.close()
|
|
96
|
+
fp2.close()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# Copyright (C) 2018-2023 Battelle Memorial Institute
|
|
2
|
+
# Copyright (C) 2024 Meltran, Inc
|
|
3
|
+
# file: EMTHubConfig.py
|
|
4
|
+
"""Set the CIM namespace and Blazegraph URL.
|
|
5
|
+
"""
|
|
6
|
+
import json
|
|
7
|
+
import urllib.request
|
|
8
|
+
|
|
9
|
+
DB_URL = ''
|
|
10
|
+
EMTHUB_PATH = ''
|
|
11
|
+
EMTHUB_PROG = ''
|
|
12
|
+
|
|
13
|
+
#******************************************************************************
|
|
14
|
+
# URL for the lyrasis Blazegraph container
|
|
15
|
+
blazegraph_url = "http://localhost:8889/bigdata/namespace/kb/sparql"
|
|
16
|
+
|
|
17
|
+
#******************************************************************************
|
|
18
|
+
# Default prefix for blazegraph queries; canonical version is now CIM100
|
|
19
|
+
|
|
20
|
+
cim100 = '<http://iec.ch/TC57/CIM100#'
|
|
21
|
+
# Prefix for all queries.
|
|
22
|
+
prefix = """PREFIX r: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
23
|
+
PREFIX c: {cimURL}>
|
|
24
|
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
25
|
+
""".format(cimURL=cim100)
|
|
26
|
+
|
|
27
|
+
def ConfigFromJsonFile (fname):
|
|
28
|
+
""" Sets the CIM namespace and Blazegraph database URL.
|
|
29
|
+
|
|
30
|
+
Blazegraph must already be started. The configuration file should be JSON
|
|
31
|
+
and include the following:
|
|
32
|
+
|
|
33
|
+
- blazegraph_url (required): for HTTP queries to Blazegraph
|
|
34
|
+
- cim_ns (required): namespace for the version of CIM used
|
|
35
|
+
- use_proxy: *true* if your computer runs a proxy server, e.g., using a VPN
|
|
36
|
+
|
|
37
|
+
Args:
|
|
38
|
+
fname (str): a JSON configuration file for Blazegraph.
|
|
39
|
+
"""
|
|
40
|
+
global blazegraph_url, prefix, cim_ns, DB_URL, EMTHUB_PATH, EMTHUB_PROG
|
|
41
|
+
with open(fname) as fp:
|
|
42
|
+
cfg = json.load(fp)
|
|
43
|
+
if 'blazegraph_url' in cfg:
|
|
44
|
+
blazegraph_url = cfg['blazegraph_url']
|
|
45
|
+
DB_URL = blazegraph_url
|
|
46
|
+
# print ('Configured URL to', blazegraph_url)
|
|
47
|
+
if 'cim_ns' in cfg:
|
|
48
|
+
cim_ns = cfg['cim_ns']
|
|
49
|
+
prefix = """PREFIX r: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
|
50
|
+
PREFIX c: {cimURL}>
|
|
51
|
+
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
|
|
52
|
+
""".format(cimURL=cim_ns)
|
|
53
|
+
# print ('Configured CIM Namespace to', cim_ns)
|
|
54
|
+
if 'use_proxy' in cfg:
|
|
55
|
+
if cfg['use_proxy'] == True:
|
|
56
|
+
proxy_support = urllib.request.ProxyHandler({})
|
|
57
|
+
opener = urllib.request.build_opener(proxy_support)
|
|
58
|
+
urllib.request.install_opener(opener)
|
|
59
|
+
if 'EMTHUB_PATH' in cfg:
|
|
60
|
+
EMTHUB_PATH = cfg['EMTHUB_PATH']
|
|
61
|
+
if 'EMTHUB_PROG' in cfg:
|
|
62
|
+
EMTHUB_PROG = cfg['EMTHUB_PROG']
|
|
63
|
+
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Copyright (C) 2018-2023 Battelle Memorial Institute
|
|
2
|
+
# Copyright (C) 2024 Meltran, Inc
|
|
3
|
+
"""List the bulk electric systems found in a Blazegraph database.
|
|
4
|
+
"""
|
|
5
|
+
from SPARQLWrapper import SPARQLWrapper2
|
|
6
|
+
import emthub.EMTHubConfig as EMTHubConfig
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
def list_bes (cfg_file=None):
|
|
10
|
+
""" List the names and mRID values of bulk electric systems (BES) found in the Blazegraph database.
|
|
11
|
+
|
|
12
|
+
Blazegraph must already be started. If not already configured, cfg_file must be provided.
|
|
13
|
+
Writes a list of BES names and mRIDs to the console.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
cfg_file (str): configuration file for Blazegraph.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
if cfg_file is not None:
|
|
20
|
+
EMTHubConfig.ConfigFromJsonFile (cfg_file)
|
|
21
|
+
|
|
22
|
+
sparql = SPARQLWrapper2(EMTHubConfig.blazegraph_url)
|
|
23
|
+
|
|
24
|
+
sparql.setQuery(EMTHubConfig.prefix +
|
|
25
|
+
"""
|
|
26
|
+
SELECT ?name ?id WHERE {
|
|
27
|
+
?s r:type c:ConnectivityNodeContainer.
|
|
28
|
+
?s c:IdentifiedObject.name ?name.
|
|
29
|
+
?s c:IdentifiedObject.mRID ?id.
|
|
30
|
+
}
|
|
31
|
+
ORDER by ?name
|
|
32
|
+
""")
|
|
33
|
+
|
|
34
|
+
ret = sparql.query()
|
|
35
|
+
#print ('binding keys are:',ret.variables)
|
|
36
|
+
print ('Bulk Electric System names and mRIDs:')
|
|
37
|
+
for b in ret.bindings:
|
|
38
|
+
print (b['name'].value,b['id'].value)
|
|
39
|
+
|
|
40
|
+
if __name__ == '__main__':
|
|
41
|
+
cfg_file = None
|
|
42
|
+
if len(sys.argv) > 1:
|
|
43
|
+
cfg_file = sys.argv[1]
|
|
44
|
+
list_bes (cfg_file)
|
|
45
|
+
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Copyright (C) 2018-2023 Battelle Memorial Institute
|
|
2
|
+
# Copyright (C) 2024 Meltran, Inc
|
|
3
|
+
"""List the distribution feeders found in a Blazegraph database.
|
|
4
|
+
"""
|
|
5
|
+
from SPARQLWrapper import SPARQLWrapper2
|
|
6
|
+
import emthub.EMTHubConfig as EMTHubConfig
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
def list_feeders (cfg_file=None):
|
|
10
|
+
""" List the names and mRID values of distribution feeders found in the Blazegraph database.
|
|
11
|
+
|
|
12
|
+
Blazegraph must already be started. If not already configured, cfg_file must be provided.
|
|
13
|
+
Writes a list of feeder names and mRIDs to the console.
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
cfg_file (str): configuration file for Blazegraph.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
if cfg_file is not None:
|
|
20
|
+
EMTHubConfig.ConfigFromJsonFile (cfg_file)
|
|
21
|
+
|
|
22
|
+
sparql = SPARQLWrapper2(EMTHubConfig.blazegraph_url)
|
|
23
|
+
|
|
24
|
+
sparql.setQuery(EMTHubConfig.prefix +
|
|
25
|
+
"""
|
|
26
|
+
SELECT ?feeder ?fid ?station ?sid ?subregion ?sgrid ?region ?rgnid WHERE {
|
|
27
|
+
?s r:type c:Feeder.
|
|
28
|
+
?s c:IdentifiedObject.name ?feeder.
|
|
29
|
+
?s c:IdentifiedObject.mRID ?fid.
|
|
30
|
+
?s c:Feeder.NormalEnergizingSubstation ?sub.
|
|
31
|
+
?sub c:IdentifiedObject.name ?station.
|
|
32
|
+
?sub c:IdentifiedObject.mRID ?sid.
|
|
33
|
+
?sub c:Substation.Region ?sgr.
|
|
34
|
+
?sgr c:IdentifiedObject.name ?subregion.
|
|
35
|
+
?sgr c:IdentifiedObject.mRID ?sgrid.
|
|
36
|
+
?sgr c:SubGeographicalRegion.Region ?rgn.
|
|
37
|
+
?rgn c:IdentifiedObject.name ?region.
|
|
38
|
+
?rgn c:IdentifiedObject.mRID ?rgnid.
|
|
39
|
+
}
|
|
40
|
+
ORDER by ?station ?feeder
|
|
41
|
+
""")
|
|
42
|
+
|
|
43
|
+
ret = sparql.query()
|
|
44
|
+
#print ('binding keys are:',ret.variables)
|
|
45
|
+
print ('Feeder names and mRIDs:')
|
|
46
|
+
for b in ret.bindings:
|
|
47
|
+
print (b['feeder'].value,b['fid'].value)
|
|
48
|
+
|
|
49
|
+
if __name__ == '__main__':
|
|
50
|
+
cfg_file = None
|
|
51
|
+
if len(sys.argv) > 1:
|
|
52
|
+
cfg_file = sys.argv[1]
|
|
53
|
+
list_feeders (cfg_file)
|
|
54
|
+
|