The problem with many OUT files is not a new one. I have not got an definitive answer from Siemens but I guess is somehow related to poor memory management.
My solution is to convert the OUT file to Excel XLSX files and then use matplotlib with openpyxl or pandas to plot.
Converting to XLSX is quite straight forward, take a look at this post Convert dynamic OUT files to Excel XLSX files. By the way, you can get rid of the Siemens watermark this way.
The dyntools module is compiled percisely because Siemens does not want anyone to see the source code. Altough you can use Python's "help()" function to see the documentations inside the module.
Edit:
The problem is that if you pass a list of OUT files to instantiate one single chnf object, it's gonna explode. It won't explode if you loop through the OUT files one by one. Python's garbage collection should make sure that the unused chnf object would be erased, so perforamce and memory should not be impacted.
You can use multiprocessing to speed up things, here is an example:
import os
import time
import multiprocessing as mp
# you may need to add the PSSBIN path to your environmental variable
import dyntools
def boolOut2Xlsx(str_path_out, str_path_xlsx, bool_show=False,
bool_overwritesheet=False, str_sheet='', list_chn=[]):
'''This function converts the PSSE OUT file into an Excel workbook (XLSX).
Dependency
----------
dyntools : PSSE Python module
Parameters
----------
str_path_out : str
The path of the OUT file.
str_path_xlsx : str
The path of the XLSX file.
bool_overwritesheet : boolean
Whether to overwrite the current worksheet.
True = overwrite;
False = not overwirte.
Defualt = Flase
str_sheet : str
Name of the worksheet.
list_chn : list
A list containing the desired channels to be included in the XLSX.
Empty list means all channels. Note that this could make the XLSX very large.
Default = emtpy list (all channels)
Returns
-------
list of two bools : list
This list has two elements. If no exception (conversion assumed successful), the
first element will be True, else, it will be False. The second element is always
True. This is to denote function end (end of conversion).'''
try:
# use the CHNF in dyntools, let it read the OUT file path
obj_chnf = dyntools.CHNF(str_path_out)
# if not empty list
if list_chn:
list_chn = list_chn
else:
# the channel ids are return as a tuple
tup_id = obj_chnf.get_id(str_path_out)
# get the total id number
# turn the tuple into a list then get the length of the list
int_id_num = len(list(tup_id[1]))
list_chn = range(1, int_id_num, 1)
# this is output line
obj_chnf.xlsout(channels=list_chn, show=bool_show,
xlsfile=str_path_xlsx, outfile=str_path_out,
sheet=str_sheet, overwritesheet=bool_overwritesheet)
return [True, True]
except Exception as e:
print(repr(e))
return [False, True]
def out2xlsx_with_mp(chunk_outfile, chunk_xlsx):
start = time.time()
jop = []
for k, v in zip(chunk_out, chunk_xlsx):
jop = []
for z in xrange(0, len(k)):
p = mp.Process(target=boolOut2Xlsx, args=(k[z], v[z]))
jop.append(p)
p.start()
for j in jop:
j.join()
dur = time.time() - start
print('Time ...
(more)