Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

columns node number, load MW, load Mvar

The status of the script is as follows:

import os import sys

PSSELOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import psspy _i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar() psspy.psseinit(100000) psspy.throwPsseExceptions = True

STUDYCASE = 'C:\path\202203010030_FO1.sav'

psspy.case(STUDY_CASE)

psspy.loaddata4(10004, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10006, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10007, '1', 1, [5, 4, 0, 0, 0, 0]) psspy.loaddata4(10008, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.machinechng2(10001, r"""1""", [1, i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.branchchng(10004, 10005, '1', [0, i, _i, _i, _i, _i], [f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])

psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0]) psspy.area2(0, 1, 1) psspy.save(STUDYCASE) psspy.rawd2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""202203010030_FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

columns node number, load MW, load Mvar

The status of the script is as follows:

import os import sys

PSSELOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import psspy _i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar() psspy.psseinit(100000) psspy.throwPsseExceptions = True

STUDYCASE = 'C:\path\202203010030_FO1.sav'

psspy.case(STUDY_CASE)

psspy.loaddata4(10004, '1', 1, [5, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10006, '1', 1, [5, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10007, '1', 1, [5, [5, 4, 0, 0, 0, 0]) psspy.loaddata4(10008, '1', 1, [5, [5, 5, 0, 0, 0, 0]) psspy.machinechng2(10001, r"""1""", r"""1""", [1, i, _i, _i, _i, _i], _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.branchchng(10004, 10005, '1', '1', [0, i, _i, _i, _i, _i], [f, _f, _f, _f, f, _f,f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])

psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0]) psspy.area2(0, 1, 1) psspy.save(STUDYCASE) psspy.rawd2(0, 2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, 0, r"""202203010030_FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

columns node number, load MW, load Mvar

The status of the script is as follows:

import os import sys

PSSELOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) LOCATION) os.environ['PATH'] = = os.environ['PATH'] + ';' + + PSSE_LOCATION

import psspy _i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar() psspy.psseinit(100000) psspy.psseinit(100000) psspy.throwPsseExceptions = True

STUDYCASE = = 'C:\path\202203010030_FO1.sav'

psspy.case(STUDY_CASE)

psspy.loaddata4(10004, '1', 1, [5, 5, 0, 0, 0, 0]) 0]) psspy.loaddata4(10006, '1', 1, [5, 5, 0, 0, 0, 0]) 0]) psspy.loaddata4(10007, '1', 1, [5, 4, 0, 0, 0, 0]) 0]) psspy.loaddata4(10008, '1', 1, [5, 5, 0, 0, 0, 0]) 0]) psspy.machinechng2(10001, r"""1""", [1, i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.branchchng(10004, 10005, '1', [0, i, _i, _i, _i, _i], [f, f, _f,f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])

f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])

psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0]) 0]) psspy.area2(0, 1, 1) 1) psspy.save(STUDYCASE) psspy.rawd2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""202203010030_FO1.raw""")

0030FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

columns node number, load MW, load Mvar

The status of the script is as follows:

import os os
import sys

PSSELOCATION sys PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSELOCATION) (x86)\PTI\PSSE33\PSSBIN" sys.path.append(PSSE_LOCATION) os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

PSSE_LOCATION import psspy _i = psspy.getdefaultint() _f = psspy.getdefaultreal() _s = psspy.getdefaultchar() psspy.psseinit(100000) psspy.getdefaultchar() psspy.psseinit(100000) psspy.throwPsseExceptions = True

STUDYCASE = 'C:\path\202203010030_FO1.sav'

psspy.case(STUDY_CASE)

psspy.loaddata4(10004, True STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav' psspy.case(STUDY_CASE) psspy.load_data_4(10004, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10006, 0]) psspy.load_data_4(10006, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.loaddata4(10007, 0]) psspy.load_data_4(10007, '1', 1, [5, 4, 0, 0, 0, 0]) psspy.loaddata4(10008, 0]) psspy.load_data_4(10008, '1', 1, [5, 5, 0, 0, 0, 0]) psspy.machinechng2(10001, 0]) psspy.machine_chng_2(10001, r"""1""", [1, i, _i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.branchchng(10004, _f]) psspy.branch_chng(10004, 10005, '1', [0, i, _i, _i, _i, _i, _i], [f, f, _f,f, f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f]) psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0]) psspy.area2(0, 1, 1) psspy.save(STUDYCASE) psspy.rawd2(0, 0]) psspy.area_2(0, 1, 1) psspy.save(STUDY_CASE) psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""202203010030FO1.raw""")

r"""20220301_0030_FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

columns node number, load MW, load MvarMvar 10004, 5, 5 10006, 5, 5 . . .

The status of the script is as follows:

import os
import sys

PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True

STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'

psspy.case(STUDY_CASE)

psspy.load_data_4(10004, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10006, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10007, '1', 1, [5, 4, 0, 0, 0, 0])
psspy.load_data_4(10008, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.machine_chng_2(10001, r"""1""", [1, _i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
psspy.branch_chng(10004, 10005, '1', [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])


psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

node number, load MW, load Mvar 10004, 5, 5 10006, 5, 5 . . .

The status of the script is as follows:

import os
import sys

PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True

STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'

psspy.case(STUDY_CASE)

psspy.load_data_4(10004, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10006, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.load_data_4(10007, '1', 1, [5, 4, 0, 0, 0, 0])
psspy.load_data_4(10008, '1', 1, [5, 5, 0, 0, 0, 0])
psspy.machine_chng_2(10001, r"""1""", [1, #My updated code is below, changed identation
with open("1.csv", 'r') as file:
    reader = csv.reader(file)
    for row in reader:
        loaddatalst = row.split(",")
        loadbus = int(loaddatalst[0])
        loadid = '1'  # or loaddatalst [x], x is position of load id in row
        loadp = float(loaddatalst[1])
        loadq = float(loaddatalst[2])
        psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [4.0, 1.0, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
psspy.branch_chng(10004, 10005, '1', [0, _i, _i, _i, _i, _i], [_f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])
[loadp, loadq, 0, 0, 0, 0])


psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

node number, load MW, load Mvar 10004, 5, 5 10006, 5, 5 . . .

The status of the script is as follows:

import os
import sys

PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True

STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'

psspy.case(STUDY_CASE)
#My updated code is below, changed identation
with open("1.csv", 'r') as file:
    reader = csv.reader(file)
    for row in reader:
        loaddatalst = row.split(",")
        loadbus = int(loaddatalst[0])
int(row[0])
        loadid = '1'  # or loaddatalst [x], x is position of load id in row
        loadp = float(loaddatalst[1])
float(row[1])
        loadq = float(loaddatalst[2])
float(row[2])
        psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [loadp, loadq, 0, 0, 0, 0])


psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

Import load (MW/Mvar) and Generation (MW) from CSV file to PSS/E case

Hello, I am trying to make a script in python that reads from CSV files the load and generation values and updates the values in the PSS/E sav case for one timestamp. csv file structure for load looks like this:

node number, load MW, load Mvar 10004, 5, 5 10006, 5, 5 . . .

The status of the script is as follows:

import os
import sys

PSSE_LOCATION = r"C:\Program Files (x86)\PTI\PSSE33\PSSBIN"
sys.path.append(PSSE_LOCATION)
os.environ['PATH'] = os.environ['PATH'] + ';' + PSSE_LOCATION

import psspy
_i = psspy.getdefaultint()
_f = psspy.getdefaultreal()
_s = psspy.getdefaultchar()
psspy.psseinit(100000)
psspy.throwPsseExceptions = True

STUDY_CASE = 'C:\\path\\20220301_0030_FO1.sav'

psspy.case(STUDY_CASE)
#My updated code is below, changed identation
with open("1.csv", 'r') as file:
    reader = csv.reader(file)
    for row in reader:
        loadbus = int(row[0])
        loadid = '1'  # or loaddatalst [x], x is position of load id in row
        loadp = float(row[1])
        loadq = float(row[2])
        psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [loadp, loadq, 0, 0, 0, 0])


psspy.fnsl([0, 0, 0, 0, 0, 0, 99, 0])
psspy.area_2(0, 1, 1)
psspy.save(STUDY_CASE)
psspy.rawd_2(0, 1, [1, 1, 1, 0, 0, 0, 0], 0, r"""20220301_0030_FO1.raw""")

The part I am struggling with is defining some way of importing the CSV list in python and applying the load (MW/Mvar) in each load node.

Thank you.

to follow up after JConto answer, my code for updating load and generation in PSSE case looks like this:

#read load p and q
with open('load.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
   loadbus = int(row[0])
   loadid = '1'  # or loaddatalst [x], x is position of load id in row
   loadp = float(row[1])
   loadq = float(row[2])
   psspy.load_data_4(loadbus, loadid, [_i, _i, _i, _i, _i, _i], [loadp, loadq, 0, 0, 0, 0])

#read generators
with open('gen.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
    genbus = int(row[0])
    genid = str(row[1])  # or loaddatalst [x], x is position of load id in row
    status = int(row[2])
    genp = float(row[3])
    genq = float(row[4])
    psspy.machine_chng_2(genbus, genid, [status, _i, _i, _i, _i, _i],[genp, genq, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f, _f])