pyyeti.nastran.op4.read¶
- pyyeti.nastran.op4.read(filename=None, namelist=None, into='dct', justmatrix=True, sparse=False)[source]¶
Read all matching matrices from op4 file into dictionary or list; non-member version of
OP4.load().This is a the same as
load()except justmatrix default is True.- Parameters:
filename (string or None; optional) – Name of op4 file to read. Can also be the name of a directory or None; in these cases, a GUI is opened for file selection.
namelist (list, string, or None; optional) – List of variable names to read in, or string with name of the single variable to read in, or None. If None, all matrices are read in.
into (string; optional) – Either ‘dct’ or ‘list’. Use ‘list’ if multiple matrices share the same name. See below.
justmatrix (bool; optional) – If True, only the matrix is stored in the dictionary. If False, a tuple of
(matrix, form, mtype)is stored. This option is ignored ifinto == 'list'.sparse (bool or None or two-tuple_like; optional) – Specifies whether output matrices will be regular numpy arrays or sparse arrays. If not two-tuple_like:
sparse
Action
None
Auto setting: each matrix will be sparse if and only if it was written in a sparse format
True
Matrices will be returned in sparse format
False
Matrices will be returned in regular (dense) numpy arrays
If sparse is two-tuple_like, the first element is either None, True, or False (see table above) and the second element is a callable, as in:
X = callable(X). A common usage of the callable would be to convert from “COO” sparse form (seescipy.sparse.coo_matrix) to a more desirable form. For example, to ensure all matrices are returned in CSC form (seescipy.sparse.csc_matrix) use:sparse=(True, scipy.sparse.coo_matrix.tocsc)
The callable is ignored for non-sparse matrices.
- Returns:
dct (
collections.OrderedDict, ifinto == 'dct') – Keys are the lower-case matrix names and the values are either just the matrix or a tuple of:(matrix, form, mtype)depending on justmatrix.tup (tuple, if
into == 'list') – Tuple of 4 lists:(names, matrices, forms, mtypes)
Notes
The default form for sparse matrices is the “COO” sparse form (see
scipy.sparse.coo_matrix). To override, provide a callable in the sparse option (see above).