Skip to content
Snippets Groups Projects
Commit 7c7bfce7 authored by Taeyoung Kim's avatar Taeyoung Kim
Browse files

adding integer and real, so real/imag value can be expressed properly as well

parent 23f43843
No related branches found
No related tags found
No related merge requests found
...@@ -76,6 +76,6 @@ INFO:cimpy.cimimport:CIM object Line created : 11 times ...@@ -76,6 +76,6 @@ INFO:cimpy.cimimport:CIM object Line created : 11 times
INFO:cimpy.cimimport:CIM object SubGeographicalRegion created : 2 times INFO:cimpy.cimimport:CIM object SubGeographicalRegion created : 2 times
INFO:cimpy.cimimport:CIM object BusbarSection created : 13 times INFO:cimpy.cimimport:CIM object BusbarSection created : 13 times
INFO:cimpy.cimimport:CIM object TopologicalIsland created : 2 times INFO:cimpy.cimimport:CIM object TopologicalIsland created : 2 times
INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.027223825454711914s INFO:cimpy.cimimport:Created totally 275 CIM objects in 0.023450851440429688s
...@@ -57,6 +57,11 @@ class CIMtoDataFrame(Exporter): ...@@ -57,6 +57,11 @@ class CIMtoDataFrame(Exporter):
return whole_thing return whole_thing
def makeReal(self, input):
return input.apply(lambda x: x.real)
def makeInt(self, input):
return input.apply(lambda x: int(x.real))
def parseNode(self): def parseNode(self):
""" """
...@@ -141,12 +146,21 @@ class CIMtoDataFrame(Exporter): ...@@ -141,12 +146,21 @@ class CIMtoDataFrame(Exporter):
power_pu_imag = power_pu.imag power_pu_imag = power_pu.imag
load_index = k load_index = int(k.real)
df.loc[k] = [ df.loc[k] = [
int(load_index), int(index), power, power_pu, power_real, power_imag, power_pu_real, power_pu_imag int(load_index), int(index), power, power_pu, power_real, power_imag, power_pu_real, power_pu_imag
] ]
#to make sure all the index is going to be integer
df["idx"] = self.makeInt(df["idx"])
df["bus_index"] = self.makeInt(df["bus_index"])
df['power_real'] = self.makeReal(df['power_real'])
df['power_imag'] = self.makeReal(df['power_imag'])
df['power_pu_real'] = self.makeReal(df['power_pu_real'])
df['power_pu_imag'] = self.makeReal(df['power_pu_imag'])
return df return df
def createGens(self): def createGens(self):
""" """
this function create generation dataframe from read CIM file. this function create generation dataframe from read CIM file.
...@@ -174,10 +188,16 @@ class CIMtoDataFrame(Exporter): ...@@ -174,10 +188,16 @@ class CIMtoDataFrame(Exporter):
power_pu_imag = power_pu.imag power_pu_imag = power_pu.imag
load_index = k load_index = k #actually gen
df.loc[k] = [ df.loc[k] = [
int(load_index), int(index), power, power_pu, power_real, power_imag, power_pu_real, power_pu_imag int(load_index), int(index), power, power_pu, power_real, power_imag, power_pu_real, power_pu_imag
] ]
df["idx"] = self.makeInt(df["idx"])
df["bus_index"] = self.makeInt(df["bus_index"])
df['power_real'] = self.makeReal(df['power_real'])
df['power_imag'] = self.makeReal(df['power_imag'])
df['power_pu_real'] = self.makeReal(df['power_pu_real'])
df['power_pu_imag'] = self.makeReal(df['power_pu_imag'])
return df return df
...@@ -280,3 +300,38 @@ class DataFrameToJson(Exporter): ...@@ -280,3 +300,38 @@ class DataFrameToJson(Exporter):
# og_template[k]['mtPowerFlowInput']['busses'][1].keys() # og_template[k]['mtPowerFlowInput']['busses'][1].keys()
return template return template
#ToDo: finish this function. But seems like we need to find a way.
# @activePowerkW, there will be rows that loads doesn't exist, so manybe we have to reset the index of loads, or put zero.
# or find a way to indexinsg bus_index of loads and use row.idx of for loop to connecting value.
def feedDataToTemplate(self, template):
data = self.dict
for k in template.keys():
if k == 'busses':
# new_keys_data = ['bus', 'load']
# new_data= {key: data[key] for key in new_keys_data if key in data}
key_mapping = {'index':'index',
'type':'type',
'name':'name',
'activePowerkW': 'power_real', #from Load
'reactivePowerkVAR' : 'power_imag',
'voltageModulePu': 'voltage_pu',
'nominalVoltagekV': 'base_voltage' }
non_mapped = {'capacityPu', 'voltageArea', 'voltagePhasePu', 'powerLine', 'voltageMaxPu', 'voltageMinPu'}
for _, row in data['bus'].iterrows():
entry = {
"index": row.idx,
"type": row.type,
"name": row['name'], # Using the CSV "name" field
"activePowerkW": 0.0, # Default value
"reactivePowerkVAR": 0.0, # Default value
"capacityPu": 0.0, # Default value
"voltageArea": 1, # Example default; adjust if necessary
"voltageModulePu": parse_complex(row['voltage_pu']),
"voltagePhasePu": 0.0, # Default value
"nominalVoltagekV": float(row['base_voltage']),
"powerLine": 0, # Default value (adjust if needed)
"voltageMaxPu": 1.1, # Default value
"voltageMinPu": 0.9 # Default value
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment