The iPython notebook for this demo can be found in:
The OP4 is a Nastran input/output format that can store matrices.
The OP2 can as well, but is less validated in regards to matrices.
In [1]:
import os
from pyNastran.utils import print_bad_path
from pyNastran.op4.op4 import read_op4
import numpy as np
from numpy import float32, float64, int32, int64, product
# decrease output precision
np.set_printoptions(precision=3, threshold=20)
In [2]:
help(read_op4)
In [3]:
# read the op4, will pop open a dialog box
#matrices = read_op4()
In [4]:
op4_filename = r'C:\Users\Steve\Desktop\ISat_Launch_Sm_4pt.op4'
assert os.path.exists(op4_filename), print_bad_path(op4_filename)
#specify the file
matrices = read_op4(op4_filename)
In [5]:
# only 1 matrix
matrices = read_op4(op4_filename, matrix_names='FLAMA', debug=False)
# 1 or more matrices
matrices = read_op4(op4_filename, matrix_names=['FLAMA','UGEXT'])
In [6]:
# extract a matrix
form, flama = matrices['FLAMA']
print("form = %s" % form)
print("type = %s" % type(flama))
In [7]:
print("keys = %s" % matrices.keys())
In [8]:
print(matrices.keys())
form_flama, flama = matrices['FLAMA']
print("shape = %s" % str(flama.shape))
print("flamat nvals = %s" % flama.size)
form_ugext, ugext = matrices['UGEXT']
print("form_ugext=%s type=%s" % (form_ugext, type(ugext[0,0])))
#print "ugext", ugext
print("ugext.shape = %s" % str(ugext.shape))
print("ugext nvals = %s" % ugext.size)
In [9]:
print(ugext[:,:])
#print(flama)