<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 OP4 Demo
The iPython notebook for this demo can be found in
Step1:  Print the docstring
Step2:  So as you can see, Nastran has many matrix formats.
Step3:  There are more ways to read an OP4
<ASSISTANT_TASK:>
Python Code:
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)
Explanation: OP4 Demo
The iPython notebook for this demo can be found in:
   - docs\quick_start\demo\op4_demo.ipynb
   - https://github.com/SteveDoyle2/pyNastran/tree/master/docs/quick_start/demo/op4_demo.ipynb
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.
Import pyNastran
End of explanation
help(read_op4)
Explanation: Print the docstring
End of explanation
# read the op4, will pop open a dialog box
#matrices = read_op4()
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)
Explanation: So as you can see, Nastran has many matrix formats.
End of explanation
# 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'])
# extract a matrix
form, flama = matrices['FLAMA']
print("form = %s" % form)
print("type = %s" % type(flama))
print("keys = %s" % matrices.keys())
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)
print(ugext[:,:])
#print(flama)
Explanation: There are more ways to read an OP4
End of explanation
<END_TASK>