GRIDAPPSD / CIMHub

16 stars 10 forks source link

Convert a CIM File to OpenDSS and Excel #31

Closed StormsHalted closed 2 years ago

StormsHalted commented 2 years ago

Morning Everyone,

My objective is to convert a CIM file into OpenDSS and Excel. My ultimate goal being to navigate into the data sets holded by the CIM and work on them.

So I complete the CIMhub installation process and also I am able to run execute the python base123.py file correctly. I get the correct output script in command line.

Now, in my insignificant and frail efforts, I attempt to piece together the script to actually perform this task, by following the line by line code exegesis (line 69 - 72) given in the tutorial readme.

My script goes like:

`import cimhub.api as cimhub import cimhub.CIMHubConfig as CIMHubConfig import subprocess import stat import shutil import os import sys

if sys.platform == 'win32': shfile_export = 'go.bat' shfile_glm = './glm/checkglm.bat' shfile_run = 'checkglm.bat' cfg_json = 'cimhubjar.json' else: shfile_export = './go.sh' shfile_glm = './glm/checkglm.sh' shfile_run = './checkglm.sh' cfg_json = 'cimhubdocker.json'

cwd = os.getcwd()

cases = [ {'dssname':'ieee123', 'root':'ieee123', 'mRID':'CBE09B55-091B-4BB0-95DA-392237B12640', 'substation':'Fictitious', 'region':'Texas', 'subregion':'Austin', 'glmvsrc': 2401.78, 'bases':[4160.0], 'export_options':' -l=1.0 -p=1.0 -e=carson', 'check_branches':[{'dss_link': 'TRANSFORMER.REG4A', 'dss_bus': '160'}, {'dss_link': 'TRANSFORMER.REG4B', 'dss_bus': '160'}, {'dss_link': 'TRANSFORMER.REG4C', 'dss_bus': '160'}, {'gld_link': 'REG_REG4', 'gld_bus': '160'}, {'dss_link': 'LINE.L115', 'dss_bus': '149', 'gld_link': 'LINE_L115', 'gld_bus': '149'}]}, ]

cimhub.make_blazegraph_script (cases, './', 'dss/', 'glm/', shfile_export) st = os.stat (shfile_export) os.chmod (shfile_export, st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH) p1 = subprocess.call (shfile_export, shell=True)`

Now I understand that, I have to modify the cases array to input a CIM XML. But someone needs to tell me exactly how to do it.

(I am also guessing, I will have to add lines 41 - 42 to activate blazegraph, as well)

Next I would attempt to convert to excel or learn Blazegraph to explore and work through my data.

temcdrm commented 2 years ago

Can you see if this helps?

https://cimhub.readthedocs.io/en/latest/Tutorial.html#starting-with-a-new-opendss-file

StormsHalted commented 2 years ago

@temcdrm

Afternoon Tom,

I am actually trying to achieve the opposite of it. I have a CIM file that I need to convert to OpenDSS.

This does gives me additional information in modifying the case statement and a few other parameters.

I still can't add a 'dssname' namespace to my case as I have to start with CIM and not DSS. If their is an already written example please point me to that.

temcdrm commented 2 years ago
temcdrm commented 2 years ago

This is about all we can do. Suggestions have been added to the CIMHub tutorial.

StormsHalted commented 2 years ago

Hi @temcdrm,

Yes, I am able to load a CIM XML to blazegraph and then Run modified versions of some of the queries.

Now it boils down to me learning a completely new SPARQL syntax to modify those queries.

AAndersn commented 10 months ago

Hi @StormsHalted -- I know this thread is now more than a year old, but we now have this capability without the need for you to do any custom SPARQL as part of the new CIMantic Graphs library: https://github.com/PNNL-CIM-Tools/CIM-Graph/tree/develop and https://pypi.org/project/cim-graph/

from cimgraph.models import FeederModel
import cimgraph.utils as utils

feeder_mrid = "49AD8E07-3BF9-A4E2-CB8F-C3722F837B62"
feeder = cim.Feeder(mRID = feeder_mrid)
network = FeederModel(connection=database, container=feeder, distributed=False)
utils.get_all_data(network)
utils.write_csv(network, output_directory)

See https://github.com/PNNL-CIM-Tools/CIM-Graph/blob/develop/examples/feeder_example.ipynb and https://cimantic-graphs.readthedocs.io/en/latest/03_feeder_model.html for a more detailed example and how you can traverse the model