[英]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. 我正在研究电源系统中的学生,并且想在PSS / E程序中使用python。 I can use python in PSS/E program to run short-circuit current data.
我可以在PSS / E程序中使用python来运行短路电流数据。 But I don't know how to use python to save short circuit current data to CSV.
但我不知道如何使用python将短路电流数据保存为CSV。 l can create one CSV file now , but I don't know how to write data to CSV.
我现在可以创建一个CSV文件,但是我不知道如何将数据写入CSV。
I use psse ver34 & python 2.7. 我使用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 您可以使用
file.write
将数据写入文件
Use 'a' to append to a given file. 使用“ a”附加到给定文件。 Use the
with
statement to guarantee the file will be closed when you are done. 使用
with
语句确保完成后文件将关闭。
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. 您可以使用PSSE开发人员编写的
pssarrays
模块执行ASCC,并在python内(即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: 在将案例加载到python内存中并定义了要应用故障的子系统(例如,通过使用
psspy.bsys()
)之后,可以按以下方式运行ASCC:
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; 它将正序电流ia1写入文件; 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. 请阅读文档字符串,即
help(pssarrays.ascc_currents)
,否则这些都没有意义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.