# ********************************************* # Importing needed Libraries from Python # ********************************************* from __future__ import division import pandas import csv import math import lookup from datetime import datetime import pickle import numpy as np import time from pytz import timezone import sys import difflib import ModifySpotLoad CYMPY_LOCATION = r"C:\Program Files (x86)\CYME\CYME" sys.path.insert(1, CYMPY_LOCATION) import cympy import cympy.rm import cympy.db import cympy.study import cympy.enums # ********************************************* # Functions created for each capability # ********************************************* def open_study(study_file_path): # Open specified study and run load flow start = datetime.now() print(' ') print('Querying Self-Contained File...') cympy.study.Open(study_file_path) load_flow = cympy.sim.LoadFlow() load_flow.Run() end = datetime.now() print('Done in ' + str((end - start).total_seconds()) + ' seconds') def list_devices(device_type, verbose=True): #start=datetime.now() #print(' ') #print('List of SELECTED Equipments in Database:') devices = cympy.study.ListDevices(device_type) devices = pandas.DataFrame(devices, columns=['device']) devices['device_type_id'] = devices['device'].apply(lambda x: x.DeviceType) devices['device_number'] = devices['device'].apply(lambda x: x.DeviceNumber) devices['device_type'] = devices['device_type_id'].apply(lambda x: lookup.type_table[x]) if verbose: unique_type = devices['device_type'].unique().tolist() for device_type in unique_type: hello=0 #print('There are ' + str(devices[devices.device_type == device_type].count()[0]) + # ' ' + device_type) #end=datetime.now() #print('list_devices PGE Done in ' + str((end - start).total_seconds()) + ' seconds') return devices def save_study(file_path): start = datetime.now() print(' ') print('Saving Study...') cympy.study.Save(file_path) end = datetime.now() print('Done in ' + str((end - start).total_seconds()) + ' seconds')