pyyeti.nastran.op2.OP2.directory

OP2.directory(verbose=True, redo=False, with_headers=False, with_trailers=False)[source]

Catalogues and optionally prints contents of op2 file

Parameters:
  • verbose (bool (or any true/false variable); optional) – If True, print names, sizes, and file offsets to screen. Also prints record headers if with_headers is True.

  • redo (bool; optional) – If True, scan through file and redefine self.dbdct even if it is already set.

  • with_headers (bool; optional) – If True and verbose is True, include the table headers and record lengths for each record that belongs to the table when printing.

  • with_trailers (bool; optional) – If True and verbose is True, include the table trailers when printing.

Returns:

dbdct (dictionary) – Dictionary indexed by data block name. Each value is a list, one element per occurrence of the data block in the op2 file. Each element is a SimpleNamespace with these attributes:

.name : string; name of data block
.start : integer; file position start
.stop : integer; file position stop (stop value is start
        of next data block)
.nbytes: number of bytes data block consumes in file
.dbtype : integer; 0 for table, 1 for matrix
.size : 2-element tuple; for matrices: (rows, cols);
        for tables: (0, 0)
.trailer : 7-element tuple; data block trailer
.headers : list; record headers for data block (see
           below)

dbdct

Described above.

Type:

dictionary

pyyeti.nastran.op2.dblist

Has the same information as dbdct, but in a file-order list. Each element is the same SimpleNamespace as in dbdct (see above).

Type:

list

pyyeti.nastran.op2.dbnames

Here only for backward compatibility; new code should use dbdct instead. Dictionary indexed by data block name. Each value is a list, one element per occurrence of the data block in the op2 file. Each element is another list that has 3 elements: [fpos, bytes, size]:

fpos : 2-element list; file position start and stop
       (stop value is start of next data block)
bytes: number of bytes data block consumes in file
size : 2-element list; for matrices, [rows, cols],
       for tables [0, 0]
Type:

dictionary

pyyeti.nastran.op2.dbstrings

File-order list of strings for printing. Contains data block names and file positions.

Type:

list

pyyeti.nastran.op2.names

File-order list of data block names.

Type:

list

pyyeti.nastran.op2.dbstarts

File-order list of data block starting byte positions.

Type:

integer 1d ndarray

pyyeti.nastran.op2.dbstops

File-order list of data block stopping byte positions.

Type:

integer 1d ndarray

pyyeti.nastran.op2.dbtypes

File-order list of data block types (0 for table, 1 for matrix).

Type:

integer 1d ndarray

pyyeti.nastran.op2.trailers

File-order list of data block trailers (tuples).

Type:

list

pyyeti.nastran.op2.headers

File-order list of header information for records in tables. Each entry that corresponds to a table will be a list (the length of which equals the number of records in the table) of lists:

[[(3-element record header), record_length],
 [(3-element record header), record_length],
 ...]

The entry for a matrix is an empty list: [].

Type:

list

Notes

As an example of using dbdct, to get a list of all sizes of matrices named ‘KAA’:

o2 = op2.OP2('mds.op2')
s = [item.size for item in o2.dbdct['KAA']]

For another example, to read in first matrix named ‘KAA’:

o2 = op2.OP2('mds.op2')
o2.set_position('KAA')
name, trailer, rectype = o2.rdop2nt()
kaa = o2.rdop2matrix(trailer)