2

Loading data from .txt file

  • retag add tags

Hi,

My question is how to get data from a file and use it in PSSE. I´m using python, and i would like to extract information from a file, values, to alter, i.e, the load values.

I can make this but only if i run the code on a console. When i try to run the python file in PSSE it says that does not recognize some of the code lines.

The idea is to make a cicle of 24 hours, varying the values of the load and generation. I have the data stored on a .txt file. So if i could do this it would save me a lot of time. But i'm incapable to extract the values from the files when i run the python file in psse.

Thanks for your time and help.

Fagundes's avatar
33
Fagundes
asked 2012-04-30 10:41:35 -0500
JervisW's avatar
1.3k
JervisW
updated 2012-06-14 02:47:59 -0500
edit flag offensive 0 remove flag close merge delete

Comments

You could write a few lines of regular expressions to extract the data, then use the API to attach them at the appropriate locations. I could give it a try but then I would need your txt file and your saved case file to start with.

amaity's avatar amaity (2012-04-30 20:05:18 -0500) edit
add a comment see more comments

2 Answers

1

Hi Fagundes,

What does your text file look like? Are you able to write a short example?

For a text file that looks like this:

date, load (MW)
02-03-12, 100
03-03-12, 110
04-03-12, 105

We would use the csv module to read the values in:

import csv
reader - csv.reader(open('fagundes.csv'))
header = reader.next()
data = list(reader)

Now you could apply the load in your saved case:

import psspy
psspy.case('fagundes.sav')

# set the load on the first day
day, load = data[0]

psspy.load_data_3(101, '1 ',
                  realar1=load) # Constant Power MW

Does your code look like this example?

jtrain's avatar
411
jtrain
answered 2012-05-01 07:36:54 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
0

Thank you for your help!!

I got there very easy. I know how to work with PSS/E, although programming PSS/E with python it's new to me.

My code stayed like this:

import csv

z=r'D:\ISEL\TESE\zTestes_python\hora'

w=".txt"

hora = 1

while(hora != 4):   
    direct=''

    number=str(hora)

    direct += z
    direct += number
    direct += w

    reader=csv.reader(open(direct))
    header = reader.next()
    data = list(reader)

    hora = hora + 1
    validade=0
    aux=0
    while(validade != 3):
        barr, pot=data[aux]
        barr1=int(barr)
        pot1=int(pot)
        psspy.load_data(barr1,r"""1""",[_i,_i,_i,_i],[ pot1,_f,_f,_f,_f,_f])
        aux=aux+1
        validade=validade+1

The barr1=int(barr) statement was necessary do to PSSE interpret barr as a string and not as integer ou float number. Do you know any doc that could help me get all the functions of psspy library?

By the way, the txt file had this written inside:

barr Pot

2 , 10

3 , 20

4 , 30
Fagundes's avatar
33
Fagundes
answered 2012-05-01 12:45:17 -0500
jtrain's avatar
411
jtrain
updated 2012-05-02 02:48:59 -0500
edit flag offensive 0 remove flag delete link

Comments

1

All the psspy API docs are in $PSSE_HOME\DOCS\PSSEAPI\API.pdf. I'm not sure if you've seen PEP8, but it's a good reference IMHO if you're starting python.

chip's avatar chip (2012-05-01 13:19:51 -0500) edit

Thanks for your help.

Fagundes's avatar Fagundes (2012-05-02 09:07:16 -0500) edit
add a comment see more comments

Your Answer

Login/Signup to Answer