pyNastran/op4

op4 Module

Inheritance diagram of pyNastran.op4.op4

class pyNastran.op4.op4.OP4(log=None)[source]

Bases: object

todo:: add endian checking todo:: test on big matrices todo:: finish write_op4

Methods

get_markers_dense(f)[source]
get_markers_sparse(f, isBigMat)[source]
read_op4(op4_filename=None, matrix_names=None, precision='default')[source]

Reads a NASTRAN OUTPUT4 file, regular or sparse, and stores the matrices as the output arguments of the function. The number of matrices read is defined by the list matrix_names. By default, all matrices will be read. The resulting output is a dictionary of matrices that are accessed by their name.

>>> from pyNastran.op4.op4 import OP4
>>> op4 = OP4()

# get all the matrices
>>> matrices = op4.read_op4(op4_filename)
>>> (formA,A) = matrices['A']
>>> (formB,B) = matrices['B']
>>> (formC,C) = matrices['C']

# or to reduce memory usage
>>> matrices = op4.read_op4(op4_filename, matrix_names=['A','B'])
>>> (formA,A) = matrices['A']
>>> (formB,B) = matrices['B']

# or because you only want A
>>> matrices = op4.read_op4(op4_filename, matrix_names='A')
>>> (formA,A) = matrices['A']

# get all the matrices, but select the file using a file dialog
>>> matrices = op4.read_op4()
>>>
Parameters:
  • op4_filename – an OP4 filename. Type=STRING.
  • matrix_names – matrix name(s) (or None); Type=LIST OF STRINGS / STRING / NONE.
  • precision – specifies if the matrices are in single or double precsion (values=’default’, ‘single’, ‘double’) which means the format will be whatever the file is in
Returns:

dictionary of matrices where the key is the name and the

value is [form, matrix]

Form Definition
Square
Rectangular
Diagonal
Symmetric
Id entity
Pseudoidentity
Matrix:

Dense Type: NUMPY.NDARRAY Sparse Type: SCIPY.SPARSE.COO_MATRIX

Note

based off the MATLAB code SAVEOP4 developed by ATA-E and later UCSD.

Note

it’s strongly recommended that you convert sparse matrices to another format before doing math on them. This is standard with sparse matrices.

Warning

sparse binary is buggy right now

read_op4_ascii(op4_filename, matrix_names=None, precision='default')[source]

matrix_names must be a list or None, but basically the same

read_op4_binary(op4_filename, matrix_names=None, precision='default')[source]

matrix_names must be a list or None, but basically the same

read_start_marker(f)[source]
show(f, n)[source]
write_op4(op4_filename, matrices, name_order=None, precision='default', is_binary=True)[source]

Writes the OP4

Parameters:op4_filename (String -> opens a file (closed at the end) file -> no file is opened and it's not closed) – The filename to write
pyNastran.op4.op4.compress_column(col)[source]
pyNastran.op4.op4.get_dtype(Type, precision='default')[source]

reset the type if ‘default’ not selected

pyNastran.op4.op4.main()[source]
pyNastran.op4.op4.matrices()[source]