Reputation: 15
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')
Upvotes: 0
Views: 1451
Reputation: 1314
You can use the pssarrays
module written by the PSSE developers to perform ASCC and read the results all within python, i.e., 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 (e.g., 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, i.e., help(pssarrays.ascc_currents)
, otherwise none of this will make sense.
Upvotes: 0
Reputation: 1519
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")
Upvotes: 0