Thanks Steve, as I've looked more into it this definitely seems to be the easiest approach.
Now, instead of trying to create a new OP2 file from scratch, I'm reading my MSC nastran OP2, processing the data, overwriting some of the existing data with my new calculations, and then writing out to a new OP2 file.
This is working fine with my small test files, and I'm able to open the resulting OP2s in Patran. But when I run tests on a "real" OP2 weighing in around 10gb, I'm having performance issues. Reading the OP2 is very fast (<30 seconds), but re-writing the OP2 never finishes. I killed it after a 1.5 hours, on a machine with 128gb ram and a NVMe hard drive. Obviously the first thing I tried was commenting out my calculations, at this point the script is nothing more than read_op2 and write_op2.
I'm running off of HEAD (I needed the MSC 2019 or 2020 support). I get the following trace whenever I kill during the write (always the same line). Are there known performance issues with write_op2 on larger files? It doesn't appear to be an obvious problem with my original OP2 data, Patran is able to open it without any issue, and when I print out some of the data using pyNastran it looks like it's probably been read in correctly.
RealSolidStressArray - isubcase=1 - CTETRA
Traceback (most recent call last):
File ".\calculate_fatigue.py", line 149, in <module>
main()
File ".\calculate_fatigue.py", line 97, in main
model.write_op2(args.out_file)
File "C:\Users\moseley\Desktop\python_v3770\python-3.7.7.amd64\lib\site-packages\pynastran-1.4.0+dev.no.checksum.error-py3.7.egg\pyNastran\op2\writer\op2_writer.py", line 84, in write_op2
nastran_format=nastran_format)
File "C:\Users\moseley\Desktop\python_v3770\python-3.7.7.amd64\lib\site-packages\pynastran-1.4.0+dev.no.checksum.error-py3.7.egg\pyNastran\op2\writer\op2_writer.py", line 133, in _write_op2
case_count = _write_result_tables(obj, fop2, fop2_ascii, struct_3i, endian, skips)
File "C:\Users\moseley\Desktop\python_v3770\python-3.7.7.amd64\lib\site-packages\pynastran-1.4.0+dev.no.checksum.error-py3.7.egg\pyNastran\op2\writer\op2_writer.py", line 287, in _write_result_tables
date, is_mag_phase=False, endian=endian)
File "C:\Users\moseley\Desktop\python_v3770\python-3.7.7.amd64\lib\site-packages\pynastran-1.4.0+dev.no.checksum.error-py3.7.egg\pyNastran\op2\tables\oes_stressStrain\real\oes_solids.py", line 601, in write_op2
j = where(eids3 == deid)[0]
KeyboardInterrupt