Python implementation of OPDM SOAP API. OPDM is used to exchange Electrical Grid Models between ENTSO-E TSO-s and RSC-s
Other relevant API-s:
pip install opdm-api
or
pip install --user opdm-api
or
python -m pip install --user opdm-api
import OPDM
service = OPDM.Client("https://opdm.elering.sise:8443", username="user", password="pass")
response = service.publication_request(file_path_or_objet)
import glob
imort os
for file_name in glob.glob1(directory_path, "*.zip"):
service.publication_request(os.path.join(directory_path, file_name))
publication_report = service.get_profile_publication_report(model_ID)
or
publication_report = service.get_profile_publication_report(filename="uploaded_file_name.zip")
available_publications = service.publication_list()
available publications: BDS, IGM, CGM
response = service.publication_subscribe("BDS")
time_horizons = [f"{item:02d}" for item in list(range(1,32))] + ["ID", "1D", "2D", "YR"]
for time_horizon in time_horizons:
print(f"Adding subscription for {time_horizon}")
response = service.publication_subscribe("IGM", subscription_id=f"IGM-{time_horizon}", metadata_dict={'pmd:timeHorizon': time_horizon})
print(response)
response = service.publication_cancel_subscription(subscription_id)
Model consists of multiple files
response = service.query_object(object_type = "IGM", metadata_dict = {'pmd:scenarioDate': '2019-07-28T00:30:00', 'pmd:timeHorizon': '1D'})
response = service.query_profile('pmd:timeHorizon': '1D', 'pmd:cgmesProfile': 'SV'})
import pandas
pandas.set_option("display.max_rows", 12)
pandas.set_option("display.max_columns", 10)
pandas.set_option("display.width", 1500)
pandas.set_option('display.max_colwidth', -1)
print(pandas.DataFrame(response['sm:QueryResult']['sm:part'][1:]))
response = service.get_content(file_UUID)
print(response['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content'])
import base64
response = service.get_content(file_UUID, return_payload=True)
with open(f"{file_UUID}.zip", 'wb') as cgmes_file:
report_file.write(base64.b64decode(response['sm:GetContentResult']['sm:part'][1]['opdm:Profile']['opde:Content'].encode()))
service.list_available_rulesets()
service.install_rulesets(version="2.0.122")
service.get_installed_ruleset_version()
service.reset_ruleset()