我正在学习电力系统的学生,我想在PSS/E程序中使用python。我可以在PSS/E程序中使用python运行短路电流数据.但我不知道如何使用python将短路电流数据保存到CSV。我现在可以创建一个CSV文件,但我不知道如何将数据写入CSV。
我使用psse ver34 &python2.7。
我有个小密码:
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')发布于 2019-07-15 18:18:57
您可以使用PSSE开发人员编写的pssarrays模块来执行ASCC,并在python (即GUI外部)中读取结果。您可以按以下方式查看文档:
import psse34
import pssarrays
help(pssarrays.ascc_currents)在您将情况加载到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
)并将结果处理如下:
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']))将正序电流ia1写入文件;您可能希望将不同的数据写入该文件。请阅读docstring,即help(pssarrays.ascc_currents),否则所有这些都没有意义。
发布于 2019-07-11 16:41:38
您可以使用file.write将数据写入文件。
使用“a”来附加到给定的文件。使用with语句保证文件在完成时将被关闭。
with open(fnameout, 'a') as file:
file.write(DATA + "\n")https://stackoverflow.com/questions/56993783
复制相似问题