[英]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.