-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathtest_opendss_to_ephasor.py
48 lines (41 loc) · 1.43 KB
/
test_opendss_to_ephasor.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
"""
test_opendss_to_ephasor
----------------------------------
Tests for OpenDSS --> Ephasor conversion
"""
import six
if six.PY2:
from backports import tempfile
else:
import tempfile
import os
import pytest as pt
current_directory = os.path.realpath(os.path.dirname(__file__))
@pt.mark.skip("Segfault occurs")
def test_opendss_to_ephasor():
'''
Test the OpenDSS to Ephasor conversion.
'''
from ditto.readers.opendss.read import Reader
from ditto.store import Store
from ditto.writers.ephasor.write import Writer
opendss_models=[f for f in os.listdir(os.path.join(current_directory, 'data/small_cases/opendss/')) if not f.startswith('.')]
for model in opendss_models:
m = Store()
r = Reader(
master_file=os.path.join(current_directory, 'data/small_cases/opendss/{model}/master.dss'.format(model=model)),
buscoordinates_file=os.path.join(current_directory, 'data/small_cases/opendss/{model}/buscoord.dss'.format(model=model))
)
r.parse(m)
m.set_names()
m.build_networkx()
m.direct_from_source()
m.set_node_voltages()
#TODO: Log properly
print('>OpenDSS model {model} red...'.format(model=model))
output_path = tempfile.TemporaryDirectory()
w = Writer(output_path=output_path)
w.write(m)
#TODO: Log properly
print('>...and written to Ephasor.\n')