使用 PSS/E 程序中的 python 将短路电流数据保存到 CSV

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

我是学电力系统的学生,想在PSS/E程序中使用python。我可以在 PSS/E 程序中使用 python 来 运行 短路电流数据。但是我不知道如何使用python将短路电流数据保存到CSV。我现在可以创建一个CSV文件,但我不知道如何将数据写入CSV。

我使用 psse ver34 & python 2.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')

您可以使用file.write将数据写入文件

使用 'a' 附加到给定文件。使用 with 语句保证文件将在您完成后关闭。

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

您可以使用 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写入文件;您可能希望将不同的数据写入文件。请阅读文档字符串,即 help(pssarrays.ascc_currents),否则 none 是有意义的。