简体   繁体   中英

Save short-circurt current data to CSV using python in PSS/E program

I am studying students in the power system and I want to use python in PSS/E program. I can use python in PSS/E program to run short-circuit current data. But I don't know how to use python to save short circuit current data to CSV. l can create one CSV file now , but I don't know how to write data to CSV.

I use psse ver34 & python 2.7.

I have this small code:

import os, math, time
sqrt3 = math.sqrt(3.0)
sbase = 100.0     # MVA

str_time = time.strftime("%Y%m%d_%H%M%S_", time.localtime())
fnamout  = str_time + 'short_circuit_in_line_slider.csv'
fnamout  = os.path.join(os.getcwd(),fnamout)
foutobj  = open(fnamout,'w')

You can use file.write to write data to a file

Use 'a' to append to a given file. Use the with statement to guarantee the file will be closed when you are done.

with open(fnameout, 'a') as file:
    file.write(DATA + "\n")

You can use the pssarrays module written by the PSSE developers to perform ASCC and read the results all within python, ie, outside the GUI. You can view the documentation as follows:

import psse34
import pssarrays

help(pssarrays.ascc_currents)

After you have loaded the case in python memory and defined your subsystem (eg, by using psspy.bsys() ) for which to apply faults you can run ASCC as follows:

robj = pssarrays.ascc_currents(
    sid=0,    # this could be different for you
    flt3ph=1, # you may wish to apply different faults
)

and process the results as follows:

with open('your_file.csv', 'w') as f:
    for bus_number, sc_results in zip(robj.fltbus, robj.flt3ph.values()):
        f.write('{},{}\n'.format(bus_number, sc_results['ia1']))

which will write the positive sequence currents ia1 to a file; you may wish to have different data written to the file. Please read the docstring, ie, help(pssarrays.ascc_currents) , otherwise none of this will make sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM