繁体   English   中英

在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) ,否则这些都没有意义。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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